Ejemplo n.º 1
0
  @Override
  public void setOption(User user, String key, String value) {

    // TODO better design?
    for (UserOption currentOption : user.getOptions()) {
      if (currentOption.getKey().equals(key)) {
        if (!currentOption.getValue().equals(value)) {
          currentOption.setValue(value);
          userDao.update(user);
          return;
        }
      }
    }
    user.getOptions().add(new UserOption(key, value));
    userDao.update(user);
    return;
  }
Ejemplo n.º 2
0
  @Override
  public User createUser(String username, String password, String email) {

    validate(username, password, email);
    try {
      String encryptedPassword = PasswordUtils.encrypt(password);

      // TODO check username unique

      // TODO check email is unique
      User u = new User();
      u.setUsername(username);
      u.setPassword(encryptedPassword);
      u.setEmail(email);
      create(u);
      return u;
    } catch (NoSuchAlgorithmException e) {
      e.printStackTrace();
    }
    return null;
  }
Ejemplo n.º 3
0
 @Override
 public User select(User user) {
   return (User) gs().get(User.class, user.getId());
 }