Examples of DbError


Examples of com.google.apps.easyconnect.demos.easyrpbasic.web.data.DbError

      resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
    }
  }

  private void editUser(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    DbError err = null;
    User user = ORMUtil.parseUser(req, "edit_");
    if (log.isLoggable(Level.INFO)) {
      StringBuilder buf = new StringBuilder();
      buf.append("DBMS Edit User: ").append(user.toString());
      log.info(buf.toString());
    }
    if (user.getBirthdayDay() == null || user.getBirthdayDay().isEmpty()) {
      user.setBirthdayDay("0");
    }
    if (user.getBirthdayMonth() == null || user.getBirthdayMonth().isEmpty()) {
      user.setBirthdayMonth("0");
    }
    if (user.getBirthdayYear() == null || user.getBirthdayYear().isEmpty()) {
      user.setBirthdayYear("0");
    }
    if (user.getEmail() == null || user.getEmail().isEmpty()) {
      err = DbError.INVALID_EMAIL;
    } else if (!UserDAO.isEmailRegistered(user.getEmail())) {
      err = DbError.EMAIL_NOT_FOUNT;
    } else if (user.getFirstName() == null || user.getFirstName().isEmpty()) {
      err = DbError.EMPTY_FIRSTNAME;
    } else if (user.getLastName() == null || user.getLastName().isEmpty()) {
      err = DbError.EMPTY_LASTNAME;
    } else if (user.getPassword() == null || user.getPassword().isEmpty()) {
      err = DbError.EMPTY_PWD;
    } else if (!Validator.isValidDay(user.getBirthdayDay())) {
      err = DbError.INVALID_DAY;
    } else if (!Validator.isValidMonth(user.getBirthdayMonth())) {
      err = DbError.INVALID_MONTH;
    } else if (!Validator.isValidYear(user.getBirthdayYear())) {
      err = DbError.INVALID_YEAR;
    }
    if (err == null) {
      UserDAO.update(user);
      log.info("Successfully update user [" + user.getEmail() + "] by DBMS.");
      resp.sendRedirect(Constants.DBMS_PAGE_URL);
    } else {
      StringBuilder buf = new StringBuilder();
      buf.append(Constants.DBMS_PAGE_URL);
      String parameters = getParameterUrl(req, req.getParameterNames());
      if (parameters != null && !parameters.isEmpty()) {
        buf.append("?").append(parameters);
      }
      buf.append("&tab=edit&error=").append(err.name());
      resp.sendRedirect(buf.toString());
    }
  }
View Full Code Here

Examples of com.google.apps.easyconnect.demos.easyrpbasic.web.data.DbError

    }
  }

  private void deleteUser(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    String email = req.getParameter("email");
    DbError err = null;
    if (email == null || email.isEmpty()) {
      err = DbError.INVALID_EMAIL;
    } else if (!UserDAO.isEmailRegistered(email)) {
      err = DbError.EMAIL_NOT_FOUNT;
    } else {
      UserDAO.delete(email);
      log.info("Successfully delete user [" + email + "] by DBMS.");
    }
    if (err == null) {
      resp.sendRedirect(Constants.DBMS_PAGE_URL);
    } else {
      resp.sendRedirect(Constants.DBMS_PAGE_URL + "?error=" + err.name());
    }
  }
View Full Code Here

Examples of com.google.apps.easyconnect.demos.easyrpbasic.web.data.DbError

      resp.sendRedirect(Constants.DBMS_PAGE_URL + "?error=" + err.name());
    }
  }

  private void newUser(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    DbError err = null;
    User user = ORMUtil.parseUser(req, "");
    if (log.isLoggable(Level.INFO)) {
      StringBuilder buf = new StringBuilder();
      buf.append("DBMS Create User: ").append(user.toString());
      log.info(buf.toString());
    }
    if (user.getBirthdayDay() == null || user.getBirthdayDay().isEmpty()) {
      user.setBirthdayDay("0");
    }
    if (user.getBirthdayMonth() == null || user.getBirthdayMonth().isEmpty()) {
      user.setBirthdayMonth("0");
    }
    if (user.getBirthdayYear() == null || user.getBirthdayYear().isEmpty()) {
      user.setBirthdayYear("0");
    }
    if (user.getEmail() == null || user.getEmail().isEmpty()
        || !Validator.isValidEmail(user.getEmail())) {
      err = DbError.INVALID_EMAIL;
    } else if (UserDAO.isEmailRegistered(user.getEmail())) {
      err = DbError.EMAIL_REGISTERED;
    } else if (user.getFirstName() == null || user.getFirstName().isEmpty()) {
      err = DbError.EMPTY_FIRSTNAME;
    } else if (user.getLastName() == null || user.getLastName().isEmpty()) {
      err = DbError.EMPTY_LASTNAME;
    } else if (user.getPassword() == null || user.getPassword().isEmpty()) {
      err = DbError.EMPTY_PWD;
    } else if (!Validator.isValidDay(user.getBirthdayDay())) {
      err = DbError.INVALID_DAY;
    } else if (!Validator.isValidMonth(user.getBirthdayMonth())) {
      err = DbError.INVALID_MONTH;
    } else if (!Validator.isValidYear(user.getBirthdayYear())) {
      err = DbError.INVALID_YEAR;
    }
    if (err == null) {
      User createdUser = UserDAO.create(user);
      if (createdUser == null) {
        err = DbError.CREATE_USER_FAIL;
      }
    }
    if (err == null) {
      UserDAO.update(user);
      log.info("Successfully create user [" + user.getEmail() + "] by DBMS.");
      resp.sendRedirect(Constants.DBMS_PAGE_URL);
    } else {
      StringBuilder buf = new StringBuilder();
      buf.append(Constants.DBMS_PAGE_URL);
      String parameters = getParameterUrl(req, req.getParameterNames());
      if (parameters != null && !parameters.isEmpty()) {
        buf.append("?").append(parameters);
      }
      buf.append("&tab=insert&error=").append(err.name());
      resp.sendRedirect(buf.toString());
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.