Package org.openbravo.base.validation

Examples of org.openbravo.base.validation.ValidationException


   *
   * @throws ValidationException
   */
  public void checkIsWritable() {
    if (isInactive()) {
      final ValidationException ve = new ValidationException();
      ve.addMessage(this, "Property " + this + " is inactive and can therefore not be changed.");
      throw ve;
    }
  }
View Full Code Here


    if (isOneToMany() && (value instanceof List)) {
      return;
    }

    if (!isPrimitive() && !(value instanceof BaseOBObjectDef)) {
      final ValidationException ve = new ValidationException();
      ve.addMessage(this, "Property " + this + " only allows reference instances of type "
          + BaseOBObjectDef.class.getName() + " but the value is an instanceof "
          + value.getClass().getName());
      throw ve;
    } else if (isPrimitive()) {
      // this specific conversion is allowed
      final boolean intToLong = getPrimitiveObjectType().isAssignableFrom(Long.class)
          && value.getClass().isAssignableFrom(Integer.class);

      if (!intToLong && !getPrimitiveObjectType().isInstance(value)) {
        final ValidationException ve = new ValidationException();
        ve.addMessage(this, "Property " + this + " only allows instances of "
            + getPrimitiveObjectType().getName() + " but the value is an instanceof "
            + value.getClass().getName());
        throw ve;
      }

      final PropertyValidator v = getValidator();
      if (v != null) {
        final String msg = v.validate(value);
        if (msg != null) {
          final ValidationException ve = new ValidationException();
          ve.addMessage(this, msg);
          throw ve;
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.openbravo.base.validation.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.