Class UserServiceImpl

java.lang.Object
org.openwms.core.uaa.impl.UserServiceImpl
All Implemented Interfaces:
org.ameba.integration.FindOperations<User,Long>, org.ameba.integration.SaveOperations<User,Long>, UserService

@TxService class UserServiceImpl extends Object implements UserService
An UserServiceImpl is a Spring managed transactional implementation of the UserService. Using Spring 2 annotation support autowires collaborators, therefore XML configuration becomes obsolete. This class is marked with Amebas TxService annotation to benefit from Springs exception translation interceptor. Traditional CRUD operations are delegated to an UserRepository.

This implementation exists since Spring 2.0.

Author:
Heiko Scherrer
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • repository

      private final UserRepository repository
    • securityObjectDao

      private final GrantRepository securityObjectDao
    • roleService

      private final RoleService roleService
    • enc

      private final org.springframework.security.crypto.password.PasswordEncoder enc
    • translator

      private final org.ameba.i18n.Translator translator
    • validator

      private final jakarta.validation.Validator validator
    • userMapper

      private final UserMapper userMapper
    • userUpdater

      private final org.springframework.plugin.core.PluginRegistry<UserUpdater,String> userUpdater
    • eventPublisher

      private final org.springframework.context.ApplicationEventPublisher eventPublisher
    • systemUsername

      private final String systemUsername
    • systemPassword

      private final String systemPassword
  • Constructor Details

    • UserServiceImpl

      UserServiceImpl(UserRepository repository, GrantRepository securityObjectDao, @Lazy RoleService roleService, org.springframework.security.crypto.password.PasswordEncoder enc, org.ameba.i18n.Translator translator, jakarta.validation.Validator validator, UserMapper userMapper, org.springframework.plugin.core.PluginRegistry<UserUpdater,String> userUpdater, org.springframework.context.ApplicationEventPublisher eventPublisher, @Value("${owms.security.system.username}") String systemUsername, @Value("${owms.security.system.password}") String systemPassword)
  • Method Details

    • save

      @Validated(Modify.class) @Measured @NotNull public @NotNull User save(@NotNull(groups=Modify.class) @Valid @NotNull(groups=Modify.class) @Valid User user, List<String> roleNames)
      Save or update an already existing User.
      Specified by:
      save in interface UserService
      Parameters:
      user - The instance to save
      roleNames - A list of Role names to assign the User to
      Returns:
      The saved instance
    • uploadImageFile

      @Measured public void uploadImageFile(@NotBlank @NotBlank String pKey, @NotNull @jakarta.validation.constraints.NotNull byte[] image)
      Attach and save an image to an User with id.
      Specified by:
      uploadImageFile in interface UserService
      Parameters:
      pKey - The persistent key of the User
      image - Image to be stored
    • save

      @Measured @NotNull public @NotNull User save(@NotNull @NotNull User entity)
      Specified by:
      save in interface org.ameba.integration.SaveOperations<User,Long>
    • saveInternal

      private User saveInternal(User entity)
    • createSystemUser

      @Transactional(readOnly=true) @Measured @NotNull public @NotNull SystemUser createSystemUser()
      Create and return the SystemUser without persisting this user.

      Marked as read-only transactional method.

      Specified by:
      createSystemUser in interface UserService
      Returns:
      the SystemUser instance
    • create

      @Measured @Validated(Create.class) @NotNull public @NotNull User create(@NotNull(groups=Create.class) @Valid @NotNull(groups=Create.class) @Valid User user, List<String> roleNames)
      Create a non-existing User.
      Specified by:
      create in interface UserService
      Parameters:
      user - The User instance to create
      roleNames - A list of Role names to assign the User to
      Returns:
      The created instance
    • findByUsername

      @Measured @NotNull public @NotNull Optional<User> findByUsername(@NotBlank @NotBlank String username)
      Find and return an User instance.
      Specified by:
      findByUsername in interface UserService
      Parameters:
      username - The unique name of the User to search for
      Returns:
      The instance
    • findByPKey

      @Measured @NotNull public @NotNull User findByPKey(@NotBlank @NotBlank String pKey)
      Find and return an User instance.
      Specified by:
      findByPKey in interface UserService
      Parameters:
      pKey - The persistent identifier of the User to search for
      Returns:
      The instance
    • findByPKeyInternal

      private User findByPKeyInternal(String pKey)
    • delete

      @Measured public void delete(@NotBlank @NotBlank String pKey)
      Delete an User.
      Specified by:
      delete in interface UserService
      Parameters:
      pKey - The identifiable persistent key
    • updatePassword

      @Measured @NotNull public @NotNull UserVO updatePassword(@NotBlank @NotBlank String pKey, @NotNull @NotNull CharSequence newPassword) throws InvalidPasswordException
      Update the password of the User.
      Specified by:
      updatePassword in interface UserService
      Parameters:
      pKey - The identifiable persistent key
      newPassword - The new password
      Returns:
      The updated instance
      Throws:
      InvalidPasswordException
    • findAll

      @Measured @NotNull public @NotNull Collection<User> findAll()
      Specified by:
      findAll in interface org.ameba.integration.FindOperations<User,Long>
    • findById

      @Measured @NotNull public @NotNull User findById(@NotNull @NotNull Long pk)
      Specified by:
      findById in interface org.ameba.integration.FindOperations<User,Long>