001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.service.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.model.ResourceConstants;
020    import com.liferay.portal.model.Role;
021    import com.liferay.portal.service.base.ResourcePermissionServiceBaseImpl;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     */
026    public class ResourcePermissionServiceImpl
027            extends ResourcePermissionServiceBaseImpl {
028    
029            public void addResourcePermission(
030                            long groupId, long companyId, String name, int scope,
031                            String primKey, long roleId, String actionId)
032                    throws PortalException, SystemException {
033    
034                    permissionService.checkPermission(
035                            groupId, Role.class.getName(), roleId);
036    
037                    resourcePermissionLocalService.addResourcePermission(
038                            companyId, name, scope, primKey, roleId, actionId);
039            }
040    
041            public void setIndividualResourcePermissions(
042                            long groupId, long companyId, String name, String primKey,
043                            long roleId, String[] actionIds)
044                    throws PortalException, SystemException {
045    
046                    permissionService.checkPermission(groupId, name, primKey);
047    
048                    resourcePermissionLocalService.setResourcePermissions(
049                            companyId, name, ResourceConstants.SCOPE_INDIVIDUAL, primKey,
050                            roleId, actionIds);
051            }
052    
053            public void removeResourcePermission(
054                            long groupId, long companyId, String name, int scope,
055                            String primKey, long roleId, String actionId)
056                    throws PortalException, SystemException {
057    
058                    permissionService.checkPermission(
059                            groupId, Role.class.getName(), roleId);
060    
061                    resourcePermissionLocalService.removeResourcePermission(
062                            companyId, name, scope, primKey, roleId, actionId);
063            }
064    
065            public void removeResourcePermissions(
066                            long groupId, long companyId, String name, int scope, long roleId,
067                            String actionId)
068                    throws PortalException, SystemException {
069    
070                    permissionService.checkPermission(
071                            groupId, Role.class.getName(), roleId);
072    
073                    resourcePermissionLocalService.removeResourcePermissions(
074                            companyId, name, scope, roleId, actionId);
075            }
076    
077    }