001    /**
002     * Copyright (c) 2000-2012 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;
016    
017    import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
018    import com.liferay.portal.kernel.util.MethodCache;
019    import com.liferay.portal.kernel.util.ReferenceRegistry;
020    
021    /**
022     * The utility for the resource permission remote service. This utility wraps {@link com.liferay.portal.service.impl.ResourcePermissionServiceImpl} and is the primary access point for service operations in application layer code running on a remote server.
023     *
024     * <p>
025     * This is a remote service. Methods of this service are expected to have security checks based on the propagated JAAS credentials because this service can be accessed remotely.
026     * </p>
027     *
028     * @author Brian Wing Shun Chan
029     * @see ResourcePermissionService
030     * @see com.liferay.portal.service.base.ResourcePermissionServiceBaseImpl
031     * @see com.liferay.portal.service.impl.ResourcePermissionServiceImpl
032     * @generated
033     */
034    public class ResourcePermissionServiceUtil {
035            /*
036             * NOTE FOR DEVELOPERS:
037             *
038             * Never modify this class directly. Add custom service methods to {@link com.liferay.portal.service.impl.ResourcePermissionServiceImpl} and rerun ServiceBuilder to regenerate this class.
039             */
040    
041            /**
042            * Grants the role permission at the scope to perform the action on
043            * resources of the type. Existing actions are retained.
044            *
045            * <p>
046            * This method cannot be used to grant individual scope permissions, but is
047            * only intended for adding permissions at the company, group, and
048            * group-template scopes. For example, this method could be used to grant a
049            * company scope permission to edit message board posts.
050            * </p>
051            *
052            * <p>
053            * If a company scope permission is granted to resources that the role
054            * already had group scope permissions to, the group scope permissions are
055            * deleted. Likewise, if a group scope permission is granted to resources
056            * that the role already had company scope permissions to, the company scope
057            * permissions are deleted. Be aware that this latter behavior can result in
058            * an overall reduction in permissions for the role.
059            * </p>
060            *
061            * <p>
062            * Depending on the scope, the value of <code>primKey</code> will have
063            * different meanings. For more information, see {@link
064            * com.liferay.portal.model.impl.ResourcePermissionImpl}.
065            * </p>
066            *
067            * @param groupId the primary key of the group
068            * @param companyId the primary key of the company
069            * @param name the resource's name, which can be either a class name or a
070            portlet ID
071            * @param scope the scope. This method only supports company, group, and
072            group-template scope.
073            * @param primKey the primary key
074            * @param roleId the primary key of the role
075            * @param actionId the action ID
076            * @throws PortalException if the user did not have permission to add
077            resource permissions, or if scope was set to individual scope or
078            if a role with the primary key or a resource action with the name
079            and action ID could not be found
080            * @throws SystemException if a system exception occurred
081            */
082            public static void addResourcePermission(long groupId, long companyId,
083                    java.lang.String name, int scope, java.lang.String primKey,
084                    long roleId, java.lang.String actionId)
085                    throws com.liferay.portal.kernel.exception.PortalException,
086                            com.liferay.portal.kernel.exception.SystemException {
087                    getService()
088                            .addResourcePermission(groupId, companyId, name, scope, primKey,
089                            roleId, actionId);
090            }
091    
092            /**
093            * Revokes permission at the scope from the role to perform the action on
094            * resources of the type. For example, this method could be used to revoke a
095            * group scope permission to edit blog posts.
096            *
097            * <p>
098            * Depending on the scope, the value of <code>primKey</code> will have
099            * different meanings. For more information, see {@link
100            * com.liferay.portal.model.impl.ResourcePermissionImpl}.
101            * </p>
102            *
103            * @param groupId the primary key of the group
104            * @param companyId the primary key of the company
105            * @param name the resource's name, which can be either a class name or a
106            portlet ID
107            * @param scope the scope
108            * @param primKey the primary key
109            * @param roleId the primary key of the role
110            * @param actionId the action ID
111            * @throws PortalException if the user did not have permission to remove
112            resource permissions, or if a role with the primary key or a
113            resource action with the name and action ID could not be found
114            * @throws SystemException if a system exception occurred
115            */
116            public static void removeResourcePermission(long groupId, long companyId,
117                    java.lang.String name, int scope, java.lang.String primKey,
118                    long roleId, java.lang.String actionId)
119                    throws com.liferay.portal.kernel.exception.PortalException,
120                            com.liferay.portal.kernel.exception.SystemException {
121                    getService()
122                            .removeResourcePermission(groupId, companyId, name, scope, primKey,
123                            roleId, actionId);
124            }
125    
126            /**
127            * Revokes all permissions at the scope from the role to perform the action
128            * on resources of the type. For example, this method could be used to
129            * revoke all individual scope permissions to edit blog posts from site
130            * members.
131            *
132            * @param groupId the primary key of the group
133            * @param companyId the primary key of the company
134            * @param name the resource's name, which can be either a class name or a
135            portlet ID
136            * @param scope the scope
137            * @param roleId the primary key of the role
138            * @param actionId the action ID
139            * @throws PortalException if the user did not have permission to remove
140            resource permissions, or if a role with the primary key or a
141            resource action with the name and action ID could not be found
142            * @throws SystemException if a system exception occurred
143            */
144            public static void removeResourcePermissions(long groupId, long companyId,
145                    java.lang.String name, int scope, long roleId, java.lang.String actionId)
146                    throws com.liferay.portal.kernel.exception.PortalException,
147                            com.liferay.portal.kernel.exception.SystemException {
148                    getService()
149                            .removeResourcePermissions(groupId, companyId, name, scope, roleId,
150                            actionId);
151            }
152    
153            /**
154            * Updates the role's permissions at the scope, setting the actions that can
155            * be performed on resources of the type. Existing actions are replaced.
156            *
157            * <p>
158            * This method can be used to set permissions at any scope, but it is
159            * generally only used at the individual scope. For example, it could be
160            * used to set the guest permissions on a blog post.
161            * </p>
162            *
163            * <p>
164            * Depending on the scope, the value of <code>primKey</code> will have
165            * different meanings. For more information, see {@link
166            * com.liferay.portal.model.impl.ResourcePermissionImpl}.
167            * </p>
168            *
169            * @param groupId the primary key of the group
170            * @param companyId the primary key of the company
171            * @param name the resource's name, which can be either a class name or a
172            portlet ID
173            * @param primKey the primary key
174            * @param roleId the primary key of the role
175            * @param actionIds the action IDs of the actions
176            * @throws PortalException if the user did not have permission to set
177            resource permissions, or if a role with the primary key or a
178            resource action with the name and action ID could not be found
179            * @throws SystemException if a system exception occurred
180            */
181            public static void setIndividualResourcePermissions(long groupId,
182                    long companyId, java.lang.String name, java.lang.String primKey,
183                    long roleId, java.lang.String[] actionIds)
184                    throws com.liferay.portal.kernel.exception.PortalException,
185                            com.liferay.portal.kernel.exception.SystemException {
186                    getService()
187                            .setIndividualResourcePermissions(groupId, companyId, name,
188                            primKey, roleId, actionIds);
189            }
190    
191            /**
192            * Updates the role's permissions at the scope, setting the actions that can
193            * be performed on resources of the type. Existing actions are replaced.
194            *
195            * <p>
196            * This method can be used to set permissions at any scope, but it is
197            * generally only used at the individual scope. For example, it could be
198            * used to set the guest permissions on a blog post.
199            * </p>
200            *
201            * <p>
202            * Depending on the scope, the value of <code>primKey</code> will have
203            * different meanings. For more information, see {@link
204            * com.liferay.portal.model.impl.ResourcePermissionImpl}.
205            * </p>
206            *
207            * @param groupId the primary key of the group
208            * @param companyId the primary key of the company
209            * @param name the resource's name, which can be either a class name or a
210            portlet ID
211            * @param primKey the primary key
212            * @param roleIdsToActionIds a map of role IDs to action IDs of the actions
213            * @throws PortalException if the user did not have permission to set
214            resource permissions, or if a role with the primary key or a
215            resource action with the name and action ID could not be found
216            * @throws SystemException if a system exception occurred
217            */
218            public static void setIndividualResourcePermissions(long groupId,
219                    long companyId, java.lang.String name, java.lang.String primKey,
220                    java.util.Map<java.lang.Long, java.lang.String[]> roleIdsToActionIds)
221                    throws com.liferay.portal.kernel.exception.PortalException,
222                            com.liferay.portal.kernel.exception.SystemException {
223                    getService()
224                            .setIndividualResourcePermissions(groupId, companyId, name,
225                            primKey, roleIdsToActionIds);
226            }
227    
228            public static ResourcePermissionService getService() {
229                    if (_service == null) {
230                            _service = (ResourcePermissionService)PortalBeanLocatorUtil.locate(ResourcePermissionService.class.getName());
231    
232                            ReferenceRegistry.registerReference(ResourcePermissionServiceUtil.class,
233                                    "_service");
234                            MethodCache.remove(ResourcePermissionService.class);
235                    }
236    
237                    return _service;
238            }
239    
240            public void setService(ResourcePermissionService service) {
241                    MethodCache.remove(ResourcePermissionService.class);
242    
243                    _service = service;
244    
245                    ReferenceRegistry.registerReference(ResourcePermissionServiceUtil.class,
246                            "_service");
247                    MethodCache.remove(ResourcePermissionService.class);
248            }
249    
250            private static ResourcePermissionService _service;
251    }