Example usage for com.google.common.base VerifyException getMessage

List of usage examples for com.google.common.base VerifyException getMessage

Introduction

In this page you can find the example usage for com.google.common.base VerifyException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.iblsoft.iwxxm.webservice.validator.IwxxmValidator.java

public ValidationResult validate(String iwxxmData, String iwxxmVersion) {
    Log.INSTANCE.debug("IwxxmWebService.validate request started");

    if (iwxxmVersion == null) {
        iwxxmVersion = defaultIwxxmVersion;
    }/*from   ww  w  .  jav  a  2 s .  co  m*/

    String catalogFile = validationCatalogFile.getAbsolutePath();
    XML10Validator validator = new XML10Validator(catalogFile);

    List<ValidationError> errors = new ArrayList<>();
    try {
        printValidatingXMLSchema(catalogFile);
        ValidationResult xsdValidationResult;
        try (StringReader reader = new StringReader(iwxxmData)) {
            xsdValidationResult = validator.validate(reader);
            errors.addAll(xsdValidationResult.getValidationErrors());
        }

        if (iwxxmVersion.isEmpty()) {
            iwxxmVersion = xsdValidationResult.getDetectedIwxxmVersion();
            if (Log.INSTANCE.isDebugEnabled()) {
                Log.INSTANCE.debug("IWXXM version detected: {}", iwxxmVersion);
            }
        }

        checkIwxxmVersion(iwxxmVersion);
        File[] schematronFiles = getSchematronFiles(iwxxmVersion);
        if (schematronFiles != null && schematronFiles.length > 0) {
            for (File schematronFile : schematronFiles) {
                if (Log.INSTANCE.isDebugEnabled()) {
                    Log.INSTANCE.debug("Validating against Schematron rules {}", schematronFile.getName());
                }

                ValidationResult schematronValidationResult = schematronValidator.validate(iwxxmData,
                        schematronFile.getAbsolutePath());
                errors.addAll(schematronValidationResult.getValidationErrors());
            }
        }
    } catch (VerifyException e) {
        errors.add(new ValidationError(e.getMessage(), "", 0, 0));
    } catch (Exception e) {
        errors.add(new ValidationError(e.toString(), "", 0, 0));
    }

    return new ValidationResult(iwxxmVersion, errors);
}