Class UserManagementServiceImpl
- java.lang.Object
-
- co.mastermindcms.modules.services.UserManagementServiceImpl
-
- All Implemented Interfaces:
UserManagementService
@Service public class UserManagementServiceImpl extends java.lang.Object implements UserManagementService
-
-
Field Summary
Fields Modifier and Type Field Description private org.springframework.context.ApplicationContext
appContext
private CommonProperties
commonProperties
private com.fasterxml.jackson.databind.ObjectMapper
mapper
private org.springframework.data.mongodb.core.MongoTemplate
mongoTemplate
private SequenceGeneratorService
sequenceGenerator
private MongoStorageService
storageService
private UserRepository
userRepository
-
Constructor Summary
Constructors Constructor Description UserManagementServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
changePassword(User user, java.lang.String password)
This method update and save password from database entity (user).java.util.Optional<User>
createUser(User user)
This method creates a database entity.java.util.Optional<User>
createUser(java.util.LinkedHashMap<java.lang.String,java.lang.Object> userAsMap)
This method creates a database entity.User
getLoggedUser()
This method does return database entity which logged in system.java.util.Deque<java.util.Map<java.lang.String,java.lang.Object>>
getPaginationFilter(java.lang.String requestJson)
This method does calculation for a pages based on the request.UserPrincipal
getPrincipal()
This method returns user principal object from context.UserRepository
getRepository()
boolean
isLogged()
This method does check is database entity logged in system.boolean
isNotLogged()
This method does check is not database entity logged in system.boolean
isSuperUser()
This method does check is database entity had super status.boolean
isUserPermissionAll()
This method does check is database entity had all permissions.boolean
isUserPermissionApplication()
This method does check is database entity had application permission.void
removeUserAndClean(java.lang.String userId)
This method removes a database entity and clean all relationships from another entities.void
removeUsersByIds(java.util.ArrayList<java.lang.String> userIds)
This method removes a list of database entities.java.util.Optional<User>
revertPasswordToSaved(java.lang.String userId)
This method does revert and save database entity field valuevoid
saveSavedPassword(java.lang.String userId)
This method update and save password from database entity (user).java.util.Optional<User>
saveUser(User user)
This method saves a database entity.java.util.Optional<User>
saveUser(java.util.LinkedHashMap<java.lang.String,java.lang.Object> userAsMap)
This method saves database entity.java.util.LinkedHashSet<User>
searchUsers(java.lang.String requestJson)
This method does search requests and returns data as list.java.util.List<User>
searchUsers(java.lang.String query, int from, int to)
This method does search requests and returns data as list.org.springframework.data.domain.Page<User>
searchUsersPaged(java.lang.String requestJson)
This method does search requests and returns data as pages.
-
-
-
Field Detail
-
mongoTemplate
@Autowired private org.springframework.data.mongodb.core.MongoTemplate mongoTemplate
-
appContext
@Autowired private org.springframework.context.ApplicationContext appContext
-
userRepository
@Autowired private UserRepository userRepository
-
commonProperties
@Autowired private CommonProperties commonProperties
-
sequenceGenerator
@Autowired private SequenceGeneratorService sequenceGenerator
-
storageService
@Autowired private MongoStorageService storageService
-
mapper
private final com.fasterxml.jackson.databind.ObjectMapper mapper
-
-
Method Detail
-
getRepository
public UserRepository getRepository()
- Specified by:
getRepository
in interfaceUserManagementService
-
getPaginationFilter
public java.util.Deque<java.util.Map<java.lang.String,java.lang.Object>> getPaginationFilter(java.lang.String requestJson)
Description copied from interface:UserManagementService
This method does calculation for a pages based on the request.- Specified by:
getPaginationFilter
in interfaceUserManagementService
- Parameters:
requestJson
- JSON-object of request contains an instructions for search queries- Returns:
- map-representation of data
-
searchUsers
public java.util.LinkedHashSet<User> searchUsers(java.lang.String requestJson)
Description copied from interface:UserManagementService
This method does search requests and returns data as list.- Specified by:
searchUsers
in interfaceUserManagementService
- Parameters:
requestJson
- search request- Returns:
- data transport entities as list
-
searchUsersPaged
public org.springframework.data.domain.Page<User> searchUsersPaged(java.lang.String requestJson)
Description copied from interface:UserManagementService
This method does search requests and returns data as pages.- Specified by:
searchUsersPaged
in interfaceUserManagementService
- Parameters:
requestJson
- JSON-object of request contains an instructions for search queries- Returns:
- database entities separated to pages
-
getPrincipal
public UserPrincipal getPrincipal()
Description copied from interface:UserManagementService
This method returns user principal object from context.- Specified by:
getPrincipal
in interfaceUserManagementService
- Returns:
- user principal object
-
getLoggedUser
public User getLoggedUser()
Description copied from interface:UserManagementService
This method does return database entity which logged in system.- Specified by:
getLoggedUser
in interfaceUserManagementService
- Returns:
- database entity
-
isSuperUser
public boolean isSuperUser()
Description copied from interface:UserManagementService
This method does check is database entity had super status.- Specified by:
isSuperUser
in interfaceUserManagementService
- Returns:
- value as boolean
-
isLogged
public boolean isLogged()
Description copied from interface:UserManagementService
This method does check is database entity logged in system.- Specified by:
isLogged
in interfaceUserManagementService
- Returns:
- value as boolean
-
isNotLogged
public boolean isNotLogged()
Description copied from interface:UserManagementService
This method does check is not database entity logged in system.- Specified by:
isNotLogged
in interfaceUserManagementService
- Returns:
- value as boolean
-
searchUsers
public java.util.List<User> searchUsers(java.lang.String query, int from, int to)
Description copied from interface:UserManagementService
This method does search requests and returns data as list.- Specified by:
searchUsers
in interfaceUserManagementService
- Parameters:
query
- search queryfrom
- field which filter and returned itemsto
- field which filter and returned items- Returns:
- database entities as list
-
createUser
@Transactional public java.util.Optional<User> createUser(java.util.LinkedHashMap<java.lang.String,java.lang.Object> userAsMap)
Description copied from interface:UserManagementService
This method creates a database entity.- Specified by:
createUser
in interfaceUserManagementService
- Parameters:
userAsMap
- map-representation of database entity- Returns:
- optional value to externally interaction
-
createUser
public java.util.Optional<User> createUser(User user)
Description copied from interface:UserManagementService
This method creates a database entity.- Specified by:
createUser
in interfaceUserManagementService
- Parameters:
user
- database entity- Returns:
- optional value to externally interaction
-
saveUser
@Transactional public java.util.Optional<User> saveUser(java.util.LinkedHashMap<java.lang.String,java.lang.Object> userAsMap)
Description copied from interface:UserManagementService
This method saves database entity.- Specified by:
saveUser
in interfaceUserManagementService
- Parameters:
userAsMap
- map-representation of database entity- Returns:
- saved instance of database entity
-
saveUser
@Transactional public java.util.Optional<User> saveUser(User user)
Description copied from interface:UserManagementService
This method saves a database entity.- Specified by:
saveUser
in interfaceUserManagementService
- Parameters:
user
- database entity- Returns:
- saved instance of database entity
-
removeUserAndClean
@Transactional public void removeUserAndClean(java.lang.String userId)
Description copied from interface:UserManagementService
This method removes a database entity and clean all relationships from another entities.- Specified by:
removeUserAndClean
in interfaceUserManagementService
- Parameters:
userId
- identification for database entity which will be removed
-
removeUsersByIds
@Transactional public void removeUsersByIds(java.util.ArrayList<java.lang.String> userIds)
Description copied from interface:UserManagementService
This method removes a list of database entities.- Specified by:
removeUsersByIds
in interfaceUserManagementService
- Parameters:
userIds
- the list of database entities which will be removed
-
changePassword
@Transactional public void changePassword(User user, java.lang.String password)
Description copied from interface:UserManagementService
This method update and save password from database entity (user).- Specified by:
changePassword
in interfaceUserManagementService
- Parameters:
user
- the database entity which will be updatedpassword
- the database entity field which will be saved
-
revertPasswordToSaved
public java.util.Optional<User> revertPasswordToSaved(java.lang.String userId)
Description copied from interface:UserManagementService
This method does revert and save database entity field value- Specified by:
revertPasswordToSaved
in interfaceUserManagementService
- Parameters:
userId
- identification for database entity which will be updated- Returns:
- saved instance of database entity
-
saveSavedPassword
public void saveSavedPassword(java.lang.String userId)
Description copied from interface:UserManagementService
This method update and save password from database entity (user).- Specified by:
saveSavedPassword
in interfaceUserManagementService
- Parameters:
userId
- identification for database entity which will be updated
-
isUserPermissionAll
public boolean isUserPermissionAll()
Description copied from interface:UserManagementService
This method does check is database entity had all permissions.- Specified by:
isUserPermissionAll
in interfaceUserManagementService
- Returns:
- value as boolean
-
isUserPermissionApplication
public boolean isUserPermissionApplication()
Description copied from interface:UserManagementService
This method does check is database entity had application permission.- Specified by:
isUserPermissionApplication
in interfaceUserManagementService
- Returns:
- value as boolean
-
-