예제 #1
0
  /** Services this request. */
  @Override
  public void service() {
    LOGGER.info("Validating the user update request.");

    if (!authenticate(AllowNewAccount.NEW_ACCOUNT_DISALLOWED)) {
      return;
    }

    try {
      LOGGER.info("Verifying that the requesting user is an admin.");
      UserServices.instance().verifyUserIsAdmin(getUser().getUsername());

      LOGGER.info("Verifying that the user to be updated exists.");
      UserServices.instance().checkUserExistance(username, true);

      LOGGER.info(
          "Verify that either the user to be updated already has a personal record or that enough information was provided to create a new one.");
      UserServices.instance()
          .verifyUserHasOrCanCreatePersonalInfo(
              username, firstName, lastName, organization, personalId);

      LOGGER.info("Updating the user.");
      UserServices.instance()
          .updateUser(
              username,
              emailAddress,
              admin,
              enabled,
              newAccount,
              campaignCreationPrivilege,
              firstName,
              lastName,
              organization,
              personalId,
              deletePersonalInfo);
    } catch (ServiceException e) {
      e.failRequest(this);
      e.logException(LOGGER);
    }
  }
  /** Services the request. */
  @Override
  public void service() {
    LOGGER.info("Servicing the user deletion request.");

    if (!authenticate(AllowNewAccount.NEW_ACCOUNT_DISALLOWED)) {
      return;
    }

    try {
      LOGGER.info("Verifying that the user is an admin.");
      UserServices.instance().verifyUserIsAdmin(getUser().getUsername());

      LOGGER.info("Verifying that the users in the list exist.");
      UserServices.instance().verifyUsersExist(usernames, true);

      LOGGER.info("Deleting the user(s).");
      UserServices.instance().deleteUser(usernames);
    } catch (ServiceException e) {
      e.failRequest(this);
      e.logException(LOGGER);
    }
  }