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