Example #1
0
  private void validateDeliveryInfo(DeliveryInfo deliveryInfo, UserDAO userDAO)
      throws EmailDuplicateException, InvalidInputException {
    String firstName = deliveryInfo.getFirstName();
    if (ValidatorUtil.isEmpty(firstName) || ValidatorUtil.isInvalidLength(firstName, 1, 20)) {
      throw new InvalidInputException("deliveryInfo.firstName");
    }
    String lastName = deliveryInfo.getLastName();
    if (ValidatorUtil.isEmpty(lastName) || ValidatorUtil.isInvalidLength(lastName, 1, 20)) {
      throw new InvalidInputException("deliveryInfo.lastName");
    }
    String email = deliveryInfo.getEmail();
    if (ValidatorUtil.isEmpty(email)
        || ValidatorUtil.isInvalidLength(email, 1, 50)
        || ValidatorUtil.isInvalidEmail(email.trim())) {
      throw new InvalidInputException("deliveryInfo.email");
    }
    String address = deliveryInfo.getAddress();
    if (ValidatorUtil.isEmpty(address) || ValidatorUtil.isInvalidLength(address, 1, 100)) {
      throw new InvalidInputException("deliveryInfo.address");
    }
    String tel = deliveryInfo.getTel();
    if (ValidatorUtil.isEmpty(tel) || ValidatorUtil.isInvalidLength(tel, 1, 50)) {
      throw new InvalidInputException("deliveryInfo.tel");
    }

    Long dbUserId = userDAO.getUserIdByEmail(email.trim());
    if (dbUserId != null) {
      if (userId == null || (dbUserId.longValue() != userId.longValue())) {
        throw new EmailDuplicateException("deliveryInfo.email");
      }
    }
  }
Example #2
0
 private void populateDeliveryInfo(DeliveryInfo inputDeliveryInfo) {
   deliveryInfo = new DeliveryInfo();
   deliveryInfo.setFirstName(TextUtil.normalize(inputDeliveryInfo.getFirstName()));
   deliveryInfo.setLastName(TextUtil.normalize(inputDeliveryInfo.getLastName()));
   deliveryInfo.setAddress(TextUtil.normalize(inputDeliveryInfo.getAddress()));
   deliveryInfo.setEmail(TextUtil.normalize(inputDeliveryInfo.getEmail()));
   deliveryInfo.setTel(TextUtil.normalize(inputDeliveryInfo.getTel()));
 }