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 * @deprecated As of 6.2.0, replaced by {@link #check(PermissionChecker, 031 * String, long, String, long)} 032 */ 033 public void check( 034 PermissionChecker permissionChecker, String className, long classPK) 035 throws PortalException, SystemException; 036 037 /** 038 * Checks if the user has permission to subscribe to the subscription entity 039 * and receive notifications about the inferred entity. 040 * 041 * @param permissionChecker the permission checker 042 * @param subscriptionClassName the class name of the subscribed entity 043 * @param subscriptionClassPK the primary key of the subscribed entity 044 * @param inferredClassName the class name of the inferred entity 045 * (optionally <code>null</code> if the the subscribed entity is the 046 * inferred entity). 047 * @param inferredClassPK the primary key of the inferred entity. 048 * @throws PortalException if the user did not have permission to view the 049 * inferred entity or receive notifications about the subscribed 050 * entity, or if a portal exception occurred 051 * @throws SystemException if a system exception occurred 052 * @see #contains(PermissionChecker, String, long, String, long) 053 */ 054 public void check( 055 PermissionChecker permissionChecker, String subscriptionClassName, 056 long subscriptionClassPK, String inferredClassName, 057 long inferredClassPK) 058 throws PortalException, SystemException; 059 060 /** 061 * @deprecated As of 6.2.0, replaced by {@link #contains(PermissionChecker, 062 * String, long, String, long)} 063 */ 064 public boolean contains( 065 PermissionChecker permissionChecker, String className, long classPK) 066 throws PortalException, SystemException; 067 068 /** 069 * Returns <code>true</code> if the user has permission to subscribe to the 070 * subscribed entity and receive notifications about the inferred entity. 071 * 072 * <p> 073 * If the subscribed entity is a container and if an inferred entity 074 * (presumably within the container) is specified, a view permission check 075 * is performed on the inferred entity. The inferred entity is the subject 076 * of the notification. A failed view check on the inferred entity 077 * short-circuits further permission checks and prevents notifications from 078 * being sent. Checking the view permission on the inferred entity is useful 079 * for enforcing permissions for private subtrees within larger container 080 * entities to which the user is subscribed. 081 * </p> 082 * 083 * <p> 084 * If the subscribed entity and the inferred entity are the same, then no 085 * inferred entity needs to be specified. Without any inferred entity 086 * specified only the subscription check on the subscribed entity is 087 * performed. 088 * </p> 089 * 090 * @param permissionChecker the permission checker 091 * @param subscriptionClassName the class name of the subscribed entity 092 * @param subscriptionClassPK the primary key of the subscribed entity 093 * @param inferredClassName the class name of the inferred entity if the 094 * subscribed entity is a container entity 095 * @param inferredClassPK the primary key of the inferred entity if the 096 * subscribed entity is a container entity 097 * @return <code>true</code> if the user has permission to subscribe to the 098 * subscribed entity and receive notifications about the inferred 099 * entity; <code>false</code> otherwise 100 * @throws PortalException if the user did not have permission to view the 101 * inferred entity or receive notifications about it via the 102 * subscribed entity, or if a portal exception occurred 103 * @throws SystemException if a system exception occurred 104 */ 105 public boolean contains( 106 PermissionChecker permissionChecker, String subscriptionClassName, 107 long subscriptionClassPK, String inferredClassName, 108 long inferredClassPK) 109 throws PortalException, SystemException; 110 111 }