You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by ve...@apache.org on 2008/06/27 16:44:03 UTC
svn commit: r672287 - in
/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse:
mediators/builtin/ValidateMediator.java
mediators/transform/XSLTMediator.java util/xpath/SourceXPathSupport.java
Author: veithen
Date: Fri Jun 27 07:44:03 2008
New Revision: 672287
URL: http://svn.apache.org/viewvc?rev=672287&view=rev
Log:
Merged ValidateMediator#getValidationSource and XSLTMediator#getTransformationSource into a single method in SourceXPathSupport.
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/ValidateMediator.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/transform/XSLTMediator.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/util/xpath/SourceXPathSupport.java
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/ValidateMediator.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/ValidateMediator.java?rev=672287&r1=672286&r2=672287&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/ValidateMediator.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/builtin/ValidateMediator.java Fri Jun 27 07:44:03 2008
@@ -31,7 +31,6 @@
import org.apache.synapse.util.AXIOMUtils;
import org.apache.synapse.util.xpath.SourceXPathSupport;
import org.apache.synapse.util.xpath.SynapseXPath;
-import org.jaxen.JaxenException;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.DefaultHandler;
@@ -207,7 +206,7 @@
private Source getValidationSource(MessageContext synCtx, SynapseLog synLog) {
try {
- OMNode validateSource = getValidateSource(synCtx);
+ OMNode validateSource = source.selectOMNode(synCtx, synLog);
if (synLog.isTraceOrDebugEnabled()) {
synLog.traceOrDebug("Validation source : " + validateSource.toString());
}
@@ -258,29 +257,6 @@
}
}
- /**
- * Return the OMNode to be validated. If a source XPath is not specified, this will
- * default to the first child of the SOAP body i.e. - //*:Envelope/*:Body/child::*
- *
- * @param synCtx the message context
- * @return the OMNode against which validation should be performed
- */
- private OMNode getValidateSource(MessageContext synCtx) {
-
- try {
- Object o = source.selectSingleNode(synCtx); // Always fetches *only* the first
- if (o instanceof OMNode) {
- return (OMNode) o;
- } else {
- handleException("The evaluation of the XPath expression "
- + source + " did not result in an OMNode : " + o, synCtx);
- }
- } catch (JaxenException e) {
- handleException("Error evaluating XPath expression : " + source, e, synCtx);
- }
- return null;
- }
-
// setters and getters
/**
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/transform/XSLTMediator.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/transform/XSLTMediator.java?rev=672287&r1=672286&r2=672287&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/transform/XSLTMediator.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/transform/XSLTMediator.java Fri Jun 27 07:44:03 2008
@@ -42,7 +42,6 @@
import org.apache.synapse.util.AXIOMUtils;
import org.apache.synapse.util.TemporaryData;
import org.apache.synapse.util.TextFileDataSource;
-import org.jaxen.JaxenException;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -195,7 +194,7 @@
private void performXSLT(MessageContext synCtx, SynapseLog synLog) {
boolean reCreate = false;
- OMNode sourceNode = getTransformSource(synCtx);
+ OMNode sourceNode = source.selectOMNode(synCtx, synLog);
TemporaryData tempTargetData = null;
OutputStream osForTarget;
boolean isSoapEnvelope = (sourceNode == synCtx.getEnvelope());
@@ -407,29 +406,6 @@
}
}
- /**
- * Return the OMNode to be used for the transformation. If a source XPath is not specified,
- * this will default to the first child of the SOAP body i.e. - //*:Envelope/*:Body/child::*
- *
- * @param synCtx the message context
- * @return the OMNode against which the transformation should be performed
- */
- private OMNode getTransformSource(MessageContext synCtx) {
-
- try {
- Object o = source.selectSingleNode(synCtx); // Always fetches *only* the first
- if (o instanceof OMNode) {
- return (OMNode) o;
- } else {
- handleException("The evaluation of the XPath expression "
- + source + " did not result in an OMNode", synCtx);
- }
- } catch (JaxenException e) {
- handleException("Error evaluating XPath expression : " + source, e, synCtx);
- }
- return null;
- }
-
public SynapseXPath getSource() {
return source.getXPath();
}
Modified: synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/util/xpath/SourceXPathSupport.java
URL: http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/util/xpath/SourceXPathSupport.java?rev=672287&r1=672286&r2=672287&view=diff
==============================================================================
--- synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/util/xpath/SourceXPathSupport.java (original)
+++ synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/util/xpath/SourceXPathSupport.java Fri Jun 27 07:44:03 2008
@@ -19,7 +19,10 @@
package org.apache.synapse.util.xpath;
+import org.apache.axiom.om.OMNode;
import org.apache.synapse.MessageContext;
+import org.apache.synapse.SynapseException;
+import org.apache.synapse.SynapseLog;
import org.jaxen.JaxenException;
/**
@@ -67,20 +70,34 @@
}
/**
- * Select the first node selected by the configured XPath expression.
+ * Get the first node selected by the configured XPath expression.
* If no XPath expression is set, the first child element of the SOAP body
* is returned, i.e. in this case the method behaves as if the XPath expression is
* <code>s11:Body/child::*[position()=1] | s12:Body/child::*[position()=1]</code>.
*
* @param synCtx the message context
+ * @param synLog
* @return the first node selected by the XPath expression
- * @throws JaxenException
+ * @throws SynapseException
+ * if the evaluation of the XPath expression failed or didn't result in an
+ * {@link OMNode}
*/
- public Object selectSingleNode(MessageContext synCtx) throws JaxenException {
+ public OMNode selectOMNode(MessageContext synCtx, SynapseLog synLog) {
if (xpath == null) {
return synCtx.getEnvelope().getBody().getFirstElement();
} else {
- return xpath.selectSingleNode(synCtx);
+ Object result;
+ try {
+ result = xpath.selectSingleNode(synCtx);
+ } catch (JaxenException e) {
+ throw new SynapseException("Error evaluating XPath expression : " + xpath, e, synLog);
+ }
+ if (result instanceof OMNode) {
+ return (OMNode) result;
+ } else {
+ throw new SynapseException("The evaluation of the XPath expression "
+ + xpath + " did not result in an OMNode : " + result, synLog);
+ }
}
}