You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2008/02/28 11:52:23 UTC
svn commit: r631927 -
/servicemix/smx3/branches/servicemix-3.2/common/servicemix-components/src/main/java/org/apache/servicemix/components/validation/ValidateComponent.java
Author: gnodet
Date: Thu Feb 28 02:52:10 2008
New Revision: 631927
URL: http://svn.apache.org/viewvc?rev=631927&view=rev
Log:
SM-1226: Validation component should optionally handle errors by propagating a 'correct JBI message' with 'fault content'
Modified:
servicemix/smx3/branches/servicemix-3.2/common/servicemix-components/src/main/java/org/apache/servicemix/components/validation/ValidateComponent.java
Modified: servicemix/smx3/branches/servicemix-3.2/common/servicemix-components/src/main/java/org/apache/servicemix/components/validation/ValidateComponent.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/common/servicemix-components/src/main/java/org/apache/servicemix/components/validation/ValidateComponent.java?rev=631927&r1=631926&r2=631927&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/common/servicemix-components/src/main/java/org/apache/servicemix/components/validation/ValidateComponent.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/common/servicemix-components/src/main/java/org/apache/servicemix/components/validation/ValidateComponent.java Thu Feb 28 02:52:10 2008
@@ -20,6 +20,7 @@
import org.apache.servicemix.jbi.FaultException;
import org.apache.servicemix.jbi.jaxp.SourceTransformer;
import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.jbi.util.MessageUtil;
import org.springframework.core.io.Resource;
import org.xml.sax.SAXException;
@@ -52,6 +53,11 @@
private Source schemaSource;
private Resource schemaResource;
private MessageAwareErrorHandlerFactory errorHandlerFactory = new CountingErrorHandlerFactory();
+
+ public static final String FAULT_FLOW = "FAULT_FLOW";
+ public static final String FAULT_JBI = "FAULT_JBI";
+
+ private String handlingErrorMethod = "FAULT_JBI";
public Schema getSchema() {
return schema;
@@ -143,9 +149,13 @@
if (errorHandler.hasErrors()) {
Fault fault = exchange.createFault();
- // set the schema and source document as properties on the fault
- fault.setProperty("org.apache.servicemix.schema", schema);
- fault.setProperty("org.apache.servicemix.xml", src);
+ // Dont set the schema and source document as properties on the fault
+ // because they are not serializable
+ //fault.setProperty("org.apache.servicemix.xml", src);
+ // Dont set the schema because it contains an instance of
+ // com.sun.org.apache.xerces.internal.jaxp.validation.xs.SchemaImpl that
+ // is not serializable
+ //fault.setProperty("org.apache.servicemix.schema", schema);
/*
* check if this error handler supports the capturing of
@@ -181,7 +191,13 @@
*/
fault.setContent(new DOMSource(result.getNode(), result.getSystemId()));
}
- throw new FaultException("Failed to validate against schema: " + schema, exchange, fault);
+ if (!handlingErrorMethod.equalsIgnoreCase(FAULT_FLOW)) {
+ // HANDLE AS JBI FAULT
+ throw new FaultException("Failed to validate against schema: " + schema, exchange, fault);
+ } else {
+ MessageUtil.transfer(fault, out);
+ return true;
+ }
}
else {
// Retrieve the ouput of the validation
@@ -207,4 +223,13 @@
protected void doValidation(Validator validator, DOMSource src, DOMResult result) throws SAXException, IOException {
validator.validate(src,result);
}
+
+ public String getHandlingErrorMethod() {
+ return handlingErrorMethod;
+ }
+
+ public void setHandlingErrorMethod(String handlingErrorMethod) {
+ this.handlingErrorMethod = handlingErrorMethod;
+ }
}
+