summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk
diff options
context:
space:
mode:
authorbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2010-08-05 02:55:46 +0000
committerbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2010-08-05 02:55:46 +0000
commit66fe1748dc4497df03c618a91be8ac0e07c7e715 (patch)
treef8e07e9045aae321e3d2885393b3579da6fd8006 /sca-java-2.x/trunk
parent656e1d2aaa6f4782609af6379fa01cdf43119a80 (diff)
Ensure that if a single PolicySet can be attached either directly or externally, the external version takes priority
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@982457 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk')
-rw-r--r--sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java
index 3930ac0e43..4d1a7d52b6 100644
--- a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java
+++ b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAttachmentBuilderImpl.java
@@ -21,6 +21,8 @@ package org.apache.tuscany.sca.builder.impl;
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 implements CompositeBuilder {
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