1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.service.impl;
16  
17  import com.liferay.portal.PortalException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portal.model.ResourceConstants;
20  import com.liferay.portal.model.Role;
21  import com.liferay.portal.service.base.ResourcePermissionServiceBaseImpl;
22  
23  import java.rmi.RemoteException;
24  
25  /**
26   * <a href="ResourcePermissionServiceImpl.java.html"><b><i>View Source</i></b>
27   * </a>
28   *
29   * @author Brian Wing Shun Chan
30   */
31  public class ResourcePermissionServiceImpl
32      extends ResourcePermissionServiceBaseImpl {
33  
34      public void addResourcePermission(
35              long groupId, long companyId, String name, int scope,
36              String primKey, long roleId, String actionId)
37          throws PortalException, SystemException {
38  
39          try {
40              permissionService.checkPermission(
41                  groupId, Role.class.getName(), roleId);
42          }
43          catch (RemoteException re) {
44              throw new SystemException(re);
45          }
46  
47          resourcePermissionLocalService.addResourcePermission(
48              companyId, name, scope, primKey, roleId, actionId);
49      }
50  
51      public void setIndividualResourcePermissions(
52              long groupId, long companyId, String name, String primKey,
53              long roleId, String[] actionIds)
54          throws PortalException, SystemException {
55  
56          try {
57              permissionService.checkPermission(groupId, name, primKey);
58          }
59          catch (RemoteException re) {
60              throw new SystemException(re);
61          }
62  
63          resourcePermissionLocalService.setResourcePermissions(
64              companyId, name, ResourceConstants.SCOPE_INDIVIDUAL, primKey,
65              roleId, actionIds);
66      }
67  
68      public void removeResourcePermission(
69              long groupId, long companyId, String name, int scope,
70              String primKey, long roleId, String actionId)
71          throws PortalException, SystemException {
72  
73          try {
74              permissionService.checkPermission(
75                  groupId, Role.class.getName(), roleId);
76          }
77          catch (RemoteException re) {
78              throw new SystemException(re);
79          }
80  
81          resourcePermissionLocalService.removeResourcePermission(
82              companyId, name, scope, primKey, roleId, actionId);
83      }
84  
85      public void removeResourcePermissions(
86              long groupId, long companyId, String name, int scope, long roleId,
87              String actionId)
88          throws PortalException, SystemException {
89  
90          try {
91              permissionService.checkPermission(
92                  groupId, Role.class.getName(), roleId);
93          }
94          catch (RemoteException re) {
95              throw new SystemException(re);
96          }
97  
98          resourcePermissionLocalService.removeResourcePermissions(
99              companyId, name, scope, roleId, actionId);
100     }
101 
102 }