Class UserServiceImpl
java.lang.Object
ru.cg.webbpm.modules.security.api.impl.service.UserServiceImpl
- All Implemented Interfaces:
 UserService
- Author:
 - Tim Urmancheev
 
- 
Constructor Summary
ConstructorsConstructorDescriptionUserServiceImpl(SecurityContext securityContext, AccessLevelService accessLevelService, UserDao userDao, UserGroupDao userGroupDao, UserRoleDao userRoleDao) User service constructor - creates new user service. - 
Method Summary
Modifier and TypeMethodDescriptionBinds group to user by user account id and group id.bindGroupByUser(String userId, String groupId, String bindingUserId) Binds group to user by user account id, group id and user account id of binding user.Inserts user into database.voidSets user's "locked" field to true according to user id.voiddelete(Collection<String> userIds) Sets user's "locked" field to true according to user account ids collection.Gets user by user account id.get(Collection<String> userIds) Gets user by user account ids.get(LoadOptions options) Gets users according to load options.getByEmail(String email) Gets user by email.getByUsername(String username) Gets user by username.getGroups(String userId, LoadOptions options) Gets groups by user account id according to load options.getRoleNamesInOrg(String orgUnitCode) Gets all role names of org unit by org unit code.getRoles(String userId, LoadOptions options) Gets roles by user account id according to load options.Gets user with maximal access level.getUserGroupLinks(String userId, LoadOptions options) Gets groups by user account id with binding timestamp according to load options.getUsersWithAuthorityIn(Collection<String> authorityIds) getUsersWithGroupIn(Collection<String> groupIds) getUsersWithRoleIn(Collection<String> roleIds) getUsersWithRoleInOrg(String roleName, String orgUnitCode) Gets users with role name in org unit.Gets any existing(not locked) user with max access level (maybe super admin)booleanChecks current user access level equals to maximal access level.voidunbindGroup(String userId, String groupId) Unbinds group from user by user account id and group id.voidunbindGroupByUser(String userId, String groupId, String unbindingUserId) Unbinds group from user by user account id, group id and user account id of unbinding user.voidUpdates user in database.voidupdateGroups(String userId, Collection<String> addedGroupIds, Collection<String> deletedGroupIds) Updates user group links by user account id, added group ids collection and deleted group ids collection Checks current user's access level to binding and unbinding groups.voidupdateLockedAndEmailConfirmed(String userId, boolean locked, boolean emailConfirmed) Updates user's emailConfirmed status. 
- 
Constructor Details
- 
UserServiceImpl
@Autowired public UserServiceImpl(SecurityContext securityContext, AccessLevelService accessLevelService, UserDao userDao, UserGroupDao userGroupDao, UserRoleDao userRoleDao) User service constructor - creates new user service.- Parameters:
 securityContext- user's security context. Instance ofSecurityContexttype.accessLevelService- access level service. Instance ofAccessLevelServicetype.userDao- user account data access object. Instance ofUserDaotype.userGroupDao- link user account user group data access object. Instance ofUserGroupDaotype.userRoleDao- link user account user role data access object. Instance ofUserRoleDaotype.
 
 - 
 - 
Method Details
- 
get
Gets user by user account id.- Specified by:
 getin interfaceUserService- Parameters:
 userId- user account id of user to receive. Instance ofStringtype.- Returns:
 - requested user or null if does not exist. Instance of 
Usertype. - See Also:
 
 - 
get
Gets users according to load options.- Specified by:
 getin interfaceUserService- Parameters:
 options- indicates load options properties. Instance ofLoadOptionstype.- Returns:
 - list of users. Instance of 
Listtype. - See Also:
 
 - 
get
Gets user by user account ids.- Specified by:
 getin interfaceUserService- Parameters:
 userIds- user account ids of objects to receive. Instance ofCollectiontype.- Returns:
 - collection of users. Instance of 
Collectiontype. - See Also:
 
 - 
getLdapUsers
- Specified by:
 getLdapUsersin interfaceUserService
 - 
getByUsername
Gets user by username.- Specified by:
 getByUsernamein interfaceUserService- Parameters:
 username- username of user to receive. Instance ofStringtype.- Returns:
 - requested user or null if does not exist. Instance of 
Usertype. - See Also:
 
 - 
getByEmail
Gets user by email.- Specified by:
 getByEmailin interfaceUserService- Parameters:
 email- email of user to receive. Instance ofStringtype.- Returns:
 - requested user or null if does not exist. Instance of 
Usertype. - See Also:
 
 - 
create
Inserts user into database. User id will be generated if it is null.- Specified by:
 createin interfaceUserService- Parameters:
 user- user to add. Instance ofUsertype.- Returns:
 - user id. Instance of 
Stringtype. - Throws:
 org.springframework.dao.DataAccessException- if username already exists.org.springframework.dao.DataAccessException- if user's org unit does not exist.- See Also:
 
 - 
update
@CacheEvict(value="user-service-id",key="#user.id()") @CacheEvict(value="runtime-user-id",key="#user.id()") @CacheEvict(value="runtime-user-username",key="#user.username()",condition="#user.username() != null") public void update(User user) Updates user in database. User's username is ignored.- Specified by:
 updatein interfaceUserService- Parameters:
 user- user to update. Instance ofUsertype.- Throws:
 org.springframework.dao.DataAccessException- if user's org unit doesn't exist.- See Also:
 
 - 
updateLockedAndEmailConfirmed
@CacheEvict(value="user-service-id",key="#userId") @CacheEvict(value="runtime-user-id",key="#userId") public void updateLockedAndEmailConfirmed(String userId, boolean locked, boolean emailConfirmed) Updates user's emailConfirmed status.- Specified by:
 updateLockedAndEmailConfirmedin interfaceUserService- Parameters:
 userId- user account id of the user to update. Instance ofStringtype.locked-emailConfirmed- emailConfirmed status of the user. Instance ofbooleantype.- See Also:
 
 - 
delete
@CacheEvict(value="user-service-id",key="#userId") @CacheEvict(value="runtime-user-id",key="#userId") @CacheEvict(value="runtime-user-username",allEntries=true) public void delete(String userId) Sets user's "locked" field to true according to user id.- Specified by:
 deletein interfaceUserService- Parameters:
 userId- user account id of user to mark removed. Instance ofStringtype.- See Also:
 
 - 
delete
@CacheEvict(value="user-service-id",allEntries=true) @CacheEvict(value="runtime-user-id",allEntries=true) @CacheEvict(value="runtime-user-username",allEntries=true) public void delete(Collection<String> userIds) Sets user's "locked" field to true according to user account ids collection.- Specified by:
 deletein interfaceUserService- Parameters:
 userIds- user account ids collection of users to mark removed. Instance ofCollectiontype.- See Also:
 
 - 
getGroups
Gets groups by user account id according to load options. Filters groups according to current user's access level.- Specified by:
 getGroupsin interfaceUserService- Parameters:
 userId- user account id of user to receive groups. Instance ofStringtype.options- indicates load options properties. Instance ofLoadOptionstype.- Returns:
 - list of groups. Instance of 
Listtype. - See Also:
 
 - 
getUserGroupLinks
Gets groups by user account id with binding timestamp according to load options. Groups are filtered according to current user's access level.- Specified by:
 getUserGroupLinksin interfaceUserService- Parameters:
 userId- user account id of user to receive groups. Instance ofStringtype.options- indicates load options properties. Instance ofLoadOptionstype.- Returns:
 - list of user and group links. Instance of 
Listtype. - See Also:
 
 - 
updateGroups
@Transactional @CacheEvict(value="user-service-id",key="#userId") @CacheEvict(value="runtime-user-id",key="#userId") @CacheEvict(value="runtime-user-username",allEntries=true) public void updateGroups(String userId, Collection<String> addedGroupIds, Collection<String> deletedGroupIds) Updates user group links by user account id, added group ids collection and deleted group ids collection Checks current user's access level to binding and unbinding groups.- Specified by:
 updateGroupsin interfaceUserService- Parameters:
 userId- user account id which groups to update. Instance ofStringtype.addedGroupIds- collection of group ids to add. Instance ofCollectiontype.deletedGroupIds- collection of group ids to remove. Instance ofCollectiontype.- Throws:
 org.springframework.dao.DataAccessException- if user already has any of groups.- See Also:
 
 - 
bindGroup
@Transactional @CacheEvict(value="user-service-id",key="#userId") @CacheEvict(value="runtime-user-id",key="#userId") @CacheEvict(value="runtime-user-username",allEntries=true) public String bindGroup(String userId, String groupId) Binds group to user by user account id and group id. Checks current user's access level to binding group.- Specified by:
 bindGroupin interfaceUserService- Parameters:
 userId- user account id of user to bind. Instance ofStringtype.groupId- group id of binding group. Instance ofStringtype.- Returns:
 - id of user group link. Instance of 
Stringtype. - Throws:
 org.springframework.dao.DataAccessException- if user already has group.- See Also:
 
 - 
bindGroupByUser
@Transactional @CacheEvict(value="user-service-id",key="#userId") @CacheEvict(value="runtime-user-id",key="#userId") @CacheEvict(value="runtime-user-username",allEntries=true) public String bindGroupByUser(String userId, String groupId, String bindingUserId) Binds group to user by user account id, group id and user account id of binding user. Checks user's access level to binding group.- Specified by:
 bindGroupByUserin interfaceUserService- Parameters:
 userId- user account id of user to bind. Instance ofStringtype.groupId- group id of binding group. Instance ofStringtype.bindingUserId- user account id of binding user. Instance ofStringtype.- Returns:
 - id of user group link. Instance of 
Stringtype. - Throws:
 org.springframework.dao.DataAccessException- if user already has group.- See Also:
 
 - 
unbindGroup
@Transactional @CacheEvict(value="user-service-id",key="#userId") @CacheEvict(value="runtime-user-id",key="#userId") @CacheEvict(value="runtime-user-username",allEntries=true) public void unbindGroup(String userId, String groupId) Unbinds group from user by user account id and group id. Checks current user's access level to unbinding group.- Specified by:
 unbindGroupin interfaceUserService- Parameters:
 userId- user account id of user to unbind. Instance ofStringtype.groupId- group id of unbinding group. Instance ofStringtype.- See Also:
 
 - 
unbindGroupByUser
@Transactional @CacheEvict(value="user-service-id",key="#userId") @CacheEvict(value="runtime-user-id",key="#userId") @CacheEvict(value="runtime-user-username",allEntries=true) public void unbindGroupByUser(String userId, String groupId, String unbindingUserId) Unbinds group from user by user account id, group id and user account id of unbinding user. Checks user's access level to unbinding group.- Specified by:
 unbindGroupByUserin interfaceUserService- Parameters:
 userId- user account id of user to unbind. Instance ofStringtype.groupId- group id of unbinding group. Instance ofStringtype.unbindingUserId- user account id of unbinding user. Instance ofStringtype.- See Also:
 
 - 
getRoles
Gets roles by user account id according to load options. Filters groups according to current user's access level.- Specified by:
 getRolesin interfaceUserService- Parameters:
 userId- user account id of user to receive roles. Instance ofStringtype.options- indicates load options properties. Instance ofLoadOptionstype.- Returns:
 - list of roles. Instance of 
Listtype. - See Also:
 
 - 
getUsersWithRoleInOrg
Gets users with role name in org unit.- Specified by:
 getUsersWithRoleInOrgin interfaceUserService- Parameters:
 roleName- user's role name. Instance ofStringtype.orgUnitCode- user's org unit code. Instance ofStringtype.- Returns:
 - list of users. Instance of 
Listtype. - See Also:
 
 - 
getRoleNamesInOrg
Gets all role names of org unit by org unit code.- Specified by:
 getRoleNamesInOrgin interfaceUserService- Parameters:
 orgUnitCode- user's org unit code. Instance ofStringtype.- Returns:
 - list of role names. Instance of 
Listtype. - See Also:
 
 - 
getSuperAdmin
Gets user with maximal access level.- Specified by:
 getSuperAdminin interfaceUserService- Returns:
 - requested user or null if does not exist. Instance of 
Usertype. - See Also:
 
 - 
getUserWithMaxAccessLevel
Gets any existing(not locked) user with max access level (maybe super admin)- Specified by:
 getUserWithMaxAccessLevelin interfaceUserService- Returns:
 - requested user or null if does not exist. Instance of 
Usertype. - See Also:
 
 - 
getUserSourceByUserId
- Specified by:
 getUserSourceByUserIdin interfaceUserService
 - 
isCurrentUserSuperAdmin
public boolean isCurrentUserSuperAdmin()Checks current user access level equals to maximal access level.- Specified by:
 isCurrentUserSuperAdminin interfaceUserService- Returns:
 - boolean result of check. Instance of 
booleantype. - See Also:
 
 - 
getUsersWithAuthorityIn
- Specified by:
 getUsersWithAuthorityInin interfaceUserService
 - 
getUsersWithRoleIn
- Specified by:
 getUsersWithRoleInin interfaceUserService
 - 
getUsersWithGroupIn
- Specified by:
 getUsersWithGroupInin interfaceUserService
 
 -