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.kernel.exception.PortalException;
18  import com.liferay.portal.kernel.exception.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  /**
24   * <a href="ResourcePermissionServiceImpl.java.html"><b><i>View Source</i></b>
25   * </a>
26   *
27   * @author Brian Wing Shun Chan
28   */
29  public class ResourcePermissionServiceImpl
30      extends ResourcePermissionServiceBaseImpl {
31  
32      public void addResourcePermission(
33              long groupId, long companyId, String name, int scope,
34              String primKey, long roleId, String actionId)
35          throws PortalException, SystemException {
36  
37          permissionService.checkPermission(
38              groupId, Role.class.getName(), roleId);
39  
40          resourcePermissionLocalService.addResourcePermission(
41              companyId, name, scope, primKey, roleId, actionId);
42      }
43  
44      public void setIndividualResourcePermissions(
45              long groupId, long companyId, String name, String primKey,
46              long roleId, String[] actionIds)
47          throws PortalException, SystemException {
48  
49          permissionService.checkPermission(groupId, name, primKey);
50  
51          resourcePermissionLocalService.setResourcePermissions(
52              companyId, name, ResourceConstants.SCOPE_INDIVIDUAL, primKey,
53              roleId, actionIds);
54      }
55  
56      public void removeResourcePermission(
57              long groupId, long companyId, String name, int scope,
58              String primKey, long roleId, String actionId)
59          throws PortalException, SystemException {
60  
61          permissionService.checkPermission(
62              groupId, Role.class.getName(), roleId);
63  
64          resourcePermissionLocalService.removeResourcePermission(
65              companyId, name, scope, primKey, roleId, actionId);
66      }
67  
68      public void removeResourcePermissions(
69              long groupId, long companyId, String name, int scope, long roleId,
70              String actionId)
71          throws PortalException, SystemException {
72  
73          permissionService.checkPermission(
74              groupId, Role.class.getName(), roleId);
75  
76          resourcePermissionLocalService.removeResourcePermissions(
77              companyId, name, scope, roleId, actionId);
78      }
79  
80  }