diff options
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; + } } |