Beispiel #1
0
  public User createUser(String username, String password) {

    if (userRepository.usernameExists(username)) {
      throw new ServiceException("Username is already taken");
    }

    String id = idGenerator.generate();
    User user = new User(id, username, password);

    userRepository.add(user);

    return user;
  }
Beispiel #2
0
 public User getUserById(String userId) {
   try {
     return userRepository.get(userId);
   } catch (RepositoryException e) {
     throw new ServiceException("User with id: " + userId + " could not be found", e);
   }
 }