directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1043150 - in /directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config: ./ beans/
Date Tue, 07 Dec 2010 18:02:16 GMT
Author: pamarcelot
Date: Tue Dec  7 18:02:15 2010
New Revision: 1043150

URL: http://svn.apache.org/viewvc?rev=1043150&view=rev
Log:
Special handling for containers which needs to write the value of the RDN of their collection
of values to a particular attribute type in the entry.

Modified:
    directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/ConfigWriter.java
    directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/Main.java
    directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/DirectoryServiceBean.java
    directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/HttpServerBean.java
    directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/LdapServerBean.java
    directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/PartitionBean.java
    directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/ServerBean.java

Modified: directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/ConfigWriter.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/ConfigWriter.java?rev=1043150&r1=1043149&r2=1043150&view=diff
==============================================================================
--- directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/ConfigWriter.java
(original)
+++ directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/ConfigWriter.java
Tue Dec  7 18:02:15 2010
@@ -71,6 +71,7 @@ public class ConfigWriter
 
         // Writing the file to disk
         FileWriter writer = new FileWriter( file );
+        writer.append( "version: 1\n" );
         for ( LdifEntry entry : entries )
         {
             writer.append( entry.toString() );
@@ -173,6 +174,32 @@ public class ConfigWriter
     private static void addBean( DN rootDn, SchemaManager schemaManager, AdsBaseBean bean,
List<LdifEntry> entries )
         throws Exception
     {
+        addBean( rootDn, schemaManager, bean, entries, null, null );
+    }
+
+
+    /**
+     * Adds a configuration bean to the list of entries.
+     *
+     * @param rootDn
+     *      the current root DN
+     * @param schemaManager
+     *      the schema manager
+     * @param bean
+     *      the configuration bean
+     * @param entries
+     *      the list of the entries
+     * @param parentEntry
+     *      the parent entry
+     * @param attributeTypeForParentEntry
+     *      the attribute type to use when adding the value of 
+     *      the RDN to the parent entry
+     * @throws Exception
+     */
+    private static void addBean( DN rootDn, SchemaManager schemaManager, AdsBaseBean bean,
List<LdifEntry> entries,
+        LdifEntry parentEntry, String attributeTypeForParentEntry )
+        throws Exception
+    {
         if ( bean != null )
         {
             // Getting the class of the bean
@@ -212,45 +239,62 @@ public class ConfigWriter
                     ConfigurationElement configurationElement = field.getAnnotation( ConfigurationElement.class
);
                     if ( configurationElement != null )
                     {
-                        // Checking if we're dealing with an attribute type
+                        // Checking if we're have a value  for the attribute type
                         String attributeType = configurationElement.attributeType();
                         if ( ( attributeType != null ) && ( !"".equals( attributeType
) ) )
                         {
-                            addAttributeTypeValues( configurationElement.attributeType(),
fieldValue, entry );
-                            continue;
-                        }
-
-                        // Checking if we're dealing with a container
-                        String container = configurationElement.container();
-                        if ( ( container != null ) && ( !"".equals( container ) )
)
-                        {
-                            // Creating the entry for the container and adding it to the
list
-                            LdifEntry containerEntry = new LdifEntry();
-                            containerEntry.setDn( entry.getDn().add( new RDN( SchemaConstants.OU_AT,
container ) ) );
-                            addObjectClassAttribute( schemaManager, containerEntry,
-                                SchemaConstants.ORGANIZATIONAL_UNIT_OC );
-                            entries.add( containerEntry );
-
-                            if ( Collection.class.isAssignableFrom( fieldClass ) )
+                            // Checking if we're dealing with a container
+                            String container = configurationElement.container();
+                            if ( ( container != null ) && ( !"".equals( container
) ) )
                             {
-                                // Looping on the Collection's objects
-                                Collection<Object> collection = ( Collection<Object>
) fieldValue;
-                                for ( Object object : collection )
+                                // Creating the entry for the container and adding it to
the list
+                                LdifEntry containerEntry = new LdifEntry();
+                                containerEntry.setDn( entry.getDn().add( new RDN( SchemaConstants.OU_AT,
container ) ) );
+                                addObjectClassAttribute( schemaManager, containerEntry,
+                                    SchemaConstants.ORGANIZATIONAL_UNIT_OC );
+                                entries.add( containerEntry );
+
+                                if ( Collection.class.isAssignableFrom( fieldClass ) )
                                 {
-                                    if ( object instanceof AdsBaseBean )
+                                    // Looping on the Collection's objects
+                                    Collection<Object> collection = ( Collection<Object>
) fieldValue;
+                                    for ( Object object : collection )
                                     {
-                                        addBean( containerEntry.getDn(), schemaManager, (
AdsBaseBean ) object, entries );
-                                        continue;
-                                    }
-                                    else
-                                    {
-                                        // TODO throw an error, if we have a container, the
type must be a subtype of AdsBaseBean
+                                        if ( object instanceof AdsBaseBean )
+                                        {
+                                            // Adding the bean
+                                            addBean( containerEntry.getDn(), schemaManager,
( AdsBaseBean ) object,
+                                                entries, entry, attributeType );
+
+                                            continue;
+                                        }
+                                        else
+                                        {
+                                            // TODO throw an error, if we have a container,
the type must be a subtype of AdsBaseBean
+                                            throw new Exception();
+                                        }
                                     }
                                 }
+                                else
+                                {
+                                    // TODO throw an error, if we have a container, the type
must be a subtype of Collection
+                                    throw new Exception();
+                                }
                             }
                             else
                             {
-                                // TODO throw an error, if we have a container, the type
must be a subtype of Collection
+                                // Is it the field value used as RDN and do we need to insert
a value in the parent entry?
+                                if ( ( configurationElement.isRDN() ) && ( parentEntry
!= null )
+                                    && ( attributeTypeForParentEntry != null ) )
+                                {
+                                    // Adding the field value to the parent entry
+                                    addAttributeTypeValues( attributeTypeForParentEntry,
fieldValue, parentEntry );
+                                }
+
+                                // Adding values to the entry
+                                addAttributeTypeValues( configurationElement.attributeType(),
fieldValue, entry );
+
+                                continue;
                             }
                         }
 

Modified: directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/Main.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/Main.java?rev=1043150&r1=1043149&r2=1043150&view=diff
==============================================================================
--- directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/Main.java
(original)
+++ directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/Main.java
Tue Dec  7 18:02:15 2010
@@ -40,14 +40,16 @@ public class Main
         configPartition.setSuffix( new DN( "ou=config" ) );
         configPartition.setSchemaManager( schemaManager );
         configPartition.initialize();
-        
 
         ConfigPartitionReader cpReader = new ConfigPartitionReader( configPartition, new
File(
             "/Users/pajbam/Development/Apache/ApacheDS/apacheds/server-config/src/main/resources/"
) );
 
         ConfigBean configBean = cpReader.readConfig( new DN( "ou=config" ) );
-        
-        ConfigWriter.writeConfiguration( schemaManager, configBean, null );
-        
+
+        long t1 = System.currentTimeMillis();
+        ConfigWriter.writeConfiguration( schemaManager, configBean, "/Users/pajbam/Desktop/config.ldif"
);
+        long t2 = System.currentTimeMillis();
+
+        System.out.println( t2 - t1 );
     }
 }

Modified: directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/DirectoryServiceBean.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/DirectoryServiceBean.java?rev=1043150&r1=1043149&r2=1043150&view=diff
==============================================================================
--- directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/DirectoryServiceBean.java
(original)
+++ directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/DirectoryServiceBean.java
Tue Dec  7 18:02:15 2010
@@ -78,15 +78,15 @@ public class DirectoryServiceBean extend
     private JournalBean journal;
 
     /** The servers */
-    @ConfigurationElement(container = "servers")
+    @ConfigurationElement(attributeType = "ads-servers", container = "servers")
     private List<ServerBean> servers = new ArrayList<ServerBean>();
 
     /** The list of declared interceptors */
-    @ConfigurationElement(container = "interceptors")
+    @ConfigurationElement(attributeType = "ads-interceptors", container = "interceptors")
     private List<InterceptorBean> interceptors = new ArrayList<InterceptorBean>();
 
     /** The set of associated partitions */
-    @ConfigurationElement(container = "partitions")
+    @ConfigurationElement(attributeType = "ads-partitions", container = "partitions")
     private List<PartitionBean> partitions = new ArrayList<PartitionBean>();
 
     /** The reference to the Password Policy component */

Modified: directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/HttpServerBean.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/HttpServerBean.java?rev=1043150&r1=1043149&r2=1043150&view=diff
==============================================================================
--- directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/HttpServerBean.java
(original)
+++ directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/HttpServerBean.java
Tue Dec  7 18:02:15 2010
@@ -38,7 +38,7 @@ public class HttpServerBean extends Serv
     private String httpConfFile;
 
     /** The list of supported web apps */
-    @ConfigurationElement(container = "httpWebApps")
+    @ConfigurationElement(attributeType = "ads-httpWebApps", container = "httpWebApps")
     private List<HttpWebAppBean> httpWebApps = new ArrayList<HttpWebAppBean>();
 
 

Modified: directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/LdapServerBean.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/LdapServerBean.java?rev=1043150&r1=1043149&r2=1043150&view=diff
==============================================================================
--- directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/LdapServerBean.java
(original)
+++ directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/LdapServerBean.java
Tue Dec  7 18:02:15 2010
@@ -78,11 +78,11 @@ public class LdapServerBean extends DSBa
     private ReplProviderBean replProvider;
 
     /** The list of supported mechanisms */
-    @ConfigurationElement(container = "saslMechHandlers")
+    @ConfigurationElement(attributeType = "ads-saslMechHandlers", container = "saslMechHandlers")
     private List<SaslMechHandlerBean> saslMechHandlers = new ArrayList<SaslMechHandlerBean>();
 
     /** The list of supported extended operation handlers */
-    @ConfigurationElement(container = "extendedOpHandlers")
+    @ConfigurationElement(attributeType = "ads-extendedOpHandlers", container = "extendedOpHandlers")
     private List<ExtendedOpHandlerBean> extendedOpHandlers = new ArrayList<ExtendedOpHandlerBean>();
 
 

Modified: directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/PartitionBean.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/PartitionBean.java?rev=1043150&r1=1043149&r2=1043150&view=diff
==============================================================================
--- directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/PartitionBean.java
(original)
+++ directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/PartitionBean.java
Tue Dec  7 18:02:15 2010
@@ -51,7 +51,7 @@ public abstract class PartitionBean exte
     private String contextEntry;
 
     /** The list of declared indexes */
-    @ConfigurationElement(container = "indexes")
+    @ConfigurationElement(attributeType = "ads-indexes", container = "indexes")
     private List<IndexBean> indexes = new ArrayList<IndexBean>();
 
 

Modified: directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/ServerBean.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/ServerBean.java?rev=1043150&r1=1043149&r2=1043150&view=diff
==============================================================================
--- directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/ServerBean.java
(original)
+++ directory/apacheds/branches/server-config-annotations/server-config/src/main/java/org/apache/directory/server/config/beans/ServerBean.java
Tue Dec  7 18:02:15 2010
@@ -38,7 +38,7 @@ public abstract class ServerBean extends
     private String serverId;
 
     /** The set of transports to use for this server */
-    @ConfigurationElement(container = "transports")
+    @ConfigurationElement(attributeType = "ads-transports", container = "transports")
     private List<TransportBean> transports = new ArrayList<TransportBean>();
 
 



Mime
View raw message