Package ca.uhn.hl7v2.validation

Examples of ca.uhn.hl7v2.validation.ValidationException


            @Override
            public ValidationException[] test(Message msg) {
                ADT_A01 a01 = (ADT_A01)msg;
                if (a01.getPID().getAdministrativeSex().getValue() == null) {
                    ValidationException[] e = new ValidationException[1];
                    e[0] = new ValidationException("No gender provided!");
                    return e;
                }
                return VALIDATION_OK;
            }
View Full Code Here


        }           
        catch (SAXException se)
        {
            log.error("Unable to parse message - please verify that it's a valid xml document");
            log.error(se.getMessage(), se);
            validationErrors.add(new ValidationException("Unable to parse message - please verify that it's a valid xml document" + " [SAXException] " + se.getMessage()));
           
        }
        catch (IOException e)
        {
            log.error("Unable to parse message - please verify that it's a valid xml document");
            log.error(e.getMessage(), e);
            validationErrors.add(new ValidationException("Unable to parse message - please verify that it's a valid xml document" + " [IOException] " + e.getMessage()));
        }
        return validationErrors.toArray(new ValidationException[0]);

    }
View Full Code Here

        {
            return schemaFilename;
        }
        else
        {
            ValidationException e = new ValidationException("Unable to retrieve a valid schema to use for message validation - please check logs");
            validationErrors.add(e);
            return "";
        }
    }
View Full Code Here

    private boolean validateNamespace(Document domDocumentToValidate, List<ValidationException> validationErrors) {
        // start by verifying the default namespace if this isn't correct the rest will fail anyway
        if (domDocumentToValidate.getDocumentElement().getNamespaceURI() == null)
        {
            ValidationException e = new ValidationException("The default namespace of the xml document is not specified - should be urn:hl7-org:v2xml");
            validationErrors.add(e);
            log.error("The default namespace of the xml document is not specified - should be urn:hl7-org:v2xml");
        }
        else
        {
            if (! domDocumentToValidate.getDocumentElement().getNamespaceURI().equals("urn:hl7-org:v2xml"))
            {
                ValidationException e = new ValidationException("The default namespace of the xml document (" + domDocumentToValidate.getDocumentElement().getNamespaceURI() + ") is incorrect - should be urn:hl7-org:v2xml");
                validationErrors.add(e);
                log.error("The default namespace of the xml document (" + domDocumentToValidate.getDocumentElement().getNamespaceURI() + ") is incorrect - should be urn:hl7-org:v2xml");
             }
             else
             {
View Full Code Here

        }

        /** Warning. */
        public void warning(SAXParseException ex) {

            validationErrors.add(new ValidationException("[Warning] "+
                           getLocationString(ex)+": "+
                           ex.getMessage() + " "));
        }
View Full Code Here

        }

        /** Error. */
        public void error(SAXParseException ex) {

            validationErrors.add(new ValidationException("[Error] "+
                           getLocationString(ex)+": "+
                           ex.getMessage() + " "));
        }
View Full Code Here

        }

        /** Fatal error. */
        public void fatalError(SAXParseException ex) throws SAXException {

            validationErrors.add(new ValidationException("[Fatal Error] "+
                           getLocationString(ex)+": "+
                           ex.getMessage() + " "));
        }
View Full Code Here

  public static ValidationContext customValidation(String contextClassName) throws ValidationException {
        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.