Author: olamy
Date: Fri Dec  7 22:34:44 2012
New Revision: 1418526

URL: http://svn.apache.org/viewvc?rev=1418526&view=rev
Log:
modify the logic as commons-configuration will store 
'ou=People,dc=archiva,dc=apache,dc=org' in a 'List' mode due to comma separator 
so using getProperty do not retrieve all values.
So moving to getList for String an concat them using defaut delimiter comma.
it's backward compat.

Modified:
    
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/main/java/org/apache/archiva/redback/components/registry/modello/AbstractRegistryGenerator.java
    
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/main/resources/org/apache/archiva/redback/components/registry/modello/RegistryReader.java.vm
    
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/test/java/org/apache/archiva/redback/components/registry/modello/AbstractRegistryGeneratorTestCase.java
    
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/test/resources/model.mdo
    
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/test/verifiers/registry-reader/RegistryReaderVerifier.java
    
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/test/verifiers/registry-reader/test.xml

Modified: 
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/main/java/org/apache/archiva/redback/components/registry/modello/AbstractRegistryGenerator.java
URL: 
http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/main/java/org/apache/archiva/redback/components/registry/modello/AbstractRegistryGenerator.java?rev=1418526&r1=1418525&r2=1418526&view=diff
==============================================================================
--- 
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/main/java/org/apache/archiva/redback/components/registry/modello/AbstractRegistryGenerator.java
 (original)
+++ 
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/main/java/org/apache/archiva/redback/components/registry/modello/AbstractRegistryGenerator.java
 Fri Dec  7 22:34:44 2012
@@ -50,6 +50,7 @@ public abstract class AbstractRegistryGe
 
         Context context = makeStubVelocityContext( model, 
getGeneratedVersion(), packageName );
 
+
         // Generate the reader
         String className = model.getName() + outputType;
 

Modified: 
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/main/resources/org/apache/archiva/redback/components/registry/modello/RegistryReader.java.vm
URL: 
http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/main/resources/org/apache/archiva/redback/components/registry/modello/RegistryReader.java.vm?rev=1418526&r1=1418525&r2=1418526&view=diff
==============================================================================
--- 
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/main/resources/org/apache/archiva/redback/components/registry/modello/RegistryReader.java.vm
 (original)
+++ 
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/main/resources/org/apache/archiva/redback/components/registry/modello/RegistryReader.java.vm
 Fri Dec  7 22:34:44 2012
@@ -43,13 +43,30 @@ import ${class.packageName}.${class.name
 #elseif ( $type == "float" )
     $javaTool.fail( "Type not yet handled: $type" )
 #elseif ( $type == "int" )
-        $type $localVar = ${registryVar}.getInt( prefix + "${name}", $getter );
+    $type $localVar = ${registryVar}.getInt( prefix + "${name}", $getter );
 #elseif ( $type == "long" )
     $javaTool.fail( "Type not yet handled: $type" )
 #elseif ( $type == "short" )
     $javaTool.fail( "Type not yet handled: $type" )
 #elseif ( $type == "String" )
-        $type $localVar = ${registryVar}.getString( prefix + "${name}", 
$getter );
+    //$type $localVar = ${registryVar}.getString( prefix + "${name}", $getter 
);
+
+    List<String> ${localVar}List = registry.getList( prefix + "${name}" );
+    String ${name} = $getter;
+    if (${localVar}List != null && !${localVar}List.isEmpty() )
+    {
+        StringBuilder sb = new StringBuilder(  );
+        for (int i = 0,size = ${localVar}List.size();i<size;i++)
+        {
+            sb.append( ${localVar}List.get( i ) );
+            if (i<size - 1)
+            {
+                sb.append( ',' );
+            }
+        }
+        ${name} = sb.toString();
+    }
+
 #elseif ( $type == "Boolean" )
     $javaTool.fail( "Type not yet handled: $type" )
 #elseif ( $type == "Date" )
@@ -77,7 +94,7 @@ import ${class.packageName}.${class.name
 #end
 
 /**
- * Generate Plexus Registry input mechanism for model '${model.name}'.
+ * Generate Redback Registry input mechanism for model '${model.name}'.
  */
 public class ${model.name}RegistryReader
 {

Modified: 
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/test/java/org/apache/archiva/redback/components/registry/modello/AbstractRegistryGeneratorTestCase.java
URL: 
http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/test/java/org/apache/archiva/redback/components/registry/modello/AbstractRegistryGeneratorTestCase.java?rev=1418526&r1=1418525&r2=1418526&view=diff
==============================================================================
--- 
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/test/java/org/apache/archiva/redback/components/registry/modello/AbstractRegistryGeneratorTestCase.java
 (original)
+++ 
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/test/java/org/apache/archiva/redback/components/registry/modello/AbstractRegistryGeneratorTestCase.java
 Fri Dec  7 22:34:44 2012
@@ -25,13 +25,17 @@ import org.codehaus.modello.ModelloParam
 import org.codehaus.modello.core.ModelloCore;
 import org.codehaus.modello.model.Model;
 import org.codehaus.modello.model.ModelValidationException;
-import org.codehaus.plexus.compiler.CompilerException;
+import org.codehaus.plexus.compiler.*;
+import org.codehaus.plexus.compiler.javac.JavacCompiler;
 import 
org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.ReaderFactory;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
 import java.util.Properties;
 
 public abstract class AbstractRegistryGeneratorTestCase
@@ -95,4 +99,50 @@ public abstract class AbstractRegistryGe
 
         compile( generatedSources, classes );
     }
+
+    protected void compile( File generatedSources, File destinationDirectory )
+        throws IOException, CompilerException
+    {
+        addDependency( "junit", "junit", "3.8.1" );
+
+        addDependency( "org.codehaus.plexus", "plexus-utils", "1.4.5" );
+
+        addDependency( "org.codehaus.modello", "modello-test", 
getModelloVersion() );
+
+        String[] classPathElements = new String[getClasspath().size() + 2];
+
+        classPathElements[0] = getTestPath( "target/classes" );
+
+        classPathElements[1] = getTestPath( "target/test-classes" );
+
+        for ( int i = 0; i < getClasspath().size(); i++ )
+        {
+            classPathElements[i + 2] = ( (File) getClasspath().get( i ) 
).getAbsolutePath();
+        }
+
+        String[] sourceDirectories =
+            new String[]{getTestPath( "src/test/verifiers/" + getName() ), 
generatedSources.getAbsolutePath()};
+
+        org.codehaus.plexus.compiler.Compiler compiler = new JavacCompiler();
+
+        CompilerConfiguration configuration = new CompilerConfiguration();
+        configuration.setClasspathEntries( Arrays.asList( classPathElements ) 
);
+        configuration.setSourceLocations( Arrays.asList( sourceDirectories ) );
+        configuration.setOutputLocation( 
destinationDirectory.getAbsolutePath() );
+        configuration.setDebug( true );
+        configuration.setSourceVersion( "1.5" );
+        configuration.setTargetVersion( "1.5" );
+
+        List messages = compiler.compile( configuration );
+
+        for ( Iterator it = messages.iterator(); it.hasNext(); )
+        {
+            CompilerError message = (CompilerError) it.next();
+
+            System.out.println( message.getFile() + "[" + 
message.getStartLine() + "," + message.getStartColumn() +
+                                    "]: " + message.getMessage() );
+        }
+
+        assertEquals( "There was compilation errors.", 0, messages.size() );
+    }
 }

Modified: 
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/test/resources/model.mdo
URL: 
http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/test/resources/model.mdo?rev=1418526&r1=1418525&r2=1418526&view=diff
==============================================================================
--- 
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/test/resources/model.mdo
 (original)
+++ 
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/test/resources/model.mdo
 Fri Dec  7 22:34:44 2012
@@ -128,6 +128,12 @@
             <multiplicity>*</multiplicity>
           </association>
         </field>
+        <field>
+          <name>baseDn</name>
+          <description>The LDAP base dn.</description>
+          <version>1.0.0+</version>
+          <type>String</type>
+        </field>
       </fields>
     </class>
     <class>

Modified: 
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/test/verifiers/registry-reader/RegistryReaderVerifier.java
URL: 
http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/test/verifiers/registry-reader/RegistryReaderVerifier.java?rev=1418526&r1=1418525&r2=1418526&view=diff
==============================================================================
--- 
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/test/verifiers/registry-reader/RegistryReaderVerifier.java
 (original)
+++ 
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/test/verifiers/registry-reader/RegistryReaderVerifier.java
 Fri Dec  7 22:34:44 2012
@@ -29,6 +29,8 @@ import org.apache.archiva.redback.compon
 import junit.framework.Assert;
 
 import java.io.File;
+import java.lang.AssertionError;
+import java.lang.System;
 import java.util.*;
 
 
@@ -87,5 +89,9 @@ public class RegistryReaderVerifier
         Assert.assertEquals( "def", model.getDefString() );
         Assert.assertEquals( 8080, model.getDefNumeric() );
         Assert.assertEquals( true, model.isDefBoolean() );
+
+        System.out.println("baseDn:" + model.getBaseDn());
+
+        Assert.assertEquals( "ou=People,dc=archiva,dc=apache,dc=org", 
model.getBaseDn() );
     }
 }

Modified: 
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/test/verifiers/registry-reader/test.xml
URL: 
http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/test/verifiers/registry-reader/test.xml?rev=1418526&r1=1418525&r2=1418526&view=diff
==============================================================================
--- 
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/test/verifiers/registry-reader/test.xml
 (original)
+++ 
archiva/redback/redback-components/trunk/spring-registry/modello-plugin-redback-registry/src/test/verifiers/registry-reader/test.xml
 Fri Dec  7 22:34:44 2012
@@ -44,4 +44,8 @@
       <else>value3</else>
     </something>
   </properties>
+  <baseDn>ou=People</baseDn>
+  <baseDn>dc=archiva</baseDn>
+  <baseDn>dc=apache</baseDn>
+  <baseDn>dc=org</baseDn>
 </configuration>


Reply via email to