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; 016 017 import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil; 018 import com.liferay.portal.kernel.util.MethodCache; 019 import com.liferay.portal.kernel.util.ReferenceRegistry; 020 021 /** 022 * The utility for the resource permission remote service. This utility wraps {@link com.liferay.portal.service.impl.ResourcePermissionServiceImpl} and is the primary access point for service operations in application layer code running on a remote server. 023 * 024 * <p> 025 * This is a remote service. Methods of this service are expected to have security checks based on the propagated JAAS credentials because this service can be accessed remotely. 026 * </p> 027 * 028 * @author Brian Wing Shun Chan 029 * @see ResourcePermissionService 030 * @see com.liferay.portal.service.base.ResourcePermissionServiceBaseImpl 031 * @see com.liferay.portal.service.impl.ResourcePermissionServiceImpl 032 * @generated 033 */ 034 public class ResourcePermissionServiceUtil { 035 /* 036 * NOTE FOR DEVELOPERS: 037 * 038 * Never modify this class directly. Add custom service methods to {@link com.liferay.portal.service.impl.ResourcePermissionServiceImpl} and rerun ServiceBuilder to regenerate this class. 039 */ 040 041 /** 042 * Grants the role permission at the scope to perform the action on 043 * resources of the type. Existing actions are retained. 044 * 045 * <p> 046 * This method cannot be used to grant individual scope permissions, but is 047 * only intended for adding permissions at the company, group, and 048 * group-template scopes. For example, this method could be used to grant a 049 * company scope permission to edit message board posts. 050 * </p> 051 * 052 * <p> 053 * If a company scope permission is granted to resources that the role 054 * already had group scope permissions to, the group scope permissions are 055 * deleted. Likewise, if a group scope permission is granted to resources 056 * that the role already had company scope permissions to, the company 057 * scope permissions are deleted. Be aware that this latter behavior can 058 * result in an overall reduction in permissions for the role. 059 * </p> 060 * 061 * <p> 062 * Depending on the scope, the value of <code>primKey</code> will have 063 * different meanings. For more information, see {@link 064 * com.liferay.portal.model.impl.ResourcePermissionImpl}. 065 * </p> 066 * 067 * @param groupId the primary key of the group 068 * @param companyId the primary key of the company 069 * @param name the resource's name, which can be either a class name or a 070 portlet ID 071 * @param scope the scope. This method only supports company, group, and 072 group-template scope. 073 * @param primKey the primary key 074 * @param roleId the primary key of the role 075 * @param actionId the action ID 076 * @throws PortalException if the user did not have permission to add 077 resource permissions, or if scope was set to individual scope or 078 if a role with the primary key or a resource action with the 079 name and action ID could not be found 080 * @throws SystemException if a system exception occurred 081 */ 082 public static void addResourcePermission(long groupId, long companyId, 083 java.lang.String name, int scope, java.lang.String primKey, 084 long roleId, java.lang.String actionId) 085 throws com.liferay.portal.kernel.exception.PortalException, 086 com.liferay.portal.kernel.exception.SystemException { 087 getService() 088 .addResourcePermission(groupId, companyId, name, scope, primKey, 089 roleId, actionId); 090 } 091 092 /** 093 * Revokes permission at the scope from the role to perform the action on 094 * resources of the type. For example, this method could be used to revoke 095 * a group scope permission to edit blog posts. 096 * 097 * <p> 098 * Depending on the scope, the value of <code>primKey</code> will have 099 * different meanings. For more information, see {@link 100 * com.liferay.portal.model.impl.ResourcePermissionImpl}. 101 * </p> 102 * 103 * @param groupId the primary key of the group 104 * @param companyId the primary key of the company 105 * @param name the resource's name, which can be either a class name or a 106 portlet ID 107 * @param scope the scope 108 * @param primKey the primary key 109 * @param roleId the primary key of the role 110 * @param actionId the action ID 111 * @throws PortalException if the user did not have permission to remove 112 resource permissions, or if a role with the primary key or a 113 resource action with the name and action ID could not be found 114 * @throws SystemException if a system exception occurred 115 */ 116 public static void removeResourcePermission(long groupId, long companyId, 117 java.lang.String name, int scope, java.lang.String primKey, 118 long roleId, java.lang.String actionId) 119 throws com.liferay.portal.kernel.exception.PortalException, 120 com.liferay.portal.kernel.exception.SystemException { 121 getService() 122 .removeResourcePermission(groupId, companyId, name, scope, primKey, 123 roleId, actionId); 124 } 125 126 /** 127 * Revokes all permissions at the scope from the role to perform the action 128 * on resources of the type. For example, this method could be used to 129 * revoke all individual scope permissions to edit blog posts from site 130 * members. 131 * 132 * @param groupId the primary key of the group 133 * @param companyId the primary key of the company 134 * @param name the resource's name, which can be either a class name or a 135 portlet ID 136 * @param scope the scope 137 * @param roleId the primary key of the role 138 * @param actionId the action ID 139 * @throws PortalException if the user did not have permission to remove 140 resource permissions, or if a role with the primary key or a 141 resource action with the name and action ID could not be found 142 * @throws SystemException if a system exception occurred 143 */ 144 public static void removeResourcePermissions(long groupId, long companyId, 145 java.lang.String name, int scope, long roleId, java.lang.String actionId) 146 throws com.liferay.portal.kernel.exception.PortalException, 147 com.liferay.portal.kernel.exception.SystemException { 148 getService() 149 .removeResourcePermissions(groupId, companyId, name, scope, roleId, 150 actionId); 151 } 152 153 /** 154 * Updates the role's permissions at the scope, setting the actions that 155 * can be performed on resources of the type. Existing actions are 156 * replaced. 157 * 158 * <p> 159 * This method can be used to set permissions at any scope, but it is 160 * generally only used at the individual scope. For example, it could be 161 * used to set the guest permissions on a blog post. 162 * </p> 163 * 164 * <p> 165 * Depending on the scope, the value of <code>primKey</code> will have 166 * different meanings. For more information, see {@link 167 * com.liferay.portal.model.impl.ResourcePermissionImpl}. 168 * </p> 169 * 170 * @param groupId the primary key of the group 171 * @param companyId the primary key of the company 172 * @param name the resource's name, which can be either a class name or a 173 portlet ID 174 * @param primKey the primary key 175 * @param roleId the primary key of the role 176 * @param actionIds the action IDs of the actions 177 * @throws PortalException if the user did not have permission to set 178 resource permissions, or if a role with the primary key or a 179 resource action with the name and action ID could not be found 180 * @throws SystemException if a system exception occurred 181 */ 182 public static void setIndividualResourcePermissions(long groupId, 183 long companyId, java.lang.String name, java.lang.String primKey, 184 long roleId, java.lang.String[] actionIds) 185 throws com.liferay.portal.kernel.exception.PortalException, 186 com.liferay.portal.kernel.exception.SystemException { 187 getService() 188 .setIndividualResourcePermissions(groupId, companyId, name, 189 primKey, roleId, actionIds); 190 } 191 192 /** 193 * Updates the role's permissions at the scope, setting the actions that 194 * can be performed on resources of the type. Existing actions are 195 * replaced. 196 * 197 * <p> 198 * This method can be used to set permissions at any scope, but it is 199 * generally only used at the individual scope. For example, it could be 200 * used to set the guest permissions on a blog post. 201 * </p> 202 * 203 * <p> 204 * Depending on the scope, the value of <code>primKey</code> will have 205 * different meanings. For more information, see {@link 206 * com.liferay.portal.model.impl.ResourcePermissionImpl}. 207 * </p> 208 * 209 * @param groupId the primary key of the group 210 * @param companyId the primary key of the company 211 * @param name the resource's name, which can be either a class name or a 212 portlet ID 213 * @param primKey the primary key 214 * @param roleIdsToActionIds a map of role IDs to action IDs of the 215 actions 216 * @throws PortalException if the user did not have permission to set 217 resource permissions, or if a role with the primary key or a 218 resource action with the name and action ID could not be found 219 * @throws SystemException if a system exception occurred 220 */ 221 public static void setIndividualResourcePermissions(long groupId, 222 long companyId, java.lang.String name, java.lang.String primKey, 223 java.util.Map<java.lang.Long, java.lang.String[]> roleIdsToActionIds) 224 throws com.liferay.portal.kernel.exception.PortalException, 225 com.liferay.portal.kernel.exception.SystemException { 226 getService() 227 .setIndividualResourcePermissions(groupId, companyId, name, 228 primKey, roleIdsToActionIds); 229 } 230 231 public static ResourcePermissionService getService() { 232 if (_service == null) { 233 _service = (ResourcePermissionService)PortalBeanLocatorUtil.locate(ResourcePermissionService.class.getName()); 234 235 ReferenceRegistry.registerReference(ResourcePermissionServiceUtil.class, 236 "_service"); 237 MethodCache.remove(ResourcePermissionService.class); 238 } 239 240 return _service; 241 } 242 243 public void setService(ResourcePermissionService service) { 244 MethodCache.remove(ResourcePermissionService.class); 245 246 _service = service; 247 248 ReferenceRegistry.registerReference(ResourcePermissionServiceUtil.class, 249 "_service"); 250 MethodCache.remove(ResourcePermissionService.class); 251 } 252 253 private static ResourcePermissionService _service; 254 }