001 /** 002 * Copyright (c) 2000-2013 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 aQute.bnd.annotation.ProviderType; 018 019 import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil; 020 import com.liferay.portal.kernel.util.ReferenceRegistry; 021 022 /** 023 * Provides the local service utility for Resource. This utility wraps 024 * {@link com.liferay.portal.service.impl.ResourceLocalServiceImpl} and is the 025 * primary access point for service operations in application layer code running 026 * on the local server. Methods of this service will not have security checks 027 * based on the propagated JAAS credentials because this service can only be 028 * accessed from within the same VM. 029 * 030 * @author Brian Wing Shun Chan 031 * @see ResourceLocalService 032 * @see com.liferay.portal.service.base.ResourceLocalServiceBaseImpl 033 * @see com.liferay.portal.service.impl.ResourceLocalServiceImpl 034 * @generated 035 */ 036 @ProviderType 037 public class ResourceLocalServiceUtil { 038 /* 039 * NOTE FOR DEVELOPERS: 040 * 041 * Never modify this class directly. Add custom service methods to {@link com.liferay.portal.service.impl.ResourceLocalServiceImpl} and rerun ServiceBuilder to regenerate this class. 042 */ 043 044 /** 045 * Returns the Spring bean ID for this bean. 046 * 047 * @return the Spring bean ID for this bean 048 */ 049 public static java.lang.String getBeanIdentifier() { 050 return getService().getBeanIdentifier(); 051 } 052 053 /** 054 * Sets the Spring bean ID for this bean. 055 * 056 * @param beanIdentifier the Spring bean ID for this bean 057 */ 058 public static void setBeanIdentifier(java.lang.String beanIdentifier) { 059 getService().setBeanIdentifier(beanIdentifier); 060 } 061 062 /** 063 * Adds resources for the model, always creating a resource at the 064 * individual scope and only creating resources at the group, group 065 * template, and company scope if such resources don't already exist. 066 * 067 * <ol> 068 * <li> 069 * If the service context specifies that default group or default guest 070 * permissions are to be added, then only default permissions are added. See 071 * {@link com.liferay.portal.service.ServiceContext#setAddGroupPermissions( 072 * boolean)} and {@link 073 * com.liferay.portal.service.ServiceContext#setAddGuestPermissions( 074 * boolean)}. 075 * </li> 076 * <li> 077 * Else ... 078 * <ol> 079 * <li> 080 * If the service context specifies to derive default permissions, then 081 * default group and guest permissions are derived from the model and 082 * added. See {@link 083 * com.liferay.portal.service.ServiceContext#setDeriveDefaultPermissions( 084 * boolean)}. 085 * </li> 086 * <li> 087 * Lastly group and guest permissions from the service 088 * context are applied. See {@link 089 * com.liferay.portal.service.ServiceContext#setGroupPermissions(String[])} 090 * and {@link 091 * com.liferay.portal.service.ServiceContext#setGuestPermissions(String[])}. 092 * </li> 093 * </ol> 094 * 095 * </li> 096 * </ol> 097 * 098 * @param auditedModel the model to associate with the resources 099 * @param serviceContext the service context to apply. Can set whether to 100 add the model's default group and guest permissions, set whether 101 to derive default group and guest permissions from the model, set 102 group permissions to apply, and set guest permissions to apply. 103 * @throws PortalException if no portal actions could be found associated 104 with the model or if a portal exception occurred 105 * @throws SystemException if a system exception occurred 106 */ 107 public static void addModelResources( 108 com.liferay.portal.model.AuditedModel auditedModel, 109 com.liferay.portal.service.ServiceContext serviceContext) 110 throws com.liferay.portal.kernel.exception.PortalException, 111 com.liferay.portal.kernel.exception.SystemException { 112 getService().addModelResources(auditedModel, serviceContext); 113 } 114 115 /** 116 * Adds resources for the model with the name and primary key, always 117 * creating a resource at the individual scope and only creating resources 118 * at the group, group template, and company scope if such resources don't 119 * already exist. 120 * 121 * @param companyId the primary key of the portal instance 122 * @param groupId the primary key of the group 123 * @param userId the primary key of the user adding the resources 124 * @param name a name for the resource, typically the model's class name 125 * @param primKey the primary key of the model instance, optionally 126 <code>0</code> if no instance exists 127 * @param groupPermissions the group permissions to be applied 128 * @param guestPermissions the guest permissions to be applied 129 * @throws PortalException if no portal actions could be found associated 130 with the model or if a portal exception occurred 131 * @throws SystemException if a system exception occurred 132 */ 133 public static void addModelResources(long companyId, long groupId, 134 long userId, java.lang.String name, long primKey, 135 java.lang.String[] groupPermissions, java.lang.String[] guestPermissions) 136 throws com.liferay.portal.kernel.exception.PortalException, 137 com.liferay.portal.kernel.exception.SystemException { 138 getService() 139 .addModelResources(companyId, groupId, userId, name, primKey, 140 groupPermissions, guestPermissions); 141 } 142 143 /** 144 * Adds resources for the model with the name and primary key string, always 145 * creating a resource at the individual scope and only creating resources 146 * at the group, group template, and company scope if such resources don't 147 * already exist. 148 * 149 * @param companyId the primary key of the portal instance 150 * @param groupId the primary key of the group 151 * @param userId the primary key of the user adding the resources 152 * @param name a name for the resource, typically the model's class name 153 * @param primKey the primary key string of the model instance, optionally 154 an empty string if no instance exists 155 * @param groupPermissions the group permissions to be applied 156 * @param guestPermissions the guest permissions to be applied 157 * @throws PortalException if no portal actions could be found associated 158 with the model or if a portal exception occurred 159 * @throws SystemException if a system exception occurred 160 */ 161 public static void addModelResources(long companyId, long groupId, 162 long userId, java.lang.String name, java.lang.String primKey, 163 java.lang.String[] groupPermissions, java.lang.String[] guestPermissions) 164 throws com.liferay.portal.kernel.exception.PortalException, 165 com.liferay.portal.kernel.exception.SystemException { 166 getService() 167 .addModelResources(companyId, groupId, userId, name, primKey, 168 groupPermissions, guestPermissions); 169 } 170 171 /** 172 * Adds resources for the entity with the name and primary key, always 173 * creating a resource at the individual scope and only creating resources 174 * at the group, group template, and company scope if such resources don't 175 * already exist. 176 * 177 * @param companyId the primary key of the portal instance 178 * @param groupId the primary key of the group 179 * @param userId the primary key of the user adding the resources 180 * @param name a name for the resource, which should be a portlet ID if the 181 resource is a portlet or the resource's class name otherwise 182 * @param primKey the primary key of the resource instance, optionally 183 <code>0</code> if no instance exists 184 * @param portletActions whether to associate portlet actions with the 185 resource 186 * @param addGroupPermissions whether to add group permissions 187 * @param addGuestPermissions whether to add guest permissions 188 * @throws PortalException if no portal actions could be found associated 189 with the resource or if a portal exception occurred 190 * @throws SystemException if a system exception occurred 191 */ 192 public static void addResources(long companyId, long groupId, long userId, 193 java.lang.String name, long primKey, boolean portletActions, 194 boolean addGroupPermissions, boolean addGuestPermissions) 195 throws com.liferay.portal.kernel.exception.PortalException, 196 com.liferay.portal.kernel.exception.SystemException { 197 getService() 198 .addResources(companyId, groupId, userId, name, primKey, 199 portletActions, addGroupPermissions, addGuestPermissions); 200 } 201 202 /** 203 * Adds resources for the entity with the name and primary key string, 204 * always creating a resource at the individual scope and only creating 205 * resources at the group, group template, and company scope if such 206 * resources don't already exist. 207 * 208 * @param companyId the primary key of the portal instance 209 * @param groupId the primary key of the group 210 * @param userId the primary key of the user adding the resources 211 * @param name a name for the resource, which should be a portlet ID if the 212 resource is a portlet or the resource's class name otherwise 213 * @param primKey the primary key string of the resource instance, 214 optionally an empty string if no instance exists 215 * @param portletActions whether to associate portlet actions with the 216 resource 217 * @param addGroupPermissions whether to add group permissions 218 * @param addGuestPermissions whether to add guest permissions 219 * @throws PortalException if no portal actions could be found associated 220 with the resource or if a portal exception occurred 221 * @throws SystemException if a system exception occurred 222 */ 223 public static void addResources(long companyId, long groupId, long userId, 224 java.lang.String name, java.lang.String primKey, 225 boolean portletActions, boolean addGroupPermissions, 226 boolean addGuestPermissions) 227 throws com.liferay.portal.kernel.exception.PortalException, 228 com.liferay.portal.kernel.exception.SystemException { 229 getService() 230 .addResources(companyId, groupId, userId, name, primKey, 231 portletActions, addGroupPermissions, addGuestPermissions); 232 } 233 234 /** 235 * Adds resources for the entity with the name. Use this method if the user 236 * is unknown or irrelevant and there is no current entity instance. 237 * 238 * @param companyId the primary key of the portal instance 239 * @param groupId the primary key of the group 240 * @param name a name for the resource, which should be a portlet ID if the 241 resource is a portlet or the resource's class name otherwise 242 * @param portletActions whether to associate portlet actions with the 243 resource 244 * @throws PortalException if no portal actions could be found associated 245 with the resource or if a portal exception occurred 246 * @throws SystemException if a system exception occurred 247 */ 248 public static void addResources(long companyId, long groupId, 249 java.lang.String name, boolean portletActions) 250 throws com.liferay.portal.kernel.exception.PortalException, 251 com.liferay.portal.kernel.exception.SystemException { 252 getService().addResources(companyId, groupId, name, portletActions); 253 } 254 255 /** 256 * Deletes the resource associated with the model at the scope. 257 * 258 * @param auditedModel the model associated with the resource 259 * @param scope the scope of the resource. For more information see {@link 260 com.liferay.portal.model.ResourceConstants}. 261 * @throws PortalException if a portal exception occurred 262 * @throws SystemException if a system exception occurred 263 */ 264 public static void deleteResource( 265 com.liferay.portal.model.AuditedModel auditedModel, int scope) 266 throws com.liferay.portal.kernel.exception.PortalException, 267 com.liferay.portal.kernel.exception.SystemException { 268 getService().deleteResource(auditedModel, scope); 269 } 270 271 /** 272 * Deletes the resource matching the primary key at the scope. 273 * 274 * @param companyId the primary key of the portal instance 275 * @param name the resource's name, which should be a portlet ID if the 276 resource is a portlet or the resource's class name otherwise 277 * @param scope the scope of the resource. For more information see {@link 278 com.liferay.portal.model.ResourceConstants}. 279 * @param primKey the primary key of the resource instance 280 * @throws PortalException if a portal exception occurred 281 * @throws SystemException if a system exception occurred 282 */ 283 public static void deleteResource(long companyId, java.lang.String name, 284 int scope, long primKey) 285 throws com.liferay.portal.kernel.exception.PortalException, 286 com.liferay.portal.kernel.exception.SystemException { 287 getService().deleteResource(companyId, name, scope, primKey); 288 } 289 290 /** 291 * Deletes the resource matching the primary key at the scope. 292 * 293 * @param companyId the primary key of the portal instance 294 * @param name the resource's name, which should be a portlet ID if the 295 resource is a portlet or the resource's class name otherwise 296 * @param scope the scope of the resource. For more information see {@link 297 com.liferay.portal.model.ResourceConstants}. 298 * @param primKey the primary key string of the resource instance 299 * @throws PortalException if a portal exception occurred 300 * @throws SystemException if a system exception occurred 301 */ 302 public static void deleteResource(long companyId, java.lang.String name, 303 int scope, java.lang.String primKey) 304 throws com.liferay.portal.kernel.exception.PortalException, 305 com.liferay.portal.kernel.exception.SystemException { 306 getService().deleteResource(companyId, name, scope, primKey); 307 } 308 309 /** 310 * Returns a new resource with the name and primary key at the scope. 311 * 312 * @param companyId the primary key of the portal instance 313 * @param name a name for the resource, which should be a portlet ID if the 314 resource is a portlet or the resource's class name otherwise 315 * @param scope the scope of the resource. For more information see {@link 316 com.liferay.portal.model.ResourceConstants}. 317 * @param primKey the primary key string of the resource 318 * @return the new resource 319 */ 320 public static com.liferay.portal.model.Resource getResource( 321 long companyId, java.lang.String name, int scope, 322 java.lang.String primKey) { 323 return getService().getResource(companyId, name, scope, primKey); 324 } 325 326 /** 327 * Returns <code>true</code> if the roles have permission to perform the 328 * action on the resources. 329 * 330 * @param userId the primary key of the user performing the permission 331 check 332 * @param resourceId the primary key of the resource, typically the scope 333 group ID representing the scope in which the permission check is 334 being performed 335 * @param resources the resources for which permissions are to be checked 336 * @param actionId the primary key of the action to be performed on the 337 resources 338 * @param roleIds the primary keys of the roles 339 * @return <code>true</code> if the roles have permission to perform the 340 action on the resources;<code>false</code> otherwise 341 * @throws PortalException if any one of the roles with the primary keys 342 could not be found or if a resource action with the action ID 343 could not be found 344 * @throws SystemException if a system exception occurred 345 */ 346 public static boolean hasUserPermissions(long userId, long resourceId, 347 java.util.List<com.liferay.portal.model.Resource> resources, 348 java.lang.String actionId, long[] roleIds) 349 throws com.liferay.portal.kernel.exception.PortalException, 350 com.liferay.portal.kernel.exception.SystemException { 351 return getService() 352 .hasUserPermissions(userId, resourceId, resources, actionId, 353 roleIds); 354 } 355 356 /** 357 * Updates the resources for the model, replacing their group and guest 358 * permissions with new ones from the service context. 359 * 360 * @param auditedModel the model associated with the resources 361 * @param serviceContext the service context to be applied. Can set group 362 and guest permissions. 363 * @throws PortalException if a portal exception occurred 364 * @throws SystemException if a system exception occurred 365 */ 366 public static void updateModelResources( 367 com.liferay.portal.model.AuditedModel auditedModel, 368 com.liferay.portal.service.ServiceContext serviceContext) 369 throws com.liferay.portal.kernel.exception.PortalException, 370 com.liferay.portal.kernel.exception.SystemException { 371 getService().updateModelResources(auditedModel, serviceContext); 372 } 373 374 /** 375 * Updates resources matching the group, name, and primary key at the 376 * individual scope, setting new group and guest permissions. 377 * 378 * @param companyId the primary key of the portal instance 379 * @param groupId the primary key of the group 380 * @param name the resource's name, which should be a portlet ID if the 381 resource is a portlet or the resource's class name otherwise 382 * @param primKey the primary key of the resource instance 383 * @param groupPermissions the group permissions to be applied 384 * @param guestPermissions the guest permissions to be applied 385 * @throws PortalException if a portal exception occurred 386 * @throws SystemException if a system exception occurred 387 */ 388 public static void updateResources(long companyId, long groupId, 389 java.lang.String name, long primKey, 390 java.lang.String[] groupPermissions, java.lang.String[] guestPermissions) 391 throws com.liferay.portal.kernel.exception.PortalException, 392 com.liferay.portal.kernel.exception.SystemException { 393 getService() 394 .updateResources(companyId, groupId, name, primKey, 395 groupPermissions, guestPermissions); 396 } 397 398 /** 399 * Updates resources matching the group, name, and primary key string at the 400 * individual scope, setting new group and guest permissions. 401 * 402 * @param companyId the primary key of the portal instance 403 * @param groupId the primary key of the group 404 * @param name the resource's name, which should be a portlet ID if the 405 resource is a portlet or the resource's class name otherwise 406 * @param primKey the primary key string of the resource instance 407 * @param groupPermissions the group permissions to be applied 408 * @param guestPermissions the guest permissions to be applied 409 * @throws PortalException if a portal exception occurred 410 * @throws SystemException if a system exception occurred 411 */ 412 public static void updateResources(long companyId, long groupId, 413 java.lang.String name, java.lang.String primKey, 414 java.lang.String[] groupPermissions, java.lang.String[] guestPermissions) 415 throws com.liferay.portal.kernel.exception.PortalException, 416 com.liferay.portal.kernel.exception.SystemException { 417 getService() 418 .updateResources(companyId, groupId, name, primKey, 419 groupPermissions, guestPermissions); 420 } 421 422 /** 423 * Updates resources matching the name, primary key string and scope, 424 * replacing the primary key of their resource permissions with the new 425 * primary key. 426 * 427 * @param companyId the primary key of the portal instance 428 * @param name the resource's name, which should be a portlet ID if the 429 resource is a portlet or the resource's class name otherwise 430 * @param scope the scope of the resource. For more information see {@link 431 com.liferay.portal.model.ResourceConstants}. 432 * @param primKey the primary key string of the resource instance 433 * @param newPrimKey the new primary key string of the resource 434 * @throws SystemException if a system exception occurred 435 */ 436 public static void updateResources(long companyId, java.lang.String name, 437 int scope, java.lang.String primKey, java.lang.String newPrimKey) 438 throws com.liferay.portal.kernel.exception.SystemException { 439 getService().updateResources(companyId, name, scope, primKey, newPrimKey); 440 } 441 442 public static ResourceLocalService getService() { 443 if (_service == null) { 444 _service = (ResourceLocalService)PortalBeanLocatorUtil.locate(ResourceLocalService.class.getName()); 445 446 ReferenceRegistry.registerReference(ResourceLocalServiceUtil.class, 447 "_service"); 448 } 449 450 return _service; 451 } 452 453 /** 454 * @deprecated As of 6.2.0 455 */ 456 public void setService(ResourceLocalService service) { 457 } 458 459 private static ResourceLocalService _service; 460 }