directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r486918 - in /directory/branches/trunks/schema2/apacheds: bootstrap-partition/ bootstrap-plugin/ bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/ core/ schema-extras/
Date Thu, 14 Dec 2006 01:10:02 GMT
Author: akarasulu
Date: Wed Dec 13 17:10:01 2006
New Revision: 486918

URL: http://svn.apache.org/viewvc?view=rev&rev=486918
Log:
finished up making bootstrap plugin use the store instead of the partition: the dep cycle
is now gone

Modified:
    directory/branches/trunks/schema2/apacheds/bootstrap-partition/pom.xml
    directory/branches/trunks/schema2/apacheds/bootstrap-plugin/pom.xml
    directory/branches/trunks/schema2/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java
    directory/branches/trunks/schema2/apacheds/core/pom.xml
    directory/branches/trunks/schema2/apacheds/schema-extras/pom.xml

Modified: directory/branches/trunks/schema2/apacheds/bootstrap-partition/pom.xml
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema2/apacheds/bootstrap-partition/pom.xml?view=diff&rev=486918&r1=486917&r2=486918
==============================================================================
--- directory/branches/trunks/schema2/apacheds/bootstrap-partition/pom.xml (original)
+++ directory/branches/trunks/schema2/apacheds/bootstrap-partition/pom.xml Wed Dec 13 17:10:01
2006
@@ -28,7 +28,7 @@
     </dependency>
     <dependency>
       <groupId>org.apache.directory.server</groupId>
-      <artifactId>apacheds-core</artifactId>
+      <artifactId>apacheds-jdbm-store</artifactId>
       <version>${pom.version}</version>
     </dependency>
   </dependencies>

Modified: directory/branches/trunks/schema2/apacheds/bootstrap-plugin/pom.xml
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema2/apacheds/bootstrap-plugin/pom.xml?view=diff&rev=486918&r1=486917&r2=486918
==============================================================================
--- directory/branches/trunks/schema2/apacheds/bootstrap-plugin/pom.xml (original)
+++ directory/branches/trunks/schema2/apacheds/bootstrap-plugin/pom.xml Wed Dec 13 17:10:01
2006
@@ -32,7 +32,7 @@
     </dependency>
     <dependency>
       <groupId>org.apache.directory.server</groupId>
-      <artifactId>apacheds-core</artifactId>
+      <artifactId>apacheds-jdbm-store</artifactId>
       <version>${pom.version}</version>
     </dependency>
     <dependency>

Modified: directory/branches/trunks/schema2/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema2/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java?view=diff&rev=486918&r1=486917&r2=486918
==============================================================================
--- directory/branches/trunks/schema2/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java
(original)
+++ directory/branches/trunks/schema2/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java
Wed Dec 13 17:10:01 2006
@@ -21,23 +21,19 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.util.HashMap;
+import java.math.BigInteger;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 
-import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttributes;
 import javax.naming.directory.DirContext;
 import javax.naming.directory.ModificationItem;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
 
-import org.apache.directory.server.core.configuration.MutablePartitionConfiguration;
-import org.apache.directory.server.core.configuration.MutableStartupConfiguration;
-import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
+import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
+import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStoreConfiguration;
 import org.apache.directory.server.core.schema.AttributeTypeRegistry;
 import org.apache.directory.server.core.schema.ComparatorRegistry;
 import org.apache.directory.server.core.schema.MatchingRuleRegistry;
@@ -53,8 +49,6 @@
 import org.apache.directory.server.core.schema.bootstrap.BootstrapSchemaLoader;
 import org.apache.directory.server.core.schema.bootstrap.CoreSchema;
 import org.apache.directory.server.core.schema.bootstrap.SystemSchema;
-import org.apache.directory.shared.ldap.filter.ExprNode;
-import org.apache.directory.shared.ldap.filter.PresenceNode;
 import org.apache.directory.shared.ldap.message.LockableAttributeImpl;
 import org.apache.directory.shared.ldap.message.LockableAttributesImpl;
 import org.apache.directory.shared.ldap.name.LdapDN;
@@ -118,8 +112,8 @@
     /** Registries of objects used to load the schema partition. */
     private Registries registries = new BootstrapRegistries();
 
-    /** The partition to load schema entities into. */
-    private JdbmPartition partition = new JdbmPartition();
+    /** The store to load schema entities into. */
+    private JdbmStore store = new JdbmStore();
     
     
     /**
@@ -152,13 +146,13 @@
             LdapDN dn = new LdapDN( "ou=schema" );
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
             
-            if ( ! partition.hasEntry( dn ) )
+            if ( ! hasEntry( dn ) )
             {
                 Attributes entry = new LockableAttributesImpl();
                 entry.put( "objectClass", "top" );
                 entry.get( "objectClass" ).add( "organizationalUnit" );
                 entry.put( "ou", "schema" );
-                partition.add( dn, entry );
+                store.add( dn, entry );
             }
 
             addSyntaxCheckers();
@@ -186,11 +180,6 @@
                 getLog().info( "" );
                 getLog().info( "------------------------------------------------------------------------"
);
             }
-
-            if ( getLog().isDebugEnabled() )
-            {
-                listEntries();
-            }
         }
         catch ( NamingException e )
         {
@@ -200,7 +189,7 @@
         
         try
         {
-            partition.sync();
+            store.sync();
         }
         catch ( NamingException e )
         {
@@ -230,7 +219,7 @@
             Attributes entry = attributesFactory.getAttributes( at );
             dn.add( "m-oid=" + at.getOid() );
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
-            partition.add( dn, entry );
+            store.add( dn, entry );
         }
         getLog().info( "" );
     }
@@ -257,7 +246,7 @@
             Attributes entry = attributesFactory.getAttributes( oc );
             dn.add( "m-oid=" + oc.getOid() );
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
-            partition.add( dn, entry );
+            store.add( dn, entry );
         }
         getLog().info( "" );
     }
@@ -284,7 +273,7 @@
             Attributes entry = attributesFactory.getAttributes( mr );
             dn.add( "m-oid=" + mr.getOid() );
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
-            partition.add( dn, entry );
+            store.add( dn, entry );
         }
         getLog().info( "" );
     }
@@ -311,7 +300,7 @@
             Attributes entry = attributesFactory.getAttributes( oid, comparatorRegistry.lookup(
oid ) );
             dn.add( "m-oid=" + oid );
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
-            partition.add( dn, entry );
+            store.add( dn, entry );
         }
         getLog().info( "" );
     }
@@ -338,7 +327,7 @@
             Attributes entry = attributesFactory.getAttributes( oid, normalizerRegistry.lookup(
oid ) );
             dn.add( "m-oid=" + oid );
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
-            partition.add( dn, entry );
+            store.add( dn, entry );
         }
         getLog().info( "" );
     }
@@ -365,7 +354,7 @@
             Attributes entry = attributesFactory.getAttributes( syntax );
             dn.add( "m-oid=" + syntax.getOid() );
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
-            partition.add( dn, entry );
+            store.add( dn, entry );
         }
         getLog().info( "" );
     }
@@ -392,7 +381,7 @@
             Attributes entry = attributesFactory.getAttributes( syntaxChecker );
             dn.add( "m-oid=" + syntaxChecker.getSyntaxOid() );
             dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
-            partition.add( dn, entry );
+            store.add( dn, entry );
         }
         getLog().info( "" );
     }
@@ -406,16 +395,17 @@
      */
     private void initializePartition() throws MojoFailureException
     {
-        // start up the schema partition
-        MutableStartupConfiguration msConf = new MutableStartupConfiguration();
-        msConf.setWorkingDirectory( outputDirectory );
+        JdbmStoreConfiguration storeConfig = new JdbmStoreConfiguration();
+        storeConfig.setAttributeTypeRegistry( registries.getAttributeTypeRegistry() );
+        storeConfig.setCacheSize( 1000 );
+        storeConfig.setEnableOptimizer( false );
+        storeConfig.setName( "schema" );
+        storeConfig.setOidRegistry( registries.getOidRegistry() );
+        storeConfig.setSuffixDn( "ou=schema" );
+        storeConfig.setSyncOnWrite( false );
         
-        MojoDSConfig dsConfig = new MojoDSConfig( registries, msConf );
-        MutablePartitionConfiguration mpConfig = new MutablePartitionConfiguration();
-        mpConfig.setCacheSize( 1000 );
-        BasicAttributes rootEntry = new BasicAttributes( "objectClass", "organizationalUnit",
true );
-        rootEntry.put( "ou", "schema" );
-        mpConfig.setContextEntry( rootEntry );
+        File workingDirectory = new File( outputDirectory, "schema" );
+        storeConfig.setWorkingDirectory( workingDirectory );
 
         // add the indices
         Set<String> indexSet = new HashSet<String>();
@@ -423,23 +413,15 @@
         {
             indexSet.add( index );
         }
-        
-        mpConfig.setIndexedAttributes( indexSet );
-        try
-        {
-            mpConfig.setSuffix( "ou=schema" );
-        }
-        catch ( NamingException e1 )
-        {
-            e1.printStackTrace();
-            throw new MojoFailureException( "Failed to setup parition configuration: " +
e1.getMessage() );
-        }
-        
-        mpConfig.setName( "schema" );
+        storeConfig.setIndexedAttributes( indexSet );
+
+        BasicAttributes rootEntry = new BasicAttributes( "objectClass", "organizationalUnit",
true );
+        rootEntry.put( "ou", "schema" );
+        storeConfig.setContextEntry( rootEntry );
         
         try
         {
-            partition.init( dsConfig, mpConfig );
+            store.init( storeConfig );
         }
         catch ( NamingException e )
         {
@@ -515,26 +497,9 @@
     }
     
 
-    private void listEntries() throws NamingException
-    {
-        LdapDN dn = new LdapDN( "ou=schema" );
-        dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
-        ExprNode filter = new PresenceNode( registries.getOidRegistry().getOid( "objectClass"
) );
-        SearchControls searchCtls = new SearchControls();
-        searchCtls.setSearchScope( SearchControls.SUBTREE_SCOPE );
-        
-        NamingEnumeration list = partition.search( dn, new HashMap<String, Object>(),
filter, searchCtls );
-        while ( list.hasMore() )
-        {
-            SearchResult sr = ( SearchResult ) list.next();
-            getLog().info( "Found entry " + sr.getName() );
-        }
-    }
-
-
     private void checkCreateContainer( LdapDN dn ) throws NamingException
     {
-        if ( partition.hasEntry( dn ) )
+        if ( hasEntry( dn ) )
         {
             return;
         }
@@ -543,7 +508,7 @@
         entry.put( "objectClass", "top" );
         entry.get( "objectClass" ).add( "organizationalUnit" );
         entry.put( "ou", dn.getRdn().getValue() );
-        partition.add( dn, entry );
+        store.add( dn, entry );
     }
     
     
@@ -552,7 +517,7 @@
         LdapDN dn = new LdapDN( "cn=" + schemaName + ",ou=schema" );
         dn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
 
-        if ( partition.hasEntry( dn ) )
+        if ( hasEntry( dn ) )
         {
             return dn;
         }
@@ -562,7 +527,7 @@
         entry.get( "objectClass" ).add( "metaTop" );
         entry.get( "objectClass" ).add( "metaSchema" );
         entry.put( "cn", schemaName );
-        partition.add( dn, entry );
+        store.add( dn, entry );
         return dn;
     }
     
@@ -574,7 +539,7 @@
         ModificationItem mod = new ModificationItem( DirContext.ADD_ATTRIBUTE, 
             new LockableAttributeImpl( M_DISABLED_AT, "TRUE" ) );
         ModificationItem[] mods = new ModificationItem[] { mod };
-        partition.modify( dn, mods );
+        store.modify( dn, mods );
     }
 
 
@@ -587,5 +552,16 @@
         }
         
         return object.getOid();
+    }
+    
+    
+    private final boolean hasEntry( LdapDN dn ) throws NamingException
+    {
+        BigInteger id = store.getEntryId( dn.toNormName() );
+        if ( id == null )
+        {
+            return false;
+        }
+        return true;
     }
 }

Modified: directory/branches/trunks/schema2/apacheds/core/pom.xml
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema2/apacheds/core/pom.xml?view=diff&rev=486918&r1=486917&r2=486918
==============================================================================
--- directory/branches/trunks/schema2/apacheds/core/pom.xml (original)
+++ directory/branches/trunks/schema2/apacheds/core/pom.xml Wed Dec 13 17:10:01 2006
@@ -60,6 +60,11 @@
       <artifactId>apacheds-btree-base</artifactId>
       <version>${pom.version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-bootstrap-partition</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
   </dependencies>
   <build>
     <resources>

Modified: directory/branches/trunks/schema2/apacheds/schema-extras/pom.xml
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema2/apacheds/schema-extras/pom.xml?view=diff&rev=486918&r1=486917&r2=486918
==============================================================================
--- directory/branches/trunks/schema2/apacheds/schema-extras/pom.xml (original)
+++ directory/branches/trunks/schema2/apacheds/schema-extras/pom.xml Wed Dec 13 17:10:01 2006
@@ -20,7 +20,12 @@
     </dependency>
     <dependency>
       <groupId>org.apache.directory.server</groupId>
-      <artifactId>apacheds-core</artifactId>
+      <artifactId>apacheds-schema-registries</artifactId>
+      <version>${pom.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.directory.server</groupId>
+      <artifactId>apacheds-schema-bootstrap</artifactId>
       <version>${pom.version}</version>
     </dependency>
   </dependencies>



Mime
View raw message