directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r487728 - in /directory/branches/trunks/schema/apacheds: bootstrap-partition/src/main/java/org/apache/directory/server/schema/bootstrap/partition/ core/src/main/java/org/apache/directory/server/core/
Date Sat, 16 Dec 2006 00:18:50 GMT
Author: akarasulu
Date: Fri Dec 15 16:18:49 2006
New Revision: 487728

URL: http://svn.apache.org/viewvc?view=rev&rev=487728
Log:
added schema partition loading code: not using it yet but the partition is being started

Modified:
    directory/branches/trunks/schema/apacheds/bootstrap-partition/src/main/java/org/apache/directory/server/schema/bootstrap/partition/DbFileListing.java
    directory/branches/trunks/schema/apacheds/bootstrap-partition/src/main/java/org/apache/directory/server/schema/bootstrap/partition/SchemaPartitionExtractor.java
    directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java

Modified: directory/branches/trunks/schema/apacheds/bootstrap-partition/src/main/java/org/apache/directory/server/schema/bootstrap/partition/DbFileListing.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/bootstrap-partition/src/main/java/org/apache/directory/server/schema/bootstrap/partition/DbFileListing.java?view=diff&rev=487728&r1=487727&r2=487728
==============================================================================
--- directory/branches/trunks/schema/apacheds/bootstrap-partition/src/main/java/org/apache/directory/server/schema/bootstrap/partition/DbFileListing.java
(original)
+++ directory/branches/trunks/schema/apacheds/bootstrap-partition/src/main/java/org/apache/directory/server/schema/bootstrap/partition/DbFileListing.java
Fri Dec 15 16:18:49 2006
@@ -24,8 +24,10 @@
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Set;
 
 
 /**
@@ -98,5 +100,17 @@
         // remove 'schema/'
         String dbfileName = dbfile.substring( 7 );
         return dbfileName.substring( 0, dbfileName.length() - 3 );
+    }
+    
+    
+    public Set<String> getIndexedAttributes()
+    {
+        Set<String> attributes = new HashSet<String>();
+        Iterator<String> ii = iterator();
+        while( ii.hasNext() )
+        {
+            attributes.add( getIndexAttributeName( ii.next() ) );
+        }
+        return attributes;
     }
 }

Modified: directory/branches/trunks/schema/apacheds/bootstrap-partition/src/main/java/org/apache/directory/server/schema/bootstrap/partition/SchemaPartitionExtractor.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/bootstrap-partition/src/main/java/org/apache/directory/server/schema/bootstrap/partition/SchemaPartitionExtractor.java?view=diff&rev=487728&r1=487727&r2=487728
==============================================================================
--- directory/branches/trunks/schema/apacheds/bootstrap-partition/src/main/java/org/apache/directory/server/schema/bootstrap/partition/SchemaPartitionExtractor.java
(original)
+++ directory/branches/trunks/schema/apacheds/bootstrap-partition/src/main/java/org/apache/directory/server/schema/bootstrap/partition/SchemaPartitionExtractor.java
Fri Dec 15 16:18:49 2006
@@ -50,6 +50,12 @@
         {
             outputDirectory.mkdirs();
         }
+        
+        File schemaDirectory = new File( outputDirectory, "schema" );
+        if ( ! schemaDirectory.exists() )
+        {
+            schemaDirectory.mkdirs();
+        }
 
         Iterator<String> ii = listing.iterator();
         while ( ii.hasNext() )

Modified: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?view=diff&rev=487728&r1=487727&r2=487728
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
(original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
Fri Dec 15 16:18:49 2006
@@ -20,7 +20,7 @@
 package org.apache.directory.server.core;
 
 
-import java.io.File;
+import java.io.IOException;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Map;
@@ -35,6 +35,7 @@
 import org.apache.directory.server.core.authz.AuthorizationService;
 import org.apache.directory.server.core.configuration.Configuration;
 import org.apache.directory.server.core.configuration.ConfigurationException;
+import org.apache.directory.server.core.configuration.MutablePartitionConfiguration;
 import org.apache.directory.server.core.configuration.StartupConfiguration;
 import org.apache.directory.server.core.interceptor.InterceptorChain;
 import org.apache.directory.server.core.jndi.AbstractContextFactory;
@@ -43,12 +44,14 @@
 import org.apache.directory.server.core.jndi.ServerLdapContext;
 import org.apache.directory.server.core.partition.DefaultPartitionNexus;
 import org.apache.directory.server.core.partition.PartitionNexus;
+import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
 import org.apache.directory.server.schema.bootstrap.ApacheSchema;
 import org.apache.directory.server.schema.bootstrap.ApachemetaSchema;
 import org.apache.directory.server.schema.bootstrap.BootstrapSchema;
 import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
 import org.apache.directory.server.schema.bootstrap.CoreSchema;
 import org.apache.directory.server.schema.bootstrap.SystemSchema;
+import org.apache.directory.server.schema.bootstrap.partition.SchemaPartitionExtractor;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.server.schema.registries.DefaultRegistries;
 import org.apache.directory.server.schema.registries.Registries;
@@ -746,7 +749,7 @@
         // --------------------------------------------------------------------
 
         // setup temporary loader and temp registry 
-        Registries bootstrapRegistries = new DefaultRegistries();
+        registries = new DefaultRegistries();
         BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
         
         // load essential bootstrap schemas 
@@ -755,10 +758,10 @@
         bootstrapSchemas.add( new ApacheSchema() );
         bootstrapSchemas.add( new CoreSchema() );
         bootstrapSchemas.add( new SystemSchema() );
-        loader.load( bootstrapSchemas, bootstrapRegistries );
+        loader.load( bootstrapSchemas, registries );
 
         // run referential integrity tests
-        java.util.List errors = bootstrapRegistries.checkRefInteg();
+        java.util.List errors = registries.checkRefInteg();
         if ( !errors.isEmpty() )
         {
             NamingException e = new NamingException();
@@ -770,14 +773,45 @@
         // If not present extract schema partition from jar
         // --------------------------------------------------------------------
 
-        
-        
-        
+        SchemaPartitionExtractor extractor = null; 
+        try
+        {
+                extractor = new SchemaPartitionExtractor( startupConfiguration.getWorkingDirectory()
);
+            extractor.extract();
+        }
+        catch ( IOException e )
+        {
+            NamingException ne = new NamingException( "Failed to extract pre-loaded schema
partition." );
+            ne.setRootCause( e );
+            throw ne;
+        }
         
         // --------------------------------------------------------------------
-        // 
+        // Initialize schema partition
         // --------------------------------------------------------------------
+        
+        MutablePartitionConfiguration pc = new MutablePartitionConfiguration();
+        pc.setName( "schema" );
+        pc.setCacheSize( 1000 );
+        pc.setIndexedAttributes( extractor.getDbFileListing().getIndexedAttributes() );
+        pc.setOptimizerEnabled( true );
+        pc.setSuffix( "ou=schema" );
+        
+        Attributes entry = new LockableAttributesImpl();
+        entry.put( "objectClass", "top" );
+        entry.get( "objectClass" ).add( "organizationalUnit" );
+        entry.put( "ou", "schema" );
+        pc.setContextEntry( entry );
+        JdbmPartition schemaPartition = new JdbmPartition();
+        schemaPartition.init( configuration, pc );
 
+        // --------------------------------------------------------------------
+        // Initialize schema subsystem and reset registries
+        // --------------------------------------------------------------------
+        
+        // To be done
+        
+        
         Set<String> binaries = new HashSet<String>();
         if ( this.environment.containsKey( BINARY_KEY ) )
         {



Mime
View raw message