directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r808631 - in /directory: apacheds/branches/apacheds-schema/core/ apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/ apacheds/branches/apacheds-schema/schema-loader/src/main/java/org/apache/directory/serve...
Date Thu, 27 Aug 2009 21:13:36 GMT
Author: akarasulu
Date: Thu Aug 27 21:13:35 2009
New Revision: 808631

URL: http://svn.apache.org/viewvc?rev=808631&view=rev
Log:
fixing initialization code to use LDIF files now for bootstrapping registries

Modified:
    directory/apacheds/branches/apacheds-schema/core/pom.xml
    directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
    directory/apacheds/branches/apacheds-schema/schema-loader/src/main/java/org/apache/directory/server/schema/loader/ldif/LdifSchemaLoader.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AbstractSchemaLoader.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaLoader.java

Modified: directory/apacheds/branches/apacheds-schema/core/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core/pom.xml?rev=808631&r1=808630&r2=808631&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core/pom.xml (original)
+++ directory/apacheds/branches/apacheds-schema/core/pom.xml Thu Aug 27 21:13:35 2009
@@ -51,6 +51,12 @@
 
     <dependency>
       <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-schema-loader</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
       <artifactId>apacheds-xdbm-tools</artifactId>
       <version>${pom.version}</version>
     </dependency>

Modified: directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=808631&r1=808630&r2=808631&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
Thu Aug 27 21:13:35 2009
@@ -76,6 +76,7 @@
 import org.apache.directory.server.schema.bootstrap.SystemSchema;
 import org.apache.directory.server.schema.bootstrap.partition.DbFileListing;
 import org.apache.directory.server.schema.bootstrap.partition.SchemaPartitionExtractor;
+import org.apache.directory.server.schema.loader.ldif.LdifSchemaLoader;
 import org.apache.directory.server.schema.registries.DefaultRegistries;
 import org.apache.directory.shared.ldap.NotImplementedException;
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
@@ -320,45 +321,8 @@
         changeLog = new DefaultChangeLog();
         journal = new DefaultJournal();
         syncPeriodMillis = DEFAULT_SYNC_PERIOD;
-        
-        // --------------------------------------------------------------------
-        // Load the bootstrap schemas to start up the schema partition
-        // --------------------------------------------------------------------
-
-        // setup temporary loader and temp registry 
-        BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
-        OidRegistry oidRegistry = new OidRegistry();
-        registries = new Registries( "bootstrap", loader, oidRegistry );
-
-        // load essential bootstrap schemas 
-        Set<Schema> bootstrapSchemas = new HashSet<Schema>();
-        bootstrapSchemas.add( new ApachemetaSchema() );
-        bootstrapSchemas.add( new ApacheSchema() );
-        bootstrapSchemas.add( new CoreSchema() );
-        bootstrapSchemas.add( new SystemSchema() );
-        
-        try
-        {
-            loader.loadWithDependencies( bootstrapSchemas, registries );
-        }
-        catch ( Exception e )
-        {
-            throw new IllegalStateException( ILLEGAL_STATE_MSG, e );
-        }
-
-        // run referential integrity tests
-        List<Throwable> errors = registries.checkRefInteg();
-        
-        if ( !errors.isEmpty() )
-        {
-            NamingException e = new NamingException();
-            e.setRootCause( errors.get( 0 ) );
-            throw new IllegalStateException( ILLEGAL_STATE_MSG, e );
-        }
-        
-        SerializableComparator.setRegistry( registries.getComparatorRegistry() );
-        
         csnFactory = new CsnFactory( replicaId );
+        registries = new Registries( new OidRegistry() );
     }
 
 
@@ -1502,9 +1466,38 @@
         }
         
         // --------------------------------------------------------------------
+        // Load schemas into the schema registry from LDIF schema repository
+        // --------------------------------------------------------------------
+
+        LdifSchemaLoader loader = new LdifSchemaLoader( schemaDirectory );
+        
+        try
+        {
+            loader.loadAllEnabled( registries );
+        }
+        catch ( Exception e )
+        {
+            throw new IllegalStateException( ILLEGAL_STATE_MSG, e );
+        }
+
+        // run referential integrity tests
+        List<Throwable> errors = registries.checkRefInteg();
+        
+        if ( !errors.isEmpty() )
+        {
+            NamingException e = new NamingException();
+            e.setRootCause( errors.get( 0 ) );
+            throw new IllegalStateException( ILLEGAL_STATE_MSG, e );
+        }
+        
+        SerializableComparator.setRegistry( registries.getComparatorRegistry() );
+        
+        // --------------------------------------------------------------------
         // Initialize schema partition
         // --------------------------------------------------------------------
 
+        
+        
         JdbmPartition schemaPartition = new JdbmPartition();
         schemaPartition.setId( "schema" );
         schemaPartition.setCacheSize( 1000 );

Modified: directory/apacheds/branches/apacheds-schema/schema-loader/src/main/java/org/apache/directory/server/schema/loader/ldif/LdifSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/schema-loader/src/main/java/org/apache/directory/server/schema/loader/ldif/LdifSchemaLoader.java?rev=808631&r1=808630&r2=808631&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/schema-loader/src/main/java/org/apache/directory/server/schema/loader/ldif/LdifSchemaLoader.java
(original)
+++ directory/apacheds/branches/apacheds-schema/schema-loader/src/main/java/org/apache/directory/server/schema/loader/ldif/LdifSchemaLoader.java
Thu Aug 27 21:13:35 2009
@@ -116,13 +116,6 @@
     /** directory containing the schema LDIF file for ou=schema */
     private final File baseDirectory;
     
-    /** 
-     * A map of all available schema names to schema objects. This map is 
-     * populated when this class is created with all the schemas present in
-     * the LDIF based schema repository.
-     */
-    private final Map<String,Schema> schemaMap = new HashMap<String,Schema>();
-    
     /** a filter for listing all the LDIF files within a directory */
     private final FilenameFilter ldifFilter = new FilenameFilter()
     {

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AbstractSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AbstractSchemaLoader.java?rev=808631&r1=808630&r2=808631&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AbstractSchemaLoader.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AbstractSchemaLoader.java
Thu Aug 27 21:13:35 2009
@@ -20,6 +20,7 @@
 package org.apache.directory.shared.ldap.schema.registries;
 
 
+import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Stack;
@@ -45,9 +46,18 @@
     /** static class logger */
     private static final Logger LOG = LoggerFactory.getLogger( AbstractSchemaLoader.class
);
     
+
     protected SchemaLoaderListener listener;
     
     
+    /** 
+     * A map of all available schema names to schema objects. This map is 
+     * populated when this class is created with all the schemas present in
+     * the LDIF based schema repository.
+     */
+    protected final Map<String,Schema> schemaMap = new HashMap<String,Schema>();
+    
+
     public void setListener( SchemaLoaderListener listener )
     {
         this.listener = listener;
@@ -73,9 +83,22 @@
     
     
     /**
+     * {@inheritDoc}
+     */
+    public final void loadAllEnabled( Registries registries ) throws Exception
+    {
+        for ( Schema schema : schemaMap.values() )
+        {
+            loadDepsFirst( schema, new Stack<String>(), 
+                new HashMap<String,Schema>(), schema, registries );
+        }
+    }
+    
+    
+    /**
      * Recursive method which loads schema's with their dependent schemas first
      * and tracks what schemas it has seen so the recursion does not go out of
-     * control with depenency cycle detection.
+     * control with dependency cycle detection.
      *
      * @param rootAncestor the triggering schema load request: the root ancestor of dependency
chain
      * @param beenthere stack of schema names we have visited and have yet to load

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java?rev=808631&r1=808630&r2=808631&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java
Thu Aug 27 21:13:35 2009
@@ -19,8 +19,8 @@
  */
 package org.apache.directory.shared.ldap.schema.registries;
 
-import java.util.ArrayList;
 import java.util.List;
+import java.util.ArrayList;
 import java.util.Map;
 import java.util.HashMap;
 import javax.naming.NamingException;
@@ -324,8 +324,6 @@
         }
     }
 
-    //List<Throwable> checkRefInteg();
-
 
     /**
      * Gets a schema that has been loaded into these Registries.

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaLoader.java?rev=808631&r1=808630&r2=808631&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaLoader.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaLoader.java
Thu Aug 27 21:13:35 2009
@@ -68,6 +68,14 @@
     void loadWithDependencies( Schema schema, Registries registries ) throws Exception;
     
     /**
+     * Loads all available enabled schemas.
+     *
+     * @param registries the registry to load all enabled schemas into
+     * @throws Exception if there are any failures
+     */
+    void loadAllEnabled( Registries registries ) throws Exception;
+    
+    /**
      * Loads a single schema.  Do not try to resolve dependencies while implementing this
method.
      * 
      * @param schema the schema to load



Mime
View raw message