Ejemplo n.º 1
0
  private void validateStatePreCreate(User user) {
    if (this.user == null) throw new IllegalStateException("resources id not initialized!");

    if (!this.user.isEmpty()) throw new IllegalStateException("user already exists!");

    if (!userId.equals(user.identity()))
      throw new IllegalArgumentException("wrong data passed - user#identity did not match!");
  }
Ejemplo n.º 2
0
  @Override
  @Modify
  public void create(User user, Result<String> result) throws AppException {

    validateStatePreCreate(user);
    getValidator()
        .validate(
            user,
            result.from(
                u -> {
                  this.user = u;
                  return user.identity().getKey();
                }));
  }