1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.service;
21  
22  
23  /**
24   * <a href="PermissionServiceUtil.java.html"><b><i>View Source</i></b></a>
25   *
26   * <p>
27   * ServiceBuilder generated this class. Modifications in this class will be
28   * overwritten the next time is generated.
29   * </p>
30   *
31   * <p>
32   * This class provides static methods for the
33   * <code>com.liferay.portal.service.PermissionService</code>
34   * bean. The static methods of this class calls the same methods of the bean
35   * instance. It's convenient to be able to just write one line to call a method
36   * on a bean instead of writing a lookup call and a method call.
37   * </p>
38   *
39   * @author Brian Wing Shun Chan
40   *
41   * @see com.liferay.portal.service.PermissionService
42   *
43   */
44  public class PermissionServiceUtil {
45      public static void checkPermission(long groupId, long resourceId)
46          throws com.liferay.portal.PortalException,
47              com.liferay.portal.SystemException {
48          getService().checkPermission(groupId, resourceId);
49      }
50  
51      public static void checkPermission(long groupId, java.lang.String name,
52          long primKey)
53          throws com.liferay.portal.PortalException,
54              com.liferay.portal.SystemException {
55          getService().checkPermission(groupId, name, primKey);
56      }
57  
58      public static void checkPermission(long groupId, java.lang.String name,
59          java.lang.String primKey)
60          throws com.liferay.portal.PortalException,
61              com.liferay.portal.SystemException {
62          getService().checkPermission(groupId, name, primKey);
63      }
64  
65      public static boolean hasGroupPermission(long groupId,
66          java.lang.String actionId, long resourceId)
67          throws com.liferay.portal.SystemException {
68          return getService().hasGroupPermission(groupId, actionId, resourceId);
69      }
70  
71      public static boolean hasUserPermission(long userId,
72          java.lang.String actionId, long resourceId)
73          throws com.liferay.portal.SystemException {
74          return getService().hasUserPermission(userId, actionId, resourceId);
75      }
76  
77      public static boolean hasUserPermissions(long userId, long groupId,
78          java.util.List<com.liferay.portal.model.Resource> resources,
79          java.lang.String actionId,
80          com.liferay.portal.security.permission.PermissionCheckerBag permissionCheckerBag)
81          throws com.liferay.portal.PortalException,
82              com.liferay.portal.SystemException {
83          return getService()
84                     .hasUserPermissions(userId, groupId, resources, actionId,
85              permissionCheckerBag);
86      }
87  
88      public static void setGroupPermissions(long groupId,
89          java.lang.String[] actionIds, long resourceId)
90          throws com.liferay.portal.PortalException,
91              com.liferay.portal.SystemException {
92          getService().setGroupPermissions(groupId, actionIds, resourceId);
93      }
94  
95      public static void setGroupPermissions(java.lang.String className,
96          java.lang.String classPK, long groupId, java.lang.String[] actionIds,
97          long resourceId)
98          throws com.liferay.portal.PortalException,
99              com.liferay.portal.SystemException {
100         getService()
101             .setGroupPermissions(className, classPK, groupId, actionIds,
102             resourceId);
103     }
104 
105     public static void setOrgGroupPermissions(long organizationId,
106         long groupId, java.lang.String[] actionIds, long resourceId)
107         throws com.liferay.portal.PortalException,
108             com.liferay.portal.SystemException {
109         getService()
110             .setOrgGroupPermissions(organizationId, groupId, actionIds,
111             resourceId);
112     }
113 
114     public static void setRolePermission(long roleId, long groupId,
115         java.lang.String name, int scope, java.lang.String primKey,
116         java.lang.String actionId)
117         throws com.liferay.portal.PortalException,
118             com.liferay.portal.SystemException {
119         getService()
120             .setRolePermission(roleId, groupId, name, scope, primKey, actionId);
121     }
122 
123     public static void setRolePermissions(long roleId, long groupId,
124         java.lang.String[] actionIds, long resourceId)
125         throws com.liferay.portal.PortalException,
126             com.liferay.portal.SystemException {
127         getService().setRolePermissions(roleId, groupId, actionIds, resourceId);
128     }
129 
130     public static void setUserPermissions(long userId, long groupId,
131         java.lang.String[] actionIds, long resourceId)
132         throws com.liferay.portal.PortalException,
133             com.liferay.portal.SystemException {
134         getService().setUserPermissions(userId, groupId, actionIds, resourceId);
135     }
136 
137     public static void unsetRolePermission(long roleId, long groupId,
138         long permissionId)
139         throws com.liferay.portal.PortalException,
140             com.liferay.portal.SystemException {
141         getService().unsetRolePermission(roleId, groupId, permissionId);
142     }
143 
144     public static void unsetRolePermission(long roleId, long groupId,
145         java.lang.String name, int scope, java.lang.String primKey,
146         java.lang.String actionId)
147         throws com.liferay.portal.PortalException,
148             com.liferay.portal.SystemException {
149         getService()
150             .unsetRolePermission(roleId, groupId, name, scope, primKey, actionId);
151     }
152 
153     public static void unsetRolePermissions(long roleId, long groupId,
154         java.lang.String name, int scope, java.lang.String actionId)
155         throws com.liferay.portal.PortalException,
156             com.liferay.portal.SystemException {
157         getService().unsetRolePermissions(roleId, groupId, name, scope, actionId);
158     }
159 
160     public static void unsetUserPermissions(long userId, long groupId,
161         java.lang.String[] actionIds, long resourceId)
162         throws com.liferay.portal.PortalException,
163             com.liferay.portal.SystemException {
164         getService().unsetUserPermissions(userId, groupId, actionIds, resourceId);
165     }
166 
167     public static PermissionService getService() {
168         if (_service == null) {
169             throw new RuntimeException("PermissionService is not set");
170         }
171 
172         return _service;
173     }
174 
175     public void setService(PermissionService service) {
176         _service = service;
177     }
178 
179     private static PermissionService _service;
180 }