Class RoleServiceUtil
Object
com.liferay.portal.kernel.service.RoleServiceUtil
Provides the remote service utility for Role. This utility wraps
com.liferay.portal.service.impl.RoleServiceImpl
and is an
access point for service operations in application layer code running on a
remote server. Methods of this service are expected to have security checks
based on the propagated JAAS credentials because this service can be
accessed remotely.- Author:
- Brian Wing Shun Chan
- See Also:
- {$generated.description}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Role
addRole
(String externalReferenceCode, String className, long classPK, String name, Map<Locale, String> titleMap, Map<Locale, String> descriptionMap, int type, String subtype, ServiceContext serviceContext) static void
addUserRoles
(long userId, long[] roleIds) Adds the roles to the user.static void
deleteRole
(long roleId) Deletes the role with the primary key and its associated permissions.static Role
fetchRole
(long roleId) static Role
static Role
fetchRoleByExternalReferenceCode
(String externalReferenceCode, long companyId) getGroupRoles
(long groupId) Returns all the roles associated with the group.getGroupRolesAndTeamRoles
(long companyId, String name, List<String> excludedNames, String title, String description, int[] types, long excludedTeamRoleId, long teamGroupId, int start, int end) static int
getGroupRolesAndTeamRolesCount
(long companyId, String name, List<String> excludedNames, String title, String description, int[] types, long excludedTeamRoleId, long teamGroupId) static String
Returns the OSGi service identifier.static Role
getRole
(long roleId) Returns the role with the primary key.static Role
Returns the role with the name in the company.static Role
getRoleByExternalReferenceCode
(String externalReferenceCode, long companyId) getRoles
(long companyId, int[] types) static RoleService
getUserGroupGroupRoles
(long userId, long groupId) Returns all the user's roles within the user group.getUserGroupRoles
(long userId, long groupId) Returns all the user's roles within the user group.getUserRelatedRoles
(long userId, List<Group> groups) Returns the union of all the user's roles within the groups.getUserRoles
(long userId) Returns all the roles associated with the user.static boolean
hasUserRole
(long userId, long companyId, String name, boolean inherited) Returnstrue
if the user is associated with the named regular role.static boolean
hasUserRoles
(long userId, long companyId, String[] names, boolean inherited) Returnstrue
if the user has any one of the named regular roles.search
(long companyId, String keywords, Integer[] types, LinkedHashMap<String, Object> params, int start, int end, OrderByComparator<Role> orderByComparator) static int
searchCount
(long companyId, String keywords, Integer[] types, LinkedHashMap<String, Object> params) static void
setService
(RoleService service) static void
unsetUserRoles
(long userId, long[] roleIds) Removes the matching roles associated with the user.static Role
updateExternalReferenceCode
(long roleId, String externalReferenceCode) static Role
updateExternalReferenceCode
(Role role, String externalReferenceCode) static Role
updateRole
(long roleId, String name, Map<Locale, String> titleMap, Map<Locale, String> descriptionMap, String subtype, ServiceContext serviceContext) Updates the role with the primary key.
-
Constructor Details
-
RoleServiceUtil
public RoleServiceUtil()
-
-
Method Details
-
addRole
public static Role addRole(String externalReferenceCode, String className, long classPK, String name, Map<Locale, String> titleMap, Map<Locale, throws PortalExceptionString> descriptionMap, int type, String subtype, ServiceContext serviceContext) - Throws:
PortalException
-
addUserRoles
Adds the roles to the user. The user is reindexed after the roles are added.- Parameters:
userId
- the primary key of the userroleIds
- the primary keys of the roles- Throws:
PortalException
-
deleteRole
Deletes the role with the primary key and its associated permissions.- Parameters:
roleId
- the primary key of the role- Throws:
PortalException
-
fetchRole
- Throws:
PortalException
-
fetchRole
- Throws:
PortalException
-
fetchRoleByExternalReferenceCode
public static Role fetchRoleByExternalReferenceCode(String externalReferenceCode, long companyId) throws PortalException - Throws:
PortalException
-
getGroupRoles
Returns all the roles associated with the group.- Parameters:
groupId
- the primary key of the group- Returns:
- the roles associated with the group
- Throws:
PortalException
-
getGroupRolesAndTeamRoles
-
getGroupRolesAndTeamRolesCount
-
getOSGiServiceIdentifier
Returns the OSGi service identifier.- Returns:
- the OSGi service identifier
-
getRole
Returns the role with the primary key.- Parameters:
roleId
- the primary key of the role- Returns:
- the role with the primary key
- Throws:
PortalException
-
getRole
Returns the role with the name in the company.The method searches the system roles map first for default roles. If a role with the name is not found, then the method will query the database.
- Parameters:
companyId
- the primary key of the companyname
- the role's name- Returns:
- the role with the name
- Throws:
PortalException
-
getRoleByExternalReferenceCode
public static Role getRoleByExternalReferenceCode(String externalReferenceCode, long companyId) throws PortalException - Throws:
PortalException
-
getRoles
- Throws:
PortalException
-
getRoles
- Throws:
PortalException
-
getUserGroupGroupRoles
Returns all the user's roles within the user group.- Parameters:
userId
- the primary key of the usergroupId
- the primary key of the group- Returns:
- the user's roles within the user group
- Throws:
PortalException
-
getUserGroupRoles
Returns all the user's roles within the user group.- Parameters:
userId
- the primary key of the usergroupId
- the primary key of the group- Returns:
- the user's roles within the user group
- Throws:
PortalException
-
getUserRelatedRoles
public static List<Role> getUserRelatedRoles(long userId, List<Group> groups) throws PortalException Returns the union of all the user's roles within the groups. If no groups are provided, only the user's directly assigned roles are returned.- Parameters:
userId
- the primary key of the usergroups
- the groups (optionallynull
)- Returns:
- the union of all the user's roles within the groups
- Throws:
PortalException
-
getUserRoles
Returns all the roles associated with the user.- Parameters:
userId
- the primary key of the user- Returns:
- the roles associated with the user
- Throws:
PortalException
-
hasUserRole
public static boolean hasUserRole(long userId, long companyId, String name, boolean inherited) throws PortalException Returnstrue
if the user is associated with the named regular role.- Parameters:
userId
- the primary key of the usercompanyId
- the primary key of the companyname
- the name of the roleinherited
- whether to include the user's inherited roles in the search- Returns:
true
if the user is associated with the regular role;false
otherwise- Throws:
PortalException
-
hasUserRoles
public static boolean hasUserRoles(long userId, long companyId, String[] names, boolean inherited) throws PortalException Returnstrue
if the user has any one of the named regular roles.- Parameters:
userId
- the primary key of the usercompanyId
- the primary key of the companynames
- the names of the rolesinherited
- whether to include the user's inherited roles in the search- Returns:
true
if the user has any one of the regular roles;false
otherwise- Throws:
PortalException
-
search
public static List<Role> search(long companyId, String keywords, Integer[] types, LinkedHashMap<String, Object> params, int start, int end, OrderByComparator<Role> orderByComparator) -
searchCount
public static int searchCount(long companyId, String keywords, Integer[] types, LinkedHashMap<String, Object> params) -
unsetUserRoles
Removes the matching roles associated with the user. The user is reindexed after the roles are removed.- Parameters:
userId
- the primary key of the userroleIds
- the primary keys of the roles- Throws:
PortalException
-
updateExternalReferenceCode
public static Role updateExternalReferenceCode(long roleId, String externalReferenceCode) throws PortalException - Throws:
PortalException
-
updateExternalReferenceCode
public static Role updateExternalReferenceCode(Role role, String externalReferenceCode) throws PortalException - Throws:
PortalException
-
updateRole
public static Role updateRole(long roleId, String name, Map<Locale, String> titleMap, Map<Locale, throws PortalExceptionString> descriptionMap, String subtype, ServiceContext serviceContext) Updates the role with the primary key.- Parameters:
roleId
- the primary key of the rolename
- the role's new nametitleMap
- the new localized titles (optionallynull
) to replace those existing for the roledescriptionMap
- the new localized descriptions (optionallynull
) to replace those existing for the rolesubtype
- the role's new subtype (optionallynull
)serviceContext
- the service context to be applied (optionallynull
). Can set the expando bridge attributes for the role.- Returns:
- the role with the primary key
- Throws:
PortalException
-
getService
-
setService
-