Package org.motechproject.mots.service
Class UserService
- java.lang.Object
 - 
- org.motechproject.mots.service.UserService
 
 
- 
@Service public class UserService extends java.lang.Object 
- 
- 
Constructor Summary
Constructors Constructor Description UserService() 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidchangeUserPassword(java.lang.String username, java.lang.String newPassword, java.lang.String currentPassword)Updates user's password.UsereditUserProfile(java.util.UUID userId, UserProfileDto userProfileDto)Save User Profile with new encoded password (if it's not blank).java.lang.Iterable<UserPermission>getPermissions()Returns UserPermissions.UserRolegetRole(java.util.UUID id)GetsUserRolewith given id.java.lang.Iterable<UserRole>getRoles()Returns UserRoles.UsergetUser(java.util.UUID id)UsergetUserByUserName(java.lang.String userName)java.lang.Iterable<User>getUsers()UserregisterNewUser(User user)Create User with new encoded password.UserRolesaveRole(UserRole role)Saves a UserRole.UsersaveUser(User user, boolean encodeNewPassword)Save User with new encoded password (if it's not blank).org.springframework.data.domain.Page<UserRole>searchRoles(java.lang.String name, org.springframework.data.domain.Pageable pageable)org.springframework.data.domain.Page<User>searchUsers(java.lang.String username, java.lang.String email, java.lang.String name, java.lang.String role, org.springframework.data.domain.Pageable pageable)FindsUsermatching all of the provided parameters. 
 - 
 
- 
- 
Method Detail
- 
getUserByUserName
public User getUserByUserName(java.lang.String userName)
 
- 
getUsers
@PreAuthorize("hasRole(\'ROLE_MANAGE_USERS\')") public java.lang.Iterable<User> getUsers() 
- 
searchUsers
@PreAuthorize("hasRole(\'ROLE_MANAGE_USERS\')") public org.springframework.data.domain.Page<User> searchUsers(java.lang.String username, java.lang.String email, java.lang.String name, java.lang.String role, org.springframework.data.domain.Pageable pageable)FindsUsermatching all of the provided parameters. If there are no parameters, return all users.- Parameters:
 pageable- pagination parameters (page size, page number, sort order)email- email of userrole- name of role of userusername- username of username- name of user- Returns:
 - page with found users.
 
 
- 
getRoles
@PreAuthorize("hasRole(\'ROLE_MANAGE_USERS\')") public java.lang.Iterable<UserRole> getRoles()Returns UserRoles.- Returns:
 - user roles
 
 
- 
getPermissions
@PreAuthorize("hasRole(\'ROLE_MANAGE_USERS\')") public java.lang.Iterable<UserPermission> getPermissions()Returns UserPermissions.- Returns:
 - user permissions
 
 
- 
getRole
@PreAuthorize("hasRole(\'ROLE_MANAGE_USERS\')") public UserRole getRole(java.util.UUID id)GetsUserRolewith given id.- Parameters:
 id- id of a role- Returns:
 - UserRole or throws error if it doesn't exists
 - Throws:
 EntityNotFoundException- if role with id not found
 
- 
saveRole
@PreAuthorize("hasRole(\'ROLE_MANAGE_USERS\')") public UserRole saveRole(UserRole role)Saves a UserRole. Checks if role has id assigned (ie. if it is an update action), if not it checks for name uniqueness. If the name is not unique it throws MotsException.- Parameters:
 role- UserRole to be created or updated.- Returns:
 - saved UserRole
 
 
- 
searchRoles
@PreAuthorize("hasRole(\'ROLE_MANAGE_USERS\')") public org.springframework.data.domain.Page<UserRole> searchRoles(java.lang.String name, org.springframework.data.domain.Pageable pageable) 
- 
getUser
@PreAuthorize("hasRole(\'ROLE_MANAGE_USERS\')") public User getUser(java.util.UUID id) 
- 
saveUser
@PreAuthorize("hasRole(\'ROLE_MANAGE_USERS\')") public User saveUser(User user, boolean encodeNewPassword)Save User with new encoded password (if it's not blank).- Parameters:
 user- User to be created.encodeNewPassword- flag indication if password should be encoded- Returns:
 - saved User
 
 
- 
registerNewUser
@PreAuthorize("hasRole(\'ROLE_MANAGE_USERS\')") public User registerNewUser(User user)Create User with new encoded password.- Parameters:
 user- User to be created.- Returns:
 - created User
 
 
- 
editUserProfile
public User editUserProfile(java.util.UUID userId, UserProfileDto userProfileDto)
Save User Profile with new encoded password (if it's not blank).- Parameters:
 userProfileDto- User Profile to be updated.userId- id of user to update- Returns:
 - saved User
 
 
- 
changeUserPassword
public void changeUserPassword(java.lang.String username, java.lang.String newPassword, java.lang.String currentPassword)Updates user's password.- Parameters:
 username- of user which password is about to change.newPassword- is new password value for user.currentPassword- is current user's password.
 
 - 
 
 -