org.openwms.core.service.spring
Class UserServiceImpl

java.lang.Object
  extended by org.openwms.core.service.spring.UserServiceImpl
All Implemented Interfaces:
UserService

@Transactional
@Service(value="userService")
public class UserServiceImpl
extends Object
implements UserService

An UserServiceImpl is a Spring supported transactional implementation of a general UserService. Using Spring 2 annotation support autowires collaborators, therefore XML configuration becomes obsolete. This class is marked with Springs Service annotation to benefit from Springs exception translation intercepter. Traditional CRUD operations are delegated to an UserDao.

This implementation can be autowired with the name "userService".

Since:
0.1
Version:
$Revision: 1597 $
Author:
Heiko Scherrer
See Also:
UserDao

Field Summary
static String COMPONENT_NAME
          Springs service name.
 
Constructor Summary
UserServiceImpl()
           
 
Method Summary
 void changeUserPassword(UserPassword userPassword)
          Change the current Users password.
 SystemUser createSystemUser()
          Create and return the SystemUser.
 List<User> findAll()
          Find and return all Users.
 User getTemplate(String username)
          Return a transient User entity object, serving as a template.
 void remove(User user)
          Remove an User.
 User save(User user)
          Update the given User or persist it when it is a transient one.
 User saveUserProfile(User user, UserPassword userPassword, UserPreference... prefs)
          Save changes on an User and additionally save the User's password and preferences.
 void uploadImageFile(String username, byte[] image)
          Call this method to store an image for an User.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPONENT_NAME

public static final String COMPONENT_NAME
Springs service name.

See Also:
Constant Field Values
Constructor Detail

UserServiceImpl

public UserServiceImpl()
Method Detail

findAll

public List<User> findAll()
Find and return all Users.

Specified by:
findAll in interface UserService
Returns:
The list of all Users

uploadImageFile

@FireAfterTransaction(events=UserChangedEvent.class)
public void uploadImageFile(String username,
                                                                             byte[] image)
Call this method to store an image for an User.

Specified by:
uploadImageFile in interface UserService
Parameters:
username - Username of the User
image - Image to be stored
Throws:
UserNotFoundException - when no User was found with this username.

save

@FireAfterTransaction(events=UserChangedEvent.class)
public User save(User user)
Update the given User or persist it when it is a transient one.

Specified by:
save in interface UserService
Parameters:
user - User entity to save
Returns:
Saved User instance
Throws:
IllegalArgumentException - when user is null

remove

@FireAfterTransaction(events=UserChangedEvent.class)
public void remove(User user)
Remove an User.

Specified by:
remove in interface UserService
Parameters:
user - User to be removed
Throws:
IllegalArgumentException - when user is null

getTemplate

@Transactional(readOnly=true)
public User getTemplate(String username)
Return a transient User entity object, serving as a template. Marked as readOnly transactional method.

Specified by:
getTemplate in interface UserService
Parameters:
username - Username of the User
Returns:
An empty User template

createSystemUser

@Transactional(readOnly=true)
public SystemUser createSystemUser()
Create and return the SystemUser. Marked as readOnly transactional method.

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

changeUserPassword

@FireAfterTransaction(events=UserChangedEvent.class)
public void changeUserPassword(UserPassword userPassword)
Change the current Users password.

Specified by:
changeUserPassword in interface UserService
Parameters:
userPassword - The UserPassword to change
Throws:
IllegalArgumentException - when userPassword is null
ServiceRuntimeException - when userPassword is not a valid password
UserNotFoundException - when no User exist

saveUserProfile

@FireAfterTransaction(events=UserChangedEvent.class)
public User saveUserProfile(User user,
                                                                             UserPassword userPassword,
                                                                             UserPreference... prefs)
Save changes on an User and additionally save the User's password and preferences.

Specified by:
saveUserProfile in interface UserService
Parameters:
user - The User to change
userPassword - The Users password
prefs - An array of UserPreference objects
Returns:
The saved User instance
Throws:
IllegalArgumentException - when user is null
See Also:
UserService.saveUserProfile(org.openwms.core.domain.system.usermanagement.User, org.openwms.core.domain.system.usermanagement.UserPassword, org.openwms.core.domain.system.usermanagement.UserPreference[])


Copyright © 2005-2011 openwms.org. All Rights Reserved.