You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by bd...@apache.org on 2010/08/05 04:55:46 UTC

svn commit: r982457 - /tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java

Author: bdaniel
Date: Thu Aug  5 02:55:46 2010
New Revision: 982457

URL: http://svn.apache.org/viewvc?rev=982457&view=rev
Log:
Ensure that if a single PolicySet can be attached either directly or externally, the external version takes priority

Modified:
    tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java

Modified: tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java?rev=982457&r1=982456&r2=982457&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java Thu Aug  5 02:55:46 2010
@@ -21,6 +21,8 @@ package org.apache.tuscany.sca.builder.i
 
 import java.io.IOException;
 import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
@@ -183,6 +185,13 @@ public class PolicyAttachmentBuilderImpl
 		        PolicySubject subject = lookup(composite, index);
 		        if (subject != null) {
 		        	ps.setIsExternalAttachment(true);
+		        	// Remove any PolicySets with the same name that may have been added
+		        	List<PolicySet> subjectPSCopy = new ArrayList<PolicySet>(subject.getPolicySets());
+		        	for ( PolicySet existingPS : subjectPSCopy ) {
+		        		if ( existingPS.getName().equals(ps.getName()) ) {
+		        			subject.getPolicySets().remove(existingPS);
+		        		}
+		        	}
 		        	subject.getPolicySets().add(ps);
 		        } else {
 		        	// raise a warning that the XPath node didn't match a node in the