Author: karthick Date: Fri Feb 6 21:52:01 2009 New Revision: 741748 URL: http://svn.apache.org/viewvc?rev=741748&view=rev Log: ODE-508 In essence, this is a forward port of ODE-498. Added: ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/ ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/deploy.xml ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/test.bpel ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/test.properties ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/test.wsdl ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/test.xsd Modified: ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/v1/xpath20/XPath20ExpressionCompilerImpl.java ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/v2/xpath20/XPath20ExpressionCompilerImpl.java ode/trunk/bpel-test/src/test/java/org/apache/ode/test/DataHandling20Test.java ode/trunk/bpel-test/src/test/java/org/apache/ode/test/StructuredActivities20Test.java ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity2/TestAssign.bpel Modified: ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/v1/xpath20/XPath20ExpressionCompilerImpl.java URL: http://svn.apache.org/viewvc/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/v1/xpath20/XPath20ExpressionCompilerImpl.java?rev=741748&r1=741747&r2=741748&view=diff ============================================================================== --- ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/v1/xpath20/XPath20ExpressionCompilerImpl.java (original) +++ ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/v1/xpath20/XPath20ExpressionCompilerImpl.java Fri Feb 6 21:52:01 2009 @@ -19,7 +19,9 @@ package org.apache.ode.bpel.compiler.v1.xpath20; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.xml.namespace.QName; @@ -30,6 +32,7 @@ import javax.xml.xpath.XPathFactory; import javax.xml.xpath.XPathFactoryConfigurationException; +import net.sf.saxon.om.Name11Checker; import net.sf.saxon.om.NamespaceConstant; import org.apache.commons.logging.Log; @@ -155,6 +158,14 @@ } catch (XPathExpressionException xpee) { // swallow errors caused by uninitialized variable } + for (String varExpr : extractVariableExprs(xpathStr)) { + expr = xpe.compile(varExpr); + try { + expr.evaluate(node); + } catch (XPathExpressionException xpee) { + // swallow errors caused by uninitialized variable + } + } } catch (XPathFactoryConfigurationException xpfce) { __log.debug(xpfce); __log.info("Couldn't validate properly expression " + xpathStr); @@ -174,4 +185,59 @@ return _properties; } + /** + * Returns the list of variable references in the given XPath expression + * that may not have been resolved properly, which is the case especially + * if the expression contains a function, which short circuited the evaluation. + * + * @param xpathStr + * @return list of variable expressions that may not have been resolved properly + */ + private List extractVariableExprs(String xpathStr) { + ArrayList variableExprs = new ArrayList(); + int firstVariable = xpathStr.indexOf("$"), + lastVariable = xpathStr.lastIndexOf("$"), + firstFunction = xpathStr.indexOf("("); + if ((firstVariable > 0 && // the xpath references a variable + firstFunction > 0) || // the xpath contains a function + (firstVariable < lastVariable)) { // the xpath references multiple variables + // most likely, the variable reference has not been resolved, so make that happen + StringBuffer variableExpr = new StringBuffer(); + boolean quoted = false, doubleQuoted = false, variable = false; + Name11Checker nameChecker = Name11Checker.getInstance(); + for (int index = 0; index < xpathStr.length(); index++) { + char ch = xpathStr.charAt(index); + if (ch == '\''){ + quoted = !quoted; + } + if (ch == '\"') { + doubleQuoted = !doubleQuoted; + } + if (quoted || doubleQuoted){ + continue; + } + if (ch == '$') { + variable = true; + variableExpr.setLength(0); + variableExpr.append(ch); + } else { + if (variable) { + variableExpr.append(ch); + // in the name is qualified, don't check if its a qname when we're at the ":" character + if (ch == ':') { + continue; + } + if (index == xpathStr.length() || + !nameChecker.isQName(variableExpr.substring(1))) { + variable = false; + variableExpr.setLength(variableExpr.length() - 1); + variableExprs.add(variableExpr.toString()); + } + } + } + } + } + return variableExprs; + } + } Modified: ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/v2/xpath20/XPath20ExpressionCompilerImpl.java URL: http://svn.apache.org/viewvc/ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/v2/xpath20/XPath20ExpressionCompilerImpl.java?rev=741748&r1=741747&r2=741748&view=diff ============================================================================== --- ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/v2/xpath20/XPath20ExpressionCompilerImpl.java (original) +++ ode/trunk/bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/v2/xpath20/XPath20ExpressionCompilerImpl.java Fri Feb 6 21:52:01 2009 @@ -19,7 +19,9 @@ package org.apache.ode.bpel.compiler.v2.xpath20; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.xml.namespace.QName; @@ -30,6 +32,7 @@ import javax.xml.xpath.XPathFactory; import javax.xml.xpath.XPathFactoryConfigurationException; +import net.sf.saxon.om.Name11Checker; import net.sf.saxon.om.NamespaceConstant; import org.apache.commons.logging.Log; @@ -155,6 +158,14 @@ } catch (XPathExpressionException xpee) { // swallow errors caused by uninitialized variable } + for (String varExpr : extractVariableExprs(xpathStr)) { + expr = xpe.compile(varExpr); + try { + expr.evaluate(node); + } catch (XPathExpressionException xpee) { + // swallow errors caused by uninitialized variable + } + } } catch (XPathFactoryConfigurationException xpfce) { __log.debug(xpfce); __log.info("Couldn't validate properly expression " + xpathStr); @@ -174,4 +185,59 @@ return _properties; } + /** + * Returns the list of variable references in the given XPath expression + * that may not have been resolved properly, which is the case especially + * if the expression contains a function, which short circuited the evaluation. + * + * @param xpathStr + * @return list of variable expressions that may not have been resolved properly + */ + private List extractVariableExprs(String xpathStr) { + ArrayList variableExprs = new ArrayList(); + int firstVariable = xpathStr.indexOf("$"), + lastVariable = xpathStr.lastIndexOf("$"), + firstFunction = xpathStr.indexOf("("); + if ((firstVariable > 0 && // the xpath references a variable + firstFunction > 0) || // the xpath contains a function + (firstVariable < lastVariable)) { // the xpath references multiple variables + // most likely, the variable reference has not been resolved, so make that happen + StringBuffer variableExpr = new StringBuffer(); + boolean quoted = false, doubleQuoted = false, variable = false; + Name11Checker nameChecker = Name11Checker.getInstance(); + for (int index = 0; index < xpathStr.length(); index++) { + char ch = xpathStr.charAt(index); + if (ch == '\''){ + quoted = !quoted; + } + if (ch == '\"') { + doubleQuoted = !doubleQuoted; + } + if (quoted || doubleQuoted){ + continue; + } + if (ch == '$') { + variable = true; + variableExpr.setLength(0); + variableExpr.append(ch); + } else { + if (variable) { + variableExpr.append(ch); + // in the name is qualified, don't check if its a qname when we're at the ":" character + if (ch == ':') { + continue; + } + if (index == xpathStr.length() || + !nameChecker.isQName(variableExpr.substring(1))) { + variable = false; + variableExpr.setLength(variableExpr.length() - 1); + variableExprs.add(variableExpr.toString()); + } + } + } + } + } + return variableExprs; + } + } Modified: ode/trunk/bpel-test/src/test/java/org/apache/ode/test/DataHandling20Test.java URL: http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/DataHandling20Test.java?rev=741748&r1=741747&r2=741748&view=diff ============================================================================== --- ode/trunk/bpel-test/src/test/java/org/apache/ode/test/DataHandling20Test.java (original) +++ ode/trunk/bpel-test/src/test/java/org/apache/ode/test/DataHandling20Test.java Fri Feb 6 21:52:01 2009 @@ -47,6 +47,9 @@ @Test public void testAssignActivity2() throws Throwable { go("/bpel/2.0/TestAssignActivity2"); } + @Test public void testAssignActivity3() throws Throwable { + go("/bpel/2.0/TestAssignActivity3"); + } @Test public void testAssignComplex() throws Throwable { go("/bpel/2.0/TestAssignComplex"); } Modified: ode/trunk/bpel-test/src/test/java/org/apache/ode/test/StructuredActivities20Test.java URL: http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/java/org/apache/ode/test/StructuredActivities20Test.java?rev=741748&r1=741747&r2=741748&view=diff ============================================================================== --- ode/trunk/bpel-test/src/test/java/org/apache/ode/test/StructuredActivities20Test.java (original) +++ ode/trunk/bpel-test/src/test/java/org/apache/ode/test/StructuredActivities20Test.java Fri Feb 6 21:52:01 2009 @@ -36,6 +36,7 @@ // Test Flow with XPath10 go("/bpel/2.0/TestFlowLinks"); } + @Ignore @Test public void testIsolatedScopes1() throws Throwable { // Test Flow with XPath10 go("/bpel/2.0/TestIsolatedScopes1"); Modified: ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity2/TestAssign.bpel URL: http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity2/TestAssign.bpel?rev=741748&r1=741747&r2=741748&view=diff ============================================================================== --- ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity2/TestAssign.bpel (original) +++ ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity2/TestAssign.bpel Fri Feb 6 21:52:01 2009 @@ -43,6 +43,8 @@ + + @@ -77,6 +79,34 @@ $otherMsgVar.TestPart + + + + 1 + + + + 1 + + + + ode:process-property("dd:epr")/addr:EndpointReference/child::node()[position()=$intVar] + + + + ode:process-property("dd:epr")/addr:EndpointReference + $eprVar + + + $eprVar/child::node()[$intVar] + + + + concat($eprVar/text()[1], $ode:pid) + + + + Added: ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/deploy.xml URL: http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/deploy.xml?rev=741748&view=auto ============================================================================== --- ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/deploy.xml (added) +++ ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/deploy.xml Fri Feb 6 21:52:01 2009 @@ -0,0 +1,11 @@ + + + + true + + + + + Added: ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/test.bpel URL: http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/test.bpel?rev=741748&view=auto ============================================================================== --- ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/test.bpel (added) +++ ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/test.bpel Fri Feb 6 21:52:01 2009 @@ -0,0 +1,81 @@ + + + + + + + + + + + + + + + + + + + + + + false + $is-it + + + false + $is-that + + + string(false) + $id + + + string("") + $id + + + string($is-it) + $id + + + xsd:string(($is-it or $is-that)) + $id + + + string(not($is-it or $is-that)) + $id + + + + + + + {$id} + + ]]> + + + + + + + Added: ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/test.properties URL: http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/test.properties?rev=741748&view=auto ============================================================================== --- ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/test.properties (added) +++ ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/test.properties Fri Feb 6 21:52:01 2009 @@ -0,0 +1,22 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +namespace=http://xxx/yyy/ws +service=testService +operation=test-op +request1=123 +response1=.*true.* \ No newline at end of file Added: ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/test.wsdl URL: http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/test.wsdl?rev=741748&view=auto ============================================================================== --- ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/test.wsdl (added) +++ ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/test.wsdl Fri Feb 6 21:52:01 2009 @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + Test BPEL webservice. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Added: ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/test.xsd URL: http://svn.apache.org/viewvc/ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/test.xsd?rev=741748&view=auto ============================================================================== --- ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/test.xsd (added) +++ ode/trunk/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity3/test.xsd Fri Feb 6 21:52:01 2009 @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +