Author: sanka
Date: Fri May 5 11:52:50 2006
New Revision: 400141
URL: http://svn.apache.org/viewcvs?rev=400141&view=rev
Log:
applied the patch. see JIRA WSCOMMONS-19
Added:
webservices/commons/trunk/modules/neethi/test-resources/normalized/test25.xml
webservices/commons/trunk/modules/neethi/test-resources/samples/test25.xml
Modified:
webservices/commons/trunk/modules/neethi/src/org/apache/ws/policy/AndCompositeAssertion.java
webservices/commons/trunk/modules/neethi/src/org/apache/ws/policy/Policy.java
webservices/commons/trunk/modules/neethi/test/org/apache/ws/policy/NormalizeTest.java
Modified:
webservices/commons/trunk/modules/neethi/src/org/apache/ws/policy/AndCompositeAssertion.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/neethi/src/org/apache/ws/policy/AndCompositeAssertion.java?rev=400141&r1=400140&r2=400141&view=diff
==============================================================================
---
webservices/commons/trunk/modules/neethi/src/org/apache/ws/policy/AndCompositeAssertion.java
(original)
+++
webservices/commons/trunk/modules/neethi/src/org/apache/ws/policy/AndCompositeAssertion.java
Fri May 5 11:52:50 2006
@@ -446,44 +446,8 @@
// processing child-XORCompositeAssertions
if (XORs.size() > 1) {
-
- XorCompositeAssertion XOR_A, XOR_B;
-
- for (int i = 0; i < XORs.size(); i++) {
-
- for (int j = i; j < XORs.size(); j++) {
-
- if (i != j) {
- XOR_A = (XorCompositeAssertion)
XORs.get(i);
- XOR_B = (XorCompositeAssertion)
XORs.get(j);
-
- Iterator interatorA =
XOR_A.getTerms().iterator();
-
- Assertion anAND_A;
- Iterator iteratorB;
-
- while (interatorA.hasNext()) {
- anAND_A = (Assertion)
interatorA.next();
- iteratorB =
XOR_B.getTerms().iterator();
-
- Assertion anAND_B;
- AndCompositeAssertion
nAND;
-
- while
(iteratorB.hasNext()) {
-
- anAND_B =
(Assertion) iteratorB.next();
-
- nAND = new
AndCompositeAssertion();
-
nAND.addTerms(anAND_A.getTerms());
-
nAND.addTerms(anAND_B.getTerms());
-
-
XOR.addTerm(nAND);
- }
- }
- }
- }
- }
-
+ XOR.addTerms(Policy.crossProduct(XORs, 0));
+
} else if (XORs.size() == 1) {
Assertion XORterm = (Assertion) XORs.get(0);
XOR.addTerms(XORterm.getTerms());
Modified:
webservices/commons/trunk/modules/neethi/src/org/apache/ws/policy/Policy.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/neethi/src/org/apache/ws/policy/Policy.java?rev=400141&r1=400140&r2=400141&view=diff
==============================================================================
---
webservices/commons/trunk/modules/neethi/src/org/apache/ws/policy/Policy.java
(original)
+++
webservices/commons/trunk/modules/neethi/src/org/apache/ws/policy/Policy.java
Fri May 5 11:52:50 2006
@@ -205,34 +205,7 @@
// processing child-XORCompositeAssertions
if (childXorTermList.size() > 1) {
- for (int i = 0; i < childXorTermList.size(); i++) {
-
- for (int j = i; j < childXorTermList.size(); j++) {
-
- if (i != j) {
- XorCompositeAssertion xorTermA =
(XorCompositeAssertion) childXorTermList
- .get(i);
- XorCompositeAssertion xorTermB =
(XorCompositeAssertion) childXorTermList
- .get(j);
-
- Iterator iterA = xorTermA.getTerms().iterator();
-
- while (iterA.hasNext()) {
- Assertion andTermA = (Assertion) iterA.next();
-
- Iterator iterB = xorTermB.getTerms().iterator();
-
- while (iterB.hasNext()) {
- Assertion andTermB = (Assertion) iterB.next();
- AndCompositeAssertion anAndTerm = new
AndCompositeAssertion();
- anAndTerm.addTerms(andTermA.getTerms());
- anAndTerm.addTerms(andTermB.getTerms());
- XOR.addTerm(anAndTerm);
- }
- }
- }
- }
- }
+ XOR.addTerms(Policy.crossProduct(childXorTermList, 0));
} else if (childXorTermList.size() == 1) {
Assertion xorTerm = (Assertion) childXorTermList.get(0);
@@ -426,6 +399,43 @@
*/
public void clearAttributes() {
attributes.clear();
+ }
+
+ /**
+ * @param allTerms
+ * XorCompositeAssertion to be corssproducted
+ * @param index
+ * starting point of cross product
+ * @return
+ */
+ protected static ArrayList crossProduct(ArrayList allTerms, int index) {
+
+ ArrayList result = new ArrayList();
+ XorCompositeAssertion firstTerm = (XorCompositeAssertion) allTerms
+ .get(index);
+ ArrayList restTerms;
+
+ if (allTerms.size() == ++index) {
+ restTerms = new ArrayList();
+ AndCompositeAssertion newTerm = new AndCompositeAssertion();
+ restTerms.add(newTerm);
+ } else
+ restTerms = crossProduct(allTerms, index);
+
+ Iterator firstTermIter = firstTerm.getTerms().iterator();
+ while (firstTermIter.hasNext()) {
+ Assertion assertion = (Assertion) firstTermIter.next();
+ Iterator restTermsItr = restTerms.iterator();
+ while (restTermsItr.hasNext()) {
+ Assertion restTerm = (Assertion) restTermsItr.next();
+ AndCompositeAssertion newTerm = new AndCompositeAssertion();
+ newTerm.addTerms(assertion.getTerms());
+ newTerm.addTerms(restTerm.getTerms());
+ result.add(newTerm);
+ }
+ }
+
+ return result;
}
}
Added:
webservices/commons/trunk/modules/neethi/test-resources/normalized/test25.xml
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/neethi/test-resources/normalized/test25.xml?rev=400141&view=auto
==============================================================================
---
webservices/commons/trunk/modules/neethi/test-resources/normalized/test25.xml
(added)
+++
webservices/commons/trunk/modules/neethi/test-resources/normalized/test25.xml
Fri May 5 11:52:50 2006
@@ -0,0 +1,36 @@
+<wsp:Policy
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+ xmlns:tst="http://sample.org/Assertions">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <tst:A>A</tst:A>
+ <tst:B>B</tst:B>
+ <tst:C>C</tst:C>
+ </wsp:All>
+ <wsp:All>
+ <tst:A>A</tst:A>
+ </wsp:All>
+ <wsp:All>
+ <tst:B>B</tst:B>
+ </wsp:All>
+ <wsp:All>
+ <tst:C>C</tst:C>
+ </wsp:All>
+ <wsp:All>
+ <tst:A>A</tst:A>
+ <tst:B>B</tst:B>
+ </wsp:All>
+ <wsp:All>
+ <tst:A>A</tst:A>
+ <tst:C>C</tst:C>
+ </wsp:All>
+ <wsp:All>
+ <tst:B>B</tst:B>
+ <tst:C>C</tst:C>
+ </wsp:All>
+ <wsp:All>
+ </wsp:All>
+ </wsp:ExactlyOne>
+</wsp:Policy>
+
+
Added:
webservices/commons/trunk/modules/neethi/test-resources/samples/test25.xml
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/neethi/test-resources/samples/test25.xml?rev=400141&view=auto
==============================================================================
--- webservices/commons/trunk/modules/neethi/test-resources/samples/test25.xml
(added)
+++ webservices/commons/trunk/modules/neethi/test-resources/samples/test25.xml
Fri May 5 11:52:50 2006
@@ -0,0 +1,7 @@
+<wsp:Policy
+ xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+ xmlns:tst="http://sample.org/Assertions">
+ <tst:A wsp:Optional="true">A</tst:A>
+ <tst:B wsp:Optional="true">B</tst:B>
+ <tst:C wsp:Optional="true">C</tst:C>
+</wsp:Policy>
\ No newline at end of file
Modified:
webservices/commons/trunk/modules/neethi/test/org/apache/ws/policy/NormalizeTest.java
URL:
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/neethi/test/org/apache/ws/policy/NormalizeTest.java?rev=400141&r1=400140&r2=400141&view=diff
==============================================================================
---
webservices/commons/trunk/modules/neethi/test/org/apache/ws/policy/NormalizeTest.java
(original)
+++
webservices/commons/trunk/modules/neethi/test/org/apache/ws/policy/NormalizeTest.java
Fri May 5 11:52:50 2006
@@ -33,7 +33,7 @@
String r1, r2;
Policy p1, p2;
- for (int i = 1; i < 25; i++) {
+ for (int i = 1; i < 26; i++) {
r1 = "samples" + File.separator + "test" + i + ".xml";
r2 = "normalized" + File.separator + "test" + i +
".xml";