Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
Ubuntu Linux 5.10, Windows XP SP2, ServiceMix HEAD
-
Patch Available
Description
The purpose of this enchancement was to provide the following:
1) Allow error messages to be captured by the ValidateComponent and sent back as the content of a fault message;
2) Preserve existing functionality; and
3) Provide a framework for extending the functionality
It was noted that the existing functionality only dealt with simple case valid or not valid schemas. It was decided to make the standard component more extensible and functional and as such this code is being contributed back to the ServiceMix project. To this end the following changes have been made and are available in the attached zip file:
1) Added MessageAwareErrorHandler interface - this interface extends the org.xml.sax.ErrorHandler interface and adds contracts for determining if the error handler has errors, whether it captures messages from the validator, and what message formats it supports.
2) Refactored CountingErrorHandler to extend from MessageAwareErrorHandler and implement the above mentioned methods
3) Created MessageAggregatingErrorHandler - this class aggregates all warning, error and fatal error messages into an XML format (via CDATA). It provides the ability to set the root document path and namespace via configuration and supports DOMSource, StringSource and String formats for the encapsulated data.
4) modified ValidateComponent - added errorHandler property to facilitate dependency injection, with a default value of CountingErrorHandler to preserve existing functionality. Refactored the handling of validation errors to use the new interfaces. errorHandlers which do not support the capturing of messages will use the previous method of sending the DOMResult back as the fault message content. errorHandlers which do support the capture of messages will send the error message xml back as the fault message content. The src document is now set as a property on the fault message.
Additionally, a null pointer check was added to the init on the schemaResource.getURL() method call.
A testcase has been added to ValidationTest and the example.xml in the validation test/resources package demonstrates the configuration of this functionality.