Interface UserService
-
- All Known Implementing Classes:
UserServiceImpl
public interface UserServiceThe UserService manages all operations concerning Users.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description UsercreateUser(User userToCreate)Creates a new User.voiddeleteUser(String id)Deletes a User.UsergetUser(String id)Gets a User.List<User>getUsers(Set<String> ids)Gets multiple Users.UsernewUser()Returns a new User with all fields being empty.UserupdateUser(User userToUpdate)Updates an existing User.
-
-
-
Method Detail
-
newUser
User newUser()
Returns a new User with all fields being empty.It will be only generated but not yet inserted until method createUser(User) is called.
- Returns:
- the new User
-
createUser
User createUser(User userToCreate) throws InvalidArgumentException, NotAuthorizedException, UserAlreadyExistException
Creates a new User.If all checks have passed the specified User will be inserted into the database. The id of the User must be set and should be unique, such that no other User with same id is already existing in the database. The first name and the last name must not be null. The fields for the full name and the long name are set according to following rules:
- fullName = lastName, firstName
- longName = lastName, firstName - (id)
- Parameters:
userToCreate- the User which should be inserted- Returns:
- the inserted User
- Throws:
InvalidArgumentException- if some fields are not set properlyNotAuthorizedException- if the current user is not admin or business-adminUserAlreadyExistException- if there already exists a User with the specified id inside the database
-
getUser
User getUser(String id) throws UserNotFoundException, InvalidArgumentException
- Parameters:
id- the id of the User to be retrieved- Returns:
- the retrieved User
- Throws:
UserNotFoundException- if there does not exist a User with the specified id inside the databaseInvalidArgumentException- if the userIds parameter is NULL or empty
-
getUsers
List<User> getUsers(Set<String> ids) throws InvalidArgumentException
Gets multiple Users.If a userId can't be found in the database it will be ignored. If none of the given userIds is valid, the returned list will be empty.
- Parameters:
ids- the ids of the Users to be retrieved- Returns:
- the retrieved Users
- Throws:
InvalidArgumentException- if the userIds parameter is NULL or empty
-
updateUser
User updateUser(User userToUpdate) throws UserNotFoundException, NotAuthorizedException, InvalidArgumentException
Updates an existing User.If a User with the specified id exists in the database and if the current user is allowed to perform the operation, the User gets updated according to the set fields of the passed object.
- Parameters:
userToUpdate- the User which should be updated- Returns:
- the updated User
- Throws:
NotAuthorizedException- if the current user is not admin or business-adminUserNotFoundException- if there does not exist a User with the specified id inside the databaseInvalidArgumentException- if some fields are not set properly
-
deleteUser
void deleteUser(String id) throws UserNotFoundException, NotAuthorizedException, InvalidArgumentException
Deletes a User.If a User with the specified id exists in the database and if the current user is allowed to perform the operation, the User gets deleted.
- Parameters:
id- the id of the User which should be deleted- Throws:
NotAuthorizedException- if the current user is not admin or business-adminUserNotFoundException- if there does not exist a User with the specified id inside the databaseInvalidArgumentException- if the userIds parameter is NULL or empty
-
-