Class UserService


  • @Service
    @Transactional
    public class UserService
    extends Object
    Service class for managing users.
    • Constructor Detail

      • UserService

        public UserService​(UserRepository userRepository,
                           org.springframework.security.crypto.password.PasswordEncoder passwordEncoder,
                           AuthorityRepository authorityRepository,
                           TenantRepository tenantRepository,
                           org.springframework.cache.CacheManager cacheManager,
                           @Value("${ca3s.ui.password.check.regexp:^(?=.*\\d)(?=.*[a-z]).{6,100}$}")
                           String passwordCheckRegExp)
    • Method Detail

      • createUser

        public User createUser​(UserDTO userDTO)
      • updateUser

        public void updateUser​(String firstName,
                               String lastName,
                               String email,
                               String langKey,
                               String imageUrl,
                               Long tenantId)
        Update basic information (first name, last name, email, language) for the current user.
        Parameters:
        firstName - first name of user.
        lastName - last name of user.
        email - email id of user.
        langKey - language key.
        imageUrl - image URL of user.
        tenantId -
      • updateUser

        public Optional<UserDTO> updateUser​(UserDTO userDTO)
        Update all information for a specific user, and return the modified user.
        Parameters:
        userDTO - user to update.
        Returns:
        updated user.
      • deleteUser

        public void deleteUser​(String login)
      • changePassword

        public void changePassword​(String currentClearTextPassword,
                                   String newPassword)
      • getAllManagedUsers

        @Transactional(readOnly=true)
        public org.springframework.data.domain.Page<UserDTO> getAllManagedUsers​(org.springframework.data.domain.Pageable pageable)
      • getUserWithAuthoritiesByLogin

        @Transactional(readOnly=true)
        public Optional<User> getUserWithAuthoritiesByLogin​(String login)
      • getUserWithAuthorities

        @Transactional(readOnly=true)
        public Optional<User> getUserWithAuthorities​(Long id)
      • getUserWithAuthorities

        @Transactional(readOnly=true)
        public Optional<User> getUserWithAuthorities()
      • removeNotActivatedUsers

        @Scheduled(cron="0 0 1 * * ?")
        public void removeNotActivatedUsers()
        Not activated users should be automatically deleted after 3 days.

        This is scheduled to get fired everyday, at 01:00 (am).

      • getAuthorities

        public List<String> getAuthorities()
        Gets a list of all the authorities.
        Returns:
        a list of all the authorities.
      • getUsersByRole

        @Transactional(readOnly=true)
        public List<User> getUsersByRole​(String role)
      • checkPassword

        public void checkPassword​(String password)