summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-11-11 18:48:11 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2009-11-11 18:48:11 +0000
commit73bbcb40d4e6f211bd1c2ca06374dc7de378236a (patch)
tree5ad38d1e47cb26e57cb46ac6c6bce7ce164cefb6
parent9d6f2d2fd74f310f2c9a87a69f44ac7091f450d3 (diff)
Add validation for missing intent map qualifiers - POL_3017
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@835009 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/policy/xml/PolicySetProcessor.java28
-rw-r--r--java/sca/modules/assembly-xml/src/main/resources/org/apache/tuscany/sca/policy/xml/policy-xml-validation-messages.properties1
2 files changed, 29 insertions, 0 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 5b143e0db8..ed62e0a406 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
@@ -459,6 +459,34 @@ public class PolicySetProcessor extends BaseStAXArtifactProcessor implements StA
// FIXME: How to resolve the policies?
}
}
+ // validate that the intent map has a qualifier for each
+ // intent qualifier. The above code has already checked that the
+ // qualifiers that are there are resolved
+ Intent providedIntent = intentMap.getProvidedIntent();
+ if (intentMap.getQualifiers().size() != providedIntent.getQualifiedIntents().size()){
+ String missingQualifiers = "";
+ for (Intent loopQualifiedIntent : providedIntent.getQualifiedIntents()){
+ boolean found = false;
+ for (Qualifier loopQualifier : intentMap.getQualifiers()){
+ if (loopQualifier.getIntent().getName().equals(loopQualifiedIntent.getName())){
+ found = true;
+ break;
+ }
+ }
+ if (!found){
+ missingQualifiers += loopQualifiedIntent.getName().getLocalPart() + " ";
+ }
+ }
+ if (missingQualifiers.length() > 0){
+ Monitor.error(context.getMonitor(),
+ this,
+ Messages.RESOURCE_BUNDLE,
+ "IntentMapMissingQualifiers",
+ policySet.getName().toString(),
+ providedIntent.getName().getLocalPart(),
+ missingQualifiers);
+ }
+ }
}
}
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 012ff1c471..b61f004b32 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
@@ -46,3 +46,4 @@ MultipleDefaultQualifiers = [POL30004] Intent {0} has more than one qualifier ma
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}
+IntentMapMissingQualifiers = [POL30020] The policy set {0} intent map {1} has missing qualifiers: {2} The intent map qualifiers must match the provided intent qualifiers.