You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by va...@apache.org on 2010/07/07 00:56:08 UTC

svn commit: r961039 - in /ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/elang: xpath10/runtime/XPath10ExpressionRuntime.java xpath20/runtime/XPath20ExpressionRuntime.java

Author: vanto
Date: Tue Jul  6 22:56:07 2010
New Revision: 961039

URL: http://svn.apache.org/viewvc?rev=961039&view=rev
Log:
Logging for selectionFailure faults improved.

Modified:
    ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath10/runtime/XPath10ExpressionRuntime.java
    ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/XPath20ExpressionRuntime.java

Modified: ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath10/runtime/XPath10ExpressionRuntime.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath10/runtime/XPath10ExpressionRuntime.java?rev=961039&r1=961038&r2=961039&view=diff
==============================================================================
--- ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath10/runtime/XPath10ExpressionRuntime.java (original)
+++ ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath10/runtime/XPath10ExpressionRuntime.java Tue Jul  6 22:56:07 2010
@@ -123,11 +123,22 @@ public class XPath10ExpressionRuntime im
 
     public Node evaluateNode(OExpression cexp, EvaluationContext ctx) throws FaultException, EvaluationException {
         List retVal = evaluate(cexp, ctx);
-        if (retVal.size() == 0)
-            throw new FaultException(cexp.getOwner().constants.qnSelectionFailure, "No results for expression: " + cexp);
-        if (retVal.size() > 1)
-            throw new FaultException(cexp.getOwner().constants.qnSelectionFailure, "Multiple results for expression: "
-                    + cexp);
+        if (retVal.size() == 0 || retVal.size() > 1) {
+            StringBuffer msg = new StringBuffer((retVal.size() == 0) ? "No results for expression: '" : "Multiple results for expression: '");
+            if (cexp instanceof OXPath10Expression) {
+                msg.append(((OXPath10Expression)cexp).xpath);
+            } else {
+                msg.append(cexp.toString());                
+            }
+            msg.append("'");
+            if (ctx.getRootNode() != null) {
+                msg.append(" against '");
+                msg.append(DOMUtils.domToString(ctx.getRootNode()));
+                msg.append("'");
+            }
+            throw new FaultException(cexp.getOwner().constants.qnSelectionFailure, msg.toString());
+        }
+            
         return (Node) retVal.get(0);
     }
 

Modified: ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/XPath20ExpressionRuntime.java
URL: http://svn.apache.org/viewvc/ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/XPath20ExpressionRuntime.java?rev=961039&r1=961038&r2=961039&view=diff
==============================================================================
--- ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/XPath20ExpressionRuntime.java (original)
+++ ode/trunk/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/XPath20ExpressionRuntime.java Tue Jul  6 22:56:07 2010
@@ -165,10 +165,25 @@ public class XPath20ExpressionRuntime im
 
     public Node evaluateNode(OExpression cexp, EvaluationContext ctx) throws FaultException, EvaluationException {
         List retVal = evaluate(cexp, ctx);
-        if (retVal.size() == 0)
-            throw new FaultException(cexp.getOwner().constants.qnSelectionFailure, "No results for expression: " + cexp, new Throwable("ignoreMissingFromData"));
-        if (retVal.size() > 1)
-            throw new FaultException(cexp.getOwner().constants.qnSelectionFailure, "Multiple results for expression: " + cexp);
+        if (retVal.size() == 0 || retVal.size() > 1) {
+            StringBuffer msg = new StringBuffer((retVal.size() == 0) ? "No results for expression: '" : "Multiple results for expression: '");
+            if (cexp instanceof OXPath10Expression) {
+                msg.append(((OXPath10Expression)cexp).xpath);
+            } else {
+                msg.append(cexp.toString());                
+            }
+            msg.append("'");
+            if (ctx.getRootNode() != null) {
+                msg.append(" against '");
+                msg.append(DOMUtils.domToString(ctx.getRootNode()));
+                msg.append("'");
+            }
+
+            if (retVal.size() == 0)
+                throw new FaultException(cexp.getOwner().constants.qnSelectionFailure, msg.toString(), new Throwable("ignoreMissingFromData"));
+            if (retVal.size() > 1)
+                throw new FaultException(cexp.getOwner().constants.qnSelectionFailure, msg.toString());
+        }
         return (Node) retVal.get(0);
     }