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