Package com.liferay.portal.service.impl
Class RoleServiceImpl
Object
com.liferay.portal.kernel.service.BaseServiceImpl
com.liferay.portal.service.base.RoleServiceBaseImpl
com.liferay.portal.service.impl.RoleServiceImpl
- All Implemented Interfaces:
com.liferay.portal.kernel.module.framework.service.IdentifiableOSGiService
,com.liferay.portal.kernel.service.BaseService
,com.liferay.portal.kernel.service.RoleService
Provides the remote service for accessing, adding, unassigning, checking,
deleting, and updating roles. Its methods include permission checks.
- Author:
- Brian Wing Shun Chan
-
Field Summary
Fields inherited from class com.liferay.portal.service.base.RoleServiceBaseImpl
counterLocalService, groupPersistence, roleFinder, roleLocalService, rolePersistence, roleService, userPersistence
Fields inherited from class com.liferay.portal.kernel.service.BaseServiceImpl
ANONYMOUS_NAMES, JRUN_ANONYMOUS, ORACLE_ANONYMOUS, SUN_ANONYMOUS, WEBLOGIC_ANONYMOUS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.liferay.portal.kernel.model.Role
addRole
(String externalReferenceCode, String className, long classPK, String name, Map<Locale, String> titleMap, Map<Locale, String> descriptionMap, int type, String subtype, com.liferay.portal.kernel.service.ServiceContext serviceContext) void
addUserRoles
(long userId, long[] roleIds) Adds the roles to the user.protected void
checkUserRolesPermission
(long userId, long[] roleIds) void
deleteRole
(long roleId) Deletes the role with the primary key and its associated permissions.com.liferay.portal.kernel.model.Role
fetchRole
(long roleId) com.liferay.portal.kernel.model.Role
com.liferay.portal.kernel.model.Role
fetchRoleByExternalReferenceCode
(String externalReferenceCode, long companyId) protected List<com.liferay.portal.kernel.model.Role>
filterRoles
(List<com.liferay.portal.kernel.model.Role> roles) List<com.liferay.portal.kernel.model.Role>
getGroupRoles
(long groupId) Returns all the roles associated with the group.List<com.liferay.portal.kernel.model.Role>
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) com.liferay.portal.kernel.model.Role
getRole
(long roleId) Returns the role with the primary key.com.liferay.portal.kernel.model.Role
Returns the role with the name in the company.com.liferay.portal.kernel.model.Role
getRoleByExternalReferenceCode
(String externalReferenceCode, long companyId) List<com.liferay.portal.kernel.model.Role>
List<com.liferay.portal.kernel.model.Role>
getRoles
(long companyId, int[] types) List<com.liferay.portal.kernel.model.Role>
getUserGroupGroupRoles
(long userId, long groupId) Returns all the user's roles within the user group.List<com.liferay.portal.kernel.model.Role>
getUserGroupRoles
(long userId, long groupId) Returns all the user's roles within the user group.List<com.liferay.portal.kernel.model.Role>
getUserRelatedRoles
(long userId, List<com.liferay.portal.kernel.model.Group> groups) Returns the union of all the user's roles within the groups.List<com.liferay.portal.kernel.model.Role>
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.List<com.liferay.portal.kernel.model.Role>
search
(long companyId, String keywords, Integer[] types, LinkedHashMap<String, Object> params, int start, int end, com.liferay.portal.kernel.util.OrderByComparator<com.liferay.portal.kernel.model.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.com.liferay.portal.kernel.model.Role
updateExternalReferenceCode
(long roleId, String externalReferenceCode) com.liferay.portal.kernel.model.Role
updateExternalReferenceCode
(com.liferay.portal.kernel.model.Role role, String externalReferenceCode) com.liferay.portal.kernel.model.Role
updateRole
(long roleId, String name, Map<Locale, String> titleMap, Map<Locale, String> descriptionMap, String subtype, com.liferay.portal.kernel.service.ServiceContext serviceContext) Updates the role with the primary key.Methods inherited from class com.liferay.portal.service.base.RoleServiceBaseImpl
afterPropertiesSet, destroy, getCounterLocalService, getModelClass, getModelClassName, getOSGiServiceIdentifier, getRoleFinder, getRoleLocalService, getRolePersistence, getRoleService, runSQL, setCounterLocalService, setRoleFinder, setRoleLocalService, setRolePersistence, setRoleService
Methods inherited from class com.liferay.portal.kernel.service.BaseServiceImpl
getClassLoader, getGuestOrUser, getGuestOrUserId, getPermissionChecker, getUser, getUserId
-
Constructor Details
-
RoleServiceImpl
public RoleServiceImpl()
-
-
Method Details
-
addRole
public com.liferay.portal.kernel.model.Role addRole(String externalReferenceCode, String className, long classPK, String name, Map<Locale, String> titleMap, Map<Locale, throws com.liferay.portal.kernel.exception.PortalExceptionString> descriptionMap, int type, String subtype, com.liferay.portal.kernel.service.ServiceContext serviceContext) - Throws:
com.liferay.portal.kernel.exception.PortalException
-
addUserRoles
public void addUserRoles(long userId, long[] roleIds) throws com.liferay.portal.kernel.exception.PortalException 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:
com.liferay.portal.kernel.exception.PortalException
-
deleteRole
public void deleteRole(long roleId) throws com.liferay.portal.kernel.exception.PortalException Deletes the role with the primary key and its associated permissions.- Parameters:
roleId
- the primary key of the role- Throws:
com.liferay.portal.kernel.exception.PortalException
-
fetchRole
public com.liferay.portal.kernel.model.Role fetchRole(long roleId) throws com.liferay.portal.kernel.exception.PortalException - Throws:
com.liferay.portal.kernel.exception.PortalException
-
fetchRole
public com.liferay.portal.kernel.model.Role fetchRole(long companyId, String name) throws com.liferay.portal.kernel.exception.PortalException - Throws:
com.liferay.portal.kernel.exception.PortalException
-
fetchRoleByExternalReferenceCode
public com.liferay.portal.kernel.model.Role fetchRoleByExternalReferenceCode(String externalReferenceCode, long companyId) throws com.liferay.portal.kernel.exception.PortalException - Throws:
com.liferay.portal.kernel.exception.PortalException
-
getGroupRoles
public List<com.liferay.portal.kernel.model.Role> getGroupRoles(long groupId) throws com.liferay.portal.kernel.exception.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:
com.liferay.portal.kernel.exception.PortalException
-
getGroupRolesAndTeamRoles
-
getGroupRolesAndTeamRolesCount
-
getRole
public com.liferay.portal.kernel.model.Role getRole(long roleId) throws com.liferay.portal.kernel.exception.PortalException Returns the role with the primary key.- Parameters:
roleId
- the primary key of the role- Returns:
- the role with the primary key
- Throws:
com.liferay.portal.kernel.exception.PortalException
-
getRole
public com.liferay.portal.kernel.model.Role getRole(long companyId, String name) throws com.liferay.portal.kernel.exception.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:
com.liferay.portal.kernel.exception.PortalException
-
getRoleByExternalReferenceCode
public com.liferay.portal.kernel.model.Role getRoleByExternalReferenceCode(String externalReferenceCode, long companyId) throws com.liferay.portal.kernel.exception.PortalException - Throws:
com.liferay.portal.kernel.exception.PortalException
-
getRoles
public List<com.liferay.portal.kernel.model.Role> getRoles(int type, String subtype) throws com.liferay.portal.kernel.exception.PortalException - Throws:
com.liferay.portal.kernel.exception.PortalException
-
getRoles
public List<com.liferay.portal.kernel.model.Role> getRoles(long companyId, int[] types) throws com.liferay.portal.kernel.exception.PortalException - Throws:
com.liferay.portal.kernel.exception.PortalException
-
getUserGroupGroupRoles
public List<com.liferay.portal.kernel.model.Role> getUserGroupGroupRoles(long userId, long groupId) throws com.liferay.portal.kernel.exception.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:
com.liferay.portal.kernel.exception.PortalException
-
getUserGroupRoles
public List<com.liferay.portal.kernel.model.Role> getUserGroupRoles(long userId, long groupId) throws com.liferay.portal.kernel.exception.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:
com.liferay.portal.kernel.exception.PortalException
-
getUserRelatedRoles
public List<com.liferay.portal.kernel.model.Role> getUserRelatedRoles(long userId, List<com.liferay.portal.kernel.model.Group> groups) throws com.liferay.portal.kernel.exception.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:
com.liferay.portal.kernel.exception.PortalException
-
getUserRoles
public List<com.liferay.portal.kernel.model.Role> getUserRoles(long userId) throws com.liferay.portal.kernel.exception.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:
com.liferay.portal.kernel.exception.PortalException
-
hasUserRole
public boolean hasUserRole(long userId, long companyId, String name, boolean inherited) throws com.liferay.portal.kernel.exception.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:
com.liferay.portal.kernel.exception.PortalException
-
hasUserRoles
public boolean hasUserRoles(long userId, long companyId, String[] names, boolean inherited) throws com.liferay.portal.kernel.exception.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:
com.liferay.portal.kernel.exception.PortalException
-
search
-
searchCount
public int searchCount(long companyId, String keywords, Integer[] types, LinkedHashMap<String, Object> params) -
unsetUserRoles
public void unsetUserRoles(long userId, long[] roleIds) throws com.liferay.portal.kernel.exception.PortalException 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:
com.liferay.portal.kernel.exception.PortalException
-
updateExternalReferenceCode
public com.liferay.portal.kernel.model.Role updateExternalReferenceCode(long roleId, String externalReferenceCode) throws com.liferay.portal.kernel.exception.PortalException - Throws:
com.liferay.portal.kernel.exception.PortalException
-
updateExternalReferenceCode
public com.liferay.portal.kernel.model.Role updateExternalReferenceCode(com.liferay.portal.kernel.model.Role role, String externalReferenceCode) throws com.liferay.portal.kernel.exception.PortalException - Throws:
com.liferay.portal.kernel.exception.PortalException
-
updateRole
public com.liferay.portal.kernel.model.Role updateRole(long roleId, String name, Map<Locale, String> titleMap, Map<Locale, throws com.liferay.portal.kernel.exception.PortalExceptionString> descriptionMap, String subtype, com.liferay.portal.kernel.service.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:
com.liferay.portal.kernel.exception.PortalException
-
checkUserRolesPermission
protected void checkUserRolesPermission(long userId, long[] roleIds) throws com.liferay.portal.kernel.exception.PortalException - Throws:
com.liferay.portal.kernel.exception.PortalException
-
filterRoles
protected List<com.liferay.portal.kernel.model.Role> filterRoles(List<com.liferay.portal.kernel.model.Role> roles) throws com.liferay.portal.kernel.exception.PortalException - Throws:
com.liferay.portal.kernel.exception.PortalException
-