コード例 #1
0
  @Override
  public Address execute() throws AppException {
    LOG.debug("starts");

    SubscriberSearchDataBean searchData = getSearchData();
    LOG.debug("get search data ==> " + searchData);

    LOG.debug("try get search result ...");
    List<SubscriberSearchBean> beans =
        DaoFactory.getInstance().getSubscriberDao().getSubscriberSearchBeans(searchData);

    LOG.debug("From db: search result ==> " + beans);
    session.setAttribute("subscriberSearchBeanList", beans);
    session.setAttribute("subscriberSearchDataBean", searchData);

    LOG.debug("finished");
    return new Address(Method.REDIRECT, Path.COMMAND_ADMIN_VIEW_SUBSCRIBERS);
  }
コード例 #2
0
  @Override
  public Address execute() throws AppException {
    LOG.trace("stats");
    Address address = new Address(Method.REDIRECT, Path.COMMAND_COMMON_VIEW_SETTINGS);
    User user = (User) session.getAttribute("user");
    String newEmail = req.getParameter("newEmail");
    String oldEmail = user.getEmail();

    if (newEmail == null) {
      addError("Please insert new email");
      return address;
    }

    if (user.getEmail().equals(newEmail)) {
      addError("New and Old email is the same");
      return address;
    }

    Validator validator = new Validator();
    validator.addRule(new EmailValidationRule(newEmail));
    if (!validator.isValid()) {
      LOG.trace("email is invalid ==> " + validator.getErrors());
      addErrorList(validator.getErrors());
      return address;
    }

    user.setEmail(newEmail);
    try {
      DaoFactory.getInstance().getUserDao().updateUser(user);
    } catch (DBException e) {
      user.setEmail(oldEmail);
      addError("Such email already exists");
      return address;
    }

    session.setAttribute("user", user);
    addSuccess("Email was updated!");
    LOG.trace("Email was updated!");

    LOG.debug("finished");
    return address;
  }