Example #1
0
  /**
   * Step by step:
   *
   * <p>0. validate user 1. get or create user 2. get or create or move right and activate it 3.
   * login user 4. redirect to need page
   *
   * @return - resolution to next page
   */
  @SynchronizeByAllEntity(entityClass = User.class)
  public Resolution execute() {
    state = new CreateUserState(request);
    final CreateUserMode mode = CreateUserModeCreator.next(request, state);
    request.setMode(mode);

    mode.getValidate().execute(this);
    if (getContext().getValidationErrors().size() > 0) {
      if (mode == CreateUserMode.INVITED_NEW) {
        return showForInvited();
      } else {
        return showInternal();
      }
    }

    persistanceTransaction.execute(
        new PersistanceTransactionContext<Void>() {

          @Override
          public Void execute() {
            mode.getCreateUser().execute(CreateUserAction.this);
            mode.getRight().execute(state);
            return null;
          }
        });
    mode.getLogin().execute(this);
    return mode.getRedirect().execute(state);
  }
Example #2
0
 /**
  * Need link /account/createUser.action ?showForInvited=true &request.confirmCode=X
  * &request.userId=X &request.invitedUserId=X
  *
  * @return - show page for accept user settings
  */
 @SynchronizeByLoginUser
 @SynchronizeByClassProperties({
   @SynchronizeByClassProperty(
       entityClass = User.class,
       entityIdFieldPath = "request.invitedUserId"),
   @SynchronizeByClassProperty(entityClass = User.class, entityIdFieldPath = "request.userId")
 })
 public Resolution showForInvited() {
   state = new CreateUserState(request);
   request.setNotWantNewUser(true);
   request.setAgree(true);
   request.setMode(CreateUserModeCreator.get(request, state));
   request.getMode().getShow().execute(this);
   return showInternal();
 }