@Override public void validate(Metacard metacard) throws ValidationException { if (!checkMetacard(metacard.getTitle(), new ArrayList<>(Arrays.asList(validWords)))) { ValidationExceptionImpl validationException = new ValidationExceptionImpl( "Metacard title does not contain any of: " + Arrays.toString(validWords)); validationException.setErrors(new ArrayList<String>(Arrays.asList("sampleError"))); validationException.setWarnings(new ArrayList<String>(Arrays.asList("sampleWarnings"))); throw validationException; } }
/** * Constructs a {@code ValidationException} with a specified summary message of the failure and * associated errors and warnings. * * @param summaryMessage summarizes why the validation operation failed * @param cause the cause of why the validation operation failed * @param errors list of human readable error messages * @param warnings list of human readable warning messages */ public ValidationExceptionImpl( String summaryMessage, Throwable cause, List<String> errors, List<String> warnings) { super(summaryMessage, cause); setErrors(errors); setWarnings(warnings); }
/** * Constructs a {@code ValidationException} with a specified summary message of the failure and * associated errors and warnings. * * @param cause the cause of why the validation operation failed * @param errors list of human readable error messages * @param warnings list of human readable warning messages */ public ValidationExceptionImpl(Throwable cause, List<String> errors, List<String> warnings) { super(cause); setErrors(errors); setWarnings(warnings); }