Package edu.uga.galileo.voci.exception

Examples of edu.uga.galileo.voci.exception.ValidationException


  public void setEmail(String email) throws ValidationException {
    this.email = email;

    if (email.length() > 0) {
      if ((email.indexOf('@') == -1) || (email.indexOf('.') == -1)) {
        throw new ValidationException(
            "Email address must contain @ and a period(.) ");
      }
    }
  }
View Full Code Here


      throws ValidationException {
    try {
      ColumnMetadata metadata = getDBColumnMetadata(variableToColumnName(variableName));
      if ((value == null) || (value.trim().length() == 0)) {
        if (!metadata.isNullable()) {
          throw new ValidationException("This is a required field.");
        }
      } else {
        // a size of -1 indicates a 'text' datatype for the column, and
        // those types have no practical limit for our purposes
        if ((metadata.getDataSize() != -1)
            && (value.length() > metadata.getDataSize())) {
          throw new ValidationException(
              "Maximum length ("
                  + metadata.getDataSize()
                  + ") exceeded by "
                  + (value.length() - metadata.getDataSize())
                  + " characters.  If that sounds wrong, keep in mind that "
View Full Code Here

      throws ValidationException {
    try {
      ColumnMetadata metadata = getDBColumnMetadata(variableToColumnName(variableName));
      if ((value == null) || (value.trim().length() == 0)) {
        if (!metadata.isNullable()) {
          throw new ValidationException("This is a required field.");
        }
      } else {
        if ((value != null)
            && (!(Pattern
                .matches(
                    "\\d\\d\\d\\d-\\d\\d-\\d\\d \\d\\d:\\d\\d:\\d\\d.\\d{1,9}",
                    value)))
            && (!(Pattern.matches("\\d\\d\\d\\d-\\d\\d-\\d\\d",
                value)))) {
          throw new ValidationException("The date you entered ("
              + value + ") isn't a valid date format.  "
              + "It must be either yyyy-mm-dd or "
              + "yyyy-mm-dd hh:mm:ss.fff... (where 'f' "
              + "is 1-9 digits of milliseconds)");
        }
      }
    } catch (NoSuchColumnException e) {
      throw new ValidationException(
          "There's a data problem that must be resolved "
              + "by a programmer:  No db column exists for '"
              + variableName + "'.");
    }
  }
View Full Code Here

      throws ValidationException {
    try {
      ColumnMetadata metadata = getDBColumnMetadata(variableToColumnName(variableName));
      if (value == null) {
        if (!metadata.isNullable()) {
          throw new ValidationException("This is a required field.");
        }
      } else {
        if ((value < metadata.getNumberMinimum())
            || (value > metadata.getNumberMaximum())) {
          throw new ValidationException(
              "Values falls outside of acceptable range ("
                  + metadata.getNumberMinimum() + " to "
                  + metadata.getNumberMaximum());
        }
      }
    } catch (NoSuchColumnException e) {
      throw new ValidationException(
          "There's a data problem that must be resolved "
              + "by a programmer:  No db column exists for '"
              + variableName + "'.");
    }
  }
View Full Code Here

    if ((element.isRequired())
        || ((value != null) && (value.trim().length() > 0))) {
      if (((value == null) || (value.trim().length() == 0))
          && (!element.getFieldType().startsWith(
              MetadataElement.CHECKBOX_FIELD))) {
        throw new ValidationException("This is a required field.");
      }

      if ((element.isUnique())
          && (!element.getFieldType().startsWith(
              MetadataElement.CHECKBOX_FIELD))) {
        if (!((new MetadataManager()).isUniqueMetadataValue(element
            .getMetadataId(), getId(), getType(), value))) {
          throw new ValidationException(
              "This field's value must be unique, but another "
                  + ContentType.valueOf(getType()).toString()
                      .toLowerCase()
                  + " exists with the same value.");
        }
      }

      String validateRegex = element.getValidateRegex();
      if ((validateRegex != null) && (validateRegex.trim().length() > 0)) {
        String[] values = value.split("\\^");
        for (String splitValue : values) {
          if (!(Pattern.matches(validateRegex, splitValue))) {
            throw new ValidationException(
                "'"
                    + value
                    + "' must match the following regular expression: "
                    + validateRegex);
          }
View Full Code Here

   *            The element.
   */
  public void setElement(String element) throws ValidationException {
    this.element = element;
    if (element.indexOf('.') != -1) {
      throw new ValidationException("No periods allowed.");
    }
  }
View Full Code Here

            + "-multi" + '|' + RADIO_FIELD + "):\\{.+\\}$",
            fieldType))
            && (!Pattern.matches("^(" + SELECT_FIELD + '|'
                + SELECT_FIELD + "-multi" + '|' + RADIO_FIELD
                + "):..+,..+\\|.+", fieldType))) {
          throw new ValidationException("'" + SELECT_FIELD
              + "' and '" + RADIO_FIELD
              + "' types must also include options "
              + "and a default value in the form, e.g., '"
              + SELECT_FIELD + ":dogs,"
              + "black cats,...,chickens|black cats, or "
              + "else they must match the format of "
              + "a field plugin (when available).");
        } else if (Pattern.matches("^(" + SELECT_FIELD + '|'
            + SELECT_FIELD + "-multi" + '|' + RADIO_FIELD
            + "):\\{.+\\}$", fieldType)) {
          String tester = fieldType.substring(
              fieldType.indexOf('{') + 1, fieldType.length() - 1);
          if (!Pattern.matches("^.+:.+$", fieldType)) {
            throw new ValidationException(
                "Invalid format for plugins.");
          } else if (FieldPluginFactory.getInstance().getPluginByID(
              tester.substring(0, tester.indexOf(':'))) == null) {
            throw new ValidationException("Requested plugin ("
                + tester + ") couldn't be found.");
          }
        } else {
          String options = fieldType.substring(
              fieldType.indexOf(':') + 1, fieldType
                  .lastIndexOf('|'));
          String values = fieldType.substring(fieldType
              .lastIndexOf('|') + 1);
          String[] splitOptions = options.split(",");
          String[] valueOptions = values.split(",");
          StringBuffer validationExceptions = new StringBuffer();
          for (String value : valueOptions) {
            if (ArrayUtils.linearSearch(splitOptions, value) == -1) {
              validationExceptions.append("Default value '"
                  + value + "' doesn't match any "
                  + "of your specified options.<br/>");
            }
          }
          if (validationExceptions.length() > 0) {
            throw new ValidationException(validationExceptions
                .toString());
          }
        }
      } else if ((!((fieldType.equals(CHECKBOX_FIELD)) || (fieldType
          .equals(CHECKBOX_FIELD + "|on"))))
          && (!fieldType.equals(TEXT_FIELD))
          && (!fieldType.equals(TEXTAREA_FIELD))
          && (!fieldType.equals(WYSIWYGABLE_FIELD))) {
        throw new ValidationException(
            "Your definition doesn't match any of "
                + "the patterns defined to the left.");
      }
    }
  }
View Full Code Here

   */
  public void setIndexMultiplier(int indexMultiplier)
      throws ValidationException {
    this.indexMultiplier = indexMultiplier;
    if ((indexMultiplier < 0) || (indexMultiplier > 1000)) {
      throw new ValidationException("Value must be in the 0-1000 range.");
    }
  }
View Full Code Here

   *            The qualifier.
   */
  public void setQualifier(String qualifier) throws ValidationException {
    this.qualifier = qualifier;
    if (element.indexOf('.') != -1) {
      throw new ValidationException("No periods allowed.");
    }
  }
View Full Code Here

TOP

Related Classes of edu.uga.galileo.voci.exception.ValidationException

Copyright © 2018 www.massapicom. 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.