directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1149411 [1/6] - in /directory/apacheds/trunk: core-annotations/src/main/java/org/apache/directory/server/core/factory/ core-annotations/src/test/java/org/apache/directory/server/core/factory/ core-api/src/main/java/org/apache/directory/ser...
Date Fri, 22 Jul 2011 00:02:18 GMT
Author: elecharny
Date: Fri Jul 22 00:02:02 2011
New Revision: 1149411

URL: http://svn.apache.org/viewvc?rev=1149411&view=rev
Log:
Refactored the Partition hierarchy :
o merged the Store and partition iplementations
o redesigned the Partition initialization
o reviexed the DS initialization
o Partition now takes a SchemaManager when constructed
o the get/setSuffix methods have been renamed get/setSuffixDn
o Added some missing Javadoc

Removed:
    directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java
Modified:
    directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/AvlPartitionFactory.java
    directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
    directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java
    directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/JdbmPartitionFactory.java
    directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/LdifPartitionFactory.java
    directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/PartitionFactory.java
    directory/apacheds/trunk/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceAnnotationTest.java
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/Partition.java
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/PartitionNexus.java
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDaoImpl.java
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/configuration/PartitionConfigurationIT.java
    directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchWithIndicesIT.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DefaultSchemaService.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
    directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
    directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ServerEntrySerializer.java
    directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
    directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/PartitionTreeTest.java
    directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/AbstractLdifPartition.java
    directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
    directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java
    directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/LdifPartitionTest.java
    directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/SingleFileLdifPartitionTest.java
    directory/apacheds/trunk/server-annotations/src/test/java/org/apache/directory/server/factory/DirectoryServiceAnnotationTest.java
    directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
    directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ReadOnlyConfigurationPartition.java
    directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ChangePasswordConfigReaderTest.java
    directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java
    directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ConfigWriterTest.java
    directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/DhcpServerConfigReaderTest.java
    directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/DnsServerConfigReaderTest.java
    directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/HttpServerConfigReaderTest.java
    directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/KerberosServerConfigReaderTest.java
    directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/LdapServerConfigReaderTest.java
    directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/NtpServerConfigReaderTest.java
    directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java
    directory/apacheds/trunk/server-jndi/src/test/java/org/apache/directory/server/configuration/ApacheDSTest.java
    directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/ServiceBuilder.java
    directory/apacheds/trunk/service/src/main/java/org/apache/directory/server/ApacheDsService.java
    directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java
    directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkSuite.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/avl/AvlPartition.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/ServerEntryCursorAdaptor.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeCursor.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java
    directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java
    directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/StoreUtils.java
    directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java
    directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java
    directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java
    directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
    directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java
    directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java
    directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java
    directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/OrCursorTest.java
    directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java
    directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubstringTest.java
    directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java
    directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/EntryNode.java
    directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java

Modified: directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/AvlPartitionFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/AvlPartitionFactory.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/AvlPartitionFactory.java (original)
+++ directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/AvlPartitionFactory.java Fri Jul 22 00:02:02 2011
@@ -28,6 +28,7 @@ import org.apache.directory.server.xdbm.
 import org.apache.directory.server.xdbm.impl.avl.AvlIndex;
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 
 
 /**
@@ -41,14 +42,15 @@ public class AvlPartitionFactory impleme
     /**
      * {@inheritDoc}
      */
-    public AvlPartition createPartition( String id, String suffix, int cacheSize, File workingDirectory )
+    public AvlPartition createPartition( SchemaManager schemaManager, String id, String suffix, int cacheSize, File workingDirectory )
         throws Exception
     {
-        AvlPartition partition = new AvlPartition();
+        AvlPartition partition = new AvlPartition( schemaManager );
         partition.setId( id );
-        partition.setSuffix( new Dn( suffix ) );
+        partition.setSuffixDn( new Dn( suffix ) );
         partition.setCacheSize( 500 );
         partition.setPartitionPath( workingDirectory.toURI() );
+        
         return partition;
     }
 

Modified: directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java (original)
+++ directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DSAnnotationProcessor.java Fri Jul 22 00:02:02 2011
@@ -22,6 +22,7 @@ package org.apache.directory.server.core
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.InputStream;
+import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.util.HashSet;
 import java.util.List;
@@ -48,6 +49,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.model.ldif.LdifReader;
 import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.junit.runner.Description;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -80,6 +82,7 @@ public class DSAnnotationProcessor
         service.getChangeLog().setEnabled( dsBuilder.enableChangeLog() );
 
         List<Interceptor> interceptorList = service.getInterceptors();
+        
         for ( Class<?> interceptorClass : dsBuilder.additionalInterceptors() )
         {
             interceptorList.add( ( Interceptor ) interceptorClass.newInstance() );
@@ -138,10 +141,12 @@ public class DSAnnotationProcessor
                 // We use the partition factory to create partition and index
                 // instances.
                 PartitionFactory partitionFactory = dsf.getPartitionFactory();
-                partition = partitionFactory.createPartition( createPartition
-                        .name(), createPartition.suffix(), createPartition
-                        .cacheSize(), new File( service.getInstanceLayout()
-                        .getPartitionsDirectory(), createPartition.name() ) );
+                partition = partitionFactory.createPartition(
+                        service.getSchemaManager(),
+                        createPartition.name(), 
+                        createPartition.suffix(), 
+                        createPartition.cacheSize(), 
+                        new File( service.getInstanceLayout().getPartitionsDirectory(), createPartition.name() ) );
 
                 CreateIndex[] indexes = createPartition.indexes();
                 
@@ -155,9 +160,11 @@ public class DSAnnotationProcessor
             {
                 // The annotation contains a specific partition type, we use
                 // that type.
-                partition = createPartition.type().newInstance();
+                Class<?> partypes[] = new Class[]{SchemaManager.class};
+                Constructor<?> constructor = createPartition.type().getConstructor(partypes);
+                partition = (Partition)constructor.newInstance( new Object[]{service.getSchemaManager()} );
                 partition.setId( createPartition.name() );
-                partition.setSuffix( new Dn( service.getSchemaManager(), createPartition.suffix() ) );
+                partition.setSuffixDn( new Dn( service.getSchemaManager(), createPartition.suffix() ) );
 
                 if ( partition instanceof AbstractBTreePartition<?> )
                 {

Modified: directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java (original)
+++ directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java Fri Jul 22 00:02:02 2011
@@ -30,6 +30,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.InstanceLayout;
 import org.apache.directory.server.core.partition.Partition;
 import org.apache.directory.server.core.partition.ldif.LdifPartition;
+import org.apache.directory.server.core.schema.DefaultSchemaService;
 import org.apache.directory.server.core.schema.SchemaPartition;
 import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
@@ -54,12 +55,6 @@ public class DefaultDirectoryServiceFact
     /** A logger for this class */
     private static final Logger LOG = LoggerFactory.getLogger( DefaultDirectoryServiceFactory.class );
 
-    /**
-     * The default factory returns stock instances of a directory
-     * service with smart defaults
-     */
-    public static final DirectoryServiceFactory DEFAULT = new DefaultDirectoryServiceFactory();
-
     /** The directory service. */
     private DirectoryService directoryService;
 
@@ -67,7 +62,7 @@ public class DefaultDirectoryServiceFact
     private PartitionFactory partitionFactory;
 
 
-    /* default access */DefaultDirectoryServiceFactory()
+    public DefaultDirectoryServiceFactory()
     {
         try
         {
@@ -87,6 +82,7 @@ public class DefaultDirectoryServiceFact
         try
         {
             String typeName = System.getProperty( "apacheds.partition.factory" );
+            
             if ( typeName != null )
             {
                 Class<? extends PartitionFactory> type = ( Class<? extends PartitionFactory> ) Class.forName( typeName );
@@ -154,12 +150,7 @@ public class DefaultDirectoryServiceFact
      */
     private void initSchema() throws Exception
     {
-        SchemaPartition schemaPartition = directoryService.getSchemaService().getSchemaPartition();
-
-        // Init the LdifPartition
-        LdifPartition ldifPartition = new LdifPartition();
         File workingDirectory = directoryService.getInstanceLayout().getPartitionsDirectory();
-        ldifPartition.setPartitionPath( new File(workingDirectory, "schema" ).toURI() );
 
         // Extract the schema on disk (a brand new one) and load the registries
         File schemaRepository = new File( workingDirectory, "schema" );
@@ -174,18 +165,24 @@ public class DefaultDirectoryServiceFact
             // The schema has already been extracted, bypass
         }
 
-        schemaPartition.setWrappedPartition( ldifPartition );
-
         SchemaLoader loader = new LdifSchemaLoader( schemaRepository );
         SchemaManager schemaManager = new DefaultSchemaManager( loader );
-        directoryService.setSchemaManager( schemaManager );
-
+        
         // We have to load the schema now, otherwise we won't be able
         // to initialize the Partitions, as we won't be able to parse 
         // and normalize their suffix Dn
         schemaManager.loadAllEnabled();
 
-        schemaPartition.setSchemaManager( schemaManager );
+        directoryService.setSchemaManager( schemaManager );
+        directoryService.setSchemaService( new DefaultSchemaService( schemaManager ) );
+
+        // Init the LdifPartition
+        LdifPartition ldifPartition = new LdifPartition( schemaManager );
+        ldifPartition.setPartitionPath( new File(workingDirectory, "schema" ).toURI() );
+
+        SchemaPartition schemaPartition = directoryService.getSchemaService().getSchemaPartition();
+
+        schemaPartition.setWrappedPartition( ldifPartition );
 
         List<Throwable> errors = schemaManager.getErrors();
 
@@ -208,7 +205,8 @@ public class DefaultDirectoryServiceFact
         // or somewhere in a temp area of the machine.
 
         // Inject the System Partition
-        Partition systemPartition = partitionFactory.createPartition( "system", ServerDNConstants.SYSTEM_DN, 500,
+        Partition systemPartition = partitionFactory.createPartition( directoryService.getSchemaManager(),
+            "system", ServerDNConstants.SYSTEM_DN, 500,
             new File( directoryService.getInstanceLayout().getPartitionsDirectory(), "system" ) );
         systemPartition.setSchemaManager( directoryService.getSchemaManager() );
 

Modified: directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/JdbmPartitionFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/JdbmPartitionFactory.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/JdbmPartitionFactory.java (original)
+++ directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/JdbmPartitionFactory.java Fri Jul 22 00:02:02 2011
@@ -28,6 +28,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 
 
 /**
@@ -41,14 +42,16 @@ public class JdbmPartitionFactory implem
     /**
      * {@inheritDoc}
      */
-    public JdbmPartition createPartition( String id, String suffix, int cacheSize, File workingDirectory )
+    public JdbmPartition createPartition( SchemaManager schemaManager, String id, String suffix, int cacheSize, File workingDirectory )
         throws Exception
     {
-        JdbmPartition partition = new JdbmPartition();
+        JdbmPartition partition = new JdbmPartition( schemaManager );
         partition.setId( id );
-        partition.setSuffix( new Dn( suffix ) );
+        partition.setSuffixDn( new Dn( suffix ) );
         partition.setCacheSize( 500 );
         partition.setPartitionPath( workingDirectory.toURI() );
+        partition.initialize();
+        
         return partition;
     }
 

Modified: directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/LdifPartitionFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/LdifPartitionFactory.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/LdifPartitionFactory.java (original)
+++ directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/LdifPartitionFactory.java Fri Jul 22 00:02:02 2011
@@ -28,6 +28,7 @@ import org.apache.directory.server.xdbm.
 import org.apache.directory.server.xdbm.impl.avl.AvlIndex;
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 
 
 /**
@@ -41,14 +42,15 @@ public class LdifPartitionFactory implem
     /**
      * {@inheritDoc}
      */
-    public LdifPartition createPartition( String id, String suffix, int cacheSize, File workingDirectory )
+    public LdifPartition createPartition( SchemaManager schemaManager, String id, String suffix, int cacheSize, File workingDirectory )
         throws Exception
     {
-        LdifPartition partition = new LdifPartition();
+        LdifPartition partition = new LdifPartition( schemaManager );
         partition.setId( id );
-        partition.setSuffix( new Dn( suffix ) );
+        partition.setSuffixDn( new Dn( suffix ) );
         partition.setCacheSize( 500 );
         partition.setPartitionPath( workingDirectory.toURI() );
+        
         return partition;
     }
 

Modified: directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/PartitionFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/PartitionFactory.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/PartitionFactory.java (original)
+++ directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/PartitionFactory.java Fri Jul 22 00:02:02 2011
@@ -23,6 +23,7 @@ import java.io.File;
 
 import org.apache.directory.server.core.partition.Partition;
 import org.apache.directory.server.xdbm.Index;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 
 
 /**
@@ -36,6 +37,7 @@ public interface PartitionFactory
     /**
      * Creates a new Partition.
      * 
+     * @param schemaManager The SchemaManager instance
      * @param id the partition id
      * @param suffix the suffix
      * @param cacheSize the cache size
@@ -43,7 +45,7 @@ public interface PartitionFactory
      * @return the partition
      * @throws Exception the exception
      */
-    Partition createPartition( String id, String suffix, int cacheSize, File workingDirectory ) throws Exception;
+    Partition createPartition( SchemaManager schemaManager, String id, String suffix, int cacheSize, File workingDirectory ) throws Exception;
 
 
     /**

Modified: directory/apacheds/trunk/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceAnnotationTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceAnnotationTest.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceAnnotationTest.java (original)
+++ directory/apacheds/trunk/core-annotations/src/test/java/org/apache/directory/server/core/factory/DirectoryServiceAnnotationTest.java Fri Jul 22 00:02:02 2011
@@ -115,13 +115,13 @@ public class DirectoryServiceAnnotationT
             if ( "example".equalsIgnoreCase( partition.getId() ) )
             {
                 assertTrue( partition.isInitialized() );
-                assertEquals( "dc=example,dc=com", partition.getSuffix().getName() );
+                assertEquals( "dc=example,dc=com", partition.getSuffixDn().getName() );
                 assertTrue( partition instanceof JdbmPartition );
             }
             else if ( "schema".equalsIgnoreCase( partition.getId() ) )
             {
                 assertTrue( partition.isInitialized() );
-                assertEquals( "ou=schema", partition.getSuffix().getName() );
+                assertEquals( "ou=schema", partition.getSuffixDn().getName() );
             }
         }
         
@@ -161,13 +161,13 @@ public class DirectoryServiceAnnotationT
             if ( "example".equalsIgnoreCase( partition.getId() ) )
             {
                 assertTrue( partition.isInitialized() );
-                assertEquals( "dc=example,dc=com", partition.getSuffix().getName() );
+                assertEquals( "dc=example,dc=com", partition.getSuffixDn().getName() );
                 assertTrue( partition instanceof AvlPartition );
             }
             else if ( "schema".equalsIgnoreCase( partition.getId() ) )
             {
                 assertTrue( partition.isInitialized() );
-                assertEquals( "ou=schema", partition.getSuffix().getName() );
+                assertEquals( "ou=schema", partition.getSuffixDn().getName() );
             }
         }
 

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java (original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java Fri Jul 22 00:02:02 2011
@@ -20,14 +20,19 @@
 package org.apache.directory.server.core.partition;
 
 
+import java.io.IOException;
+import java.io.OutputStream;
+
 import javax.naming.InvalidNameException;
 
-import org.apache.directory.server.core.interceptor.context.EntryOperationContext;
-import org.apache.directory.server.core.interceptor.context.LookupOperationContext;
+import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.exception.LdapOtherException;
+import org.apache.directory.shared.ldap.model.name.Dn;
 import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+import org.apache.directory.shared.util.Strings;
 
 
 /**
@@ -48,6 +53,12 @@ public abstract class AbstractPartition 
     /** The partition ContextEntry */
     protected Entry contextEntry;
 
+    /** The partition ID */
+    protected String id;
+    
+    /** The root Dn for this partition */
+    protected Dn suffixDn;
+
     protected AbstractPartition()
     {
     }
@@ -59,7 +70,7 @@ public abstract class AbstractPartition 
      * {@link #doInit()} returns without any errors.  {@link #destroy()} is called automatically
      * as a clean-up process if {@link #doInit()} throws an exception.
      */
-    public final void initialize( ) throws LdapException
+    public void initialize( ) throws LdapException
     {
         if ( initialized )
         {
@@ -93,6 +104,13 @@ public abstract class AbstractPartition 
     }
     
 
+
+    /**
+     * Override this method to put your initialization code.
+     */
+    protected abstract void doDestroy() throws Exception;
+
+
     /**
      * Override this method to put your initialization code.
      * @throws Exception 
@@ -119,59 +137,73 @@ public abstract class AbstractPartition 
 
 
     /**
-     * Override this method to put your initialization code.
+     * Returns <tt>true</tt> if this context partition is initialized successfully.
      */
-    protected abstract void doDestroy() throws Exception;
+    public final boolean isInitialized()
+    {
+        return initialized;
+    }
 
 
     /**
-     * Returns <tt>true</tt> if this context partition is initialized successfully.
+     * {@inheritDoc}
      */
-    public boolean isInitialized()
+    public void setSchemaManager( SchemaManager schemaManager )
     {
-        return initialized;
+        this.schemaManager = schemaManager;
     }
 
 
     /**
-     * This method does nothing by default.
+     * {@inheritDoc}
      */
-    public abstract void sync() throws Exception;
+    public final SchemaManager getSchemaManager()
+    {
+        return schemaManager;
+    }
 
 
     /**
-     * This method calls {@link Partition#lookup(LookupOperationContext)} and return <tt>true</tt>
-     * if it returns an entry by default.  Please override this method if
-     * there is more effective way for your implementation.
+     * {@inheritDoc}
      */
-    public boolean hasEntry( EntryOperationContext entryContext ) throws LdapException
+    public final String getId()
     {
-        try
-        {
-            return entryContext.lookup( entryContext.getDn(), ByPassConstants.LOOKUP_BYPASS ) != null; 
-        }
-        catch ( LdapException e )
-        {
-            return false;
-        }
+        return id;
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public void setSchemaManager( SchemaManager schemaManager )
+    public void setId( String id )
     {
-        this.schemaManager = schemaManager;
+        checkInitialized( "id" );
+        this.id = id;
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public SchemaManager getSchemaManager()
+    public final Dn getSuffixDn()
     {
-        return schemaManager;
+        return suffixDn;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void setSuffixDn( Dn suffixDn ) throws LdapInvalidDnException
+    {
+        checkInitialized( "suffixDn" );
+
+        this.suffixDn = suffixDn;
+
+        if ( schemaManager != null )
+        {
+            this.suffixDn.apply( schemaManager );
+        }
     }
     
     
@@ -191,4 +223,26 @@ public abstract class AbstractPartition 
     {
         this.contextEntry = contextEntry;
     }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void dumpIndex( OutputStream stream, String name ) throws IOException
+    {
+        stream.write( Strings.getBytesUtf8( "Nothing to dump for index " + name ) );
+    }
+
+    
+    /**
+     * Check that the operation is done on an initialized store
+     * @param property
+     */
+    protected void checkInitialized( String property )
+    {
+        if ( initialized )
+        {
+            throw new IllegalStateException( I18n.err( I18n.ERR_576, property ) );
+        }
+    }
 }

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/Partition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/Partition.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/Partition.java (original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/Partition.java Fri Jul 22 00:02:02 2011
@@ -20,6 +20,9 @@
 package org.apache.directory.server.core.partition;
 
 
+import java.io.IOException;
+import java.io.OutputStream;
+
 import org.apache.directory.server.core.entry.ServerSearchResult;
 import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.interceptor.context.AddOperationContext;
@@ -71,15 +74,6 @@ public interface Partition
 
 
     /**
-     * Sets the user provided suffix for this Partition as a String.
-     *
-     * @param suffix the suffix String for this Partition.
-     * @throws LdapInvalidDnException if the suffix does not conform to LDAP Dn syntax
-     */
-    void setSuffix( Dn suffix ) throws LdapInvalidDnException;
-
-
-    /**
      * Gets the schema manager assigned to this Partition.
      *
      * @return the schema manager
@@ -115,7 +109,15 @@ public interface Partition
      * @return the suffix for this Partition.
      * @throws IllegalStateException if the Partition has not been initialized
      */
-    Dn getSuffix();
+    Dn getSuffixDn();
+
+
+    /**
+     * Sets the suffix Dn, must be normalized.
+     * 
+     * @param suffixDn the new suffix Dn
+     */
+    void setSuffixDn( Dn suffixDn ) throws LdapInvalidDnException;
 
 
     /**
@@ -286,4 +288,12 @@ public interface Partition
      * @throws Exception if something goes wrong
      */
     void unbind( UnbindOperationContext unbindContext ) throws LdapException;
+    
+    
+    /**
+     * Dump the requested index to a given stream
+     * @param name The index to dump to stdout
+     * @throws IOException if we can't write the data
+     */
+    void dumpIndex( OutputStream stream, String name ) throws IOException;
 }

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/PartitionNexus.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/PartitionNexus.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/PartitionNexus.java (original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/partition/PartitionNexus.java Fri Jul 22 00:02:02 2011
@@ -78,12 +78,6 @@ public interface PartitionNexus extends 
 
 
     /**
-     * @return The ou=system partition 
-     */
-    public Partition getSystemPartition();
-
-
-    /**
      * Get's the partition corresponding to a distinguished name.  This 
      * name need not be the name of the partition suffix.  When used in 
      * conjunction with get suffix this can properly find the partition 
@@ -105,7 +99,7 @@ public interface PartitionNexus extends 
      * @return the suffix portion of dn, or the valid empty string Dn if no
      * naming context was found for dn.
      */
-    public Dn findSuffix( Dn dn ) throws LdapException;
+    public Dn getSuffixDn( Dn dn ) throws LdapException;
 
 
     /**

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java (original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java Fri Jul 22 00:02:02 2011
@@ -24,7 +24,6 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.directory.server.constants.ApacheSchemaConstants;
-import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.interceptor.context.AddOperationContext;
 import org.apache.directory.server.core.interceptor.context.BindOperationContext;
@@ -51,8 +50,10 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.entry.Modification;
 import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.message.controls.Cascade;
 import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.apache.directory.shared.ldap.model.schema.SchemaUtils;
 import org.apache.directory.shared.util.DateUtils;
 import org.slf4j.Logger;
@@ -105,7 +106,7 @@ public final class SchemaPartition exten
     private static final Logger LOG = LoggerFactory.getLogger( SchemaPartition.class );
 
     /** the fixed id: 'schema' */
-    private static final String ID = "schema";
+    private static final String SCHEMA_ID = "schema";
 
     /** the wrapped Partition */
     private Partition wrapped;
@@ -114,12 +115,29 @@ public final class SchemaPartition exten
     private RegistrySynchronizerAdaptor synchronizer;
 
     /** A static Dn for the ou=schemaModifications entry */
-    private static Dn schemaModificationDn;
+    private static Dn SCHEMA_MODIFICATION_DN;
 
     /** A static Dn for the ou=schema partition */
-    private static Dn schemaDn;
+    private static Dn SCHEMA_DN;
 
 
+    public SchemaPartition( SchemaManager schemaManager )
+    {
+        try
+        {
+            SCHEMA_DN = new Dn( schemaManager, SchemaConstants.OU_SCHEMA );
+        }
+        catch ( LdapInvalidDnException lide )
+        {
+            // Nothing to do : this is a valid DN anyways
+        }
+        
+        id = SCHEMA_ID;
+        suffixDn = SCHEMA_DN;
+        this.schemaManager = schemaManager;
+    }
+    
+    
     /**
      * Sets the wrapped {@link Partition} which must be supplied or 
      * {@link Partition#initialize()} will fail with a NullPointerException.
@@ -149,39 +167,12 @@ public final class SchemaPartition exten
 
 
     /**
-     * Get's the ID which is fixed: 'schema'.
-     */
-    public String getId()
-    {
-        return ID;
-    }
-
-
-    /**
-     * Has no affect: the id is fixed at {@link SchemaPartition#ID}: 'schema'.
+     * Has no affect: the id is fixed at {@link SchemaPartition#SCHEMA_ID}: 'schema'.
      * A warning is logged.
      */
     public void setId( String id )
     {
-        LOG.warn( "This partition's ID is fixed: {}", ID );
-    }
-
-
-    /**
-     * Always returns {@link ServerDNConstants#OU_SCHEMA_DN_NORMALIZED}: '2.5.4.11=schema'.
-     */
-    public Dn getSuffix()
-    {
-        return wrapped.getSuffix();
-    }
-
-
-    /**
-     * Has no affect: just logs a warning.
-     */
-    public void setSuffix( Dn suffix )
-    {
-        LOG.warn( "This partition's suffix is fixed: {}", SchemaConstants.OU_SCHEMA );
+        LOG.warn( "This partition's ID is fixed: {}", SCHEMA_ID );
     }
 
 
@@ -205,29 +196,30 @@ public final class SchemaPartition exten
     @Override
     protected void doInit() throws Exception
     {
-        // -----------------------------------------------------------------------
-        // Load apachemeta schema from within the ldap-schema Jar with all the
-        // schema it depends on.  This is a minimal mandatory set of schemas.
-        // -----------------------------------------------------------------------
-        schemaDn = new Dn( schemaManager, SchemaConstants.OU_SCHEMA );
-        
-        wrapped.setId( ID );
-        wrapped.setSuffix( schemaDn );
-        wrapped.setSchemaManager( schemaManager );
-
-        try
-        {
-            wrapped.initialize();
-
-            synchronizer = new RegistrySynchronizerAdaptor( schemaManager );
-        }
-        catch ( Exception e )
+        if ( !initialized )
         {
-            LOG.error( I18n.err( I18n.ERR_90 ), e );
-            throw new RuntimeException( e );
+            // -----------------------------------------------------------------------
+            // Load apachemeta schema from within the ldap-schema Jar with all the
+            // schema it depends on.  This is a minimal mandatory set of schemas.
+            // -----------------------------------------------------------------------
+            wrapped.setId( SCHEMA_ID );
+            wrapped.setSuffixDn( SCHEMA_DN );
+            wrapped.setSchemaManager( schemaManager );
+    
+            try
+            {
+                wrapped.initialize();
+    
+                synchronizer = new RegistrySynchronizerAdaptor( schemaManager );
+            }
+            catch ( Exception e )
+            {
+                LOG.error( I18n.err( I18n.ERR_90 ), e );
+                throw new RuntimeException( e );
+            }
+    
+            SCHEMA_MODIFICATION_DN = new Dn( schemaManager, SchemaConstants.SCHEMA_MODIFICATIONS_DN );
         }
-
-        schemaModificationDn = new Dn( schemaManager, SchemaConstants.SCHEMA_MODIFICATIONS_DN );
     }
 
 
@@ -355,7 +347,7 @@ public final class SchemaPartition exten
             wrapped.modify( modifyContext );
         }
 
-        if ( !modifyContext.getDn().equals(schemaModificationDn) )
+        if ( !modifyContext.getDn().equals( SCHEMA_MODIFICATION_DN ) )
         {
             updateSchemaModificationAttributes( modifyContext );
         }
@@ -459,7 +451,7 @@ public final class SchemaPartition exten
             ApacheSchemaConstants.SCHEMA_MODIFIERS_NAME_AT, schemaManager
                 .lookupAttributeTypeRegistry( ApacheSchemaConstants.SCHEMA_MODIFIERS_NAME_AT ), modifiersName ) ) );
 
-        opContext.modify(schemaModificationDn, mods, ByPassConstants.SCHEMA_MODIFICATION_ATTRIBUTES_UPDATE_BYPASS );
+        opContext.modify( SCHEMA_MODIFICATION_DN, mods, ByPassConstants.SCHEMA_MODIFICATION_ATTRIBUTES_UPDATE_BYPASS );
     }
 
 
@@ -468,6 +460,6 @@ public final class SchemaPartition exten
      */
     public String toString()
     {
-        return "Partition : " + ID;
+        return "Partition : " + SCHEMA_ID;
     }
 }

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDaoImpl.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDaoImpl.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDaoImpl.java (original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDaoImpl.java Fri Jul 22 00:02:02 2011
@@ -116,7 +116,7 @@ public class SchemaPartitionDaoImpl impl
     private final AttributeType M_DEPENDENCIES_AT;
 
     private final Set<AttributeTypeOptions> schemaAttributesToReturn = new HashSet<AttributeTypeOptions>();
-    private final AttributeType disabledAttributeType;
+    private final AttributeType DISABLED_ATTRIBUTE_TYPE_AT;
 
 
     /**
@@ -132,21 +132,21 @@ public class SchemaPartitionDaoImpl impl
         this.factory = new SchemaEntityFactory();
         this.schemaManager = schemaManager;
 
-        this.M_NAME_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_NAME_AT );
-        this.disabledAttributeType = schemaManager.getAttributeType( MetaSchemaConstants.M_DISABLED_AT );
-        this.M_OID_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_OID_AT );
+        M_NAME_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_NAME_AT );
+        DISABLED_ATTRIBUTE_TYPE_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_DISABLED_AT );
+        M_OID_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_OID_AT );
         OBJECT_CLASS_AT = schemaManager.getAttributeType( SchemaConstants.OBJECT_CLASS_AT );
-        this.M_SYNTAX_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_SYNTAX_AT );
-        this.M_ORDERING_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_ORDERING_AT );
-        this.M_EQUALITY_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_EQUALITY_AT );
-        this.M_SUBSTRING_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_SUBSTR_AT );
-        this.M_SUP_ATTRIBUTE_TYPE_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_SUP_ATTRIBUTE_TYPE_AT );
-        this.M_MUST_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_MUST_AT );
-        this.M_MAY_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_MAY_AT );
-        this.M_AUX_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_AUX_AT );
-        this.M_OC_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_OC_AT );
-        this.M_SUP_OBJECT_CLASS_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_SUP_OBJECT_CLASS_AT );
-        this.M_DEPENDENCIES_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_DEPENDENCIES_AT );
+        M_SYNTAX_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_SYNTAX_AT );
+        M_ORDERING_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_ORDERING_AT );
+        M_EQUALITY_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_EQUALITY_AT );
+        M_SUBSTRING_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_SUBSTR_AT );
+        M_SUP_ATTRIBUTE_TYPE_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_SUP_ATTRIBUTE_TYPE_AT );
+        M_MUST_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_MUST_AT );
+        M_MAY_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_MAY_AT );
+        M_AUX_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_AUX_AT );
+        M_OC_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_OC_AT );
+        M_SUP_OBJECT_CLASS_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_SUP_OBJECT_CLASS_AT );
+        M_DEPENDENCIES_AT = schemaManager.getAttributeType( MetaSchemaConstants.M_DEPENDENCIES_AT );
 
         for ( String attrId : SCHEMA_ATTRIBUTES )
         {
@@ -242,7 +242,7 @@ public class SchemaPartitionDaoImpl impl
 
         try
         {
-            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffix(),
+            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffixDn(),
                 filter, searchControls );
             searchOperationContext.setAliasDerefMode( AliasDerefMode.DEREF_ALWAYS );
 
@@ -294,7 +294,7 @@ public class SchemaPartitionDaoImpl impl
 
         try
         {
-            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffix(),
+            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffixDn(),
                 filter, searchControls );
             searchOperationContext.setAliasDerefMode( AliasDerefMode.DEREF_ALWAYS );
 
@@ -346,7 +346,7 @@ public class SchemaPartitionDaoImpl impl
 
         try
         {
-            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffix(),
+            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffixDn(),
                 filter, searchControls );
             searchOperationContext.setAliasDerefMode( AliasDerefMode.DEREF_ALWAYS );
 
@@ -398,7 +398,7 @@ public class SchemaPartitionDaoImpl impl
 
         try
         {
-            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffix(),
+            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffixDn(),
                 filter, searchControls );
             searchOperationContext.setAliasDerefMode( AliasDerefMode.DEREF_ALWAYS );
 
@@ -450,7 +450,7 @@ public class SchemaPartitionDaoImpl impl
 
         try
         {
-            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffix(),
+            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffixDn(),
                 filter, searchControls );
             searchOperationContext.setAliasDerefMode( AliasDerefMode.DEREF_ALWAYS );
 
@@ -530,7 +530,7 @@ public class SchemaPartitionDaoImpl impl
 
         try
         {
-            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffix(),
+            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffixDn(),
                 filter, searchControls );
             searchOperationContext.setAliasDerefMode( AliasDerefMode.DEREF_ALWAYS );
 
@@ -567,7 +567,7 @@ public class SchemaPartitionDaoImpl impl
     {
         Dn dn = new Dn( schemaManager, "cn=" + schemaName + ",ou=schema" );
         Entry entry = partition.lookup( new LookupOperationContext( null, dn ) );
-        Attribute disabledAttr = entry.get( disabledAttributeType );
+        Attribute disabledAttr = entry.get( DISABLED_ATTRIBUTE_TYPE_AT );
         List<Modification> mods = new ArrayList<Modification>( 3 );
 
         if ( disabledAttr == null )
@@ -623,7 +623,7 @@ public class SchemaPartitionDaoImpl impl
 
         try
         {
-            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffix(),
+            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffixDn(),
                 filter, searchControls );
             searchOperationContext.setAliasDerefMode( AliasDerefMode.DEREF_ALWAYS );
 
@@ -682,7 +682,7 @@ public class SchemaPartitionDaoImpl impl
 
         try
         {
-            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffix(),
+            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffixDn(),
                 filter, searchControls );
             searchOperationContext.setAliasDerefMode( AliasDerefMode.DEREF_ALWAYS );
 
@@ -718,7 +718,7 @@ public class SchemaPartitionDaoImpl impl
         filter.addNode( new PresenceNode( M_OID_AT ) );
         filter.addNode( new PresenceNode( M_NAME_AT ) );
 
-        SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffix(),
+        SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffixDn(),
             filter, searchControls );
         searchOperationContext.setAliasDerefMode( AliasDerefMode.DEREF_ALWAYS );
 
@@ -772,7 +772,7 @@ public class SchemaPartitionDaoImpl impl
 
         try
         {
-            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffix(),
+            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffixDn(),
                 filter, searchControls );
             searchOperationContext.setAliasDerefMode( AliasDerefMode.DEREF_ALWAYS );
 
@@ -820,7 +820,7 @@ public class SchemaPartitionDaoImpl impl
 
         try
         {
-            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffix(),
+            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffixDn(),
                 filter, searchControls );
             searchOperationContext.setAliasDerefMode( AliasDerefMode.DEREF_ALWAYS );
 
@@ -862,7 +862,7 @@ public class SchemaPartitionDaoImpl impl
 
         try
         {
-            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffix(),
+            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffixDn(),
                 filter, searchControls );
             searchOperationContext.setAliasDerefMode( AliasDerefMode.DEREF_ALWAYS );
 
@@ -871,7 +871,7 @@ public class SchemaPartitionDaoImpl impl
             while ( cursor.next() )
             {
                 Entry sr = cursor.get();
-                Attribute disabled = sr.get( disabledAttributeType );
+                Attribute disabled = sr.get( DISABLED_ATTRIBUTE_TYPE_AT );
 
                 if ( disabled == null )
                 {
@@ -948,7 +948,7 @@ public class SchemaPartitionDaoImpl impl
 
         try
         {
-            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffix(),
+            SearchOperationContext searchOperationContext = new SearchOperationContext( null, partition.getSuffixDn(),
                 filter, searchControls );
             searchOperationContext.setAliasDerefMode( AliasDerefMode.DEREF_ALWAYS );
 

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaService.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaService.java (original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaService.java Fri Jul 22 00:02:02 2011
@@ -48,14 +48,6 @@ public interface SchemaService
     SchemaPartition getSchemaPartition();
 
     /**
-     * Initializes the SchemaService
-     *
-     * @throws Exception If the initializaion fails
-     */
-    void initialize() throws LdapException;
-
-
-    /**
      * A seriously unsafe (unsynchronized) means to access the schemaSubentry.
      *
      * @return the schemaSubentry

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/configuration/PartitionConfigurationIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/configuration/PartitionConfigurationIT.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/configuration/PartitionConfigurationIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/configuration/PartitionConfigurationIT.java Fri Jul 22 00:02:02 2011
@@ -28,6 +28,7 @@ import java.util.UUID;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.server.core.annotations.CreateDS;
 import org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory;
+import org.apache.directory.server.core.factory.DirectoryServiceFactory;
 import org.apache.directory.server.core.factory.PartitionFactory;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
@@ -55,8 +56,9 @@ public class PartitionConfigurationIT ex
     @Test
     public void testAddAndRemove() throws Exception
     {
-        PartitionFactory partitionFactory = DefaultDirectoryServiceFactory.DEFAULT.getPartitionFactory();
-        Partition partition = partitionFactory.createPartition( "removable", "ou=removable", 100, getService()
+        DirectoryServiceFactory dsFactory = DefaultDirectoryServiceFactory.class.newInstance();
+        PartitionFactory partitionFactory = dsFactory.getPartitionFactory();
+        Partition partition = partitionFactory.createPartition( getService().getSchemaManager(), "removable", "ou=removable", 100, getService()
             .getInstanceLayout().getPartitionsDirectory() );
 
         // Test AddContextPartition

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchWithIndicesIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchWithIndicesIT.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchWithIndicesIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchWithIndicesIT.java Fri Jul 22 00:02:02 2011
@@ -29,6 +29,7 @@ import java.util.Set;
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.server.core.annotations.CreateDS;
 import org.apache.directory.server.core.factory.DefaultDirectoryServiceFactory;
+import org.apache.directory.server.core.factory.DirectoryServiceFactory;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.server.core.integ.IntegrationUtils;
@@ -79,7 +80,8 @@ public class SearchWithIndicesIT extends
         isNisDisabled = nisEntry.contains( "m-disabled", "TRUE" );
 
         Partition systemPartition = getService().getSystemPartition();
-        DefaultDirectoryServiceFactory.DEFAULT.getPartitionFactory().addIndex( systemPartition, "gidNumber", 100 );
+        DirectoryServiceFactory dsFactory = DefaultDirectoryServiceFactory.class.newInstance();
+        dsFactory.getPartitionFactory().addIndex( systemPartition, "gidNumber", 100 );
         
         // Restart the service so that the index is created
         getService().shutdown();

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java Fri Jul 22 00:02:02 2011
@@ -99,6 +99,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.model.ldif.LdifReader;
 import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.ldap.model.name.DnUtils;
 import org.apache.directory.shared.ldap.model.name.Rdn;
 import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.apache.directory.shared.ldap.util.tree.DnNode;
@@ -326,7 +327,6 @@ public class DefaultDirectoryService imp
         journal = new DefaultJournal();
         syncPeriodMillis = DEFAULT_SYNC_PERIOD;
         csnFactory = new CsnFactory( replicaId );
-        schemaService = new DefaultSchemaService();
     }
 
 
@@ -668,7 +668,7 @@ public class DefaultDirectoryService imp
             // can be null when called before starting up
             if ( partitionNexus != null )
             {
-                partitionNexus.removeContextPartition( partition.getSuffix() );
+                partitionNexus.removeContextPartition( partition.getSuffixDn() );
             }
         }
         catch ( LdapException le )
@@ -988,7 +988,7 @@ public class DefaultDirectoryService imp
 
         // load the last stored valid CSN value
         LookupOperationContext loc = new LookupOperationContext( getAdminSession() );
-        loc.setDn( systemPartition.getSuffix() );
+        loc.setDn( systemPartition.getSuffixDn() );
         loc.setAttrsId( new String[]{ SchemaConstants.CONTEXT_CSN_AT } );
         Entry entry = systemPartition.lookup( loc );
 
@@ -1472,6 +1472,36 @@ public class DefaultDirectoryService imp
             }
         }
     }
+    
+    
+    private void initializeSystemPartition() throws Exception
+    {
+        Partition system = getSystemPartition();
+        
+        // Add root context entry for system partition
+        Dn systemSuffixDn = getDnFactory().create( ServerDNConstants.SYSTEM_DN );
+        CoreSession adminSession = getAdminSession();
+
+        if ( !system.hasEntry( new EntryOperationContext( adminSession, systemSuffixDn ) ) )
+        {
+            Entry systemEntry = new DefaultEntry( schemaManager, systemSuffixDn );
+            
+            // Add the ObjectClasses
+            systemEntry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC,
+                SchemaConstants.ORGANIZATIONAL_UNIT_OC, SchemaConstants.EXTENSIBLE_OBJECT_OC );
+            
+            // Add some operational attributes
+            systemEntry.put( SchemaConstants.CREATORS_NAME_AT, ServerDNConstants.ADMIN_SYSTEM_DN );
+            systemEntry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
+            systemEntry.add( SchemaConstants.ENTRY_CSN_AT, getCSN().toString() );
+            systemEntry.add( SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString() );
+            systemEntry.put( DnUtils.getRdnAttributeType( ServerDNConstants.SYSTEM_DN ), DnUtils
+                .getRdnValue( ServerDNConstants.SYSTEM_DN ) );
+            
+            AddOperationContext addOperationContext = new AddOperationContext( adminSession, systemEntry );
+            system.add( addOperationContext );
+        }
+    }
 
 
     /**
@@ -1486,6 +1516,11 @@ public class DefaultDirectoryService imp
             LOG.debug( "---> Initializing the DefaultDirectoryService " );
         }
         
+        if ( schemaService == null )
+        {
+            schemaService = new DefaultSchemaService( schemaManager );
+        }
+
         cacheService = new CacheService();
         cacheService.initialize( this );
 
@@ -1498,10 +1533,9 @@ public class DefaultDirectoryService imp
         dnFactory = new DefaultDnFactory( schemaManager, cacheService.getCache( "dnCache" ) );
         
         // triggers partition to load schema fully from schema partition
-        schemaService.initialize();
         schemaService.getSchemaPartition().initialize();
         partitions.add( schemaService.getSchemaPartition() );
-        systemPartition.getSuffix().apply( schemaManager );
+        systemPartition.getSuffixDn().apply( schemaManager );
 
         adminDn = getDnFactory().create( ServerDNConstants.ADMIN_SYSTEM_DN );
         adminSession = new DefaultCoreSession( new LdapPrincipal( schemaManager, adminDn, AuthenticationLevel.STRONG ), this );
@@ -1511,6 +1545,8 @@ public class DefaultDirectoryService imp
         partitionNexus.setDirectoryService( this );
         partitionNexus.initialize( );
 
+        initializeSystemPartition();
+        
         // --------------------------------------------------------------------
         // Create all the bootstrap entries before initializing chain
         // --------------------------------------------------------------------
@@ -1530,7 +1566,7 @@ public class DefaultDirectoryService imp
 
             if( changeLog.isExposed() && changeLog.isTagSearchSupported() )
             {
-                String clSuffix = ( ( TaggableSearchableChangeLogStore ) changeLog.getChangeLogStore() ).getPartition().getSuffix().getName();
+                String clSuffix = ( ( TaggableSearchableChangeLogStore ) changeLog.getChangeLogStore() ).getPartition().getSuffixDn().getName();
                 partitionNexus.getRootDSE( null ).add( SchemaConstants.CHANGELOG_CONTEXT_AT, clSuffix );
             }
         }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java Fri Jul 22 00:02:02 2011
@@ -50,6 +50,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.message.controls.ManageDsaITImpl;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.apache.directory.shared.ldap.model.schema.AttributeType;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -70,6 +71,9 @@ public class ChangeLogInterceptor extend
     /** the changelog service to log changes to */
     private ChangeLog changeLog;
     
+    /** we need the schema manager to deal with special conditions */
+    private SchemaManager schemaManager;
+    
     /** we need the schema service to deal with special conditions */
     private SchemaService schemaService;
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java Fri Jul 22 00:02:02 2011
@@ -126,7 +126,7 @@ public class ExceptionInterceptor extend
             throw new LdapEntryAlreadyExistsException( I18n.err( I18n.ERR_249 ) );
         }
 
-        Dn suffix = nexus.findSuffix( name );
+        Dn suffix = nexus.getSuffixDn( name );
 
         // we're adding the suffix entry so just ignore stuff to mess with the parent
         if ( suffix.equals( name ) )



Mime
View raw message