Class ResourcePermissionLocalServiceUtil
com.liferay.portal.service.impl.ResourcePermissionLocalServiceImpl
and
is an access point for service operations in application layer code running
on the local server. Methods of this service will not have security checks
based on the propagated JAAS credentials because this service can only be
accessed from within the same VM.- Author:
- Brian Wing Shun Chan
- See Also:
- {$generated.description}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addModelResourcePermissions
(long companyId, long groupId, long userId, String name, String primKey, ModelPermissions modelPermissions) static void
addModelResourcePermissions
(long companyId, long groupId, long userId, String name, String primKey, String[] groupPermissions, String[] guestPermissions) Adds resources for the model with the name and primary key string, always creating a resource at the individual scope and only creating resources at the group, group template, and company scope if such resources don't already exist.static void
addModelResourcePermissions
(AuditedModel auditedModel, ServiceContext serviceContext) static void
addResourcePermission
(long companyId, String name, int scope, String primKey, long roleId, String actionId) Grants the role permission at the scope to perform the action on resources of the type.static ResourcePermission
addResourcePermission
(ResourcePermission resourcePermission) Adds the resource permission to the database.static void
addResourcePermissions
(long companyId, long groupId, long userId, String name, String[] primKeys, boolean portletActions, ServiceContext serviceContext) static void
addResourcePermissions
(long companyId, long groupId, long userId, String name, String primKey, boolean portletActions, ServiceContext serviceContext) Adds resources for the entity with the name and primary key string, always creating a resource at the individual scope and only creating resources at the group, group template, and company scope if such resources don't already exist.static void
addResourcePermissions
(String resourceName, String roleName, int scope, long resourceActionBitwiseValue) Grants the role permissions at the scope to perform the actions on all resources of the type.static void
copyModelResourcePermissions
(long companyId, String name, long sourcePrimKey, long targetPrimKey) static PersistedModel
createPersistedModel
(Serializable primaryKeyObj) static ResourcePermission
createResourcePermission
(long resourcePermissionId) Creates a new resource permission with the primary key.static PersistedModel
deletePersistedModel
(PersistedModel persistedModel) static ResourcePermission
deleteResourcePermission
(long resourcePermissionId) Deletes the resource permission with the primary key from the database.static ResourcePermission
deleteResourcePermission
(ResourcePermission resourcePermission) Deletes the resource permission from the database.static void
deleteResourcePermissions
(long companyId, String name, int scope) static void
deleteResourcePermissions
(long companyId, String name, int scope, long primKey) Deletes all resource permissions at the scope to resources of the type.static void
deleteResourcePermissions
(long companyId, String name, int scope, String primKey) Deletes all resource permissions at the scope to resources of the type.static void
static <T> T
dslQuery
(com.liferay.petra.sql.dsl.query.DSLQuery dslQuery) static int
dslQueryCount
(com.liferay.petra.sql.dsl.query.DSLQuery dslQuery) static DynamicQuery
static <T> List<T>
dynamicQuery
(DynamicQuery dynamicQuery) Performs a dynamic query on the database and returns the matching rows.static <T> List<T>
dynamicQuery
(DynamicQuery dynamicQuery, int start, int end) Performs a dynamic query on the database and returns a range of the matching rows.static <T> List<T>
dynamicQuery
(DynamicQuery dynamicQuery, int start, int end, OrderByComparator<T> orderByComparator) Performs a dynamic query on the database and returns an ordered range of the matching rows.static long
dynamicQueryCount
(DynamicQuery dynamicQuery) Returns the number of rows matching the dynamic query.static long
dynamicQueryCount
(DynamicQuery dynamicQuery, Projection projection) Returns the number of rows matching the dynamic query.static ResourcePermission
fetchResourcePermission
(long resourcePermissionId) static ResourcePermission
fetchResourcePermission
(long companyId, String name, int scope, String primKey, long roleId) static ActionableDynamicQuery
getAvailableResourcePermissionActionIds
(long companyId, String name, int scope, String primKey, long roleId, Collection<String> actionIds) Returns the intersection of action IDs the role has permission at the scope to perform on resources of the type.getAvailableResourcePermissionActionIds
(long companyId, String name, int scope, String primKey, Collection<String> actionIds) static Map<String,
List<ResourcePermission>> getIndividualPortletResourcePermissions
(long companyId) static String
Returns the OSGi service identifier.static PersistedModel
getPersistedModel
(Serializable primaryKeyObj) static ResourcePermission
getResourcePermission
(long resourcePermissionId) Returns the resource permission with the primary key.static ResourcePermission
getResourcePermission
(long companyId, String name, int scope, String primKey, long roleId) Returns the resource permission for the role at the scope to perform the actions on resources of the type.static List<ResourcePermission>
getResourcePermissions
(int start, int end) Returns a range of all the resource permissions.static List<ResourcePermission>
getResourcePermissions
(long companyId, String name, int scope, long roleId, boolean viewActionId) static List<ResourcePermission>
getResourcePermissions
(long companyId, String name, int scope, String primKey) Returns all the resource permissions at the scope of the type.static List<ResourcePermission>
getResourcePermissions
(String name) static int
Returns the number of resource permissions.static int
getResourcePermissionsCount
(long companyId, String name, int scope, String primKey) Returns the number of resource permissions at the scope of the type.static List<ResourcePermission>
getResourceResourcePermissions
(long companyId, long groupId, String name, String primKey) Returns the resource permissions that apply to the resource.static List<ResourcePermission>
getRoleResourcePermissions
(long roleId) Returns all the resource permissions for the role.static List<ResourcePermission>
getRoleResourcePermissions
(long roleId, int[] scopes, int start, int end) Returns a range of all the resource permissions for the role at the scopes.static List<ResourcePermission>
getScopeResourcePermissions
(int[] scopes) Returns all the resource permissions where scope = any ?.static boolean
hasActionId
(ResourcePermission resourcePermission, ResourceAction resourceAction) Returnstrue
if the resource permission grants permission to perform the resource action.static boolean
hasResourcePermission
(long companyId, String name, int scope, String primKey, long[] roleIds, String actionId) Returnstrue
if the roles have permission at the scope to perform the action on resources of the type.static boolean
hasResourcePermission
(long companyId, String name, int scope, String primKey, long roleId, String actionId) Returnstrue
if the role has permission at the scope to perform the action on resources of the type.static boolean
hasResourcePermission
(List<Resource> resources, long[] roleIds, String actionId) Returnstrue
if the roles have permission at the scope to perform the action on the resources.static boolean
hasScopeResourcePermission
(long companyId, String name, int scope, long roleId, String actionId) Returnstrue
if the role has permission at the scope to perform the action on the resource.static void
initDefaultModelResourcePermissions
(long companyId, Collection<String> modelResources) static void
initPortletDefaultPermissions
(Portlet portlet) static void
mergePermissions
(long fromRoleId, long toRoleId) Reassigns all the resource permissions from the source role to the destination role, and deletes the source role.static void
reassignPermissions
(long resourcePermissionId, long toRoleId) Grants the role default permissions to all the resources of the type and at the scope stored in the resource permission, deletes the resource permission, and deletes the resource permission's role if it has no permissions remaining.static void
removeResourcePermission
(long companyId, String name, int scope, String primKey, long roleId, String actionId) Revokes permission at the scope from the role to perform the action on resources of the type.static void
removeResourcePermissions
(long companyId, String name, int scope, long roleId, String actionId) Revokes all permissions at the scope from the role to perform the action on resources of the type.static void
setOwnerResourcePermissions
(long companyId, String name, int scope, String primKey, long roleId, long ownerId, String[] actionIds) Updates the role's permissions at the scope, setting the actions that can be performed on resources of the type, also setting the owner of any newly created resource permissions.static void
setResourcePermissions
(long companyId, String name, int scope, String primKey, long roleId, String[] actionIds) Updates the role's permissions at the scope, setting the actions that can be performed on resources of the type.static void
setResourcePermissions
(long companyId, String name, int scope, String primKey, Map<Long, String[]> roleIdsToActionIds) Updates the role's permissions at the scope, setting the actions that can be performed on resources of the type.static void
setService
(ResourcePermissionLocalService service) static void
updateModelResourcePermissions
(AuditedModel auditedModel, ServiceContext serviceContext) Updates the resources for the model, replacing their group and guest permissions with new ones from the service context.static ResourcePermission
updateResourcePermission
(ResourcePermission resourcePermission) Updates the resource permission in the database or adds it if it does not yet exist.static void
updateResourcePermissions
(long companyId, long groupId, String name, long primKey, String[] groupPermissions, String[] guestPermissions) Updates resources matching the group, name, and primary key at the individual scope, setting new group and guest permissions.static void
updateResourcePermissions
(long companyId, long groupId, String name, String primKey, ModelPermissions modelPermissions) static void
updateResourcePermissions
(long companyId, long groupId, String name, String primKey, String[] groupPermissions, String[] guestPermissions) static void
updateResourcePermissions
(long companyId, String name, int scope, String primKey, String newPrimKey)
-
Constructor Details
-
ResourcePermissionLocalServiceUtil
public ResourcePermissionLocalServiceUtil()
-
-
Method Details
-
addModelResourcePermissions
public static void addModelResourcePermissions(AuditedModel auditedModel, ServiceContext serviceContext) throws PortalException - Throws:
PortalException
-
addModelResourcePermissions
public static void addModelResourcePermissions(long companyId, long groupId, long userId, String name, String primKey, ModelPermissions modelPermissions) throws PortalException - Throws:
PortalException
-
addModelResourcePermissions
public static void addModelResourcePermissions(long companyId, long groupId, long userId, String name, String primKey, String[] groupPermissions, String[] guestPermissions) throws PortalException Adds resources for the model with the name and primary key string, always creating a resource at the individual scope and only creating resources at the group, group template, and company scope if such resources don't already exist.- Parameters:
companyId
- the primary key of the portal instancegroupId
- the primary key of the groupuserId
- the primary key of the user adding the resourcesname
- a name for the resource, typically the model's class nameprimKey
- the primary key string of the model instance, optionally an empty string if no instance existsgroupPermissions
- the group permissions to be appliedguestPermissions
- the guest permissions to be applied- Throws:
PortalException
-
addResourcePermission
public static void addResourcePermission(long companyId, String name, int scope, String primKey, long roleId, String actionId) throws PortalException Grants the role permission at the scope to perform the action on resources of the type. Existing actions are retained.This method cannot be used to grant individual scope permissions, but is only intended for adding permissions at the company, group, and group-template scopes. For example, this method could be used to grant a company scope permission to edit message board posts.
If a company scope permission is granted to resources that the role already had group scope permissions to, the group scope permissions are deleted. Likewise, if a group scope permission is granted to resources that the role already had company scope permissions to, the company scope permissions are deleted. Be aware that this latter behavior can result in an overall reduction in permissions for the role.
Depending on the scope, the value of
primKey
will have different meanings. For more information, seeResourcePermissionImpl
.- Parameters:
companyId
- the primary key of the companyname
- the resource's name, which can be either a class name or a portlet IDscope
- the scope. This method only supports company, group, and group-template scope.primKey
- the primary keyroleId
- the primary key of the roleactionId
- the action ID- Throws:
PortalException
-
addResourcePermission
Adds the resource permission to the database. Also notifies the appropriate model listeners.Important: Inspect ResourcePermissionLocalServiceImpl for overloaded versions of the method. If provided, use these entry points to the API, as the implementation logic may require the additional parameters defined there.
- Parameters:
resourcePermission
- the resource permission- Returns:
- the resource permission that was added
-
addResourcePermissions
public static void addResourcePermissions(long companyId, long groupId, long userId, String name, String primKey, boolean portletActions, ServiceContext serviceContext) throws PortalException Adds resources for the entity with the name and primary key string, always creating a resource at the individual scope and only creating resources at the group, group template, and company scope if such resources don't already exist.- Parameters:
companyId
- the primary key of the portal instancegroupId
- the primary key of the groupuserId
- the primary key of the user adding the resourcesname
- a name for the resource, which should be a portlet ID if the resource is a portlet or the resource's class name otherwiseprimKey
- the primary key string of the resource instance, optionally an empty string if no instance existsportletActions
- whether to associate portlet actions with the resource- Throws:
PortalException
-
addResourcePermissions
public static void addResourcePermissions(long companyId, long groupId, long userId, String name, String[] primKeys, boolean portletActions, ServiceContext serviceContext) throws PortalException - Throws:
PortalException
-
addResourcePermissions
public static void addResourcePermissions(String resourceName, String roleName, int scope, long resourceActionBitwiseValue) Grants the role permissions at the scope to perform the actions on all resources of the type. Existing actions are retained.This method should only be used to add default permissions to existing resources en masse during upgrades or while verifying permissions. For example, this method could be used to grant site members individual scope permissions to view all blog posts.
- Parameters:
resourceName
- the resource's name, which can be either a class name or a portlet IDroleName
- the role's namescope
- the scoperesourceActionBitwiseValue
- the bitwise IDs of the actions
-
copyModelResourcePermissions
public static void copyModelResourcePermissions(long companyId, String name, long sourcePrimKey, long targetPrimKey) throws PortalException - Throws:
PortalException
-
createPersistedModel
public static PersistedModel createPersistedModel(Serializable primaryKeyObj) throws PortalException - Throws:
PortalException
-
createResourcePermission
Creates a new resource permission with the primary key. Does not add the resource permission to the database.- Parameters:
resourcePermissionId
- the primary key for the new resource permission- Returns:
- the new resource permission
-
deletePersistedModel
public static PersistedModel deletePersistedModel(PersistedModel persistedModel) throws PortalException - Throws:
PortalException
-
deleteResourcePermission
public static ResourcePermission deleteResourcePermission(long resourcePermissionId) throws PortalException Deletes the resource permission with the primary key from the database. Also notifies the appropriate model listeners.Important: Inspect ResourcePermissionLocalServiceImpl for overloaded versions of the method. If provided, use these entry points to the API, as the implementation logic may require the additional parameters defined there.
- Parameters:
resourcePermissionId
- the primary key of the resource permission- Returns:
- the resource permission that was removed
- Throws:
PortalException
- if a resource permission with the primary key could not be found
-
deleteResourcePermission
Deletes the resource permission from the database. Also notifies the appropriate model listeners.Important: Inspect ResourcePermissionLocalServiceImpl for overloaded versions of the method. If provided, use these entry points to the API, as the implementation logic may require the additional parameters defined there.
- Parameters:
resourcePermission
- the resource permission- Returns:
- the resource permission that was removed
-
deleteResourcePermissions
public static void deleteResourcePermissions(long companyId, String name, int scope) throws PortalException - Throws:
PortalException
-
deleteResourcePermissions
public static void deleteResourcePermissions(long companyId, String name, int scope, long primKey) throws PortalException Deletes all resource permissions at the scope to resources of the type. This method should not be confused with any of theremoveResourcePermission
methods, as its purpose is very different. This method should only be used for deleting resource permissions that refer to a resource when that resource is deleted. For example this method could be used to delete all individual scope permissions to a blog post when it is deleted.Depending on the scope, the value of
primKey
will have different meanings. For more information, seeResourcePermissionImpl
.- Parameters:
companyId
- the primary key of the companyname
- the resource's name, which can be either a class name or a portlet IDscope
- the scopeprimKey
- the primary key- Throws:
PortalException
-
deleteResourcePermissions
public static void deleteResourcePermissions(long companyId, String name, int scope, String primKey) throws PortalException Deletes all resource permissions at the scope to resources of the type. This method should not be confused with any of theremoveResourcePermission
methods, as its purpose is very different. This method should only be used for deleting resource permissions that refer to a resource when that resource is deleted. For example this method could be used to delete all individual scope permissions to a blog post when it is deleted.Depending on the scope, the value of
primKey
will have different meanings. For more information, seeResourcePermissionImpl
.- Parameters:
companyId
- the primary key of the companyname
- the resource's name, which can be either a class name or a portlet IDscope
- the scopeprimKey
- the primary key- Throws:
PortalException
-
deleteResourcePermissions
-
dslQuery
public static <T> T dslQuery(com.liferay.petra.sql.dsl.query.DSLQuery dslQuery) -
dslQueryCount
public static int dslQueryCount(com.liferay.petra.sql.dsl.query.DSLQuery dslQuery) -
dynamicQuery
-
dynamicQuery
Performs a dynamic query on the database and returns the matching rows.- Parameters:
dynamicQuery
- the dynamic query- Returns:
- the matching rows
-
dynamicQuery
Performs a dynamic query on the database and returns a range of the matching rows.Useful when paginating results. Returns a maximum of
end - start
instances.start
andend
are not primary keys, they are indexes in the result set. Thus,0
refers to the first result in the set. Setting bothstart
andend
tocom.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS
will return the full result set. IforderByComparator
is specified, then the query will include the given ORDER BY logic. IforderByComparator
is absent, then the query will include the default ORDER BY logic fromcom.liferay.portal.model.impl.ResourcePermissionModelImpl
.- Parameters:
dynamicQuery
- the dynamic querystart
- the lower bound of the range of model instancesend
- the upper bound of the range of model instances (not inclusive)- Returns:
- the range of matching rows
-
dynamicQuery
public static <T> List<T> dynamicQuery(DynamicQuery dynamicQuery, int start, int end, OrderByComparator<T> orderByComparator) Performs a dynamic query on the database and returns an ordered range of the matching rows.Useful when paginating results. Returns a maximum of
end - start
instances.start
andend
are not primary keys, they are indexes in the result set. Thus,0
refers to the first result in the set. Setting bothstart
andend
tocom.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS
will return the full result set. IforderByComparator
is specified, then the query will include the given ORDER BY logic. IforderByComparator
is absent, then the query will include the default ORDER BY logic fromcom.liferay.portal.model.impl.ResourcePermissionModelImpl
.- Parameters:
dynamicQuery
- the dynamic querystart
- the lower bound of the range of model instancesend
- the upper bound of the range of model instances (not inclusive)orderByComparator
- the comparator to order the results by (optionallynull
)- Returns:
- the ordered range of matching rows
-
dynamicQueryCount
Returns the number of rows matching the dynamic query.- Parameters:
dynamicQuery
- the dynamic query- Returns:
- the number of rows matching the dynamic query
-
dynamicQueryCount
Returns the number of rows matching the dynamic query.- Parameters:
dynamicQuery
- the dynamic queryprojection
- the projection to apply to the query- Returns:
- the number of rows matching the dynamic query
-
fetchResourcePermission
-
fetchResourcePermission
public static ResourcePermission fetchResourcePermission(long companyId, String name, int scope, String primKey, long roleId) -
getActionableDynamicQuery
-
getAvailableResourcePermissionActionIds
-
getAvailableResourcePermissionActionIds
public static List<String> getAvailableResourcePermissionActionIds(long companyId, String name, int scope, String primKey, long roleId, Collection<String> actionIds) throws PortalException Returns the intersection of action IDs the role has permission at the scope to perform on resources of the type.- Parameters:
companyId
- he primary key of the companyname
- the resource's name, which can be either a class name or a portlet IDscope
- the scopeprimKey
- the primary keyroleId
- the primary key of the roleactionIds
- the action IDs- Returns:
- the intersection of action IDs the role has permission at the scope to perform on resources of the type
- Throws:
PortalException
-
getIndexableActionableDynamicQuery
-
getIndividualPortletResourcePermissions
public static Map<String,List<ResourcePermission>> getIndividualPortletResourcePermissions(long companyId) -
getOSGiServiceIdentifier
Returns the OSGi service identifier.- Returns:
- the OSGi service identifier
-
getPersistedModel
- Throws:
PortalException
-
getResourcePermission
public static ResourcePermission getResourcePermission(long resourcePermissionId) throws PortalException Returns the resource permission with the primary key.- Parameters:
resourcePermissionId
- the primary key of the resource permission- Returns:
- the resource permission
- Throws:
PortalException
- if a resource permission with the primary key could not be found
-
getResourcePermission
public static ResourcePermission getResourcePermission(long companyId, String name, int scope, String primKey, long roleId) throws PortalException Returns the resource permission for the role at the scope to perform the actions on resources of the type.- Parameters:
companyId
- the primary key of the companyname
- the resource's name, which can be either a class name or a portlet IDscope
- the scopeprimKey
- the primary keyroleId
- the primary key of the role- Returns:
- the resource permission for the role at the scope to perform the actions on resources of the type
- Throws:
PortalException
-
getResourcePermissions
Returns a range of all the resource permissions.Useful when paginating results. Returns a maximum of
end - start
instances.start
andend
are not primary keys, they are indexes in the result set. Thus,0
refers to the first result in the set. Setting bothstart
andend
tocom.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS
will return the full result set. IforderByComparator
is specified, then the query will include the given ORDER BY logic. IforderByComparator
is absent, then the query will include the default ORDER BY logic fromcom.liferay.portal.model.impl.ResourcePermissionModelImpl
.- Parameters:
start
- the lower bound of the range of resource permissionsend
- the upper bound of the range of resource permissions (not inclusive)- Returns:
- the range of resource permissions
-
getResourcePermissions
public static List<ResourcePermission> getResourcePermissions(long companyId, String name, int scope, long roleId, boolean viewActionId) -
getResourcePermissions
public static List<ResourcePermission> getResourcePermissions(long companyId, String name, int scope, String primKey) Returns all the resource permissions at the scope of the type.- Parameters:
companyId
- the primary key of the companyname
- the resource's name, which can be either a class name or a portlet IDscope
- the scopeprimKey
- the primary key- Returns:
- the resource permissions at the scope of the type
-
getResourcePermissions
-
getResourcePermissionsCount
public static int getResourcePermissionsCount()Returns the number of resource permissions.- Returns:
- the number of resource permissions
-
getResourcePermissionsCount
public static int getResourcePermissionsCount(long companyId, String name, int scope, String primKey) Returns the number of resource permissions at the scope of the type.- Parameters:
companyId
- the primary key of the companyname
- the resource's name, which can be either a class name or a portlet IDscope
- the scopeprimKey
- the primary key- Returns:
- the number of resource permissions at the scope of the type
-
getResourceResourcePermissions
public static List<ResourcePermission> getResourceResourcePermissions(long companyId, long groupId, String name, String primKey) Returns the resource permissions that apply to the resource.- Parameters:
companyId
- the primary key of the resource's companygroupId
- the primary key of the resource's groupname
- the resource's name, which can be either a class name or a portlet IDprimKey
- the primary key of the resource- Returns:
- the resource permissions associated with the resource
-
getRoleResourcePermissions
Returns all the resource permissions for the role.- Parameters:
roleId
- the primary key of the role- Returns:
- the resource permissions for the role
-
getRoleResourcePermissions
public static List<ResourcePermission> getRoleResourcePermissions(long roleId, int[] scopes, int start, int end) Returns a range of all the resource permissions for the role at the scopes.Useful when paginating results. Returns a maximum of
end - start
instances.start
andend
are not primary keys, they are indexes in the result set. Thus,0
refers to the first result in the set. Setting bothstart
andend
toQueryUtil.ALL_POS
will return the full result set.- Parameters:
roleId
- the primary key of the rolescopes
- the scopesstart
- the lower bound of the range of resultsend
- the upper bound of the range of results (not inclusive)- Returns:
- the range of resource permissions for the role at the scopes
-
getRoles
public static List<Role> getRoles(long companyId, String name, int scope, String primKey, String actionId) throws PortalException - Throws:
PortalException
-
getScopeResourcePermissions
Returns all the resource permissions where scope = any ?.Useful when paginating results. Returns a maximum of
end - start
instances.start
andend
are not primary keys, they are indexes in the result set. Thus,0
refers to the first result in the set. Setting bothstart
andend
toQueryUtil.ALL_POS
will return the full result set.- Parameters:
scopes
- the scopes- Returns:
- the resource permissions where scope = any ?
-
hasActionId
public static boolean hasActionId(ResourcePermission resourcePermission, ResourceAction resourceAction) Returnstrue
if the resource permission grants permission to perform the resource action. Note that this method does not ensure that the resource permission refers to the same type of resource as the resource action.- Parameters:
resourcePermission
- the resource permissionresourceAction
- the resource action- Returns:
true
if the resource permission grants permission to perform the resource action
-
hasResourcePermission
public static boolean hasResourcePermission(List<Resource> resources, long[] roleIds, String actionId) throws PortalException Returnstrue
if the roles have permission at the scope to perform the action on the resources.Depending on the scope, the value of
primKey
will have different meanings. For more information, seeResourcePermissionImpl
.- Parameters:
resources
- the resourcesroleIds
- the primary keys of the rolesactionId
- the action ID- Returns:
true
if any one of the roles has permission to perform the action on any one of the resources;false
otherwise- Throws:
PortalException
-
hasResourcePermission
public static boolean hasResourcePermission(long companyId, String name, int scope, String primKey, long roleId, String actionId) throws PortalException Returnstrue
if the role has permission at the scope to perform the action on resources of the type.Depending on the scope, the value of
primKey
will have different meanings. For more information, seeResourcePermissionImpl
.- Parameters:
companyId
- the primary key of the companyname
- the resource's name, which can be either a class name or a portlet IDscope
- the scopeprimKey
- the primary keyroleId
- the primary key of the roleactionId
- the action ID- Returns:
true
if the role has permission to perform the action on the resource;false
otherwise- Throws:
PortalException
-
hasResourcePermission
public static boolean hasResourcePermission(long companyId, String name, int scope, String primKey, long[] roleIds, String actionId) throws PortalException Returnstrue
if the roles have permission at the scope to perform the action on resources of the type.Depending on the scope, the value of
primKey
will have different meanings. For more information, seeResourcePermissionImpl
.- Parameters:
companyId
- the primary key of the companyname
- the resource's name, which can be either a class name or a portlet IDscope
- the scopeprimKey
- the primary keyroleIds
- the primary keys of the rolesactionId
- the action ID- Returns:
true
if any one of the roles has permission to perform the action on the resource;false
otherwise- Throws:
PortalException
-
hasScopeResourcePermission
public static boolean hasScopeResourcePermission(long companyId, String name, int scope, long roleId, String actionId) throws PortalException Returnstrue
if the role has permission at the scope to perform the action on the resource.Depending on the scope, the value of
primKey
will have different meanings. For more information, seeResourcePermissionImpl
.- Parameters:
companyId
- the primary key of the companyname
- the resource's name, which can be either a class name or a portlet IDscope
- the scoperoleId
- the primary key of the roleactionId
- the action ID- Returns:
true
if the role has permission to perform the action on the resource;false
otherwise- Throws:
PortalException
-
initDefaultModelResourcePermissions
public static void initDefaultModelResourcePermissions(long companyId, Collection<String> modelResources) throws PortalException - Throws:
PortalException
-
initPortletDefaultPermissions
- Throws:
PortalException
-
mergePermissions
Reassigns all the resource permissions from the source role to the destination role, and deletes the source role.- Parameters:
fromRoleId
- the primary key of the source roletoRoleId
- the primary key of the destination role- Throws:
PortalException
-
reassignPermissions
public static void reassignPermissions(long resourcePermissionId, long toRoleId) throws PortalException Grants the role default permissions to all the resources of the type and at the scope stored in the resource permission, deletes the resource permission, and deletes the resource permission's role if it has no permissions remaining.- Parameters:
resourcePermissionId
- the primary key of the resource permissiontoRoleId
- the primary key of the role- Throws:
PortalException
-
removeResourcePermission
public static void removeResourcePermission(long companyId, String name, int scope, String primKey, long roleId, String actionId) throws PortalException Revokes permission at the scope from the role to perform the action on resources of the type. For example, this method could be used to revoke a group scope permission to edit blog posts.Depending on the scope, the value of
primKey
will have different meanings. For more information, seeResourcePermissionImpl
.- Parameters:
companyId
- the primary key of the companyname
- the resource's name, which can be either a class name or a portlet IDscope
- the scopeprimKey
- the primary keyroleId
- the primary key of the roleactionId
- the action ID- Throws:
PortalException
-
removeResourcePermissions
public static void removeResourcePermissions(long companyId, String name, int scope, long roleId, String actionId) throws PortalException Revokes all permissions at the scope from the role to perform the action on resources of the type. For example, this method could be used to revoke all individual scope permissions to edit blog posts from site members.- Parameters:
companyId
- the primary key of the companyname
- the resource's name, which can be either a class name or a portlet IDscope
- the scoperoleId
- the primary key of the roleactionId
- the action ID- Throws:
PortalException
-
setOwnerResourcePermissions
public static void setOwnerResourcePermissions(long companyId, String name, int scope, String primKey, long roleId, long ownerId, String[] actionIds) throws PortalException Updates the role's permissions at the scope, setting the actions that can be performed on resources of the type, also setting the owner of any newly created resource permissions. Existing actions are replaced.This method can be used to set permissions at any scope, but it is generally only used at the individual scope. For example, it could be used to set the guest permissions on a blog post.
Depending on the scope, the value of
primKey
will have different meanings. For more information, seeResourcePermissionImpl
.- Parameters:
companyId
- the primary key of the companyname
- the resource's name, which can be either a class name or a portlet IDscope
- the scopeprimKey
- the primary keyroleId
- the primary key of the roleownerId
- the primary key of the owner (generally the user that created the resource)actionIds
- the action IDs of the actions- Throws:
PortalException
-
setResourcePermissions
public static void setResourcePermissions(long companyId, String name, int scope, String primKey, long roleId, String[] actionIds) throws PortalException Updates the role's permissions at the scope, setting the actions that can be performed on resources of the type. Existing actions are replaced.This method can be used to set permissions at any scope, but it is generally only used at the individual scope. For example, it could be used to set the guest permissions on a blog post.
Depending on the scope, the value of
primKey
will have different meanings. For more information, seeResourcePermissionImpl
.- Parameters:
companyId
- the primary key of the companyname
- the resource's name, which can be either a class name or a portlet IDscope
- the scopeprimKey
- the primary keyroleId
- the primary key of the roleactionIds
- the action IDs of the actions- Throws:
PortalException
-
setResourcePermissions
public static void setResourcePermissions(long companyId, String name, int scope, String primKey, Map<Long, String[]> roleIdsToActionIds) throws PortalExceptionUpdates the role's permissions at the scope, setting the actions that can be performed on resources of the type. Existing actions are replaced.This method can be used to set permissions at any scope, but it is generally only used at the individual scope. For example, it could be used to set the guest permissions on a blog post.
Depending on the scope, the value of
primKey
will have different meanings. For more information, seeResourcePermissionImpl
.- Parameters:
companyId
- the primary key of the companyname
- the resource's name, which can be either a class name or a portlet IDscope
- the scopeprimKey
- the primary keyroleIdsToActionIds
- a map of role IDs to action IDs of the actions- Throws:
PortalException
-
updateModelResourcePermissions
public static void updateModelResourcePermissions(AuditedModel auditedModel, ServiceContext serviceContext) throws PortalException Updates the resources for the model, replacing their group and guest permissions with new ones from the service context.- Parameters:
auditedModel
- the model associated with the resourcesserviceContext
- the service context to be applied. Can set group and guest permissions.- Throws:
PortalException
-
updateResourcePermission
Updates the resource permission in the database or adds it if it does not yet exist. Also notifies the appropriate model listeners.Important: Inspect ResourcePermissionLocalServiceImpl for overloaded versions of the method. If provided, use these entry points to the API, as the implementation logic may require the additional parameters defined there.
- Parameters:
resourcePermission
- the resource permission- Returns:
- the resource permission that was updated
-
updateResourcePermissions
public static void updateResourcePermissions(long companyId, long groupId, String name, long primKey, String[] groupPermissions, String[] guestPermissions) throws PortalException Updates resources matching the group, name, and primary key at the individual scope, setting new group and guest permissions.- Parameters:
companyId
- the primary key of the portal instancegroupId
- the primary key of the groupname
- the resource's name, which should be a portlet ID if the resource is a portlet or the resource's class name otherwiseprimKey
- the primary key of the resource instancegroupPermissions
- the group permissions to be appliedguestPermissions
- the guest permissions to be applied- Throws:
PortalException
-
updateResourcePermissions
public static void updateResourcePermissions(long companyId, long groupId, String name, String primKey, ModelPermissions modelPermissions) throws PortalException - Throws:
PortalException
-
updateResourcePermissions
public static void updateResourcePermissions(long companyId, long groupId, String name, String primKey, String[] groupPermissions, String[] guestPermissions) throws PortalException - Throws:
PortalException
-
updateResourcePermissions
-
getService
-
setService
-