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 permission remote service. This utility wraps {@link com.liferay.portal.service.impl.PermissionServiceImpl} 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 PermissionService
030     * @see com.liferay.portal.service.base.PermissionServiceBaseImpl
031     * @see com.liferay.portal.service.impl.PermissionServiceImpl
032     * @generated
033     */
034    public class PermissionServiceUtil {
035            /*
036             * NOTE FOR DEVELOPERS:
037             *
038             * Never modify this class directly. Add custom service methods to {@link com.liferay.portal.service.impl.PermissionServiceImpl} and rerun ServiceBuilder to regenerate this class.
039             */
040    
041            /**
042            * Checks to see if the group has permission to the resource.
043            *
044            * @param groupId the primary key of the group
045            * @param resourceId the primary key of the resource
046            * @throws PortalException if the group did not have permission to the
047            resource, or if a group or resource with the primary key could
048            not be found or was invalid
049            * @throws SystemException if a system exception occurred
050            */
051            public static void checkPermission(long groupId, long resourceId)
052                    throws com.liferay.portal.kernel.exception.PortalException,
053                            com.liferay.portal.kernel.exception.SystemException {
054                    getService().checkPermission(groupId, resourceId);
055            }
056    
057            /**
058            * Checks to see if the group has permission to the service.
059            *
060            * @param groupId the primary key of the group
061            * @param name the service name
062            * @param primKey the primary key of the service
063            * @throws PortalException if the group did not have permission to the
064            service, if a group with the primary key could not be found or if
065            the permission information was invalid
066            * @throws SystemException if a system exception occurred
067            */
068            public static void checkPermission(long groupId, java.lang.String name,
069                    long primKey)
070                    throws com.liferay.portal.kernel.exception.PortalException,
071                            com.liferay.portal.kernel.exception.SystemException {
072                    getService().checkPermission(groupId, name, primKey);
073            }
074    
075            /**
076            * Checks to see if the group has permission to the service.
077            *
078            * @param groupId the primary key of the group
079            * @param name the service name
080            * @param primKey the primary key of the service
081            * @throws PortalException if the group did not have permission to the
082            service, if a group with the primary key could not be found or if
083            the permission information was invalid
084            * @throws SystemException if a system exception occurred
085            */
086            public static void checkPermission(long groupId, java.lang.String name,
087                    java.lang.String primKey)
088                    throws com.liferay.portal.kernel.exception.PortalException,
089                            com.liferay.portal.kernel.exception.SystemException {
090                    getService().checkPermission(groupId, name, primKey);
091            }
092    
093            /**
094            * Returns <code>true</code> if the group has permission to perform the
095            * action on the resource.
096            *
097            * @param groupId the primary key of the group
098            * @param actionId the action's ID
099            * @param resourceId the primary key of the resource
100            * @return <code>true</code> if the group has permission to perform the
101            action on the resource; <code>false</code> otherwise
102            * @throws SystemException if a system exception occurred
103            */
104            public static boolean hasGroupPermission(long groupId,
105                    java.lang.String actionId, long resourceId)
106                    throws com.liferay.portal.kernel.exception.SystemException {
107                    return getService().hasGroupPermission(groupId, actionId, resourceId);
108            }
109    
110            /**
111            * Returns <code>true</code> if the user has permission to perform the
112            * action on the resource.
113            *
114            * @param userId the primary key of the user
115            * @param actionId the action's ID
116            * @param resourceId the primary key of the resource
117            * @return <code>true</code> if the user has permission to perform the
118            action on the resource; <code>false</code> otherwise
119            * @throws SystemException if a system exception occurred
120            */
121            public static boolean hasUserPermission(long userId,
122                    java.lang.String actionId, long resourceId)
123                    throws com.liferay.portal.kernel.exception.SystemException {
124                    return getService().hasUserPermission(userId, actionId, resourceId);
125            }
126    
127            /**
128            * Returns <code>true</code> if the user has permission to perform the
129            * action on the resources.
130            *
131            * <p>
132            * This method does not support resources managed by the resource block
133            * system.
134            * </p>
135            *
136            * @param userId the primary key of the user
137            * @param groupId the primary key of the group containing the resource
138            * @param resources representations of the resource at each scope level
139            returned by {@link
140            com.liferay.portal.security.permission.AdvancedPermissionChecker#getResources(
141            long, long, String, String, String)}
142            * @param actionId the action's ID
143            * @param permissionCheckerBag the permission checker bag
144            * @return <code>true</code> if the user has permission to perform the
145            action on the resources; <code>false</code> otherwise
146            * @throws PortalException if a resource action based on any one of the
147            resources and the action ID could not be found
148            * @throws SystemException if a system exception occurred
149            */
150            public static boolean hasUserPermissions(long userId, long groupId,
151                    java.util.List<com.liferay.portal.model.Resource> resources,
152                    java.lang.String actionId,
153                    com.liferay.portal.security.permission.PermissionCheckerBag permissionCheckerBag)
154                    throws com.liferay.portal.kernel.exception.PortalException,
155                            com.liferay.portal.kernel.exception.SystemException {
156                    return getService()
157                                       .hasUserPermissions(userId, groupId, resources, actionId,
158                            permissionCheckerBag);
159            }
160    
161            /**
162            * Sets the group's permissions to perform the actions on the resource,
163            * replacing the group's existing permissions on the resource.
164            *
165            * @param groupId the primary key of the group
166            * @param actionIds the primary keys of the actions
167            * @param resourceId the primary key of the resource
168            * @throws PortalException if a group with the primary key could not be
169            found or if the group did not have permission to the resource
170            * @throws SystemException if a system exception occurred
171            */
172            public static void setGroupPermissions(long groupId,
173                    java.lang.String[] actionIds, long resourceId)
174                    throws com.liferay.portal.kernel.exception.PortalException,
175                            com.liferay.portal.kernel.exception.SystemException {
176                    getService().setGroupPermissions(groupId, actionIds, resourceId);
177            }
178    
179            /**
180            * Sets the entity's group permissions to perform the actions on the
181            * resource, replacing the entity's existing group permissions on the
182            * resource. Only {@link com.liferay.portal.model.Organization} and {@link
183            * com.liferay.portal.model.UserGroup} class entities are supported.
184            *
185            * @param className the class name of an organization or user group
186            * @param classPK the primary key of the class
187            * @param groupId the primary key of the group
188            * @param actionIds the primary keys of the actions
189            * @param resourceId the primary key of the resource
190            * @throws PortalException if the group did not have permission to the
191            resource, if an entity with the class name and primary key could
192            not be found, or if the entity's associated group could not be
193            found
194            * @throws SystemException if a system exception occurred
195            */
196            public static void setGroupPermissions(java.lang.String className,
197                    java.lang.String classPK, long groupId, java.lang.String[] actionIds,
198                    long resourceId)
199                    throws com.liferay.portal.kernel.exception.PortalException,
200                            com.liferay.portal.kernel.exception.SystemException {
201                    getService()
202                            .setGroupPermissions(className, classPK, groupId, actionIds,
203                            resourceId);
204            }
205    
206            /**
207            * Sets the permissions of each role to perform respective actions on the
208            * resource, replacing the existing permissions of each role on the
209            * resource.
210            *
211            * @param groupId the primary key of the group
212            * @param companyId the primary key of the company
213            * @param roleIdsToActionIds the map of roles to their new actions on the
214            resource
215            * @param resourceId the primary key of the resource
216            * @throws PortalException if the group did not have permission to the
217            resource
218            * @throws SystemException if a system exception occurred
219            */
220            public static void setIndividualPermissions(long groupId, long companyId,
221                    java.util.Map<java.lang.Long, java.lang.String[]> roleIdsToActionIds,
222                    long resourceId)
223                    throws com.liferay.portal.kernel.exception.PortalException,
224                            com.liferay.portal.kernel.exception.SystemException {
225                    getService()
226                            .setIndividualPermissions(groupId, companyId, roleIdsToActionIds,
227                            resourceId);
228            }
229    
230            /**
231            * Sets the organization permission to perform the actions on the resource
232            * for a particular group, replacing the organization's existing permissions
233            * on the resource.
234            *
235            * @param organizationId the primary key of the organization
236            * @param groupId the primary key of the group in which to scope the
237            permissions
238            * @param actionIds the primary keys of the actions
239            * @param resourceId the primary key of the resource
240            * @throws PortalException if the group did not have permission to the
241            resource or if an organization with the primary key could not be
242            found
243            * @throws SystemException if a system exception occurred
244            */
245            public static void setOrgGroupPermissions(long organizationId,
246                    long groupId, java.lang.String[] actionIds, long resourceId)
247                    throws com.liferay.portal.kernel.exception.PortalException,
248                            com.liferay.portal.kernel.exception.SystemException {
249                    getService()
250                            .setOrgGroupPermissions(organizationId, groupId, actionIds,
251                            resourceId);
252            }
253    
254            /**
255            * Sets the role's permissions to perform the action on the named resource,
256            * replacing the role's existing permissions on the resource.
257            *
258            * @param roleId the primary key of the role
259            * @param groupId the primary key of the group
260            * @param name the resource name
261            * @param scope the resource scope
262            * @param primKey the resource primKey
263            * @param actionId the action's ID
264            * @throws PortalException if the group did not have permission to the role
265            or if the scope was {@link
266            com.liferay.portal.model.ResourceConstants#SCOPE_INDIVIDUAL}
267            * @throws SystemException if a system exception occurred
268            */
269            public static void setRolePermission(long roleId, long groupId,
270                    java.lang.String name, int scope, java.lang.String primKey,
271                    java.lang.String actionId)
272                    throws com.liferay.portal.kernel.exception.PortalException,
273                            com.liferay.portal.kernel.exception.SystemException {
274                    getService()
275                            .setRolePermission(roleId, groupId, name, scope, primKey, actionId);
276            }
277    
278            /**
279            * Sets the role's permissions to perform the actions on the resource,
280            * replacing the role's existing permissions on the resource.
281            *
282            * @param roleId the primary key of the role
283            * @param groupId the primary key of the group
284            * @param actionIds the primary keys of the actions
285            * @param resourceId the primary key of the resource
286            * @throws PortalException if the group did not have permission to the
287            resource or if a role with the primary key could not be found
288            * @throws SystemException if a system exception occurred
289            */
290            public static void setRolePermissions(long roleId, long groupId,
291                    java.lang.String[] actionIds, long resourceId)
292                    throws com.liferay.portal.kernel.exception.PortalException,
293                            com.liferay.portal.kernel.exception.SystemException {
294                    getService().setRolePermissions(roleId, groupId, actionIds, resourceId);
295            }
296    
297            /**
298            * Sets the user's permissions to perform the actions on the resource,
299            * replacing the user's existing permissions on the resource.
300            *
301            * @param userId the primary key of the user
302            * @param groupId the primary key of the group
303            * @param actionIds the primary keys of the actions
304            * @param resourceId the primary key of the resource
305            * @throws PortalException if the group did not have permission to the
306            resource or if a user with the primary key could not be found
307            * @throws SystemException if a system exception occurred
308            */
309            public static void setUserPermissions(long userId, long groupId,
310                    java.lang.String[] actionIds, long resourceId)
311                    throws com.liferay.portal.kernel.exception.PortalException,
312                            com.liferay.portal.kernel.exception.SystemException {
313                    getService().setUserPermissions(userId, groupId, actionIds, resourceId);
314            }
315    
316            /**
317            * Removes the permission from the role.
318            *
319            * @param roleId the primary key of the role
320            * @param groupId the primary key of the group
321            * @param permissionId the primary key of the permission
322            * @throws PortalException if the group did not have permission to the role
323            * @throws SystemException if a system exception occurred
324            */
325            public static void unsetRolePermission(long roleId, long groupId,
326                    long permissionId)
327                    throws com.liferay.portal.kernel.exception.PortalException,
328                            com.liferay.portal.kernel.exception.SystemException {
329                    getService().unsetRolePermission(roleId, groupId, permissionId);
330            }
331    
332            /**
333            * Removes the role's permissions to perform the action on the named
334            * resource with the scope and primKey.
335            *
336            * @param roleId the primary key of the role
337            * @param groupId the primary key of the group
338            * @param name the resource name
339            * @param scope the resource scope
340            * @param primKey the resource primKey
341            * @param actionId the action's ID
342            * @throws PortalException if the group did not have permission to the role
343            * @throws SystemException if a system exception occurred
344            */
345            public static void unsetRolePermission(long roleId, long groupId,
346                    java.lang.String name, int scope, java.lang.String primKey,
347                    java.lang.String actionId)
348                    throws com.liferay.portal.kernel.exception.PortalException,
349                            com.liferay.portal.kernel.exception.SystemException {
350                    getService()
351                            .unsetRolePermission(roleId, groupId, name, scope, primKey, actionId);
352            }
353    
354            /**
355            * Removes the role's permissions to perform the action on the named
356            * resource.
357            *
358            * @param roleId the primary key of the role
359            * @param groupId the primary key of the group
360            * @param name the resource name
361            * @param scope the resource scope
362            * @param actionId the action's ID
363            * @throws PortalException if the group did not have permission to the role
364            * @throws SystemException if a system exception occurred
365            */
366            public static void unsetRolePermissions(long roleId, long groupId,
367                    java.lang.String name, int scope, java.lang.String actionId)
368                    throws com.liferay.portal.kernel.exception.PortalException,
369                            com.liferay.portal.kernel.exception.SystemException {
370                    getService().unsetRolePermissions(roleId, groupId, name, scope, actionId);
371            }
372    
373            /**
374            * Removes the user's permissions to perform the actions on the resource.
375            *
376            * @param userId the primary key of the user
377            * @param groupId the primary key of the group
378            * @param actionIds the primary keys of the actions
379            * @param resourceId the primary key of the resource
380            * @throws PortalException if the group did not have permission to the
381            resource
382            * @throws SystemException if a system exception occurred
383            */
384            public static void unsetUserPermissions(long userId, long groupId,
385                    java.lang.String[] actionIds, long resourceId)
386                    throws com.liferay.portal.kernel.exception.PortalException,
387                            com.liferay.portal.kernel.exception.SystemException {
388                    getService().unsetUserPermissions(userId, groupId, actionIds, resourceId);
389            }
390    
391            public static PermissionService getService() {
392                    if (_service == null) {
393                            _service = (PermissionService)PortalBeanLocatorUtil.locate(PermissionService.class.getName());
394    
395                            ReferenceRegistry.registerReference(PermissionServiceUtil.class,
396                                    "_service");
397                            MethodCache.remove(PermissionService.class);
398                    }
399    
400                    return _service;
401            }
402    
403            public void setService(PermissionService service) {
404                    MethodCache.remove(PermissionService.class);
405    
406                    _service = service;
407    
408                    ReferenceRegistry.registerReference(PermissionServiceUtil.class,
409                            "_service");
410                    MethodCache.remove(PermissionService.class);
411            }
412    
413            private static PermissionService _service;
414    }