Search in sources :

Example 1 with AggregatedXmlMessageValidationException

use of org.springframework.integration.xml.AggregatedXmlMessageValidationException in project spring-integration by spring-projects.

the class XmlValidatingMessageSelector method accept.

@Override
public boolean accept(Message<?> message) {
    SAXParseException[] validationExceptions = null;
    try {
        validationExceptions = this.xmlValidator.validate(this.converter.convertToSource(message.getPayload()));
    } catch (Exception e) {
        throw new MessageHandlingException(message, e);
    }
    boolean validationSuccess = ObjectUtils.isEmpty(validationExceptions);
    if (!validationSuccess) {
        if (this.throwExceptionOnRejection) {
            throw new MessageRejectedException(message, "Message was rejected due to XML Validation errors", new AggregatedXmlMessageValidationException(Arrays.<Throwable>asList(validationExceptions)));
        }
        this.logger.debug("Message was rejected due to XML Validation errors");
    }
    return validationSuccess;
}
Also used : AggregatedXmlMessageValidationException(org.springframework.integration.xml.AggregatedXmlMessageValidationException) SAXParseException(org.xml.sax.SAXParseException) MessageRejectedException(org.springframework.integration.MessageRejectedException) IOException(java.io.IOException) AggregatedXmlMessageValidationException(org.springframework.integration.xml.AggregatedXmlMessageValidationException) SAXParseException(org.xml.sax.SAXParseException) MessageRejectedException(org.springframework.integration.MessageRejectedException) MessageHandlingException(org.springframework.messaging.MessageHandlingException) MessageHandlingException(org.springframework.messaging.MessageHandlingException)

Aggregations

IOException (java.io.IOException)1 MessageRejectedException (org.springframework.integration.MessageRejectedException)1 AggregatedXmlMessageValidationException (org.springframework.integration.xml.AggregatedXmlMessageValidationException)1 MessageHandlingException (org.springframework.messaging.MessageHandlingException)1 SAXParseException (org.xml.sax.SAXParseException)1