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 ResourcePermission. This utility wraps 024 * {@link com.liferay.portal.service.impl.ResourcePermissionLocalServiceImpl} 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 ResourcePermissionLocalService 032 * @see com.liferay.portal.service.base.ResourcePermissionLocalServiceBaseImpl 033 * @see com.liferay.portal.service.impl.ResourcePermissionLocalServiceImpl 034 * @generated 035 */ 036 @ProviderType 037 public class ResourcePermissionLocalServiceUtil { 038 /* 039 * NOTE FOR DEVELOPERS: 040 * 041 * Never modify this class directly. Add custom service methods to {@link com.liferay.portal.service.impl.ResourcePermissionLocalServiceImpl} and rerun ServiceBuilder to regenerate this class. 042 */ 043 044 /** 045 * Grants the role permission at the scope to perform the action on 046 * resources of the type. Existing actions are retained. 047 * 048 * <p> 049 * This method cannot be used to grant individual scope permissions, but is 050 * only intended for adding permissions at the company, group, and 051 * group-template scopes. For example, this method could be used to grant a 052 * company scope permission to edit message board posts. 053 * </p> 054 * 055 * <p> 056 * If a company scope permission is granted to resources that the role 057 * already had group scope permissions to, the group scope permissions are 058 * deleted. Likewise, if a group scope permission is granted to resources 059 * that the role already had company scope permissions to, the company scope 060 * permissions are deleted. Be aware that this latter behavior can result in 061 * an overall reduction in permissions for the role. 062 * </p> 063 * 064 * <p> 065 * Depending on the scope, the value of <code>primKey</code> will have 066 * different meanings. For more information, see {@link 067 * com.liferay.portal.model.impl.ResourcePermissionImpl}. 068 * </p> 069 * 070 * @param companyId the primary key of the company 071 * @param name the resource's name, which can be either a class name or a 072 portlet ID 073 * @param scope the scope. This method only supports company, group, and 074 group-template scope. 075 * @param primKey the primary key 076 * @param roleId the primary key of the role 077 * @param actionId the action ID 078 */ 079 public static void addResourcePermission(long companyId, 080 java.lang.String name, int scope, java.lang.String primKey, 081 long roleId, java.lang.String actionId) 082 throws com.liferay.portal.kernel.exception.PortalException { 083 getService() 084 .addResourcePermission(companyId, name, scope, primKey, roleId, 085 actionId); 086 } 087 088 /** 089 * Adds the resource permission to the database. Also notifies the appropriate model listeners. 090 * 091 * @param resourcePermission the resource permission 092 * @return the resource permission that was added 093 */ 094 public static com.liferay.portal.model.ResourcePermission addResourcePermission( 095 com.liferay.portal.model.ResourcePermission resourcePermission) { 096 return getService().addResourcePermission(resourcePermission); 097 } 098 099 /** 100 * Grants the role permissions at the scope to perform the actions on all 101 * resources of the type. Existing actions are retained. 102 * 103 * <p> 104 * This method should only be used to add default permissions to existing 105 * resources en masse during upgrades or while verifying permissions. For 106 * example, this method could be used to grant site members individual scope 107 * permissions to view all blog posts. 108 * </p> 109 * 110 * @param resourceName the resource's name, which can be either a class name 111 or a portlet ID 112 * @param roleName the role's name 113 * @param scope the scope 114 * @param resourceActionBitwiseValue the bitwise IDs of the actions 115 */ 116 public static void addResourcePermissions(java.lang.String resourceName, 117 java.lang.String roleName, int scope, long resourceActionBitwiseValue) { 118 getService() 119 .addResourcePermissions(resourceName, roleName, scope, 120 resourceActionBitwiseValue); 121 } 122 123 /** 124 * Creates a new resource permission with the primary key. Does not add the resource permission to the database. 125 * 126 * @param resourcePermissionId the primary key for the new resource permission 127 * @return the new resource permission 128 */ 129 public static com.liferay.portal.model.ResourcePermission createResourcePermission( 130 long resourcePermissionId) { 131 return getService().createResourcePermission(resourcePermissionId); 132 } 133 134 /** 135 * @throws PortalException 136 */ 137 public static com.liferay.portal.model.PersistedModel deletePersistedModel( 138 com.liferay.portal.model.PersistedModel persistedModel) 139 throws com.liferay.portal.kernel.exception.PortalException { 140 return getService().deletePersistedModel(persistedModel); 141 } 142 143 /** 144 * Deletes the resource permission from the database. Also notifies the appropriate model listeners. 145 * 146 * @param resourcePermission the resource permission 147 * @return the resource permission that was removed 148 */ 149 public static com.liferay.portal.model.ResourcePermission deleteResourcePermission( 150 com.liferay.portal.model.ResourcePermission resourcePermission) { 151 return getService().deleteResourcePermission(resourcePermission); 152 } 153 154 /** 155 * Deletes the resource permission with the primary key from the database. Also notifies the appropriate model listeners. 156 * 157 * @param resourcePermissionId the primary key of the resource permission 158 * @return the resource permission that was removed 159 * @throws PortalException if a resource permission with the primary key could not be found 160 */ 161 public static com.liferay.portal.model.ResourcePermission deleteResourcePermission( 162 long resourcePermissionId) 163 throws com.liferay.portal.kernel.exception.PortalException { 164 return getService().deleteResourcePermission(resourcePermissionId); 165 } 166 167 /** 168 * Deletes all resource permissions at the scope to resources of the type. 169 * This method should not be confused with any of the 170 * <code>removeResourcePermission</code> methods, as its purpose is very 171 * different. This method should only be used for deleting resource 172 * permissions that refer to a resource when that resource is deleted. For 173 * example this method could be used to delete all individual scope 174 * permissions to a blog post when it is deleted. 175 * 176 * <p> 177 * Depending on the scope, the value of <code>primKey</code> will have 178 * different meanings. For more information, see {@link 179 * com.liferay.portal.model.impl.ResourcePermissionImpl}. 180 * </p> 181 * 182 * @param companyId the primary key of the company 183 * @param name the resource's name, which can be either a class name or a 184 portlet ID 185 * @param scope the scope 186 * @param primKey the primary key 187 */ 188 public static void deleteResourcePermissions(long companyId, 189 java.lang.String name, int scope, long primKey) 190 throws com.liferay.portal.kernel.exception.PortalException { 191 getService().deleteResourcePermissions(companyId, name, scope, primKey); 192 } 193 194 /** 195 * Deletes all resource permissions at the scope to resources of the type. 196 * This method should not be confused with any of the 197 * <code>removeResourcePermission</code> methods, as its purpose is very 198 * different. This method should only be used for deleting resource 199 * permissions that refer to a resource when that resource is deleted. For 200 * example this method could be used to delete all individual scope 201 * permissions to a blog post when it is deleted. 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 companyId the primary key of the company 210 * @param name the resource's name, which can be either a class name or a 211 portlet ID 212 * @param scope the scope 213 * @param primKey the primary key 214 */ 215 public static void deleteResourcePermissions(long companyId, 216 java.lang.String name, int scope, java.lang.String primKey) 217 throws com.liferay.portal.kernel.exception.PortalException { 218 getService().deleteResourcePermissions(companyId, name, scope, primKey); 219 } 220 221 public static com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery() { 222 return getService().dynamicQuery(); 223 } 224 225 /** 226 * Performs a dynamic query on the database and returns the matching rows. 227 * 228 * @param dynamicQuery the dynamic query 229 * @return the matching rows 230 */ 231 public static <T> java.util.List<T> dynamicQuery( 232 com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery) { 233 return getService().dynamicQuery(dynamicQuery); 234 } 235 236 /** 237 * Performs a dynamic query on the database and returns a range of the matching rows. 238 * 239 * <p> 240 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.ResourcePermissionModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. 241 * </p> 242 * 243 * @param dynamicQuery the dynamic query 244 * @param start the lower bound of the range of model instances 245 * @param end the upper bound of the range of model instances (not inclusive) 246 * @return the range of matching rows 247 */ 248 public static <T> java.util.List<T> dynamicQuery( 249 com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery, int start, 250 int end) { 251 return getService().dynamicQuery(dynamicQuery, start, end); 252 } 253 254 /** 255 * Performs a dynamic query on the database and returns an ordered range of the matching rows. 256 * 257 * <p> 258 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.ResourcePermissionModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. 259 * </p> 260 * 261 * @param dynamicQuery the dynamic query 262 * @param start the lower bound of the range of model instances 263 * @param end the upper bound of the range of model instances (not inclusive) 264 * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) 265 * @return the ordered range of matching rows 266 */ 267 public static <T> java.util.List<T> dynamicQuery( 268 com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery, int start, 269 int end, 270 com.liferay.portal.kernel.util.OrderByComparator<T> orderByComparator) { 271 return getService() 272 .dynamicQuery(dynamicQuery, start, end, orderByComparator); 273 } 274 275 /** 276 * Returns the number of rows matching the dynamic query. 277 * 278 * @param dynamicQuery the dynamic query 279 * @return the number of rows matching the dynamic query 280 */ 281 public static long dynamicQueryCount( 282 com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery) { 283 return getService().dynamicQueryCount(dynamicQuery); 284 } 285 286 /** 287 * Returns the number of rows matching the dynamic query. 288 * 289 * @param dynamicQuery the dynamic query 290 * @param projection the projection to apply to the query 291 * @return the number of rows matching the dynamic query 292 */ 293 public static long dynamicQueryCount( 294 com.liferay.portal.kernel.dao.orm.DynamicQuery dynamicQuery, 295 com.liferay.portal.kernel.dao.orm.Projection projection) { 296 return getService().dynamicQueryCount(dynamicQuery, projection); 297 } 298 299 public static com.liferay.portal.model.ResourcePermission fetchResourcePermission( 300 long companyId, java.lang.String name, int scope, 301 java.lang.String primKey, long roleId) { 302 return getService() 303 .fetchResourcePermission(companyId, name, scope, primKey, 304 roleId); 305 } 306 307 public static com.liferay.portal.model.ResourcePermission fetchResourcePermission( 308 long resourcePermissionId) { 309 return getService().fetchResourcePermission(resourcePermissionId); 310 } 311 312 public static com.liferay.portal.kernel.dao.orm.ActionableDynamicQuery getActionableDynamicQuery() { 313 return getService().getActionableDynamicQuery(); 314 } 315 316 public static java.util.Map<java.lang.Long, java.util.Set<java.lang.String>> getAvailableResourcePermissionActionIds( 317 long companyId, java.lang.String name, int scope, 318 java.lang.String primKey, 319 java.util.Collection<java.lang.String> actionIds) { 320 return getService() 321 .getAvailableResourcePermissionActionIds(companyId, name, 322 scope, primKey, actionIds); 323 } 324 325 /** 326 * Returns the intersection of action IDs the role has permission at the 327 * scope to perform on resources of the type. 328 * 329 * @param companyId he primary key of the company 330 * @param name the resource's name, which can be either a class name or a 331 portlet ID 332 * @param scope the scope 333 * @param primKey the primary key 334 * @param roleId the primary key of the role 335 * @param actionIds the action IDs 336 * @return the intersection of action IDs the role has permission at the 337 scope to perform on resources of the type 338 */ 339 public static java.util.List<java.lang.String> getAvailableResourcePermissionActionIds( 340 long companyId, java.lang.String name, int scope, 341 java.lang.String primKey, long roleId, 342 java.util.Collection<java.lang.String> actionIds) 343 throws com.liferay.portal.kernel.exception.PortalException { 344 return getService() 345 .getAvailableResourcePermissionActionIds(companyId, name, 346 scope, primKey, roleId, actionIds); 347 } 348 349 /** 350 * @deprecated As of 7.0.0, replaced by {@link 351 #getAvailableResourcePermissionActionIds(long, String, int, 352 String, Collection)} 353 */ 354 @Deprecated 355 public static java.util.Map<java.lang.Long, java.util.Set<java.lang.String>> getAvailableResourcePermissionActionIds( 356 long companyId, java.lang.String name, int scope, 357 java.lang.String primKey, long[] roleIds, 358 java.util.Collection<java.lang.String> actionIds) { 359 return getService() 360 .getAvailableResourcePermissionActionIds(companyId, name, 361 scope, primKey, roleIds, actionIds); 362 } 363 364 /** 365 * Returns the OSGi service identifier. 366 * 367 * @return the OSGi service identifier 368 */ 369 public static java.lang.String getOSGiServiceIdentifier() { 370 return getService().getOSGiServiceIdentifier(); 371 } 372 373 public static com.liferay.portal.model.PersistedModel getPersistedModel( 374 java.io.Serializable primaryKeyObj) 375 throws com.liferay.portal.kernel.exception.PortalException { 376 return getService().getPersistedModel(primaryKeyObj); 377 } 378 379 /** 380 * Returns the resource permission for the role at the scope to perform the 381 * actions on resources of the type. 382 * 383 * @param companyId the primary key of the company 384 * @param name the resource's name, which can be either a class name or a 385 portlet ID 386 * @param scope the scope 387 * @param primKey the primary key 388 * @param roleId the primary key of the role 389 * @return the resource permission for the role at the scope to perform the 390 actions on resources of the type 391 */ 392 public static com.liferay.portal.model.ResourcePermission getResourcePermission( 393 long companyId, java.lang.String name, int scope, 394 java.lang.String primKey, long roleId) 395 throws com.liferay.portal.kernel.exception.PortalException { 396 return getService() 397 .getResourcePermission(companyId, name, scope, primKey, 398 roleId); 399 } 400 401 /** 402 * Returns the resource permission with the primary key. 403 * 404 * @param resourcePermissionId the primary key of the resource permission 405 * @return the resource permission 406 * @throws PortalException if a resource permission with the primary key could not be found 407 */ 408 public static com.liferay.portal.model.ResourcePermission getResourcePermission( 409 long resourcePermissionId) 410 throws com.liferay.portal.kernel.exception.PortalException { 411 return getService().getResourcePermission(resourcePermissionId); 412 } 413 414 /** 415 * Returns all the resource permissions at the scope of the type. 416 * 417 * @param companyId the primary key of the company 418 * @param name the resource's name, which can be either a class name or a 419 portlet ID 420 * @param scope the scope 421 * @param primKey the primary key 422 * @return the resource permissions at the scope of the type 423 */ 424 public static java.util.List<com.liferay.portal.model.ResourcePermission> getResourcePermissions( 425 long companyId, java.lang.String name, int scope, 426 java.lang.String primKey) { 427 return getService() 428 .getResourcePermissions(companyId, name, scope, primKey); 429 } 430 431 /** 432 * Returns a range of all the resource permissions. 433 * 434 * <p> 435 * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set. If <code>orderByComparator</code> is specified, then the query will include the given ORDER BY logic. If <code>orderByComparator</code> is absent and pagination is required (<code>start</code> and <code>end</code> are not {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS}), then the query will include the default ORDER BY logic from {@link com.liferay.portal.model.impl.ResourcePermissionModelImpl}. If both <code>orderByComparator</code> and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. 436 * </p> 437 * 438 * @param start the lower bound of the range of resource permissions 439 * @param end the upper bound of the range of resource permissions (not inclusive) 440 * @return the range of resource permissions 441 */ 442 public static java.util.List<com.liferay.portal.model.ResourcePermission> getResourcePermissions( 443 int start, int end) { 444 return getService().getResourcePermissions(start, end); 445 } 446 447 /** 448 * Returns the number of resource permissions. 449 * 450 * @return the number of resource permissions 451 */ 452 public static int getResourcePermissionsCount() { 453 return getService().getResourcePermissionsCount(); 454 } 455 456 /** 457 * Returns the number of resource permissions at the scope of the type. 458 * 459 * @param companyId the primary key of the company 460 * @param name the resource's name, which can be either a class name or a 461 portlet ID 462 * @param scope the scope 463 * @param primKey the primary key 464 * @return the number of resource permissions at the scope of the type 465 */ 466 public static int getResourcePermissionsCount(long companyId, 467 java.lang.String name, int scope, java.lang.String primKey) { 468 return getService() 469 .getResourcePermissionsCount(companyId, name, scope, primKey); 470 } 471 472 /** 473 * Returns the resource permissions that apply to the resource. 474 * 475 * @param companyId the primary key of the resource's company 476 * @param groupId the primary key of the resource's group 477 * @param name the resource's name, which can be either a class name or a 478 portlet ID 479 * @param primKey the primary key of the resource 480 * @return the resource permissions associated with the resource 481 */ 482 public static java.util.List<com.liferay.portal.model.ResourcePermission> getResourceResourcePermissions( 483 long companyId, long groupId, java.lang.String name, 484 java.lang.String primKey) { 485 return getService() 486 .getResourceResourcePermissions(companyId, groupId, name, 487 primKey); 488 } 489 490 /** 491 * Returns all the resource permissions for the role. 492 * 493 * @param roleId the primary key of the role 494 * @return the resource permissions for the role 495 */ 496 public static java.util.List<com.liferay.portal.model.ResourcePermission> getRoleResourcePermissions( 497 long roleId) { 498 return getService().getRoleResourcePermissions(roleId); 499 } 500 501 /** 502 * Returns a range of all the resource permissions for the role at the 503 * scopes. 504 * 505 * <p> 506 * Useful when paginating results. Returns a maximum of <code>end - 507 * start</code> instances. <code>start</code> and <code>end</code> are not 508 * primary keys, they are indexes in the result set. Thus, <code>0</code> 509 * refers to the first result in the set. Setting both <code>start</code> 510 * and <code>end</code> to {@link 511 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full 512 * result set. 513 * </p> 514 * 515 * @param roleId the primary key of the role 516 * @param scopes the scopes 517 * @param start the lower bound of the range of results 518 * @param end the upper bound of the range of results (not inclusive) 519 * @return the range of resource permissions for the role at the scopes 520 */ 521 public static java.util.List<com.liferay.portal.model.ResourcePermission> getRoleResourcePermissions( 522 long roleId, int[] scopes, int start, int end) { 523 return getService() 524 .getRoleResourcePermissions(roleId, scopes, start, end); 525 } 526 527 public static java.util.List<com.liferay.portal.model.Role> getRoles( 528 long companyId, java.lang.String name, int scope, 529 java.lang.String primKey, java.lang.String actionId) 530 throws com.liferay.portal.kernel.exception.PortalException { 531 return getService().getRoles(companyId, name, scope, primKey, actionId); 532 } 533 534 /** 535 * Returns all the resource permissions where scope = any ?. 536 * 537 * <p> 538 * Useful when paginating results. Returns a maximum of <code>end - 539 * start</code> instances. <code>start</code> and <code>end</code> are not 540 * primary keys, they are indexes in the result set. Thus, <code>0</code> 541 * refers to the first result in the set. Setting both <code>start</code> 542 * and <code>end</code> to {@link 543 * com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full 544 * result set. 545 * </p> 546 * 547 * @param scopes the scopes 548 * @return the resource permissions where scope = any ? 549 */ 550 public static java.util.List<com.liferay.portal.model.ResourcePermission> getScopeResourcePermissions( 551 int[] scopes) { 552 return getService().getScopeResourcePermissions(scopes); 553 } 554 555 /** 556 * Returns <code>true</code> if the resource permission grants permission to 557 * perform the resource action. Note that this method does not ensure that 558 * the resource permission refers to the same type of resource as the 559 * resource action. 560 * 561 * @param resourcePermission the resource permission 562 * @param resourceAction the resource action 563 * @return <code>true</code> if the resource permission grants permission to 564 perform the resource action 565 */ 566 public static boolean hasActionId( 567 com.liferay.portal.model.ResourcePermission resourcePermission, 568 com.liferay.portal.model.ResourceAction resourceAction) { 569 return getService().hasActionId(resourcePermission, resourceAction); 570 } 571 572 /** 573 * Returns <code>true</code> if the role has permission at the scope to 574 * perform the action on resources of the type. 575 * 576 * <p> 577 * Depending on the scope, the value of <code>primKey</code> will have 578 * different meanings. For more information, see {@link 579 * com.liferay.portal.model.impl.ResourcePermissionImpl}. 580 * </p> 581 * 582 * @param companyId the primary key of the company 583 * @param name the resource's name, which can be either a class name or a 584 portlet ID 585 * @param scope the scope 586 * @param primKey the primary key 587 * @param roleId the primary key of the role 588 * @param actionId the action ID 589 * @return <code>true</code> if the role has permission to perform the 590 action on the resource; <code>false</code> otherwise 591 */ 592 public static boolean hasResourcePermission(long companyId, 593 java.lang.String name, int scope, java.lang.String primKey, 594 long roleId, java.lang.String actionId) 595 throws com.liferay.portal.kernel.exception.PortalException { 596 return getService() 597 .hasResourcePermission(companyId, name, scope, primKey, 598 roleId, actionId); 599 } 600 601 /** 602 * Returns <code>true</code> if the roles have permission at the scope to 603 * perform the action on resources of the type. 604 * 605 * <p> 606 * Depending on the scope, the value of <code>primKey</code> will have 607 * different meanings. For more information, see {@link 608 * com.liferay.portal.model.impl.ResourcePermissionImpl}. 609 * </p> 610 * 611 * @param companyId the primary key of the company 612 * @param name the resource's name, which can be either a class name or a 613 portlet ID 614 * @param scope the scope 615 * @param primKey the primary key 616 * @param roleIds the primary keys of the roles 617 * @param actionId the action ID 618 * @return <code>true</code> if any one of the roles has permission to 619 perform the action on the resource; <code>false</code> otherwise 620 */ 621 public static boolean hasResourcePermission(long companyId, 622 java.lang.String name, int scope, java.lang.String primKey, 623 long[] roleIds, java.lang.String actionId) 624 throws com.liferay.portal.kernel.exception.PortalException { 625 return getService() 626 .hasResourcePermission(companyId, name, scope, primKey, 627 roleIds, actionId); 628 } 629 630 /** 631 * Returns <code>true</code> if the roles have permission at the scope to 632 * perform the action on the resources. 633 * 634 * <p> 635 * Depending on the scope, the value of <code>primKey</code> will have 636 * different meanings. For more information, see {@link 637 * com.liferay.portal.model.impl.ResourcePermissionImpl}. 638 * </p> 639 * 640 * @param resources the resources 641 * @param roleIds the primary keys of the roles 642 * @param actionId the action ID 643 * @return <code>true</code> if any one of the roles has permission to 644 perform the action on any one of the resources; 645 <code>false</code> otherwise 646 */ 647 public static boolean hasResourcePermission( 648 java.util.List<com.liferay.portal.model.Resource> resources, 649 long[] roleIds, java.lang.String actionId) 650 throws com.liferay.portal.kernel.exception.PortalException { 651 return getService().hasResourcePermission(resources, roleIds, actionId); 652 } 653 654 /** 655 * @deprecated As of 7.0.0, replaced by {@link #getRoles(long, String, int, 656 String, String} 657 */ 658 @Deprecated 659 public static boolean[] hasResourcePermissions(long companyId, 660 java.lang.String name, int scope, java.lang.String primKey, 661 long[] roleIds, java.lang.String actionId) 662 throws com.liferay.portal.kernel.exception.PortalException { 663 return getService() 664 .hasResourcePermissions(companyId, name, scope, primKey, 665 roleIds, actionId); 666 } 667 668 /** 669 * Returns <code>true</code> if the role has permission at the scope to 670 * perform the action on the resource. 671 * 672 * <p> 673 * Depending on the scope, the value of <code>primKey</code> will have 674 * different meanings. For more information, see {@link 675 * com.liferay.portal.model.impl.ResourcePermissionImpl}. 676 * </p> 677 * 678 * @param companyId the primary key of the company 679 * @param name the resource's name, which can be either a class name or a 680 portlet ID 681 * @param scope the scope 682 * @param roleId the primary key of the role 683 * @param actionId the action ID 684 * @return <code>true</code> if the role has permission to perform the 685 action on the resource; <code>false</code> otherwise 686 */ 687 public static boolean hasScopeResourcePermission(long companyId, 688 java.lang.String name, int scope, long roleId, java.lang.String actionId) 689 throws com.liferay.portal.kernel.exception.PortalException { 690 return getService() 691 .hasScopeResourcePermission(companyId, name, scope, roleId, 692 actionId); 693 } 694 695 /** 696 * Reassigns all the resource permissions from the source role to the 697 * destination role, and deletes the source role. 698 * 699 * @param fromRoleId the primary key of the source role 700 * @param toRoleId the primary key of the destination role 701 */ 702 public static void mergePermissions(long fromRoleId, long toRoleId) 703 throws com.liferay.portal.kernel.exception.PortalException { 704 getService().mergePermissions(fromRoleId, toRoleId); 705 } 706 707 /** 708 * Grants the role default permissions to all the resources of the type and 709 * at the scope stored in the resource permission, deletes the resource 710 * permission, and deletes the resource permission's role if it has no 711 * permissions remaining. 712 * 713 * @param resourcePermissionId the primary key of the resource permission 714 * @param toRoleId the primary key of the role 715 */ 716 public static void reassignPermissions(long resourcePermissionId, 717 long toRoleId) 718 throws com.liferay.portal.kernel.exception.PortalException { 719 getService().reassignPermissions(resourcePermissionId, toRoleId); 720 } 721 722 /** 723 * Revokes permission at the scope from the role to perform the action on 724 * resources of the type. For example, this method could be used to revoke a 725 * group scope permission to edit blog posts. 726 * 727 * <p> 728 * Depending on the scope, the value of <code>primKey</code> will have 729 * different meanings. For more information, see {@link 730 * com.liferay.portal.model.impl.ResourcePermissionImpl}. 731 * </p> 732 * 733 * @param companyId the primary key of the company 734 * @param name the resource's name, which can be either a class name or a 735 portlet ID 736 * @param scope the scope 737 * @param primKey the primary key 738 * @param roleId the primary key of the role 739 * @param actionId the action ID 740 */ 741 public static void removeResourcePermission(long companyId, 742 java.lang.String name, int scope, java.lang.String primKey, 743 long roleId, java.lang.String actionId) 744 throws com.liferay.portal.kernel.exception.PortalException { 745 getService() 746 .removeResourcePermission(companyId, name, scope, primKey, roleId, 747 actionId); 748 } 749 750 /** 751 * Revokes all permissions at the scope from the role to perform the action 752 * on resources of the type. For example, this method could be used to 753 * revoke all individual scope permissions to edit blog posts from site 754 * members. 755 * 756 * @param companyId the primary key of the company 757 * @param name the resource's name, which can be either a class name or a 758 portlet ID 759 * @param scope the scope 760 * @param roleId the primary key of the role 761 * @param actionId the action ID 762 */ 763 public static void removeResourcePermissions(long companyId, 764 java.lang.String name, int scope, long roleId, java.lang.String actionId) 765 throws com.liferay.portal.kernel.exception.PortalException { 766 getService() 767 .removeResourcePermissions(companyId, name, scope, roleId, actionId); 768 } 769 770 /** 771 * Updates the role's permissions at the scope, setting the actions that can 772 * be performed on resources of the type, also setting the owner of any 773 * newly created resource permissions. Existing actions are replaced. 774 * 775 * <p> 776 * This method can be used to set permissions at any scope, but it is 777 * generally only used at the individual scope. For example, it could be 778 * used to set the guest permissions on a blog post. 779 * </p> 780 * 781 * <p> 782 * Depending on the scope, the value of <code>primKey</code> will have 783 * different meanings. For more information, see {@link 784 * com.liferay.portal.model.impl.ResourcePermissionImpl}. 785 * </p> 786 * 787 * @param companyId the primary key of the company 788 * @param name the resource's name, which can be either a class name or a 789 portlet ID 790 * @param scope the scope 791 * @param primKey the primary key 792 * @param roleId the primary key of the role 793 * @param ownerId the primary key of the owner (generally the user that 794 created the resource) 795 * @param actionIds the action IDs of the actions 796 */ 797 public static void setOwnerResourcePermissions(long companyId, 798 java.lang.String name, int scope, java.lang.String primKey, 799 long roleId, long ownerId, java.lang.String[] actionIds) 800 throws com.liferay.portal.kernel.exception.PortalException { 801 getService() 802 .setOwnerResourcePermissions(companyId, name, scope, primKey, 803 roleId, ownerId, actionIds); 804 } 805 806 /** 807 * Updates the role's permissions at the scope, setting the actions that can 808 * be performed on resources of the type. Existing actions are replaced. 809 * 810 * <p> 811 * This method can be used to set permissions at any scope, but it is 812 * generally only used at the individual scope. For example, it could be 813 * used to set the guest permissions on a blog post. 814 * </p> 815 * 816 * <p> 817 * Depending on the scope, the value of <code>primKey</code> will have 818 * different meanings. For more information, see {@link 819 * com.liferay.portal.model.impl.ResourcePermissionImpl}. 820 * </p> 821 * 822 * @param companyId the primary key of the company 823 * @param name the resource's name, which can be either a class name or a 824 portlet ID 825 * @param scope the scope 826 * @param primKey the primary key 827 * @param roleId the primary key of the role 828 * @param actionIds the action IDs of the actions 829 */ 830 public static void setResourcePermissions(long companyId, 831 java.lang.String name, int scope, java.lang.String primKey, 832 long roleId, java.lang.String[] actionIds) 833 throws com.liferay.portal.kernel.exception.PortalException { 834 getService() 835 .setResourcePermissions(companyId, name, scope, primKey, roleId, 836 actionIds); 837 } 838 839 /** 840 * Updates the role's permissions at the scope, setting the actions that can 841 * be performed on resources of the type. Existing actions are replaced. 842 * 843 * <p> 844 * This method can be used to set permissions at any scope, but it is 845 * generally only used at the individual scope. For example, it could be 846 * used to set the guest permissions on a blog post. 847 * </p> 848 * 849 * <p> 850 * Depending on the scope, the value of <code>primKey</code> will have 851 * different meanings. For more information, see {@link 852 * com.liferay.portal.model.impl.ResourcePermissionImpl}. 853 * </p> 854 * 855 * @param companyId the primary key of the company 856 * @param name the resource's name, which can be either a class name or a 857 portlet ID 858 * @param scope the scope 859 * @param primKey the primary key 860 * @param roleIdsToActionIds a map of role IDs to action IDs of the actions 861 */ 862 public static void setResourcePermissions(long companyId, 863 java.lang.String name, int scope, java.lang.String primKey, 864 java.util.Map<java.lang.Long, java.lang.String[]> roleIdsToActionIds) 865 throws com.liferay.portal.kernel.exception.PortalException { 866 getService() 867 .setResourcePermissions(companyId, name, scope, primKey, 868 roleIdsToActionIds); 869 } 870 871 /** 872 * Updates the resource permission in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners. 873 * 874 * @param resourcePermission the resource permission 875 * @return the resource permission that was updated 876 */ 877 public static com.liferay.portal.model.ResourcePermission updateResourcePermission( 878 com.liferay.portal.model.ResourcePermission resourcePermission) { 879 return getService().updateResourcePermission(resourcePermission); 880 } 881 882 public static ResourcePermissionLocalService getService() { 883 if (_service == null) { 884 _service = (ResourcePermissionLocalService)PortalBeanLocatorUtil.locate(ResourcePermissionLocalService.class.getName()); 885 886 ReferenceRegistry.registerReference(ResourcePermissionLocalServiceUtil.class, 887 "_service"); 888 } 889 890 return _service; 891 } 892 893 /** 894 * @deprecated As of 6.2.0 895 */ 896 @Deprecated 897 public void setService(ResourcePermissionLocalService service) { 898 } 899 900 private static ResourcePermissionLocalService _service; 901 }