Package org.openwms.core.uaa.impl
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
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 Summary
Modifier and TypeFieldDescriptionprivate final org.springframework.security.crypto.password.PasswordEncoder
private final org.springframework.context.ApplicationEventPublisher
private static final org.slf4j.Logger
private final UserRepository
private final RoleService
private final GrantRepository
private final String
private final String
private final org.ameba.i18n.Translator
private final UserMapper
private final org.springframework.plugin.core.PluginRegistry
<UserUpdater, String> private final jakarta.validation.Validator
-
Constructor Summary
ConstructorDescriptionUserServiceImpl
(UserRepository repository, GrantRepository securityObjectDao, 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, String systemUsername, String systemPassword) -
Method Summary
Modifier and TypeMethodDescription@NotNull User
create
(@NotNull(groups=Create.class) @Valid User user, List<String> roleNames) Create a non-existing User.@NotNull SystemUser
Create and return theSystemUser
without persisting this user.void
Delete anUser
.@NotNull Collection
<User> findAll()
@NotNull User
@NotNull User
findByPKey
(@NotBlank String pKey) Find and return anUser
instance.private User
findByPKeyInternal
(String pKey) findByUsername
(@NotBlank String username) Find and return anUser
instance.@NotNull User
save
(@NotNull(groups=Modify.class) @Valid User user, List<String> roleNames) Save or update an already existingUser
.@NotNull User
private User
saveInternal
(User entity) @NotNull UserVO
updatePassword
(@NotBlank String pKey, @NotNull CharSequence newPassword) Update the password of theUser
.void
uploadImageFile
(@NotBlank String pKey, @jakarta.validation.constraints.NotNull byte[] image)
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
repository
-
securityObjectDao
-
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
-
userUpdater
-
eventPublisher
private final org.springframework.context.ApplicationEventPublisher eventPublisher -
systemUsername
-
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 existingUser
.- Specified by:
save
in interfaceUserService
- Parameters:
user
- The instance to saveroleNames
- 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) - Specified by:
uploadImageFile
in interfaceUserService
- Parameters:
pKey
- The persistent key of the Userimage
- Image to be stored
-
save
-
saveInternal
-
createSystemUser
Create and return theSystemUser
without persisting this user.Marked as read-only transactional method.
- Specified by:
createSystemUser
in interfaceUserService
- 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 interfaceUserService
- Parameters:
user
- The User instance to createroleNames
- 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 anUser
instance.- Specified by:
findByUsername
in interfaceUserService
- Parameters:
username
- The unique name of the User to search for- Returns:
- The instance
-
findByPKey
Find and return anUser
instance.- Specified by:
findByPKey
in interfaceUserService
- Parameters:
pKey
- The persistent identifier of the User to search for- Returns:
- The instance
-
findByPKeyInternal
-
delete
Delete anUser
.- Specified by:
delete
in interfaceUserService
- 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 theUser
.- Specified by:
updatePassword
in interfaceUserService
- Parameters:
pKey
- The identifiable persistent keynewPassword
- The new password- Returns:
- The updated instance
- Throws:
InvalidPasswordException
-
findAll
-
findById
-