001 /** 002 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved. 003 * 004 * This library is free software; you can redistribute it and/or modify it under 005 * the terms of the GNU Lesser General Public License as published by the Free 006 * Software Foundation; either version 2.1 of the License, or (at your option) 007 * any later version. 008 * 009 * This library is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 011 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 012 * details. 013 */ 014 015 package com.liferay.portal.service.permission; 016 017 import com.liferay.portal.kernel.exception.PortalException; 018 import com.liferay.portal.kernel.exception.SystemException; 019 import com.liferay.portal.security.permission.PermissionChecker; 020 021 /** 022 * Checks permissions with respect to subscriptions. 023 * 024 * @author Mate Thurzo 025 * @author Raymond Aug?? 026 */ 027 public interface SubscriptionPermission { 028 029 /** 030 * Checks if the user has permission to subscribe to the subscription entity 031 * and receive notifications about the inferred entity. 032 * 033 * @param permissionChecker the permission checker 034 * @param subscriptionClassName the class name of the subscribed entity 035 * @param subscriptionClassPK the primary key of the subscribed entity 036 * @param inferredClassName the class name of the inferred entity 037 * (optionally <code>null</code> if the the subscribed entity is the 038 * inferred entity). 039 * @param inferredClassPK the primary key of the inferred entity. 040 * @throws PortalException if the user did not have permission to view the 041 * inferred entity or receive notifications about the subscribed 042 * entity, or if a portal exception occurred 043 * @throws SystemException if a system exception occurred 044 * @see #contains(PermissionChecker, String, long, String, long) 045 */ 046 public void check( 047 PermissionChecker permissionChecker, String subscriptionClassName, 048 long subscriptionClassPK, String inferredClassName, 049 long inferredClassPK) 050 throws PortalException, SystemException; 051 052 /** 053 * Returns <code>true</code> if the user has permission to subscribe to the 054 * subscribed entity and receive notifications about the inferred entity. 055 * 056 * <p> 057 * If the subscribed entity is a container and if an inferred entity 058 * (presumably within the container) is specified, a view permission check 059 * is performed on the inferred entity. The inferred entity is the subject 060 * of the notification. A failed view check on the inferred entity 061 * short-circuits further permission checks and prevents notifications from 062 * being sent. Checking the view permission on the inferred entity is useful 063 * for enforcing permissions for private subtrees within larger container 064 * entities to which the user is subscribed. 065 * </p> 066 * 067 * <p> 068 * If the subscribed entity and the inferred entity are the same, then no 069 * inferred entity needs to be specified. Without any inferred entity 070 * specified only the subscription check on the subscribed entity is 071 * performed. 072 * </p> 073 * 074 * @param permissionChecker the permission checker 075 * @param subscriptionClassName the class name of the subscribed entity 076 * @param subscriptionClassPK the primary key of the subscribed entity 077 * @param inferredClassName the class name of the inferred entity if the 078 * subscribed entity is a container entity 079 * @param inferredClassPK the primary key of the inferred entity if the 080 * subscribed entity is a container entity 081 * @return <code>true</code> if the user has permission to subscribe to the 082 * subscribed entity and receive notifications about the inferred 083 * entity; <code>false</code> otherwise 084 * @throws PortalException if the user did not have permission to view the 085 * inferred entity or receive notifications about it via the 086 * subscribed entity, or if a portal exception occurred 087 * @throws SystemException if a system exception occurred 088 */ 089 public boolean contains( 090 PermissionChecker permissionChecker, String subscriptionClassName, 091 long subscriptionClassPK, String inferredClassName, 092 long inferredClassPK) 093 throws PortalException, SystemException; 094 095 }