directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1149411 [3/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
Modified: directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java (original)
+++ directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java Fri Jul 22 00:02:02 2011
@@ -29,12 +29,10 @@ import java.util.List;
 import java.util.UUID;
 
 import org.apache.directory.server.core.interceptor.context.AddOperationContext;
-import org.apache.directory.server.core.interceptor.context.BindOperationContext;
 import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
 import org.apache.directory.server.core.interceptor.context.MoveAndRenameOperationContext;
 import org.apache.directory.server.core.interceptor.context.MoveOperationContext;
 import org.apache.directory.server.core.interceptor.context.RenameOperationContext;
-import org.apache.directory.server.core.partition.impl.avl.AvlPartition;
 import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.xdbm.IndexEntry;
@@ -53,6 +51,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.apache.directory.shared.ldap.model.name.Rdn;
 import org.apache.directory.shared.ldap.model.schema.AttributeType;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.apache.directory.shared.util.Strings;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -122,9 +121,9 @@ public class LdifPartition extends Abstr
     /**
      * Creates a new instance of LdifPartition.
      */
-    public LdifPartition()
+    public LdifPartition( SchemaManager schemaManager )
     {
-        wrappedPartition = new AvlPartition();
+        super( schemaManager );
     }
 
 
@@ -133,92 +132,85 @@ public class LdifPartition extends Abstr
      */
     protected void doInit() throws Exception
     {
-        // Initialize the AvlPartition
-        wrappedPartition.setId( id );
-        wrappedPartition.setSuffix( suffix );
-        wrappedPartition.initialize();
-
-        this.searchEngine = wrappedPartition.getSearchEngine();
-
-        LOG.debug( "id is : {}", wrappedPartition.getId() );
-
-        File partitionDir = new File( getPartitionPath() );
-
-        // Initialize the suffixDirectory : it's a composition
-        // of the workingDirectory followed by the suffix
-        if ( ( suffix == null ) || ( suffix.isEmpty() ) )
-        {
-            String msg = I18n.err( I18n.ERR_150 );
-            LOG.error( msg );
-            throw new LdapInvalidDnException( msg );
-        }
-
-        if ( !suffix.isSchemaAware() )
-        {
-            suffix.apply( schemaManager );
-        }
-
-        String suffixDirName = getFileName( suffix );
-        suffixDirectory = new File( partitionDir, suffixDirName );
-
-        // Create the context entry now, if it does not exists, or load the
-        // existing entries
-        if ( suffixDirectory.exists() )
+        if ( !initialized )
         {
-            loadEntries( partitionDir );
-        }
-        else
-        {
-            // The partition directory does not exist, we have to create it, including parent directories
-            try
+            File partitionDir = new File( getPartitionPath() );
+    
+            // Initialize the suffixDirectory : it's a composition
+            // of the workingDirectory followed by the suffix
+            if ( ( suffixDn == null ) || ( suffixDn.isEmpty() ) )
             {
-                suffixDirectory.mkdirs();
+                String msg = I18n.err( I18n.ERR_150 );
+                LOG.error( msg );
+                throw new LdapInvalidDnException( msg );
             }
-            catch ( SecurityException se )
+    
+            if ( !suffixDn.isSchemaAware() )
             {
-                String msg = I18n.err( I18n.ERR_151, suffixDirectory.getAbsolutePath(), se.getLocalizedMessage() );
-                LOG.error( msg );
-                throw se;
+                suffixDn.apply( schemaManager );
             }
-
-            // And create the context entry too
-            File contextEntryFile = new File( suffixDirectory + CONF_FILE_EXTN );
-
-            LOG.info( "ldif file doesn't exist {}, creating it.", contextEntryFile.getAbsolutePath() );
-
-            if ( contextEntry == null )
+    
+            String suffixDirName = getFileName( suffixDn );
+            suffixDirectory = new File( partitionDir, suffixDirName );
+    
+            super.doInit();
+    
+            // Create the context entry now, if it does not exists, or load the
+            // existing entries
+            if ( suffixDirectory.exists() )
+            {
+                loadEntries( partitionDir );
+            }
+            else
             {
-                if ( contextEntryFile.exists() )
+                // The partition directory does not exist, we have to create it, including parent directories
+                try
                 {
-                    LdifReader reader = new LdifReader( contextEntryFile );
-                    contextEntry = new DefaultEntry( schemaManager, reader.next().getEntry() );
-                    reader.close();
+                    suffixDirectory.mkdirs();
                 }
-                else
+                catch ( SecurityException se )
                 {
-                    // No context entry and no LDIF file exists.
-                    // Skip initialization of context entry here, it will be added later.
-                    return;
+                    String msg = I18n.err( I18n.ERR_151, suffixDirectory.getAbsolutePath(), se.getLocalizedMessage() );
+                    LOG.error( msg );
+                    throw se;
                 }
+    
+                // And create the context entry too
+                File contextEntryFile = new File( suffixDirectory + CONF_FILE_EXTN );
+    
+                LOG.info( "ldif file doesn't exist {}, creating it.", contextEntryFile.getAbsolutePath() );
+    
+                if ( contextEntry == null )
+                {
+                    if ( contextEntryFile.exists() )
+                    {
+                        LdifReader reader = new LdifReader( contextEntryFile );
+                        contextEntry = new DefaultEntry( schemaManager, reader.next().getEntry() );
+                        reader.close();
+                    }
+                    else
+                    {
+                        // No context entry and no LDIF file exists.
+                        // Skip initialization of context entry here, it will be added later.
+                        return;
+                    }
+                }
+    
+                if ( contextEntry.get( SchemaConstants.ENTRY_CSN_AT ) == null )
+                {
+                    contextEntry.add( SchemaConstants.ENTRY_CSN_AT, defaultCSNFactory.newInstance().toString() );
+                }
+    
+                if ( contextEntry.get( SchemaConstants.ENTRY_UUID_AT ) == null )
+                {
+                    String uuid = UUID.randomUUID().toString();
+                    contextEntry.add( SchemaConstants.ENTRY_UUID_AT, uuid );
+                }
+    
+                // And add this entry to the underlying partition
+                AddOperationContext addContext = new AddOperationContext( null, contextEntry );
+                add( addContext );
             }
-
-            if ( contextEntry.get( SchemaConstants.ENTRY_CSN_AT ) == null )
-            {
-                contextEntry.add( SchemaConstants.ENTRY_CSN_AT, defaultCSNFactory.newInstance().toString() );
-            }
-
-            if ( contextEntry.get( SchemaConstants.ENTRY_UUID_AT ) == null )
-            {
-                String uuid = UUID.randomUUID().toString();
-                contextEntry.add( SchemaConstants.ENTRY_UUID_AT, uuid );
-            }
-
-            FileWriter fw = new FileWriter( contextEntryFile );
-            fw.write( LdifUtils.convertToLdif( contextEntry ) );
-            fw.close();
-
-            // And add this entry to the underlying partition
-            wrappedPartition.getStore().add( contextEntry );
         }
     }
 
@@ -231,29 +223,19 @@ public class LdifPartition extends Abstr
      */
     public void add( AddOperationContext addContext ) throws LdapException
     {
-        wrappedPartition.add( addContext );
-        add( addContext.getEntry() );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void bind( BindOperationContext bindContext ) throws LdapException
-    {
-        wrappedPartition.bind( bindContext );
+        super.add( addContext );
+        addEntry( addContext.getEntry() );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    @Override
     public void delete( Long id ) throws LdapException
     {
         Entry entry = lookup( id );
 
-        wrappedPartition.delete( id );
+        super.delete( id );
 
         if ( entry != null )
         {
@@ -272,9 +254,7 @@ public class LdifPartition extends Abstr
 
                 LOG.debug( "deleted file {} {}", parentFile.getAbsoluteFile(), deleted );
             }
-
         }
-
     }
 
 
@@ -285,7 +265,14 @@ public class LdifPartition extends Abstr
     {
         Long id = getEntryId( modifyContext.getDn() );
 
-        wrappedPartition.modify( modifyContext.getDn(), modifyContext.getModItems().toArray( new Modification[]{} ) );
+        try
+        {
+            super.modify( modifyContext.getDn(), modifyContext.getModItems().toArray( new Modification[]{} ) );
+        }
+        catch ( Exception e )
+        {
+            throw new LdapOperationException( e.getMessage(), e );
+        }
 
         // Get the modified entry and store it in the context for post usage
         Entry modifiedEntry = lookup( id );
@@ -316,7 +303,7 @@ public class LdifPartition extends Abstr
         Dn oldDn = moveContext.getDn();
         Long id = getEntryId( oldDn );
 
-        wrappedPartition.move( moveContext );
+        super.move( moveContext );
 
         // Get the modified entry
         Entry modifiedEntry = lookup( id );
@@ -333,7 +320,7 @@ public class LdifPartition extends Abstr
         Dn oldDn = moveAndRenameContext.getDn();
         Long id = getEntryId( oldDn );
 
-        wrappedPartition.moveAndRename( moveAndRenameContext );
+        super.moveAndRename( moveAndRenameContext );
 
         // Get the modified entry and store it in the context for post usage
         Entry modifiedEntry = lookup( id );
@@ -352,7 +339,7 @@ public class LdifPartition extends Abstr
         Long id = getEntryId( oldDn );
 
         // Create the new entry
-        wrappedPartition.rename( renameContext );
+        super.rename( renameContext );
 
         // Get the modified entry and store it in the context for post usage
         Entry modifiedEntry = lookup( id );
@@ -377,7 +364,7 @@ public class LdifPartition extends Abstr
     private void entryMoved( Dn oldEntryDn, Entry modifiedEntry, Long entryIdOld ) throws LdapException
     {
         // First, add the new entry
-        add( modifiedEntry );
+        addEntry( modifiedEntry );
 
         // Then, if there are some children, move then to the new place
         try
@@ -391,7 +378,7 @@ public class LdifPartition extends Abstr
                 // except the parent entry add the rest of entries
                 if ( entry.getId() != entryIdOld )
                 {
-                    add( wrappedPartition.lookup( entry.getId() ) );
+                    addEntry( lookup( entry.getId() ) );
                 }
             }
 
@@ -467,7 +454,8 @@ public class LdifPartition extends Abstr
                     }
 
                     // call add on the wrapped partition not on the self
-                    wrappedPartition.getStore().add( serverEntry );
+                    AddOperationContext addContext = new AddOperationContext( null, serverEntry );
+                    super.add( addContext );
                 }
             }
 
@@ -496,29 +484,30 @@ public class LdifPartition extends Abstr
      */
     private File getFile( Dn entryDn, boolean create ) throws LdapException
     {
-        StringBuilder filePath = new StringBuilder();
-        filePath.append( suffixDirectory ).append( File.separator );
-
-        Dn baseDn = entryDn.getDescendantOf( suffix );
-        int size = baseDn.size();
-
-        for ( int i = 0; i < size - 1; i++ )
-        {
-            String rdnFileName = getFileName( baseDn.getRdn( size - 1 - i ) );
-
-            filePath.append( rdnFileName ).append( File.separator );
-        }
-
-        String rdnFileName = getFileName( entryDn.getRdn() ) + CONF_FILE_EXTN;
-
         String parentDir = null;
+        String rdnFileName = null;
 
-        if ( entryDn.equals( suffix ) )
+        if ( entryDn.equals( suffixDn ) )
         {
             parentDir = suffixDirectory.getParent() + File.separator;
+            rdnFileName = suffixDn.getName() + CONF_FILE_EXTN;
         }
         else
         {
+            StringBuilder filePath = new StringBuilder();
+            filePath.append( suffixDirectory ).append( File.separator );
+
+            Dn baseDn = entryDn.getDescendantOf( suffixDn );
+            int size = baseDn.size();
+
+            for ( int i = 0; i < size - 1; i++ )
+            {
+                rdnFileName = getFileName( baseDn.getRdn( size - 1 - i ) );
+
+                filePath.append( rdnFileName ).append( File.separator );
+            }
+
+            rdnFileName = getFileName( entryDn.getRdn() ) + CONF_FILE_EXTN;
             parentDir = filePath.toString();
         }
 
@@ -553,6 +542,7 @@ public class LdifPartition extends Abstr
         StringBuilder fileName = new StringBuilder( "" );
 
         Iterator<Ava> iterator = rdn.iterator();
+        
         while ( iterator.hasNext() )
         {
             Ava ava = iterator.next();
@@ -695,10 +685,10 @@ public class LdifPartition extends Abstr
 
 
     /**
-     * Write the new entry on disk. It does not exist, as this ha sbeen checked
+     * Write the new entry on disk. It does not exist, as this has been checked
      * by the ExceptionInterceptor.
      */
-    private void add( Entry entry ) throws LdapException
+    private void addEntry( Entry entry ) throws LdapException
     {
         try
         {
@@ -741,15 +731,6 @@ public class LdifPartition extends Abstr
 
 
     /**
-      * @return the contextEntry
-      */
-    public Entry getContextEntry()
-    {
-        return contextEntry;
-    }
-
-
-    /**
      * @param contextEntry the contextEntry to set
      */
     public void setContextEntry( String contextEntry ) throws LdapLdifException
@@ -775,12 +756,4 @@ public class LdifPartition extends Abstr
             throw new LdapLdifException( le.getMessage(), le );
         }
     }
-
-
-    @Override
-    protected void doDestroy() throws Exception
-    {
-        wrappedPartition.destroy();
-    }
-
 }
\ No newline at end of file

Modified: directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java (original)
+++ directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java Fri Jul 22 00:02:02 2011
@@ -32,24 +32,24 @@ import java.util.UUID;
 import javax.naming.InvalidNameException;
 
 import org.apache.directory.server.core.interceptor.context.AddOperationContext;
-import org.apache.directory.server.core.interceptor.context.BindOperationContext;
 import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
 import org.apache.directory.server.core.interceptor.context.MoveAndRenameOperationContext;
 import org.apache.directory.server.core.interceptor.context.MoveOperationContext;
 import org.apache.directory.server.core.interceptor.context.RenameOperationContext;
-import org.apache.directory.server.core.partition.impl.avl.AvlPartition;
 import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.xdbm.IndexEntry;
-import org.apache.directory.server.xdbm.impl.avl.AvlStore;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
 import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.apache.directory.shared.ldap.model.entry.Modification;
 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.LdapOperationException;
 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.ldif.LdifUtils;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.apache.directory.shared.util.Strings;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -81,53 +81,51 @@ public class SingleFileLdifPartition ext
     /**
      * Creates a new instance of SingleFileLdifPartition.
      */
-    public SingleFileLdifPartition()
+    public SingleFileLdifPartition( SchemaManager schemaManager )
     {
-        wrappedPartition = new AvlPartition();
+        super( schemaManager );
     }
 
 
     @Override
     protected void doInit() throws InvalidNameException, Exception
     {
-        if ( getPartitionPath() == null )
+        if ( !initialized )
         {
-            throw new IllegalArgumentException( "Partition path cannot be null" );
-        }
-
-        File partitionFile = new File( getPartitionPath() );
-        if ( partitionFile.exists() && !partitionFile.isFile() )
-        {
-            throw new IllegalArgumentException( "Partition path must be a LDIF file" );
-        }
-
-        ldifFile = new RandomAccessFile( partitionFile, "rws" );
-
-        // Initialize the AvlPartition
-        wrappedPartition.setId( id );
-        wrappedPartition.setSuffix( suffix );
-        wrappedPartition.setSchemaManager( schemaManager );
-        wrappedPartition.initialize();
-
-        this.searchEngine = wrappedPartition.getSearchEngine();
-
-        LOG.debug( "id is : {}", wrappedPartition.getId() );
-
-        // Initialize the suffixDirectory : it's a composition
-        // of the workingDirectory followed by the suffix
-        if ( ( suffix == null ) || ( suffix.isEmpty() ) )
-        {
-            String msg = I18n.err( I18n.ERR_150 );
-            LOG.error( msg );
-            throw new LdapInvalidDnException( msg );
-        }
-
-        if ( !suffix.isSchemaAware() )
-        {
-            suffix.apply( schemaManager );
+            if ( getPartitionPath() == null )
+            {
+                throw new IllegalArgumentException( "Partition path cannot be null" );
+            }
+    
+            File partitionFile = new File( getPartitionPath() );
+            
+            if ( partitionFile.exists() && !partitionFile.isFile() )
+            {
+                throw new IllegalArgumentException( "Partition path must be a LDIF file" );
+            }
+    
+            ldifFile = new RandomAccessFile( partitionFile, "rws" );
+    
+            LOG.debug( "id is : {}", getId() );
+    
+            // Initialize the suffixDirectory : it's a composition
+            // of the workingDirectory followed by the suffix
+            if ( ( suffixDn == null ) || ( suffixDn.isEmpty() ) )
+            {
+                String msg = I18n.err( I18n.ERR_150 );
+                LOG.error( msg );
+                throw new LdapInvalidDnException( msg );
+            }
+    
+            if ( !suffixDn.isSchemaAware() )
+            {
+                suffixDn.apply( schemaManager );
+            }
+    
+            super.doInit();
+            
+            loadEntries();
         }
-
-        loadEntries();
     }
 
 
@@ -150,12 +148,12 @@ public class SingleFileLdifPartition ext
 
         contextEntry = new DefaultEntry( schemaManager, ldifEntry.getEntry() );
 
-        AvlStore store = wrappedPartition.getStore();
-
-        if ( suffix.equals( contextEntry.getDn() ) )
+        if ( suffixDn.equals( contextEntry.getDn() ) )
         {
             addMandatoryOpAt( contextEntry );
-            store.add( contextEntry );
+
+            AddOperationContext addContext = new AddOperationContext( null, contextEntry );
+            super.add( addContext );
         }
         else
         {
@@ -169,30 +167,32 @@ public class SingleFileLdifPartition ext
             Entry entry = new DefaultEntry( schemaManager, ldifEntry.getEntry() );
 
             addMandatoryOpAt( entry );
-            store.add( entry );
+
+            AddOperationContext addContext = new AddOperationContext( null, entry );
+            super.add( addContext );
         }
 
         parser.close();
     }
 
 
-    public void bind( BindOperationContext bindContext ) throws LdapException
-    {
-        wrappedPartition.bind( bindContext );
-    }
-
-
+    //---------------------------------------------------------------------------------------------
+    // Operations
+    //---------------------------------------------------------------------------------------------
+    /**
+     * {@inheritDoc}
+     */
     public void add( AddOperationContext addContext ) throws LdapException
     {
         synchronized ( lock )
         {
-            wrappedPartition.add( addContext );
+            super.add( addContext );
 
             if ( contextEntry == null )
             {
                 Entry entry = addContext.getEntry();
 
-                if ( entry.getDn().equals( suffix ) )
+                if ( entry.getDn().equals( suffixDn ) )
                 {
                     contextEntry = entry;
                 }
@@ -204,44 +204,65 @@ public class SingleFileLdifPartition ext
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void modify( ModifyOperationContext modifyContext ) throws LdapException
     {
         synchronized ( lock )
         {
-            wrappedPartition.modify( modifyContext );
+            try
+            {
+                Entry modifiedEntry = super.modify( modifyContext.getDn(), modifyContext.getModItems().toArray( new Modification[]{} ) );
+                modifyContext.setAlteredEntry( modifiedEntry );
+            }
+            catch ( Exception e )
+            {
+                throw new LdapOperationException( e.getMessage(), e );
+            }
+
             dirty = true;
             rewritePartitionData();
         }
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void rename( RenameOperationContext renameContext ) throws LdapException
     {
         synchronized ( lock )
         {
-            wrappedPartition.rename( renameContext );
+            super.rename( renameContext );
             dirty = true;
             rewritePartitionData();
         }
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void move( MoveOperationContext moveContext ) throws LdapException
     {
         synchronized ( lock )
         {
-            wrappedPartition.move( moveContext );
+            super.move( moveContext );
             dirty = true;
             rewritePartitionData();
         }
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void moveAndRename( MoveAndRenameOperationContext opContext ) throws LdapException
     {
         synchronized ( lock )
         {
-            wrappedPartition.moveAndRename( opContext );
+            super.moveAndRename( opContext );
             dirty = true;
             rewritePartitionData();
         }
@@ -253,7 +274,7 @@ public class SingleFileLdifPartition ext
     {
         synchronized ( lock )
         {
-            wrappedPartition.delete( id );
+            super.delete( id );
             dirty = true;
             rewritePartitionData();
         }
@@ -279,7 +300,7 @@ public class SingleFileLdifPartition ext
             {
                 ldifFile.setLength( 0 ); // wipe the file clean
 
-                Long suffixId = wrappedPartition.getEntryId( suffix );
+                Long suffixId = getEntryId( suffixDn );
 
                 if( suffixId == null )
                 {
@@ -287,16 +308,16 @@ public class SingleFileLdifPartition ext
                     return;
                 }
                 
-                IndexCursor<Long, Entry, Long> cursor = wrappedPartition.getOneLevelIndex().forwardCursor( suffixId );
+                IndexCursor<Long, Entry, Long> cursor = getOneLevelIndex().forwardCursor( suffixId );
 
 
-                appendLdif( wrappedPartition.lookup( suffixId ) );
+                appendLdif( lookup( suffixId ) );
 
                 while ( cursor.next() )
                 {
                     Long childId = cursor.get().getId();
 
-                    Entry entry = wrappedPartition.lookup( childId );
+                    Entry entry = lookup( childId );
 
                     appendLdif( entry );
 
@@ -340,7 +361,7 @@ public class SingleFileLdifPartition ext
 
             if ( cursor == null )
             {
-                cursor = wrappedPartition.getOneLevelIndex().forwardCursor( entryId );
+                cursor = getOneLevelIndex().forwardCursor( entryId );
                 cursor.beforeFirst();
                 cursorMap.put( entryId, cursor );
             }
@@ -355,9 +376,9 @@ public class SingleFileLdifPartition ext
                 do
                 {
                     IndexEntry<Long, Entry, Long> idxEntry = cursor.get();
-                    Entry entry = wrappedPartition.lookup( idxEntry.getId() );
+                    Entry entry = lookup( idxEntry.getId() );
 
-                    Long childId = wrappedPartition.getEntryId( entry.getDn() );
+                    Long childId = getEntryId( entry.getDn() );
 
                     appendLdif( entry );
 
@@ -443,6 +464,9 @@ public class SingleFileLdifPartition ext
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     @Override
     protected void doDestroy() throws Exception
     {

Modified: directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/LdifPartitionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/LdifPartitionTest.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/LdifPartitionTest.java (original)
+++ directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/LdifPartitionTest.java Fri Jul 22 00:02:02 2011
@@ -137,9 +137,9 @@ public class LdifPartitionTest
 
         // initialize the store
         // initialize the partition
-        partition = new LdifPartition();
+        partition = new LdifPartition( schemaManager );
         partition.setId( "test-ldif" );
-        partition.setSuffix( new Dn( "ou=test,ou=system" ) );
+        partition.setSuffixDn( new Dn( "ou=test,ou=system" ) );
         partition.setSchemaManager( schemaManager );
         partition.setPartitionPath( wkdir.toURI() );
 
@@ -152,10 +152,9 @@ public class LdifPartitionTest
 
     private Entry createEntry( String dn ) throws Exception
     {
-        Entry entry = new DefaultEntry( schemaManager );
-        entry.setDn( new Dn( schemaManager, dn ) );
-        entry.put( SchemaConstants.ENTRY_CSN_AT, defaultCSNFactory.newInstance().toString() );
-        entry.add( SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString() );
+        Entry entry = new DefaultEntry( schemaManager, dn,
+            SchemaConstants.ENTRY_CSN_AT, defaultCSNFactory.newInstance().toString(),
+            SchemaConstants.ENTRY_UUID_AT, UUID.randomUUID().toString() );
 
         Entry clonedEntry = new ClonedServerEntry( entry );
 

Modified: directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/SingleFileLdifPartitionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/SingleFileLdifPartitionTest.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/SingleFileLdifPartitionTest.java (original)
+++ directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/SingleFileLdifPartitionTest.java Fri Jul 22 00:02:02 2011
@@ -212,10 +212,10 @@ public class SingleFileLdifPartitionTest
             rf.setLength( 0 );
         }
 
-        SingleFileLdifPartition partition = new SingleFileLdifPartition();
+        SingleFileLdifPartition partition = new SingleFileLdifPartition( schemaManager );
         partition.setId( "test-ldif" );
         partition.setPartitionPath( new File( fileName ).toURI() );
-        partition.setSuffix( new Dn( "ou=test,ou=system" ) );
+        partition.setSuffixDn( new Dn( "ou=test,ou=system" ) );
         partition.setSchemaManager( schemaManager );
         partition.initialize();
 
@@ -351,7 +351,7 @@ public class SingleFileLdifPartitionTest
         partition.add( addCtx );
 
         ModifyOperationContext modOpCtx = new ModifyOperationContext( mockSession );
-        modOpCtx.setEntry( new ClonedServerEntry( contextEntry ) );
+        modOpCtx.setEntry( contextEntry );
 
         List<Modification> modItems = new ArrayList<Modification>();
 

Modified: directory/apacheds/trunk/server-annotations/src/test/java/org/apache/directory/server/factory/DirectoryServiceAnnotationTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-annotations/src/test/java/org/apache/directory/server/factory/DirectoryServiceAnnotationTest.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/server-annotations/src/test/java/org/apache/directory/server/factory/DirectoryServiceAnnotationTest.java (original)
+++ directory/apacheds/trunk/server-annotations/src/test/java/org/apache/directory/server/factory/DirectoryServiceAnnotationTest.java Fri Jul 22 00:02:02 2011
@@ -153,12 +153,12 @@ 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() );
             }
             else if ( "schema".equalsIgnoreCase( partition.getId() ) )
             {
                 assertTrue( partition.isInitialized() );
-                assertEquals( "ou=schema", partition.getSuffix().getName() );
+                assertEquals( "ou=schema", partition.getSuffixDn().getName() );
             }
         }
         
@@ -220,12 +220,12 @@ 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() );
             }
             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/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java (original)
+++ directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigPartitionReader.java Fri Jul 22 00:02:02 2011
@@ -38,7 +38,6 @@ import javax.naming.directory.SearchCont
 
 import org.apache.directory.server.config.beans.AdsBaseBean;
 import org.apache.directory.server.config.beans.ConfigBean;
-import org.apache.directory.server.config.beans.ReplConsumerBean;
 import org.apache.directory.server.core.partition.impl.btree.AbstractBTreePartition;
 import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.server.xdbm.ForwardIndexEntry;
@@ -749,7 +748,7 @@ public class ConfigPartitionReader
 
                     // the requested element is mandatory so let's throw an exception
                     String message = "No directoryService instance was configured under the Dn "
-                        + configPartition.getSuffix();
+                        + configPartition.getSuffixDn();
                     LOG.error( message );
                     throw new ConfigurationException( message );
                 }
@@ -899,7 +898,7 @@ public class ConfigPartitionReader
 
         if ( baseDn == null )
         {
-            baseDn = configPartition.getSuffix();
+            baseDn = configPartition.getSuffixDn();
         }
 
         List<AdsBaseBean> beans = read( baseDn, objectClass, SearchScope.ONELEVEL, MANDATORY );

Modified: directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ReadOnlyConfigurationPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ReadOnlyConfigurationPartition.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ReadOnlyConfigurationPartition.java (original)
+++ directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ReadOnlyConfigurationPartition.java Fri Jul 22 00:02:02 2011
@@ -27,17 +27,16 @@ import java.util.UUID;
 import javax.naming.InvalidNameException;
 
 import org.apache.directory.server.core.interceptor.context.AddOperationContext;
-import org.apache.directory.server.core.interceptor.context.BindOperationContext;
 import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
 import org.apache.directory.server.core.interceptor.context.MoveAndRenameOperationContext;
 import org.apache.directory.server.core.interceptor.context.MoveOperationContext;
 import org.apache.directory.server.core.interceptor.context.RenameOperationContext;
 import org.apache.directory.server.core.partition.ldif.AbstractLdifPartition;
-import org.apache.directory.server.xdbm.impl.avl.AvlStore;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
 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.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.model.ldif.LdifReader;
 import org.apache.directory.shared.ldap.model.name.Dn;
@@ -65,8 +64,18 @@ public class ReadOnlyConfigurationPartit
      */
     public ReadOnlyConfigurationPartition( InputStream inputStream, SchemaManager schemaManager )
     {
+        super( schemaManager );
         this.inputStream = inputStream;
-        setSchemaManager( schemaManager );
+        id = "config";
+        
+        try
+        {
+            suffixDn = new Dn( schemaManager, "ou=config" );
+        }
+        catch ( LdapInvalidDnException lide )
+        {
+            // Nothing to do
+        }
     }
 
 
@@ -75,17 +84,14 @@ public class ReadOnlyConfigurationPartit
      */
     protected void doInit() throws InvalidNameException, Exception
     {
-        // Initializing the wrapped partition
-        setId( "config" );
-        setSuffix( new Dn( "ou=config" ) );
-        wrappedPartition.setSchemaManager( schemaManager );
-        wrappedPartition.initialize();
-
-        // Getting the search engine
-        searchEngine = wrappedPartition.getSearchEngine();
-
-        // Load LDIF entries
-        loadLdifEntries();
+        if ( ! initialized )
+        {
+            // Initializing the wrapped partition
+            super.doInit();
+    
+            // Load LDIF entries
+            loadLdifEntries();
+        }
     }
 
 
@@ -108,18 +114,17 @@ public class ReadOnlyConfigurationPartit
                 return;
             }
 
-            // Getting the wrapped partition store
-            AvlStore<Entry> store = wrappedPartition.getStore();
-
             // Getting the context entry
             LdifEntry ldifEntry = itr.next();
             contextEntry = new DefaultEntry( schemaManager, ldifEntry.getEntry() );
 
             // Checking the context entry
-            if ( suffix.equals( contextEntry.getDn() ) )
+            if ( suffixDn.equals( contextEntry.getDn() ) )
             {
                 addMandatoryOpAt( contextEntry );
-                store.add( contextEntry );
+                
+                AddOperationContext addContext = new AddOperationContext( null, contextEntry );
+                super.add( addContext );
             }
             else
             {
@@ -131,7 +136,9 @@ public class ReadOnlyConfigurationPartit
             {
                 Entry entry = new DefaultEntry( schemaManager, itr.next().getEntry() );
                 addMandatoryOpAt( entry );
-                store.add( entry );
+                
+                AddOperationContext addContext = new AddOperationContext( null, contextEntry );
+                super.add( addContext );
             }
 
             // Closing the reader
@@ -160,15 +167,9 @@ public class ReadOnlyConfigurationPartit
     }
 
 
-    /**
-     * {@inheritDoc}
-     */
-    public void bind( BindOperationContext bindContext ) throws LdapException
-    {
-        wrappedPartition.bind( bindContext );
-    }
-
-
+    //---------------------------------------------------------------------------------------------
+    // Operations
+    //---------------------------------------------------------------------------------------------
     /**
      * {@inheritDoc}
      */

Modified: directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ChangePasswordConfigReaderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ChangePasswordConfigReaderTest.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ChangePasswordConfigReaderTest.java (original)
+++ directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ChangePasswordConfigReaderTest.java Fri Jul 22 00:02:02 2011
@@ -110,10 +110,10 @@ public class ChangePasswordConfigReaderT
         File configDir = new File( workDir, "changePasswordServer" ); // could be any directory, cause the config is now in a single file
         String configFile = LdifConfigExtractor.extractSingleFileConfig( configDir, "changePasswordServer.ldif", true );
 
-        SingleFileLdifPartition configPartition = new SingleFileLdifPartition();
+        SingleFileLdifPartition configPartition = new SingleFileLdifPartition( schemaManager );
         configPartition.setId( "config" );
         configPartition.setPartitionPath( new File( configFile ).toURI() );
-        configPartition.setSuffix( new Dn( "ou=config" ) );
+        configPartition.setSuffixDn( new Dn( "ou=config" ) );
         configPartition.setSchemaManager( schemaManager );
         
         configPartition.initialize();

Modified: directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java (original)
+++ directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ConfigPartitionReaderTest.java Fri Jul 22 00:02:02 2011
@@ -103,10 +103,10 @@ public class ConfigPartitionReaderTest
 
         String configFile = LdifConfigExtractor.extractSingleFileConfig( configDir, "config.ldif", true );
 
-        SingleFileLdifPartition configPartition = new SingleFileLdifPartition();
+        SingleFileLdifPartition configPartition = new SingleFileLdifPartition( schemaManager );
         configPartition.setId( "config" );
         configPartition.setPartitionPath( new File( configFile ).toURI() );
-        configPartition.setSuffix( new Dn( "ou=config" ) );
+        configPartition.setSuffixDn( new Dn( "ou=config" ) );
         configPartition.setSchemaManager( schemaManager );
 
         configPartition.initialize();

Modified: directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ConfigWriterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ConfigWriterTest.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ConfigWriterTest.java (original)
+++ directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/ConfigWriterTest.java Fri Jul 22 00:02:02 2011
@@ -32,8 +32,6 @@ import java.util.Comparator;
 import java.util.List;
 
 import org.apache.commons.io.FileUtils;
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
 import org.apache.directory.server.config.beans.ConfigBean;
 import org.apache.directory.server.core.partition.ldif.SingleFileLdifPartition;
 import org.apache.directory.shared.ldap.model.entry.Entry;
@@ -51,6 +49,9 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
 
 /**
  * Test class for ConfigWriter
@@ -109,10 +110,10 @@ public class ConfigWriterTest
         String configFile = LdifConfigExtractor.extractSingleFileConfig( configDir, "config.ldif", true );
 
         // Creating of the config partition
-        SingleFileLdifPartition configPartition = new SingleFileLdifPartition();
+        SingleFileLdifPartition configPartition = new SingleFileLdifPartition( schemaManager );
         configPartition.setId( "config" );
         configPartition.setPartitionPath( new File( configFile ).toURI() );
-        configPartition.setSuffix( new Dn( "ou=config" ) );
+        configPartition.setSuffixDn( new Dn( "ou=config" ) );
         configPartition.setSchemaManager( schemaManager );
         configPartition.initialize();
 

Modified: directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/DhcpServerConfigReaderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/DhcpServerConfigReaderTest.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/DhcpServerConfigReaderTest.java (original)
+++ directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/DhcpServerConfigReaderTest.java Fri Jul 22 00:02:02 2011
@@ -103,10 +103,10 @@ public class DhcpServerConfigReaderTest
         File configDir = new File( workDir, "dhcpServer" ); // could be any directory, cause the config is now in a single file
         String configFile = LdifConfigExtractor.extractSingleFileConfig( configDir, "dhcpServer.ldif", true );
 
-        SingleFileLdifPartition configPartition = new SingleFileLdifPartition();
+        SingleFileLdifPartition configPartition = new SingleFileLdifPartition( schemaManager );
         configPartition.setId( "config" );
         configPartition.setPartitionPath( new File( configFile ).toURI() );
-        configPartition.setSuffix( new Dn( "ou=config" ) );
+        configPartition.setSuffixDn( new Dn( "ou=config" ) );
         configPartition.setSchemaManager( schemaManager );
         
         configPartition.initialize();

Modified: directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/DnsServerConfigReaderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/DnsServerConfigReaderTest.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/DnsServerConfigReaderTest.java (original)
+++ directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/DnsServerConfigReaderTest.java Fri Jul 22 00:02:02 2011
@@ -101,10 +101,10 @@ public class DnsServerConfigReaderTest
         File configDir = new File( workDir, "dnsServer" ); // could be any directory, cause the config is now in a single file
         String configFile = LdifConfigExtractor.extractSingleFileConfig( configDir, "dnsServer.ldif", true );
 
-        SingleFileLdifPartition configPartition = new SingleFileLdifPartition();
+        SingleFileLdifPartition configPartition = new SingleFileLdifPartition( schemaManager );
         configPartition.setId( "config" );
         configPartition.setPartitionPath( new File( configFile ).toURI() );
-        configPartition.setSuffix( new Dn( "ou=config" ) );
+        configPartition.setSuffixDn( new Dn( "ou=config" ) );
         configPartition.setSchemaManager( schemaManager );
         
         configPartition.initialize();

Modified: directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/HttpServerConfigReaderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/HttpServerConfigReaderTest.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/HttpServerConfigReaderTest.java (original)
+++ directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/HttpServerConfigReaderTest.java Fri Jul 22 00:02:02 2011
@@ -101,13 +101,14 @@ public class HttpServerConfigReaderTest
         File configDir = new File( workDir, "httpServer" ); // could be any directory, cause the config is now in a single file
         String configFile = LdifConfigExtractor.extractSingleFileConfig( configDir, "httpServer.ldif", true );
 
-        SingleFileLdifPartition configPartition = new SingleFileLdifPartition();
+        SingleFileLdifPartition configPartition = new SingleFileLdifPartition( schemaManager );
         configPartition.setId( "config" );
         configPartition.setPartitionPath( new File( configFile ).toURI() );
-        configPartition.setSuffix( new Dn( "ou=config" ) );
+        configPartition.setSuffixDn( new Dn( "ou=config" ) );
         configPartition.setSchemaManager( schemaManager );
         
         configPartition.initialize();
+                
         ConfigPartitionReader cpReader = new ConfigPartitionReader( configPartition );
         
         ConfigBean configBean = cpReader.readConfig( new Dn( schemaManager, "ou=servers,ads-directoryServiceId=default,ou=config" ), ConfigSchemaConstants.ADS_HTTP_SERVER_OC.getValue() );

Modified: directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/KerberosServerConfigReaderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/KerberosServerConfigReaderTest.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/KerberosServerConfigReaderTest.java (original)
+++ directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/KerberosServerConfigReaderTest.java Fri Jul 22 00:02:02 2011
@@ -102,10 +102,10 @@ public class KerberosServerConfigReaderT
         File configDir = new File( workDir, "kerberosServer" ); // could be any directory, cause the config is now in a single file
         String configFile = LdifConfigExtractor.extractSingleFileConfig( configDir, "kerberosServer.ldif", true );
 
-        SingleFileLdifPartition configPartition = new SingleFileLdifPartition();
+        SingleFileLdifPartition configPartition = new SingleFileLdifPartition( schemaManager );
         configPartition.setId( "config" );
         configPartition.setPartitionPath( new File( configFile ).toURI() );
-        configPartition.setSuffix( new Dn( "ou=config" ) );
+        configPartition.setSuffixDn( new Dn( "ou=config" ) );
         configPartition.setSchemaManager( schemaManager );
         
         configPartition.initialize();

Modified: directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/LdapServerConfigReaderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/LdapServerConfigReaderTest.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/LdapServerConfigReaderTest.java (original)
+++ directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/LdapServerConfigReaderTest.java Fri Jul 22 00:02:02 2011
@@ -102,10 +102,10 @@ public class LdapServerConfigReaderTest
         File configDir = new File( workDir, "ldapServer" ); // could be any directory, cause the config is now in a single file
         String configFile = LdifConfigExtractor.extractSingleFileConfig( configDir, "ldapServer.ldif", true );
 
-        SingleFileLdifPartition configPartition = new SingleFileLdifPartition();
+        SingleFileLdifPartition configPartition = new SingleFileLdifPartition( schemaManager );
         configPartition.setId( "config" );
         configPartition.setPartitionPath( new File( configFile ).toURI() );
-        configPartition.setSuffix( new Dn( "ou=config" ) );
+        configPartition.setSuffixDn( new Dn( "ou=config" ) );
         configPartition.setSchemaManager( schemaManager );
         
         configPartition.initialize();

Modified: directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/NtpServerConfigReaderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/NtpServerConfigReaderTest.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/NtpServerConfigReaderTest.java (original)
+++ directory/apacheds/trunk/server-config/src/test/java/org/apache/directory/server/config/NtpServerConfigReaderTest.java Fri Jul 22 00:02:02 2011
@@ -101,10 +101,10 @@ public class NtpServerConfigReaderTest
         File configDir = new File( workDir, "ntpServer" ); // could be any directory, cause the config is now in a single file
         String configFile = LdifConfigExtractor.extractSingleFileConfig( configDir, "ntpServer.ldif", true );
 
-        SingleFileLdifPartition configPartition = new SingleFileLdifPartition();
+        SingleFileLdifPartition configPartition = new SingleFileLdifPartition( schemaManager );
         configPartition.setId( "config" );
         configPartition.setPartitionPath( new File( configFile ).toURI() );
-        configPartition.setSuffix( new Dn( "ou=config" ) );
+        configPartition.setSuffixDn( new Dn( "ou=config" ) );
         configPartition.setSchemaManager( schemaManager );
         
         configPartition.initialize();

Modified: directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java (original)
+++ directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java Fri Jul 22 00:02:02 2011
@@ -140,7 +140,7 @@ public class ApacheDS
                 
                 if( p.getSchemaManager() == null )
                 {
-                    LOG.info( "setting the schema manager for partition {}", p.getSuffix() );
+                    LOG.info( "setting the schema manager for partition {}", p.getSuffixDn() );
                     p.setSchemaManager( schemaManager );
                 }
             }
@@ -155,7 +155,7 @@ public class ApacheDS
 
             if( sysPartition.getSchemaManager() == null )
             {
-                LOG.info( "setting the schema manager for partition {}", sysPartition.getSuffix() );
+                LOG.info( "setting the schema manager for partition {}", sysPartition.getSuffixDn() );
                 sysPartition.setSchemaManager( schemaManager );
             }
             
@@ -475,11 +475,7 @@ public class ApacheDS
     private void initSchema() throws Exception
     {
         SchemaPartition schemaPartition = directoryService.getSchemaService().getSchemaPartition();
-
-        // Init the LdifPartition
-        LdifPartition ldifPartition = new LdifPartition();
         String workingDirectory = directoryService.getInstanceLayout().getPartitionsDirectory().getPath();
-        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" );
@@ -494,12 +490,16 @@ public class ApacheDS
             extractor.extractOrCopy();
         }
 
-        schemaPartition.setWrappedPartition( ldifPartition );
-
         SchemaLoader loader = new LdifSchemaLoader( schemaRepository );
         SchemaManager schemaManager = new DefaultSchemaManager( loader );
         directoryService.setSchemaManager( schemaManager );
 
+        // Init the LdifPartition
+        LdifPartition ldifPartition = new LdifPartition( schemaManager );
+        ldifPartition.setPartitionPath( new File( workingDirectory, "schema" ).toURI() );
+
+        schemaPartition.setWrappedPartition( ldifPartition );
+
         // 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

Modified: directory/apacheds/trunk/server-jndi/src/test/java/org/apache/directory/server/configuration/ApacheDSTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-jndi/src/test/java/org/apache/directory/server/configuration/ApacheDSTest.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/server-jndi/src/test/java/org/apache/directory/server/configuration/ApacheDSTest.java (original)
+++ directory/apacheds/trunk/server-jndi/src/test/java/org/apache/directory/server/configuration/ApacheDSTest.java Fri Jul 22 00:02:02 2011
@@ -52,7 +52,7 @@ public class ApacheDSTest
 
         JdbmPartition example = new JdbmPartition();
         example.setId( "example" );
-        example.setSuffix( "dc=example,dc=com" );
+        example.setSuffixDn( "dc=example,dc=com" );
         Dn contextDn = new Dn( "dc=example,dc=com" );
         contextDn.normalize( directoryService.getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
         ServerEntry contextEntry = new DefaultServerEntry( directoryService.getRegistries(), contextDn );

Modified: directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/ServiceBuilder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/ServiceBuilder.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/ServiceBuilder.java (original)
+++ directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/ServiceBuilder.java Fri Jul 22 00:02:02 2011
@@ -1138,7 +1138,7 @@ public class ServiceBuilder
             return null;
         }
         
-        JdbmPartition jdbmPartition = new JdbmPartition();
+        JdbmPartition jdbmPartition = new JdbmPartition( directoryService.getSchemaManager() );
         
         jdbmPartition.setCacheSize( jdbmPartitionBean.getPartitionCacheSize() );
         jdbmPartition.setId( jdbmPartitionBean.getPartitionId() );
@@ -1148,7 +1148,7 @@ public class ServiceBuilder
         
         try
         {
-            jdbmPartition.setSuffix( jdbmPartitionBean.getPartitionSuffix() );
+            jdbmPartition.setSuffixDn( jdbmPartitionBean.getPartitionSuffix() );
         }
         catch ( LdapInvalidDnException lide )
         {

Modified: directory/apacheds/trunk/service/src/main/java/org/apache/directory/server/ApacheDsService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/service/src/main/java/org/apache/directory/server/ApacheDsService.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/service/src/main/java/org/apache/directory/server/ApacheDsService.java (original)
+++ directory/apacheds/trunk/service/src/main/java/org/apache/directory/server/ApacheDsService.java Fri Jul 22 00:02:02 2011
@@ -149,6 +149,7 @@ public class ApacheDsService
 
         LOG.info( "using partition dir {}", partitionsDir.getAbsolutePath() );
         
+        initSchemaManager( instanceLayout );
         initSchemaLdifPartition( instanceLayout );
         initConfigPartition( instanceLayout );
 
@@ -184,21 +185,17 @@ public class ApacheDsService
         startHttpServer( directoryServiceBean.getHttpServerBean(), directoryService );
     }
 
-
+    
     /**
-     * initialize the schema partition by loading the schema LDIF files
+     * Initialize the schema Manager by loading the schema LDIF files
      * 
      * @param instanceLayout the instance layout
      * @throws Exception in case of any problems while extracting and writing the schema files
      */
-    private void initSchemaLdifPartition( InstanceLayout instanceLayout ) throws Exception
+    private void initSchemaManager( InstanceLayout instanceLayout ) throws Exception
     {
         File schemaPartitionDirectory = new File( instanceLayout.getPartitionsDirectory(), "schema" );
 
-        // Init the LdifPartition
-        schemaLdifPartition = new LdifPartition();
-        schemaLdifPartition.setPartitionPath( schemaPartitionDirectory.toURI() );
-
         // Extract the schema on disk (a brand new one) and load the registries
         if ( schemaPartitionDirectory.exists() )
         {
@@ -214,6 +211,7 @@ public class ApacheDsService
         SchemaLoader loader = new LdifSchemaLoader( schemaPartitionDirectory );
         schemaManager = new DefaultSchemaManager( loader );
 
+
         // 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
@@ -226,6 +224,22 @@ public class ApacheDsService
             throw new Exception( I18n.err( I18n.ERR_317, Exceptions.printErrors(errors) ) );
         }
     }
+    
+
+    /**
+     * Initialize the schema partition
+     * 
+     * @param instanceLayout the instance layout
+     * @throws Exception in case of any problems while initializing the SchemaPartition
+     */
+    private void initSchemaLdifPartition( InstanceLayout instanceLayout ) throws Exception
+    {
+        File schemaPartitionDirectory = new File( instanceLayout.getPartitionsDirectory(), "schema" );
+
+        // Init the LdifPartition
+        schemaLdifPartition = new LdifPartition( schemaManager );
+        schemaLdifPartition.setPartitionPath( schemaPartitionDirectory.toURI() );
+    }
 
 
     /**
@@ -249,10 +263,10 @@ public class ApacheDsService
             isConfigPartitionFirstExtraction = true;
         }
 
-        configPartition = new SingleFileLdifPartition();
+        configPartition = new SingleFileLdifPartition( schemaManager );
         configPartition.setId( "config" );
         configPartition.setPartitionPath( confFile.toURI() );
-        configPartition.setSuffix( new Dn( schemaManager, "ou=config" ) );
+        configPartition.setSuffixDn( new Dn( schemaManager, "ou=config" ) );
         configPartition.setSchemaManager( schemaManager );
 
         configPartition.initialize();
@@ -269,7 +283,6 @@ public class ApacheDsService
 
         SchemaPartition schemaPartition = directoryService.getSchemaService().getSchemaPartition();
         schemaPartition.setWrappedPartition( schemaLdifPartition );
-        schemaPartition.setSchemaManager( schemaManager );
 
         directoryService.addPartition( configPartition );
 
@@ -632,7 +645,7 @@ public class ApacheDsService
 
         ExprNode filter = new PresenceNode( SchemaConstants.OBJECT_CLASS_AT );
 
-        EntryFilteringCursor cursor = session.search( partition.getSuffix(), SearchScope.SUBTREE, filter,
+        EntryFilteringCursor cursor = session.search( partition.getSuffixDn(), SearchScope.SUBTREE, filter,
             AliasDerefMode.NEVER_DEREF_ALIASES, new HashSet<AttributeTypeOptions>( MANDATORY_ENTRY_ATOP_MAP.values() ) );
         cursor.beforeFirst();
 

Modified: directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java (original)
+++ directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkRunner.java Fri Jul 22 00:02:02 2011
@@ -173,7 +173,7 @@ public class FrameworkRunner extends Blo
                     else
                     {
                         // No : define a default DS for the suite then
-                        DirectoryServiceFactory dsf = DefaultDirectoryServiceFactory.DEFAULT;
+                        DirectoryServiceFactory dsf = DefaultDirectoryServiceFactory.class.newInstance();
 
                         directoryService = dsf.getDirectoryService();
                         // enable CL explicitly cause we are not using DSAnnotationProcessor
@@ -196,7 +196,7 @@ public class FrameworkRunner extends Blo
                 else
                 {
                     // No : define a default class DS then
-                    DirectoryServiceFactory dsf = DefaultDirectoryServiceFactory.DEFAULT;
+                    DirectoryServiceFactory dsf = DefaultDirectoryServiceFactory.class.newInstance();
 
                     directoryService = dsf.getDirectoryService();
                     // enable CL explicitly cause we are not using DSAnnotationProcessor
@@ -247,7 +247,8 @@ public class FrameworkRunner extends Blo
             if ( suite == null )
             {
                 // print out information which partition factory we use
-                PartitionFactory partitionFactory = DefaultDirectoryServiceFactory.DEFAULT.getPartitionFactory();
+                DirectoryServiceFactory dsFactory = DefaultDirectoryServiceFactory.class.newInstance();
+                PartitionFactory partitionFactory = dsFactory.getPartitionFactory();
                 LOG.debug( "Using partition factory {}", partitionFactory.getClass().getSimpleName() );
             }
 

Modified: directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkSuite.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkSuite.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkSuite.java (original)
+++ directory/apacheds/trunk/test-framework/src/main/java/org/apache/directory/server/core/integ/FrameworkSuite.java Fri Jul 22 00:02:02 2011
@@ -24,6 +24,7 @@ import org.apache.directory.server.annot
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.factory.DSAnnotationProcessor;
 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.factory.ServerAnnotationProcessor;
 import org.apache.directory.server.ldap.LdapServer;
@@ -163,7 +164,8 @@ public class FrameworkSuite extends Suit
         try
         {
             // print out information which partition factory we use
-            PartitionFactory partitionFactory = DefaultDirectoryServiceFactory.DEFAULT.getPartitionFactory();
+            DirectoryServiceFactory dsFactory = DefaultDirectoryServiceFactory.class.newInstance();
+            PartitionFactory partitionFactory = dsFactory.getPartitionFactory();
             LOG.debug( "Using partition factory {}", partitionFactory.getClass().getSimpleName() );
 
             // Create and initialize the Suite DS

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/avl/AvlPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/avl/AvlPartition.java?rev=1149411&r1=1149410&r2=1149411&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/avl/AvlPartition.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/avl/AvlPartition.java Fri Jul 22 00:02:02 2011
@@ -20,22 +20,24 @@
 package org.apache.directory.server.core.partition.impl.avl;
 
 
-import java.util.HashSet;
-import java.util.Set;
+import java.net.URI;
 
+import org.apache.directory.server.constants.ApacheSchemaConstants;
+import org.apache.directory.server.core.partition.impl.btree.LongComparator;
 import org.apache.directory.server.core.partition.impl.xdbm.AbstractXdbmPartition;
+import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.server.xdbm.impl.avl.AvlIndex;
-import org.apache.directory.server.xdbm.impl.avl.AvlStore;
+import org.apache.directory.server.xdbm.impl.avl.AvlMasterTable;
+import org.apache.directory.server.xdbm.impl.avl.AvlRdnIndex;
 import org.apache.directory.server.xdbm.search.impl.CursorBuilder;
 import org.apache.directory.server.xdbm.search.impl.DefaultOptimizer;
 import org.apache.directory.server.xdbm.search.impl.DefaultSearchEngine;
 import org.apache.directory.server.xdbm.search.impl.EvaluatorBuilder;
 import org.apache.directory.server.xdbm.search.impl.NoOpOptimizer;
 import org.apache.directory.shared.ldap.model.entry.Entry;
-import org.apache.directory.shared.ldap.model.entry.Modification;
-import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.exception.LdapOperationErrorException;
-import org.apache.directory.shared.ldap.model.name.Dn;
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -45,16 +47,16 @@ import org.apache.directory.shared.ldap.
  */
 public class AvlPartition extends AbstractXdbmPartition<Long>
 {
-    private Set<AvlIndex<?, Entry>> indexedAttributes;
-
+    /** static logger */
+    private static final Logger LOG = LoggerFactory.getLogger( AvlPartition.class );
 
+    
     /**
      * Creates a store based on AVL Trees.
      */
-    public AvlPartition()
+    public AvlPartition( SchemaManager schemaManager )
     {
-        super( new AvlStore<Entry>() );
-        indexedAttributes = new HashSet<AvlIndex<?, Entry>>();
+        super( schemaManager );
     }
 
 
@@ -63,80 +65,123 @@ public class AvlPartition extends Abstra
      */
     protected void doInit() throws Exception
     {
-        setSchemaManager( schemaManager );
-
-        EvaluatorBuilder<Long> evaluatorBuilder = new EvaluatorBuilder<Long>( store, schemaManager );
-        CursorBuilder<Long> cursorBuilder = new CursorBuilder<Long>( store, evaluatorBuilder );
-
-        // setup optimizer and registries for parent
-        if ( !optimizerEnabled )
-        {
-            optimizer = new NoOpOptimizer();
-        }
-        else
+        if ( !initialized )
         {
-            optimizer = new DefaultOptimizer<Entry, Long>( store );
+            EvaluatorBuilder<Long> evaluatorBuilder = new EvaluatorBuilder<Long>( this, schemaManager );
+            CursorBuilder<Long> cursorBuilder = new CursorBuilder<Long>( this, evaluatorBuilder );
+    
+            // setup optimizer and registries for parent
+            if ( !optimizerEnabled )
+            {
+                optimizer = new NoOpOptimizer();
+            }
+            else
+            {
+                optimizer = new DefaultOptimizer<Entry, Long>( this );
+            }
+    
+            searchEngine = new DefaultSearchEngine<Long>( this, cursorBuilder, evaluatorBuilder, optimizer );
+    
+            if ( isInitialized() )
+            {
+                return;
+            }
+    
+            // Create the master table (the table containing all the entries)
+            master = new AvlMasterTable<Entry>( id, new LongComparator(), null, false );
+    
+            setupSystemIndices();
+            setupUserIndices();
         }
+    }
 
-        searchEngine = new DefaultSearchEngine<Long>( store, cursorBuilder, evaluatorBuilder, optimizer );
 
-        if ( store.isInitialized() )
-        {
-            return;
-        }
+    @Override
+    protected void doDestroy() throws Exception
+    {
+        // Nothing to do, we currently have no index (yet)
+    }
 
-        // initialize the store
-        store.setId( getId() );
-        suffix.apply( schemaManager );
-        store.setSuffixDn( suffix );
 
-        for ( AvlIndex<?, Entry> index : indexedAttributes )
-        {
-            String oid = schemaManager.getAttributeTypeRegistry().getOidByName( index.getAttributeId() );
-            
-            if ( !index.getAttributeId().equals( oid ) )
-            {
-                index.setAttributeId( oid );
-            }
-            
-            store.addIndex( index );
-        }
+    /**
+     * {@inheritDoc}
+     */
+    public Long getDefaultId()
+    {
+        return 1L;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Long getRootId()
+    {
+        return 0L;
+    }
 
-        store.init( schemaManager );
+
+    /**
+     * {@inheritDoc}
+     */
+    public void sync() throws Exception
+    {
+        // Nothing to do
     }
 
 
-    public final void modify( Dn dn, Modification... modifications ) throws LdapException
+    /**
+     * always returns false, cause this is a in-memory store
+     */
+    @Override
+    public boolean isSyncOnWrite()
     {
-        try
-        {
-            store.modify( dn, modifications );
-        }
-        catch ( Exception e )
-        {
-            throw new LdapOperationErrorException( e.getMessage(), e );
-        }
+        return false;
     }
 
 
-    /*
-     * TODO requires review
-     *
-     * This getter deviates from the norm. all the partitions
-     * so far written never return a reference to store but I think that in this
-     * case the presence of this method gives significant ease and advantage to perform
-     * add/delete etc. operations without creating a operation context.
+    /**
+     * Always returns 0 (zero), cause this is a in-memory store
      */
-    public AvlStore<Entry> getStore()
+    @Override
+    public int getCacheSize()
     {
-        return ( org.apache.directory.server.xdbm.impl.avl.AvlStore<Entry> ) store;
+        return 0;
     }
 
 
     @Override
-    protected void doDestroy() throws Exception
+    protected Index<?, Entry, Long> convertAndInit( Index<?, Entry, Long> index ) throws Exception
     {
-        store.destroy();        
+        AvlIndex<?, Entry> avlIndex;
+
+        if ( index.getAttributeId().equals( ApacheSchemaConstants.APACHE_RDN_AT_OID ) )
+        {
+            avlIndex = new AvlRdnIndex<Entry>( index.getAttributeId() );
+        }
+        else if ( index instanceof AvlIndex<?, ?> )
+        {
+            avlIndex = (AvlIndex<?, Entry> ) index;
+        }
+        else
+        {
+            LOG.debug( "Supplied index {} is not a AvlIndex. "
+                + "Will create new AvlIndex using copied configuration parameters.", index );
+            avlIndex = new AvlIndex( index.getAttributeId() );
+        }
+     
+        avlIndex.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( index.getAttributeId() ) );
+      
+        return avlIndex;
     }
 
+    
+    /**
+     * {@inheritDoc}
+     */
+    public URI getPartitionPath()
+    {
+        // It's a in-memory partition, return null
+        return null;
+    }
 }



Mime
View raw message