[jboss-svn-commits] JBL Code SVN: r35106 - labs/jbossesb/workspace/johan.kumps/product/rosetta/src/org/jboss/soa/esb/actions/validation.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Sep 10 14:37:41 EDT 2010
Author: johan.kumps
Date: 2010-09-10 14:37:40 -0400 (Fri, 10 Sep 2010)
New Revision: 35106
Modified:
labs/jbossesb/workspace/johan.kumps/product/rosetta/src/org/jboss/soa/esb/actions/validation/SchematronValidationAction.java
Log:
Modified: labs/jbossesb/workspace/johan.kumps/product/rosetta/src/org/jboss/soa/esb/actions/validation/SchematronValidationAction.java
===================================================================
--- labs/jbossesb/workspace/johan.kumps/product/rosetta/src/org/jboss/soa/esb/actions/validation/SchematronValidationAction.java 2010-09-10 18:16:00 UTC (rev 35105)
+++ labs/jbossesb/workspace/johan.kumps/product/rosetta/src/org/jboss/soa/esb/actions/validation/SchematronValidationAction.java 2010-09-10 18:37:40 UTC (rev 35106)
@@ -152,46 +152,52 @@
private TransformerFactory factory;
/*
- * Boolean indicating whether the original message will be preserved.
- * If so the validation result will be stored in a different body location.
+ * Boolean indicating whether the original message will be preserved. If so
+ * the validation result will be stored in a different body location.
*/
private boolean preserveOriginalMessage = false;
/*
- * The name of the configuration parameter representing the preserveOriginalMessage boolean.
+ * The name of the configuration parameter representing the
+ * preserveOriginalMessage boolean.
*/
protected static final String PRESERVE_ORIGINAL_MESSAGE_PARAM_NAME = "preserveOriginalMessage";
/*
- * Boolean indicating whether we throw a ValidationException in case of rule failures
+ * Boolean indicating whether we throw a ValidationException in case of rule
+ * failures
*/
private boolean onErrorCancelProcessingPipeline = false;
/*
- * The name of the configuration parameter representing the onErrorCancelProcessingPipeline boolean.
+ * The name of the configuration parameter representing the
+ * onErrorCancelProcessingPipeline boolean.
*/
protected static final String ON_ERROR_CANCEL_PROCESSING_PIPELINE_PARAM_NAME = "onErrorCancelProcessingPipeline";
/*
- * Name of the location in the message body containing the validation result.
+ * Name of the location in the message body containing the validation
+ * result.
*/
public static final String VALIDATION_RESULT_BODY_LOCATION_NAME = "validation-result";
-
+
/*
- * Xpath expression counting the number of failed rules in a validation result.
+ * Xpath expression counting the number of failed rules in a validation
+ * result.
*/
private static XPathExpression XPATH_GETTING_FAILURE_COUNT = null;
-
+
/*
- * Xpath expression string counting the number of failed rules in a validation result.
+ * Xpath expression string counting the number of failed rules in a
+ * validation result.
*/
- private static final String XPATH_EXPRESSION_GETTING_FAILURE_COUNT= "count(//schematron-output/failed-assert)";
-
+ private static final String XPATH_EXPRESSION_GETTING_FAILURE_COUNT = "count(//schematron-output/failed-assert)";
+
/*
* Message given when an error occurs during the XPath initialisation
*/
private static final String ERROR_INTIALISING_XPATH = "An error occured while initialising the XPath expressions.";
-
+
/**
* Constructor that parses the passed-in {@link ConfigTree} for mandatory
* attributes and sets the fields of this instance.
@@ -234,9 +240,10 @@
this.factory.setURIResolver(new ClasspathXslURIResolver());
XPathFactory xPathFactory = XPathFactory.newInstance();
XPath xpath = xPathFactory.newXPath();
-
- XPATH_GETTING_FAILURE_COUNT = xpath.compile(XPATH_EXPRESSION_GETTING_FAILURE_COUNT);
-
+
+ XPATH_GETTING_FAILURE_COUNT = xpath
+ .compile(XPATH_EXPRESSION_GETTING_FAILURE_COUNT);
+
} catch (final TransformerConfigurationException e) {
throw new ActionLifecycleException(e.getMessage(), e);
} catch (XPathExpressionException e) {
@@ -262,7 +269,7 @@
+ (System.currentTimeMillis() - start)
+ "ms. Now starting to handle result...");
}
-
+
if (containsRuleFailures(validationResult)) {
if (!onErrorCancelProcessingPipeline) {
if (log.isDebugEnabled()) {
@@ -284,12 +291,13 @@
if (log.isDebugEnabled()) {
log.debug("Not preserving original message.");
}
- try{
- payloadProxy.setPayload(message, ResultFactory.getInstance()
- .extractResult(validationResult, ResultType.STRING));
- } catch (MessageDeliverException e) {
- throw new ActionProcessingException(e.getMessage(), e);
- }
+ try {
+ payloadProxy.setPayload(message, ResultFactory
+ .getInstance().extractResult(validationResult,
+ ResultType.STRING));
+ } catch (MessageDeliverException e) {
+ throw new ActionProcessingException(e.getMessage(), e);
+ }
}
} else {
if (log.isDebugEnabled()) {
@@ -302,7 +310,7 @@
}
return message;
}
-
+
@Override
public String toString() {
return String.format("%s failOnWarning=%b, features=%s, attributes=%s",
@@ -310,7 +318,6 @@
.getFeatures(), transformerConfig.getAttributes());
}
-
/**
* Method checking whether the given {@link Result} contains any validation
* rule failures.
@@ -325,17 +332,29 @@
document = DocumentFactory.getInstance().createDocument(
ResultFactory.getInstance().extractResult(validationResult,
ResultType.STRING));
-
- return (Double)XPATH_GETTING_FAILURE_COUNT
- .evaluate(document, XPathConstants.NUMBER) > 0;
+
+ return (Double) XPATH_GETTING_FAILURE_COUNT.evaluate(document,
+ XPathConstants.NUMBER) > 0;
} catch (ParserConfigurationException e) {
- log.error("Error counting failures. For safety sake we assume there were failures", e);
+ log
+ .error(
+ "Error counting failures. For safety sake we assume there were failures",
+ e);
} catch (SAXException e) {
- log.error("Error counting failures. For safety sake we assume there were failures", e);
+ log
+ .error(
+ "Error counting failures. For safety sake we assume there were failures",
+ e);
} catch (IOException e) {
- log.error("Error counting failures. For safety sake we assume there were failures", e);
+ log
+ .error(
+ "Error counting failures. For safety sake we assume there were failures",
+ e);
} catch (XPathExpressionException e) {
- log.error("Error counting failures. For safety sake we assume there were failures", e);
+ log
+ .error(
+ "Error counting failures. For safety sake we assume there were failures",
+ e);
}
return true;
}
@@ -346,7 +365,7 @@
*
* @param schematronRulesDefinition
* the given Schematron rule definition
- * @throws ActionLifecycleException
+ * @throws ActionLifecycleException
*/
private void compileSchematronRulesRefinition(
String schematronRulesDefinition) throws ActionLifecycleException {
@@ -487,7 +506,7 @@
+ payload.getClass().getName() + "'");
}
}
-
+
/**
* Parses the passed-in ESB {@link ConfigTree} and populates a
* {@link TransformerFactoryConfig}.
More information about the jboss-svn-commits
mailing list