001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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    }