summaryrefslogtreecommitdiffstats
path: root/java/sca
diff options
context:
space:
mode:
authorramkumar <ramkumar@13f79535-47bb-0310-9956-ffa450edef68>2009-11-16 11:57:01 +0000
committerramkumar <ramkumar@13f79535-47bb-0310-9956-ffa450edef68>2009-11-16 11:57:01 +0000
commit81d3b65d274e57f93a5dc769be126d35aa3ac652 (patch)
tree5169a2a2420e9c0c08a6ef66c47e366e3066fb9a /java/sca
parentabea253e89cc96d0c08b33f2c866cb6f9419b4db (diff)
Fixes for validating uniqueness in <import.java> and <export.java>
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@880717 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca')
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java26
-rw-r--r--java/sca/modules/contribution/src/main/resources/contribution-xml-validation-messages.properties3
2 files changed, 27 insertions, 2 deletions
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java
index 4700041775..eebc49edbb 100644
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java
+++ b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/xml/ContributionMetadataProcessor.java
@@ -34,6 +34,8 @@ import org.apache.tuscany.sca.contribution.ContributionFactory;
import org.apache.tuscany.sca.contribution.ContributionMetadata;
import org.apache.tuscany.sca.contribution.Export;
import org.apache.tuscany.sca.contribution.Import;
+import org.apache.tuscany.sca.contribution.java.JavaImport;
+import org.apache.tuscany.sca.contribution.java.JavaExport;
import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
@@ -157,8 +159,30 @@ public class ContributionMetadataProcessor extends BaseStAXArtifactProcessor imp
Object extension = extensionProcessor.read(reader, context);
if (extension != null && contribution != null) {
if (extension instanceof Import) {
- contribution.getImports().add((Import)extension);
+ // The value of the @package attribute on the <import.java/> element MUST be
+ // unique across all other <import.java/> elements within the contribution.
+ if (extension instanceof JavaImport) {
+ for (Import imports : contribution.getImports()) {
+ if (imports instanceof JavaImport) {
+ if (((JavaImport)extension).getPackage().equals(((JavaImport) imports).getPackage())) {
+ error(context.getMonitor(), "DuplicateJavaImports", reader);
+ }
+ }
+ }
+ }
+ contribution.getImports().add((Import)extension);
} else if (extension instanceof Export) {
+ // The value of the @package attribute on the <export.java/> element MUST be
+ // unique across all other <export.java/> elements within the contribution.
+ if (extension instanceof JavaExport) {
+ for (Export exports : contribution.getExports()) {
+ if (exports instanceof JavaExport) {
+ if (((JavaExport)extension).getPackage().equals(((JavaExport) exports).getPackage())) {
+ error(context.getMonitor(), "DuplicateJavaExports", reader);
+ }
+ }
+ }
+ }
contribution.getExports().add((Export)extension);
} else {
contribution.getExtensions().add(extension);
diff --git a/java/sca/modules/contribution/src/main/resources/contribution-xml-validation-messages.properties b/java/sca/modules/contribution/src/main/resources/contribution-xml-validation-messages.properties
index 4827fd5e94..2c39055e4b 100644
--- a/java/sca/modules/contribution/src/main/resources/contribution-xml-validation-messages.properties
+++ b/java/sca/modules/contribution/src/main/resources/contribution-xml-validation-messages.properties
@@ -21,4 +21,5 @@
XMLStreamException = XMLStreamException occured due to : {0}
IOException = IOException occured due to : {0}
AttributeCompositeMissing = Attribute 'composite' is missing
-
+DuplicateJavaImports = The value of the @package attribute on the <import.java/> element is not unique across all other <import.java/> elements within the contribution.
+DuplicateJavaExports = The value of the @package attribute on the <export.java/> element is not unique across all other <export.java/> elements within the contribution.