diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 16:38:32 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-11 16:38:32 +0000 |
commit | 5b661a4d43094c3e1dd2651187edf2d9a0e453f7 (patch) | |
tree | c809cb822c9a7d08d2421715f6651e83a839c4c1 /java/sca | |
parent | 2a91173b12e0e4238f6c858dfd2f21b2bc144927 (diff) |
Check that the intent maps in a policy set are unique POL_3009
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@834952 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
3 files changed, 28 insertions, 2 deletions
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java index e647d1e575..4b62c7dbea 100644 --- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java +++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java @@ -194,7 +194,6 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA readIntentMap(reader, policySet, mappedIntent, context); } else { error(monitor, "IntentNotSpecified", policySet, policySetName); - //throw new ContributionReadException("Intent Map provides for Intent not specified as provided by parent PolicySet - " + policySetName); } } else { error(monitor, "IntentMapProvidesMissing", reader, policySetName); @@ -248,7 +247,16 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA QName intentName = getQName(reader, INTENT_MAP); intentMap.setProvidedIntent(mappedIntent); - policySet.getIntentMaps().add(intentMap); + if (!policySet.getIntentMaps().contains(intentMap)){ + policySet.getIntentMaps().add(intentMap); + } else { + Monitor.error(context.getMonitor(), + this, + Messages.RESOURCE_BUNDLE, + "IntentMapIsNotUnique", + policySet.getName().toString(), + mappedIntent.getName().getLocalPart()); + } String qualifierName = null; String qualfiedIntentName = null; diff --git a/java/sca/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/policy/xml/policy-xml-validation-messages.properties b/java/sca/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/policy/xml/policy-xml-validation-messages.properties index c889ce9447..012ff1c471 100644 --- a/java/sca/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/policy/xml/policy-xml-validation-messages.properties +++ b/java/sca/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/policy/xml/policy-xml-validation-messages.properties @@ -45,3 +45,4 @@ ConstrainedTypeNotFound = Unable to find the extension type {0} constrained by i MultipleDefaultQualifiers = [POL30004] Intent {0} has more than one qualifier marked as the default qualifier QualifierIsNotUnique = [POL30005] The intent {0} has more than one qualifier with the name {1} ProfileIntentNameWithPeriod = [POL30006] The profile intent name {0} must not have the character "." in it +IntentMapIsNotUnique = [POL30010] The policy set {0} has more than one intent map with the name {1} diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java index 6e2941ff5c..357b7afab4 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/policy/impl/IntentMapImpl.java @@ -58,4 +58,21 @@ public class IntentMapImpl implements IntentMap { public List<Qualifier> getQualifiers() { return qualifiers; } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + IntentMapImpl other = (IntentMapImpl)obj; + if (providedIntent == null) { + if (other.providedIntent != null) + return false; + } else if (!providedIntent.equals(other.providedIntent)) + return false; + return true; + } } |