001    /**
002     * Copyright (c) 2000-present 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.security.permission.PermissionChecker;
019    
020    /**
021     * Checks permissions with respect to subscriptions.
022     *
023     * @author Mate Thurzo
024     * @author Raymond Aug??
025     */
026    public interface SubscriptionPermission {
027    
028            /**
029             * @deprecated As of 6.2.0, replaced by {@link #check(PermissionChecker,
030             *             String, long, String, long)}
031             */
032            @Deprecated
033            public void check(
034                            PermissionChecker permissionChecker, String className, long classPK)
035                    throws PortalException;
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             * @see    #contains(PermissionChecker, String, long, String, long)
052             */
053            public void check(
054                            PermissionChecker permissionChecker, String subscriptionClassName,
055                            long subscriptionClassPK, String inferredClassName,
056                            long inferredClassPK)
057                    throws PortalException;
058    
059            /**
060             * @deprecated As of 6.2.0, replaced by {@link #contains(PermissionChecker,
061             *             String, long, String, long)}
062             */
063            @Deprecated
064            public boolean contains(
065                            PermissionChecker permissionChecker, String className, long classPK)
066                    throws PortalException;
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             */
104            public boolean contains(
105                            PermissionChecker permissionChecker, String subscriptionClassName,
106                            long subscriptionClassPK, String inferredClassName,
107                            long inferredClassPK)
108                    throws PortalException;
109    
110    }