From a000967da541dc7f51c0380a000f09846c88f739 Mon Sep 17 00:00:00 2001 From: antelder Date: Tue, 25 Aug 2009 13:31:34 +0000 Subject: Fix TUSCANY-3231 and ASM_5029, spot that property with many=false has multiple value elements git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@807619 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java | 8 +++++++- .../apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java | 2 +- .../org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java | 4 ++-- .../tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) (limited to 'java/sca') diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java index bab3b94ba4..0c0614ef8a 100644 --- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java +++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java @@ -514,7 +514,7 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor { * @throws ContributionReadException * @throws ParserConfigurationException */ - protected Document readPropertyValue(QName element, QName type, XMLStreamReader reader) throws XMLStreamException, + protected Document readPropertyValue(QName element, QName type, boolean isMany, XMLStreamReader reader) throws XMLStreamException, ContributionReadException { Document document; try { @@ -565,6 +565,7 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor { valueElement.setTextContent(valueAttr); } + boolean gotOneValue = false; boolean isTextForProperty = true; StringBuffer text = new StringBuffer(); @@ -587,7 +588,12 @@ abstract class BaseAssemblyProcessor extends BaseStAXArtifactProcessor { } // Read if (VALUE_QNAME.equals(name)) { + if (gotOneValue && !isMany) { + // TODO: TUSCANY-3231 this should be error not warning but that breaks OASIS tests + warning("ASM50032: multiple value elements for single-valued property", name, name); + } loadElement(reader, root); + gotOneValue = true; } else { // Global elements loadElement(reader, root); diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java index 0ea78177ff..aee2d89b7c 100644 --- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java +++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ComponentTypeProcessor.java @@ -140,7 +140,7 @@ public class ComponentTypeProcessor extends BaseAssemblyProcessor implements StA policyProcessor.readPolicies(property, reader); // Read the property value - Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader); + Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), property.isMany(), reader); property.setValue(value); componentType.getProperties().add(property); diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java index 581901a32e..d47059bac5 100644 --- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java +++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java @@ -369,7 +369,7 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt readAbstractProperty(componentProperty, reader); // Read the property value - Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader); + Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), property.isMany(), reader); property.setValue(value); component.getProperties().add(componentProperty); @@ -381,7 +381,7 @@ public class CompositeProcessor extends BaseAssemblyProcessor implements StAXArt readAbstractProperty(property, reader); // Read the property value - Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), reader); + Document value = readPropertyValue(property.getXSDElement(), property.getXSDType(), property.isMany(), reader); property.setValue(value); composite.getProperties().add(property); diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java index 34c4bc9909..bf53be5dfa 100644 --- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java +++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ConstrainingTypeProcessor.java @@ -127,7 +127,7 @@ public class ConstrainingTypeProcessor extends BaseAssemblyProcessor implements readAbstractProperty(abstractProperty, reader); // Read the property value - Document value = readPropertyValue(abstractProperty.getXSDElement(), abstractProperty.getXSDType(), reader); + Document value = readPropertyValue(abstractProperty.getXSDElement(), abstractProperty.getXSDType(), abstractProperty.isMany(), reader); abstractProperty.setValue(value); constrainingType.getProperties().add(abstractProperty); -- cgit v1.2.3