Search in sources :

Example 6 with ValidationExceptionImpl

use of ddf.catalog.validation.impl.ValidationExceptionImpl in project ddf by codice.

the class SampleMetacardValidator method validate.

@Override
public void validate(Metacard metacard) throws ValidationException {
    if (checkMetacardForWarningWords(metacard.getTitle())) {
        ValidationExceptionImpl validationException = new ValidationExceptionImpl("Metacard title contains one of the warning words: " + warningWords);
        validationException.setWarnings(Collections.singletonList("sampleWarnings"));
        throw validationException;
    }
    if (checkMetacardForErrorWords(metacard.getTitle())) {
        ValidationExceptionImpl validationException = new ValidationExceptionImpl("Metacard title contains one of the error words: " + errorWords);
        validationException.setErrors(Collections.singletonList("sampleError"));
        throw validationException;
    }
    if (!checkMetacardForValidWords(metacard.getTitle())) {
        ValidationExceptionImpl validationException = new ValidationExceptionImpl("Metacard title does not contain any of: " + validWords);
        validationException.setErrors(Collections.singletonList("sampleError"));
        validationException.setWarnings(Collections.singletonList("sampleWarnings"));
        throw validationException;
    }
}
Also used : ValidationExceptionImpl(ddf.catalog.validation.impl.ValidationExceptionImpl)

Aggregations

ValidationExceptionImpl (ddf.catalog.validation.impl.ValidationExceptionImpl)6 MetacardValidationReport (ddf.catalog.validation.report.MetacardValidationReport)2 Geometry (com.vividsolutions.jts.geom.Geometry)1 WKTWriter (com.vividsolutions.jts.io.WKTWriter)1 Metacard (ddf.catalog.data.Metacard)1 MetacardValidationReportImpl (ddf.catalog.validation.impl.report.MetacardValidationReportImpl)1 ValidationViolationImpl (ddf.catalog.validation.impl.violation.ValidationViolationImpl)1 FileInputStream (java.io.FileInputStream)1 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 Templates (javax.xml.transform.Templates)1 AbstractGeometryType (net.opengis.gml.v_3_1_1.AbstractGeometryType)1 ParserException (org.codice.ddf.parser.ParserException)1 Gml3ToWkt (org.codice.ddf.transformer.xml.streaming.Gml3ToWkt)1 SaxEventHandlerFactory (org.codice.ddf.transformer.xml.streaming.SaxEventHandlerFactory)1 XmlInputTransformer (org.codice.ddf.transformer.xml.streaming.lib.XmlInputTransformer)1 Test (org.junit.Test)1 DefaultRootObjectLocator (org.jvnet.jaxb2_commons.locator.DefaultRootObjectLocator)1 ConversionFailedException (org.jvnet.ogc.gml.v_3_1_1.jts.ConversionFailedException)1