use of ddf.catalog.validation.report.MetacardValidationReport in project ddf by codice.
the class SchematronValidationService method validate.
@Override
public void validate(Metacard metacard) throws ValidationException {
MetacardValidationReport report = generateReport(metacard);
List<String> errors = new ArrayList<>();
List<String> warnings = new ArrayList<>();
report.getMetacardValidationViolations().forEach(violation -> {
if (violation.getSeverity() == ValidationViolation.Severity.ERROR) {
errors.add(violation.getMessage());
} else {
warnings.add(violation.getMessage());
}
});
SchematronValidationException exception = new SchematronValidationException("Schematron validation failed", errors, warnings);
if (!errors.isEmpty()) {
throw exception;
}
if (!suppressWarnings && !warnings.isEmpty()) {
throw exception;
}
}
Aggregations