Interface UserService
- All Known Implementing Classes:
UserServiceImpl
-
Method Summary
Modifier and TypeMethodDescriptioncreateUser(User userToCreate) Creates a new User.voiddeleteUser(String id) Deletes a User.Gets a User.Gets multiple Users.newUser()Returns a new User with all fields being empty.updateUser(User userToUpdate) Updates an existing User.
-
Method Details
-
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, UserAlreadyExistException, NotAuthorizedException 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
- 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
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, InvalidArgumentException, NotAuthorizedException 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, InvalidArgumentException, NotAuthorizedException 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
-