Package ca.uhn.hl7v2.validation

Examples of ca.uhn.hl7v2.validation.ValidationException


                Class<? extends ValidationContext> c;
                try {
                    c = (Class<? extends ValidationContext>) Class.forName(contextClassName);
                    ourContext = (ValidationContext) c.newInstance();
                } catch (Exception e) {
                    throw new ValidationException(e);
                }
            }
        }
        return ourContext;
    }
View Full Code Here


    String msg = String.format(description, String.valueOf(value));
    return failed("Validation failed: " + msg);
  }

  protected ValidationException[] failed(String msg) {
    return new ValidationException[] { new ValidationException(msg) };
  }
View Full Code Here

  }

  protected ValidationException[] failed(Exception e) {
    if (e instanceof ValidationException)
      return new ValidationException[] { (ValidationException) e };
    return new ValidationException[] { new ValidationException("Validation failed: "
        + e.getMessage(), e) };
  }
View Full Code Here

      if (hasCorrectNamespace(doc, validationErrors)) {
        XMLUtils.validate(doc, getSchemaLocation(doc), new ErrorHandler(validationErrors));
      }
    } catch (Exception e) {
      log.error("Unable to validate message: {}", e.getMessage(), e);
      validationErrors.add(new ValidationException("Unable to validate message "
          + e.getMessage(), e));
    }

    return validationErrors.toArray(new ValidationException[0]);
View Full Code Here

  private boolean hasCorrectNamespace(Document domDocumentToValidate,
      List<ValidationException> validationErrors) {
    String nsUri = domDocumentToValidate.getDocumentElement().getNamespaceURI();
    boolean ok = DEFAULT_NS.equals(nsUri);
    if (!ok) {
      ValidationException e = new ValidationException(
          "The default namespace of the XML document is incorrect - should be "
              + DEFAULT_NS + " but was " + nsUri);
      validationErrors.add(e);
      log.error(e.getMessage());
    }
    return ok;
  }
View Full Code Here

      super();
      this.validationErrors = validationErrors;
    }

    public boolean handleError(DOMError error) {
      validationErrors.add(new ValidationException(getSeverity(error) + error.getMessage()));
      return true;
    }
View Full Code Here

    try {
      Class<? extends ValidationRuleBuilder> c = (Class<? extends ValidationRuleBuilder>) Class
          .forName(ruleBuilderClassName);
      return c.newInstance();
    } catch (Exception e) {
      throw new ValidationException(e);
    }
  }
View Full Code Here

    try {
      Class<? extends ValidationContext> c = (Class<? extends ValidationContext>) Class
          .forName(contextClassName);
      return c.newInstance();
    } catch (Exception e) {
      throw new ValidationException(e);
    }
  }
View Full Code Here

                try {
                    ValidationException[] shortList = testAgainstProfile(msg, ids[i]);
                    log.debug("{} non-conformances", shortList.length);
                    problems.addAll(Arrays.asList(shortList));
                } catch (ProfileException e) {
                    problems.add(new ValidationException("Can't validate", e));
                }
            }           
        } catch (HL7Exception e) {
            problems.add(new ValidationException("Can't validate", e));
        }
       
        return (ValidationException[]) problems.toArray(new ValidationException[0]);
    }
View Full Code Here

            throw new ProfileException("Error retreiving profile " + id, e);
        }
       
        ValidationException[] result = new ValidationException[exceptions.length];
        for (int i = 0; i < exceptions.length; i++) {
            result[i] = new ValidationException(exceptions[i].getMessage(), exceptions[i]);
        }
        return result;
    }
View Full Code Here

TOP

Related Classes of ca.uhn.hl7v2.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.