1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.service.impl;
24  
25  import com.liferay.portal.PortalException;
26  import com.liferay.portal.SystemException;
27  import com.liferay.portal.model.ResourceConstants;
28  import com.liferay.portal.model.Role;
29  import com.liferay.portal.service.base.ResourcePermissionServiceBaseImpl;
30  
31  import java.rmi.RemoteException;
32  
33  /**
34   * <a href="ResourcePermissionServiceImpl.java.html"><b><i>View Source</i></b>
35   * </a>
36   *
37   * @author Brian Wing Shun Chan
38   */
39  public class ResourcePermissionServiceImpl
40      extends ResourcePermissionServiceBaseImpl {
41  
42      public void addResourcePermission(
43              long groupId, long companyId, String name, int scope,
44              String primKey, long roleId, String actionId)
45          throws PortalException, SystemException {
46  
47          try {
48              permissionService.checkPermission(
49                  groupId, Role.class.getName(), roleId);
50          }
51          catch (RemoteException re) {
52              throw new SystemException(re);
53          }
54  
55          resourcePermissionLocalService.addResourcePermission(
56              companyId, name, scope, primKey, roleId, actionId);
57      }
58  
59      public void setIndividualResourcePermissions(
60              long groupId, long companyId, String name, String primKey,
61              long roleId, String[] actionIds)
62          throws PortalException, SystemException {
63  
64          try {
65              permissionService.checkPermission(groupId, name, primKey);
66          }
67          catch (RemoteException re) {
68              throw new SystemException(re);
69          }
70  
71          resourcePermissionLocalService.setResourcePermissions(
72              companyId, name, ResourceConstants.SCOPE_INDIVIDUAL, primKey,
73              roleId, actionIds);
74      }
75  
76      public void removeResourcePermission(
77              long groupId, long companyId, String name, int scope,
78              String primKey, long roleId, String actionId)
79          throws PortalException, SystemException {
80  
81          try {
82              permissionService.checkPermission(
83                  groupId, Role.class.getName(), roleId);
84          }
85          catch (RemoteException re) {
86              throw new SystemException(re);
87          }
88  
89          resourcePermissionLocalService.removeResourcePermission(
90              companyId, name, scope, primKey, roleId, actionId);
91      }
92  
93      public void removeResourcePermissions(
94              long groupId, long companyId, String name, int scope, long roleId,
95              String actionId)
96          throws PortalException, SystemException {
97  
98          try {
99              permissionService.checkPermission(
100                 groupId, Role.class.getName(), roleId);
101         }
102         catch (RemoteException re) {
103             throw new SystemException(re);
104         }
105 
106         resourcePermissionLocalService.removeResourcePermissions(
107             companyId, name, scope, roleId, actionId);
108     }
109 
110 }