From 2c4fb4511421e0e82c46f0e3297b2faf6a40418e Mon Sep 17 00:00:00 2001 From: slaws Date: Fri, 9 Oct 2009 16:13:41 +0000 Subject: TUSCANY-3231 fail if property has many values and many="false". Re-applied the fix from the base class to the new builders. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@823604 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/builder/impl/ComponentBuilderImpl.java | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'java/sca/modules/builder/src/main/java/org/apache/tuscany') diff --git a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java index 8ba5e98f68..76d5a850d1 100644 --- a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java +++ b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java @@ -310,6 +310,17 @@ public class ComponentBuilderImpl { component.getName(), componentProperty.getName()); } + + // check that not too many values are supplied + if (!componentProperty.isMany() && isPropertyManyValued(componentProperty)){ + Monitor.error(monitor, + this, + Messages.ASSEMBLY_VALIDATION, + "PropertyHasManyValues", + component.getName(), + componentProperty.getName()); + } + } } @@ -1003,6 +1014,23 @@ public class ComponentBuilderImpl { return true; } + + /** + * Look to see is a property has more than one value + * + * @param property + * @return true is the property has more than one value + */ + private boolean isPropertyManyValued(Property property) { + + if (isPropertyValueSet(property)){ + Document value = (Document)property.getValue(); + if (value.getFirstChild().getChildNodes().getLength() > 1){ + return true; + } + } + return false; + } private boolean isValidMultiplicityOverride(Multiplicity definedMul, Multiplicity overridenMul) { if (definedMul != overridenMul) { -- cgit v1.2.3