Interface RoleService
- All Superinterfaces:
BaseService
- All Known Implementing Classes:
RoleServiceWrapper
@AccessControlled
@CTAware
@JSONWebService
@ProviderType
@Transactional(isolation=PORTAL,
rollbackFor={PortalException.class,SystemException.class})
public interface RoleService
extends BaseService
Provides the remote service interface for Role. 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}
-
Method Summary
Modifier and TypeMethodDescriptionaddRole
(String externalReferenceCode, String className, long classPK, String name, Map<Locale, String> titleMap, Map<Locale, String> descriptionMap, int type, String subtype, ServiceContext serviceContext) void
addUserRoles
(long userId, long[] roleIds) Adds the roles to the user.void
deleteRole
(long roleId) Deletes the role with the primary key and its associated permissions.fetchRole
(long roleId) 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) int
getGroupRolesAndTeamRolesCount
(long companyId, String name, List<String> excludedNames, String title, String description, int[] types, long excludedTeamRoleId, long teamGroupId) Returns the OSGi service identifier.getRole
(long roleId) Returns the role with the primary key.Returns the role with the name in the company.getRoleByExternalReferenceCode
(String externalReferenceCode, long companyId) getRoles
(long companyId, int[] types) 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.boolean
hasUserRole
(long userId, long companyId, String name, boolean inherited) Returnstrue
if the user is associated with the named regular role.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) int
searchCount
(long companyId, String keywords, Integer[] types, LinkedHashMap<String, Object> params) void
unsetUserRoles
(long userId, long[] roleIds) Removes the matching roles associated with the user.updateExternalReferenceCode
(long roleId, String externalReferenceCode) updateExternalReferenceCode
(Role role, String externalReferenceCode) updateRole
(long roleId, String name, Map<Locale, String> titleMap, Map<Locale, String> descriptionMap, String subtype, ServiceContext serviceContext) Updates the role with the primary key.
-
Method Details
-
addRole
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
@Transactional(propagation=SUPPORTS, readOnly=true) Role fetchRole(long roleId) throws PortalException - Throws:
PortalException
-
fetchRole
@Transactional(propagation=SUPPORTS, readOnly=true) Role fetchRole(long companyId, String name) throws PortalException - Throws:
PortalException
-
fetchRoleByExternalReferenceCode
@Transactional(propagation=SUPPORTS, readOnly=true) Role fetchRoleByExternalReferenceCode(String externalReferenceCode, long companyId) throws PortalException - Throws:
PortalException
-
getGroupRoles
@Transactional(propagation=SUPPORTS, readOnly=true) List<Role> getGroupRoles(long groupId) throws PortalException 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
@Transactional(propagation=SUPPORTS, readOnly=true) int getGroupRolesAndTeamRolesCount(long companyId, String name, List<String> excludedNames, String title, String description, int[] types, long excludedTeamRoleId, long teamGroupId) -
getOSGiServiceIdentifier
String getOSGiServiceIdentifier()Returns the OSGi service identifier.- Returns:
- the OSGi service identifier
-
getRole
@Transactional(propagation=SUPPORTS, readOnly=true) Role getRole(long roleId) throws PortalException 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
@Transactional(propagation=SUPPORTS, readOnly=true) Role getRole(long companyId, String name) throws PortalException 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
@Transactional(propagation=SUPPORTS, readOnly=true) Role getRoleByExternalReferenceCode(String externalReferenceCode, long companyId) throws PortalException - Throws:
PortalException
-
getRoles
@Transactional(propagation=SUPPORTS, readOnly=true) List<Role> getRoles(int type, String subtype) throws PortalException - Throws:
PortalException
-
getRoles
@Transactional(propagation=SUPPORTS, readOnly=true) List<Role> getRoles(long companyId, int[] types) throws PortalException - Throws:
PortalException
-
getUserGroupGroupRoles
@Transactional(propagation=SUPPORTS, readOnly=true) List<Role> getUserGroupGroupRoles(long userId, long groupId) throws PortalException 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
@Transactional(propagation=SUPPORTS, readOnly=true) List<Role> getUserGroupRoles(long userId, long groupId) throws PortalException 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
@Transactional(propagation=SUPPORTS, readOnly=true) 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
@Transactional(propagation=SUPPORTS, readOnly=true) List<Role> getUserRoles(long userId) throws PortalException 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
@Transactional(propagation=SUPPORTS, readOnly=true) 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
@Transactional(propagation=SUPPORTS, readOnly=true) 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
@Transactional(propagation=SUPPORTS, readOnly=true) List<Role> search(long companyId, String keywords, Integer[] types, LinkedHashMap<String, Object> params, int start, int end, OrderByComparator<Role> orderByComparator) -
searchCount
@Transactional(propagation=SUPPORTS, readOnly=true) 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
- Throws:
PortalException
-
updateExternalReferenceCode
- Throws:
PortalException
-
updateRole
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
-