Author: slaws
Date: Fri Oct  9 16:13:41 2009
New Revision: 823604

URL: http://svn.apache.org/viewvc?rev=823604&view=rev
Log:
TUSCANY-3231 fail if property has many values and many="false". Re-applied the 
fix from the base class to the new builders. 

Modified:
    
tuscany/java/sca/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties
    
tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java

Modified: 
tuscany/java/sca/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties?rev=823604&r1=823603&r2=823604&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties
 (original)
+++ 
tuscany/java/sca/modules/assembly/src/main/resources/org/apache/tuscany/sca/assembly/builder/assembly-validation-messages.properties
 Fri Oct  9 16:13:41 2009
@@ -65,9 +65,10 @@
 PropertySourceNotFound = The property source {0} for property {1} in component 
{2} cannot be resolved to a composite property
 PropertySourceValueInvalid = The property source {0} for property {1} in 
component {2} has an invalid value. It should start with $ followed by the name 
of a composite property
 PropertySourceXPathInvalid = The property source {0} for property {1} in 
component {2} has an invalid XPath expression. The following error was returned 
while processing the XPath expression: {3}
-PropertySourceXPathInvalid = The property file {0} for property {1} in 
component {2} is an invalid value. The following error was returned while 
processing the file name: {3}
+PropertyFileValueInvalid = The property file {0} for property {1} in component 
{2} is an invalid value. The following error was returned while processing the 
file name: {3}
 PolicyRelatedException = Policy Related Exception occured due to : {0}
 IntentNotFound = Intent {0} is not defined in SCA definitions
 PolicySetNotFound = PolicySet {0} is not defined in SCA definitions
 MutuallyExclusiveIntents = [POL40009] Intent {0} and {1} are mutually 
exclusive 
-PropertyXpathExpressionReturnedNull = The property XPath expression for 
component {0} property {1} expression {2} did not match anything in the source 
property
\ No newline at end of file
+PropertyXpathExpressionReturnedNull = The property XPath expression for 
component {0} property {1} expression {2} did not match anything in the source 
property
+PropertyHasManyValues = The property component {0} property {1} has many 
values but its "many" attribute is set to false
\ No newline at end of file

Modified: 
tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
URL: 
http://svn.apache.org/viewvc/tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java?rev=823604&r1=823603&r2=823604&view=diff
==============================================================================
--- 
tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
 (original)
+++ 
tuscany/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
 Fri Oct  9 16:13:41 2009
@@ -310,6 +310,17 @@
                               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 @@
 
         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) {


Reply via email to