/** @param p The person context to set. */
  public void setPerson(final Node p) {
    // perform the set in a txn as certain bean calls require it
    FacesContext context = FacesContext.getCurrentInstance();
    RetryingTransactionHelper txnHelper = Repository.getRetryingTransactionHelper(context);
    RetryingTransactionCallback callback =
        new RetryingTransactionCallback() {
          public Object execute() throws Throwable {
            person = p;
            userName = (String) person.getProperties().get(ContentModel.PROP_USERNAME);

            // rebuild the property immutability map helper object
            immutabilty =
                new PropertyImmutabilityMap(
                    getUserRegistrySynchronizer().getPersonMappedProperties(userName));

            return null;
          }
        };
    try {
      txnHelper.doInTransaction(callback, false);
    } catch (Throwable e) {
      // reset the flag so we can re-attempt the operation
      if (e instanceof ReportedException == false) {
        Utils.addErrorMessage(e.getMessage(), e);
      }
      ReportedException.throwIfNecessary(e);
    }
  }
Example #2
0
  @Override
  protected String finishImpl(FacesContext context, String outcome) throws Throwable {
    // TODO: implement create new Person object from specified details
    try {
      if (!this.password.equals(this.confirm)) {
        Utils.addErrorMessage(Application.getMessage(context, UsersDialog.ERROR_PASSWORD_MATCH));
        outcome = null;
      }

      if (checkTenantUserName() == false) {
        outcome = null;
      }

      if (outcome != null) {
        // create properties for Person type from submitted Form data
        Map<QName, Serializable> props = new HashMap<QName, Serializable>(7, 1.0f);
        setPersonPropertiesAndCreateHomeSpaceIfNeeded(props, null, context);

        // create the node to represent the Person
        getPersonService().createPerson(props);

        // ensure the user can access their own Person object
        // getPermissionService().setPermission(newPerson, this.userName,
        // getPermissionService().getAllPermission(), true);
        // Not required - now done by the person service.

        if (logger.isDebugEnabled())
          logger.debug("Created Person node for username: "******"Created User Authentication instance for username: " + this.userName);

        if ((this.sizeQuota != null) && (this.sizeQuota < 0L)) {
          Utils.addErrorMessage(
              MessageFormat.format(
                  Application.getMessage(context, UsersDialog.ERROR_NEGATIVE_QUOTA),
                  this.sizeQuota));
          outcome = null;
        } else {
          putSizeQuotaProperty(this.userName, this.sizeQuota, this.sizeQuotaUnits);
        }
      }
      invalidateUserList();
    } catch (Throwable e) {
      Utils.addErrorMessage(
          MessageFormat.format(
              Application.getMessage(FacesContext.getCurrentInstance(), ERROR), e.getMessage()),
          e);
      outcome = null;
      this.isFinished = false;
      ReportedException.throwIfNecessary(e);
    }

    if (outcome == null) {
      this.isFinished = false;
    }

    return outcome;
  }