directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r763084 - in /directory/apacheds/branches/ldif-partition: avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/ jdbm-partition/src/main/java/org/apache/directory/server/core/partition/jdbm/ xdbm-base/src/main/java/org/...
Date Wed, 08 Apr 2009 02:34:45 GMT
Author: akarasulu
Date: Wed Apr  8 02:34:45 2009
New Revision: 763084

URL: http://svn.apache.org/viewvc?rev=763084&view=rev
Log:
cleaned up xdbm and jdbm partition implementations and pushed most Store wrapping functionality
into the XdbmPartition base class

Modified:
    directory/apacheds/branches/ldif-partition/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
    directory/apacheds/branches/ldif-partition/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/jdbm/JdbmPartition.java
    directory/apacheds/branches/ldif-partition/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/jdbm/JdbmStore.java
    directory/apacheds/branches/ldif-partition/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java
    directory/apacheds/branches/ldif-partition/xdbm-base/src/main/java/org/apache/directory/server/xdbm/XdbmPartition.java

Modified: directory/apacheds/branches/ldif-partition/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java?rev=763084&r1=763083&r2=763084&view=diff
==============================================================================
--- directory/apacheds/branches/ldif-partition/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
(original)
+++ directory/apacheds/branches/ldif-partition/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
Wed Apr  8 02:34:45 2009
@@ -1852,4 +1852,12 @@
             subAliasIdx.drop( ancestorId, targetId );
         }
     }
+
+
+    /**
+     * @{inhertDoc}
+     */
+    public void sync() throws Exception
+    {
+    }
 }

Modified: directory/apacheds/branches/ldif-partition/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/jdbm/JdbmPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/jdbm/JdbmPartition.java?rev=763084&r1=763083&r2=763084&view=diff
==============================================================================
--- directory/apacheds/branches/ldif-partition/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/jdbm/JdbmPartition.java
(original)
+++ directory/apacheds/branches/ldif-partition/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/jdbm/JdbmPartition.java
Wed Apr  8 02:34:45 2009
@@ -22,37 +22,19 @@
 
 import org.apache.directory.server.constants.ApacheSchemaConstants;
 import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.core.entry.ServerEntry;
-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.interceptor.context.UnbindOperationContext;
 import org.apache.directory.server.core.partition.Partition;
 import org.apache.directory.server.xdbm.XdbmPartition;
 import org.apache.directory.server.xdbm.Index;
-import org.apache.directory.server.xdbm.IndexCursor;
-import org.apache.directory.server.xdbm.IndexNotFoundException;
 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.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
-import org.apache.directory.shared.ldap.exception.LdapAuthenticationNotSupportedException;
-import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.name.LdapDN;
-
-import javax.naming.NamingException;
 
 import java.io.File;
 import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
 import java.util.Set;
 
 
@@ -66,7 +48,6 @@
  */
 public class JdbmPartition extends XdbmPartition
 {
-    private JdbmStore<ServerEntry> store;
     private boolean optimizerEnabled = true;
     private Set<JdbmIndex<?,ServerEntry>> indexedAttributes;
     private int cacheSize;
@@ -83,7 +64,7 @@
      */
     public JdbmPartition()
     {
-        store = new JdbmStore<ServerEntry>();
+        super.setStore( new JdbmStore<ServerEntry>() );
         indexedAttributes = new HashSet<JdbmIndex<?,ServerEntry>>();
     }
 
@@ -93,12 +74,6 @@
     // ------------------------------------------------------------------------
 
 
-    public String getSuffix()
-    {
-        return suffix;
-    }
-
-
     public void setSuffix( String suffix )
     {
         this.suffix = suffix;
@@ -149,44 +124,34 @@
 
     public void setSyncOnWrite( boolean syncOnWrite )
     {
-        store.setSyncOnWrite( syncOnWrite );
+        getJdbmStore().setSyncOnWrite( syncOnWrite );
     }
 
 
     public boolean isSyncOnWrite()
     {
-        return store.isSyncOnWrite();
+        return getJdbmStore().isSyncOnWrite();
     }
 
 
+    private JdbmStore<ServerEntry> getJdbmStore()
+    {
+        return ( JdbmStore<ServerEntry> ) getStore();
+    }
+    
+    
     // ------------------------------------------------------------------------
     // E N D   C O N F I G U R A T I O N   M E T H O D S
     // ------------------------------------------------------------------------
 
 
-    /**
-     * @org.apache.xbean.Property hidden="true"
-     */
-    public void setRegistries( Registries registries ) throws Exception
-    {
-        initRegistries( registries );
-    }
-
-
-    protected void initRegistries( Registries registries ) throws Exception
-    {
-        this.registries = registries;
-        store.initRegistries( registries );
-    }
-
-
     @SuppressWarnings("unchecked")
     public final void init( DirectoryService directoryService ) throws Exception
     {
-        initRegistries( directoryService.getRegistries() );
+        setRegistries( directoryService.getRegistries() );
 
-        EvaluatorBuilder evaluatorBuilder = new EvaluatorBuilder( store, registries );
-        CursorBuilder cursorBuilder = new CursorBuilder( store, evaluatorBuilder );
+        EvaluatorBuilder evaluatorBuilder = new EvaluatorBuilder( getJdbmStore(), getRegistries()
);
+        CursorBuilder cursorBuilder = new CursorBuilder( getJdbmStore(), evaluatorBuilder
);
 
         // setup optimizer and registries for parent
         if ( ! optimizerEnabled )
@@ -195,16 +160,16 @@
         }
         else
         {
-            optimizer = new DefaultOptimizer<ServerEntry>( store );
+            optimizer = new DefaultOptimizer<ServerEntry>( getJdbmStore() );
         }
 
-        searchEngine = new DefaultSearchEngine( store, cursorBuilder, evaluatorBuilder, optimizer
);
+        searchEngine = new DefaultSearchEngine( getJdbmStore(), cursorBuilder, evaluatorBuilder,
optimizer );
         
         // initialize the store
-        store.setCacheSize( getCacheSize() );
-        store.setName( getId() );
-        store.setSuffixDn( suffix );
-        store.setWorkingDirectory( new File( directoryService.getWorkingDirectory().getPath()
+ File.separator + getId() ) );
+        getJdbmStore().setCacheSize( getCacheSize() );
+        getJdbmStore().setName( getId() );
+        getJdbmStore().setSuffixDn( suffix );
+        getJdbmStore().setWorkingDirectory( new File( directoryService.getWorkingDirectory().getPath()
+ File.separator + getId() ) );
 
         Set<JdbmIndex<?,ServerEntry>> userIndices = new HashSet<JdbmIndex<?,ServerEntry>>();
         
@@ -224,41 +189,41 @@
                 index.setWkDirPath( obj.getWkDirPath() );
             }
 
-            String oid = registries.getOidRegistry().getOid( index.getAttributeId() );
+            String oid = getRegistries().getOidRegistry().getOid( index.getAttributeId()
);
             
-            if ( SYS_INDEX_OIDS.contains( registries.getOidRegistry().getOid( index.getAttributeId()
) ) )
+            if ( SYS_INDEX_OIDS.contains( getRegistries().getOidRegistry().getOid( index.getAttributeId()
) ) )
             {
                 if ( oid.equals( ApacheSchemaConstants.APACHE_ALIAS_OID ) )
                 {
-                    store.setAliasIndex( ( Index<String,ServerEntry> ) index );
+                    getJdbmStore().setAliasIndex( ( Index<String,ServerEntry> ) index
);
                 }
                 else if ( oid.equals( ApacheSchemaConstants.APACHE_EXISTANCE_OID ) )
                 {
-                    store.setPresenceIndex( ( Index<String,ServerEntry> ) index );
+                    getJdbmStore().setPresenceIndex( ( Index<String,ServerEntry> )
index );
                 }
                 else if ( oid.equals( ApacheSchemaConstants.APACHE_ONE_LEVEL_OID ) )
                 {
-                    store.setOneLevelIndex( ( Index<Long,ServerEntry> ) index );
+                    getJdbmStore().setOneLevelIndex( ( Index<Long,ServerEntry> ) index
);
                 }
                 else if ( oid.equals( ApacheSchemaConstants.APACHE_N_DN_OID ) )
                 {
-                    store.setNdnIndex( ( Index<String,ServerEntry> ) index );
+                    getJdbmStore().setNdnIndex( ( Index<String,ServerEntry> ) index
);
                 }
                 else if ( oid.equals( ApacheSchemaConstants.APACHE_ONE_ALIAS_OID ) )
                 {
-                    store.setOneAliasIndex( ( Index<Long,ServerEntry> ) index );
+                    getJdbmStore().setOneAliasIndex( ( Index<Long,ServerEntry> ) index
);
                 }
                 else if ( oid.equals( ApacheSchemaConstants.APACHE_SUB_ALIAS_OID ) )
                 {
-                    store.setSubAliasIndex( ( Index<Long,ServerEntry> ) index );
+                    getJdbmStore().setSubAliasIndex( ( Index<Long,ServerEntry> ) index
);
                 }
                 else if ( oid.equals( ApacheSchemaConstants.APACHE_UP_DN_OID ) )
                 {
-                    store.setUpdnIndex( ( Index<String,ServerEntry> ) index );
+                    getJdbmStore().setUpdnIndex( ( Index<String,ServerEntry> ) index
);
                 }
                 else if ( oid.equals( SchemaConstants.OBJECT_CLASS_AT_OID ) )
                 {
-                    store.addIndex( ( Index<String,ServerEntry> ) index );
+                    getJdbmStore().addIndex( ( Index<String,ServerEntry> ) index );
                 }
                 else
                 {
@@ -270,357 +235,9 @@
                 userIndices.add( index );
             }
             
-            store.setUserIndices( userIndices );
-        }
-
-        store.init( registries );
-    }
-
-
-    public final void destroy() throws Exception
-    {
-        store.destroy();
-    }
-
-
-    public final boolean isInitialized()
-    {
-        return store.isInitialized();
-    }
-
-
-    public final void sync() throws Exception
-    {
-        store.sync();
-    }
-
-
-    // ------------------------------------------------------------------------
-    // I N D E X   M E T H O D S
-    // ------------------------------------------------------------------------
-
-
-    public final void addIndexOn( Index<Long, ServerEntry> index ) throws Exception
-    {
-        store.addIndex( index );
-    }
-
-
-    public final Index<String, ServerEntry> getExistanceIndex()
-    {
-        return store.getPresenceIndex();
-    }
-
-
-    /**
-     * @org.apache.xbean.Property hidden="true"
-     */
-    public final void setPresenceIndexOn( Index<String, ServerEntry> index ) throws
Exception
-    {
-        store.setPresenceIndex( index );
-    }
-
-
-    public final Index<Long, ServerEntry> getOneLevelIndex()
-    {
-        return store.getOneLevelIndex();
-    }
-
-
-    /**
-     * @org.apache.xbean.Property hidden="true"
-     */
-    public final void setOneLevelIndexOn( Index<Long, ServerEntry> index ) throws Exception
-    {
-        store.setOneLevelIndex( index );
-    }
-
-
-    public final Index<String, ServerEntry> getAliasIndex()
-    {
-        return store.getAliasIndex();
-    }
-
-
-    /**
-     * @org.apache.xbean.Property hidden="true"
-     */
-    public final void setAliasIndexOn( Index<String, ServerEntry> index ) throws Exception
-    {
-        store.setAliasIndex( index );
-    }
-
-
-    public final Index<Long,ServerEntry> getOneAliasIndex()
-    {
-        return store.getOneAliasIndex();
-    }
-
-
-    /**
-     * @org.apache.xbean.Property hidden="true"
-     */
-    public final void setOneAliasIndexOn( Index<Long,ServerEntry> index ) throws NamingException
-    {
-        store.setOneAliasIndex( ( Index<Long,ServerEntry> ) index );
-    }
-
-
-    public final Index<Long,ServerEntry> getSubAliasIndex()
-    {
-        return store.getSubAliasIndex();
-    }
-
-
-    /**
-     * @org.apache.xbean.Property hidden="true"
-     */
-    public final void setSubAliasIndexOn( Index<Long,ServerEntry> index ) throws NamingException
-    {
-            store.setSubAliasIndex( ( Index<Long,ServerEntry> ) index );
-    }
-
-
-    public final Index<String,ServerEntry> getUpdnIndex()
-    {
-        return store.getUpdnIndex();
-    }
-
-
-    /**
-     * @org.apache.xbean.Property hidden="true"
-     */
-    public final void setUpdnIndexOn( Index<String,ServerEntry> index ) throws NamingException
-    {
-        store.setUpdnIndex( ( Index<String,ServerEntry> ) index );
-    }
-
-
-    public final Index<String,ServerEntry> getNdnIndex()
-    {
-        return store.getNdnIndex();
-    }
-
-
-    /**
-     * @org.apache.xbean.Property hidden="true"
-     */
-    public final void setNdnIndexOn( Index<String,ServerEntry> index ) throws NamingException
-    {
-        store.setNdnIndex( ( Index<String,ServerEntry> ) index );
-    }
-
-
-    public final Iterator<String> getUserIndices()
-    {
-        return store.userIndices();
-    }
-
-
-    public final Iterator<String> getSystemIndices()
-    {
-        return store.systemIndices();
-    }
-
-
-    public final boolean hasUserIndexOn( String id ) throws NamingException
-    {
-        return store.hasUserIndexOn( id );
-    }
-
-
-    public final boolean hasSystemIndexOn( String id ) throws NamingException
-    {
-        return store.hasSystemIndexOn( id );
-    }
-
-
-    /**
-     * @see org.apache.directory.server.core.partition.impl.btree.XdbmPartition#getUserIndex(String)
-     */
-    public final Index<?,ServerEntry> getUserIndex( String id ) throws IndexNotFoundException
-    {
-        return store.getUserIndex( id );
-    }
-
-
-    /**
-     * @see XdbmPartition#getEntryId(String)
-     */
-    public final Index<?,ServerEntry> getSystemIndex( String id ) throws IndexNotFoundException
-    {
-        return store.getSystemIndex( id );
-    }
-
-
-    public final Long getEntryId( String dn ) throws Exception
-    {
-        return store.getEntryId( dn );
-    }
-
-
-    public final String getEntryDn( Long id ) throws Exception
-    {
-        return store.getEntryDn( id );
-    }
-
-
-    public final Long getParentId( String dn ) throws Exception
-    {
-        return store.getParentId( dn );
-    }
-
-
-    public final Long getParentId( Long childId ) throws Exception
-    {
-        return store.getParentId( childId );
-    }
-
-
-    public final String getEntryUpdn( Long id ) throws Exception
-    {
-        return store.getEntryUpdn( id );
-    }
-
-
-    public final String getEntryUpdn( String dn ) throws Exception
-    {
-        return store.getEntryUpdn( dn );
-    }
-
-
-    public final int count() throws Exception
-    {
-        return store.count();
-    }
-
-    
-    public final void add( AddOperationContext addContext ) throws Exception
-    {
-        store.add( addContext.getDn(), (ServerEntry)((ClonedServerEntry)addContext.getEntry()).getClonedEntry()
);
-    }
-
-
-    public final ClonedServerEntry lookup( Long id ) throws Exception
-    {
-        return new ClonedServerEntry( store.lookup( id ) );
-    }
-
-
-    public final void delete( Long id ) throws Exception
-    {
-        store.delete( id );
-    }
-
-
-    public final IndexCursor<Long, ServerEntry> list( Long id ) throws Exception
-    {
-        return store.list( id );
-    }
-
-
-    public final int getChildCount( Long id ) throws Exception
-    {
-        return store.getChildCount( id );
-    }
-
-
-    public final LdapDN getSuffixDn()
-    {
-        return store.getSuffix();
-    }
-
-    public final LdapDN getUpSuffixDn()
-    {
-        return store.getUpSuffix();
-    }
-
-
-    public final void setProperty( String propertyName, String propertyValue ) throws Exception
-    {
-        store.setProperty( propertyName, propertyValue );
-    }
-
-
-    public final String getProperty( String propertyName ) throws Exception
-    {
-        return store.getProperty( propertyName );
-    }
-
-    
-    public final void modify( ModifyOperationContext modifyContext ) throws Exception
-    {
-        store.modify( modifyContext.getDn(), modifyContext.getModItems() );
-    }
-
-    public final void rename( RenameOperationContext renameContext ) throws Exception
-    {
-        store.rename( renameContext.getDn(), renameContext.getNewRdn(), renameContext.getDelOldDn()
);
-    }
-
-
-    public final void moveAndRename( MoveAndRenameOperationContext moveAndRenameContext )
throws Exception
-    {
-        store.move( moveAndRenameContext.getDn(), 
-            moveAndRenameContext.getParent(), 
-            moveAndRenameContext.getNewRdn(), 
-            moveAndRenameContext.getDelOldDn() );
-    }
-
-
-    public final void move( MoveOperationContext moveContext ) throws Exception
-    {
-        store.move( moveContext.getDn(), moveContext.getParent() );
-    }
-
-
-    public final void bind( LdapDN bindDn, byte[] credentials, List<String> mechanisms,
String saslAuthId ) throws Exception
-    {
-        if ( bindDn == null || credentials == null || mechanisms == null ||  saslAuthId ==
null )
-        {
-            // do nothing just using variables to prevent yellow lights : bad :)
+            getJdbmStore().setUserIndices( userIndices );
         }
-        
-        // does nothing
-        throw new LdapAuthenticationNotSupportedException(
-                "Bind requests only tunnel down into partitions if there are no authenticators
to handle the mechanism.\n"
-                        + "Check to see if you have correctly configured authenticators for
the server.",
-                ResultCodeEnum.AUTH_METHOD_NOT_SUPPORTED );
-    }
-    
-
-    public final void bind( BindOperationContext bindContext ) throws Exception
-    {
-        // does nothing
-        throw new LdapAuthenticationNotSupportedException(
-            "Bind requests only tunnel down into partitions if there are no authenticators
to handle the mechanism.\n"
-                + "Check to see if you have correctly configured authenticators for the server.",
-            ResultCodeEnum.AUTH_METHOD_NOT_SUPPORTED );
-    }
-
 
-    public final void unbind( UnbindOperationContext unbindContext ) throws Exception
-    {
-    }
-
-
-    public Index<String, ServerEntry> getPresenceIndex()
-    {
-        return store.getPresenceIndex();
-    }
-
-
-    public Index<Long, ServerEntry> getSubLevelIndex()
-    {
-        return store.getSubLevelIndex();
-    }
-    
-    
-    /**
-     * @see Object#toString()
-     */
-    public String toString()
-    {
-        return "Partition<" + getId() + ">"; 
+        getJdbmStore().init( getRegistries() );
     }
 }

Modified: directory/apacheds/branches/ldif-partition/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/jdbm/JdbmStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/jdbm/JdbmStore.java?rev=763084&r1=763083&r2=763084&view=diff
==============================================================================
--- directory/apacheds/branches/ldif-partition/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/jdbm/JdbmStore.java
(original)
+++ directory/apacheds/branches/ldif-partition/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/jdbm/JdbmStore.java
Wed Apr  8 02:34:45 2009
@@ -1955,11 +1955,4 @@
             subAliasIdx.drop( ancestorId, targetId );
         }
     }
-
-
-    public void initRegistries( Registries registries )
-    {
-        this.attributeTypeRegistry = registries.getAttributeTypeRegistry();
-        this.oidRegistry = registries.getOidRegistry();
-    }
 }

Modified: directory/apacheds/branches/ldif-partition/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java?rev=763084&r1=763083&r2=763084&view=diff
==============================================================================
--- directory/apacheds/branches/ldif-partition/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java
(original)
+++ directory/apacheds/branches/ldif-partition/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java
Wed Apr  8 02:34:45 2009
@@ -119,7 +119,7 @@
 
 
     /**
-     * Close the parttion : we have to close all the userIndices and the master table.
+     * Close the partition : we have to close all the userIndices and the master table.
      *
      * @throws Exception lazily thrown on any closer failures to avoid leaving
      * open files
@@ -299,6 +299,6 @@
 
     void move( LdapDN oldChildDn, LdapDN newParentDn ) throws Exception;
 
-
-    void initRegistries( Registries registries );
+    
+    void sync() throws Exception;
 }

Modified: directory/apacheds/branches/ldif-partition/xdbm-base/src/main/java/org/apache/directory/server/xdbm/XdbmPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/xdbm-base/src/main/java/org/apache/directory/server/xdbm/XdbmPartition.java?rev=763084&r1=763083&r2=763084&view=diff
==============================================================================
--- directory/apacheds/branches/ldif-partition/xdbm-base/src/main/java/org/apache/directory/server/xdbm/XdbmPartition.java
(original)
+++ directory/apacheds/branches/ldif-partition/xdbm-base/src/main/java/org/apache/directory/server/xdbm/XdbmPartition.java
Wed Apr  8 02:34:45 2009
@@ -26,6 +26,7 @@
 import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.filtering.BaseEntryFilteringCursor;
 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.DeleteOperationContext;
 import org.apache.directory.server.core.interceptor.context.EntryOperationContext;
 import org.apache.directory.server.core.interceptor.context.ListOperationContext;
@@ -35,13 +36,16 @@
 import org.apache.directory.server.core.interceptor.context.MoveOperationContext;
 import org.apache.directory.server.core.interceptor.context.RenameOperationContext;
 import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
+import org.apache.directory.server.core.interceptor.context.UnbindOperationContext;
 import org.apache.directory.server.core.partition.Partition;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.server.xdbm.search.Optimizer;
 import org.apache.directory.server.xdbm.search.SearchEngine;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.exception.LdapAuthenticationNotSupportedException;
 import org.apache.directory.shared.ldap.exception.LdapContextNotEmptyException;
 import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 
@@ -49,6 +53,7 @@
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Set;
 
 
@@ -80,7 +85,8 @@
     protected SearchEngine<ServerEntry> searchEngine;
     protected Optimizer optimizer;
 
-    protected Registries registries;
+    private Store<ServerEntry> store;
+    private Registries registries;
 
     private String id;
 
@@ -116,6 +122,18 @@
     }
     
     
+    protected void setStore( Store<ServerEntry> store )
+    {
+        this.store = store;
+    }
+    
+    
+    protected Store<ServerEntry> getStore()
+    {
+        return this.store;
+    }
+    
+    
     // ------------------------------------------------------------------------
     // Public methods - not declared in any interfaces just for this class
     // ------------------------------------------------------------------------
@@ -131,9 +149,18 @@
      * @param registries the schema entity registries
      * @throws Exception 
      */
-    public abstract void setRegistries( Registries registries ) throws Exception;
+    public void setRegistries( Registries registries ) throws Exception
+    {
+        this.registries = registries;
+    }
 
     
+    public Registries getRegistries()
+    {
+        return registries;
+    }
+    
+    
     /**
      * Gets the DefaultSearchEngine used by this ContextPartition to search the
      * Database. 
@@ -150,340 +177,426 @@
     // Partition Interface Method Implementations
     // ------------------------------------------------------------------------
 
-
-    public void delete( DeleteOperationContext opContext ) throws Exception
+    
+    public final void addIndexOn( Index<Long, ServerEntry> index ) throws Exception
     {
-        LdapDN dn = opContext.getDn();
-        
-        Long id = getEntryId( dn.getNormName() );
-
-        // don't continue if id is null
-        if ( id == null )
-        {
-            throw new LdapNameNotFoundException( "Could not find entry at '" + dn + "' to
delete it!" );
-        }
+        store.addIndex( index );
+    }
 
-        if ( getChildCount( id ) > 0 )
-        {
-            LdapContextNotEmptyException cnee = new LdapContextNotEmptyException( "[66] Cannot
delete entry " + dn
-                + " it has children!" );
-            cnee.setRemainingName( dn );
-            throw cnee;
-        }
 
-        delete( id );
+    public final Index<String, ServerEntry> getExistanceIndex()
+    {
+        return store.getPresenceIndex();
     }
 
 
-    public abstract void add( AddOperationContext opContext ) throws Exception;
+    /**
+     * @org.apache.xbean.Property hidden="true"
+     */
+    public final void setPresenceIndexOn( Index<String, ServerEntry> index ) throws
Exception
+    {
+        store.setPresenceIndex( index );
+    }
 
 
-    public abstract void modify( ModifyOperationContext opContext ) throws Exception;
+    public final Index<Long, ServerEntry> getOneLevelIndex()
+    {
+        return store.getOneLevelIndex();
+    }
 
 
-    public EntryFilteringCursor list( ListOperationContext opContext ) throws Exception
+    /**
+     * @org.apache.xbean.Property hidden="true"
+     */
+    public final void setOneLevelIndexOn( Index<Long, ServerEntry> index ) throws Exception
     {
-        return new BaseEntryFilteringCursor( new ServerEntryCursorAdaptor( this, 
-            list( getEntryId( opContext.getDn().getNormName() ) ) ), opContext );
+        store.setOneLevelIndex( index );
     }
 
 
-    public EntryFilteringCursor search( SearchOperationContext opContext ) throws Exception
+    public final Index<String, ServerEntry> getAliasIndex()
     {
-        SearchControls searchCtls = opContext.getSearchControls();
-        IndexCursor<Long,ServerEntry> underlying;
+        return store.getAliasIndex();
+    }
 
-        underlying = searchEngine.cursor( 
-            opContext.getDn(),
-            opContext.getAliasDerefMode(),
-            opContext.getFilter(), 
-            searchCtls );
 
-        return new BaseEntryFilteringCursor( new ServerEntryCursorAdaptor( this, underlying
), opContext );
+    /**
+     * @org.apache.xbean.Property hidden="true"
+     */
+    public final void setAliasIndexOn( Index<String, ServerEntry> index ) throws Exception
+    {
+        store.setAliasIndex( index );
     }
 
 
-    public ClonedServerEntry lookup( LookupOperationContext opContext ) throws Exception
+    public final Index<Long,ServerEntry> getOneAliasIndex()
     {
-        Long id = getEntryId( opContext.getDn().getNormName() );
-        
-        if ( id == null )
-        {
-            return null;
-        }
-        
-        ClonedServerEntry entry = lookup( id );
+        return store.getOneAliasIndex();
+    }
 
-        if ( ( opContext.getAttrsId() == null ) || ( opContext.getAttrsId().size() == 0 )
)
-        {
-            return entry;
-        }
 
-        for ( AttributeType attributeType : ((ServerEntry)entry.getOriginalEntry()).getAttributeTypes()
)
-        {
-            if ( ! opContext.getAttrsId().contains( attributeType.getOid() ) )
-            {
-                entry.removeAttributes( attributeType );
-            }
-        }
+    /**
+     * @org.apache.xbean.Property hidden="true"
+     */
+    public final void setOneAliasIndexOn( Index<Long,ServerEntry> index ) throws Exception
+    {
+        store.setOneAliasIndex( ( Index<Long,ServerEntry> ) index );
+    }
 
-        return entry;
+
+    public final Index<Long,ServerEntry> getSubAliasIndex()
+    {
+        return store.getSubAliasIndex();
     }
 
 
-    public boolean hasEntry( EntryOperationContext opContext ) throws Exception
+    /**
+     * @org.apache.xbean.Property hidden="true"
+     */
+    public final void setSubAliasIndexOn( Index<Long,ServerEntry> index ) throws Exception
     {
-        return null != getEntryId( opContext.getDn().getNormName() );
+            store.setSubAliasIndex( ( Index<Long,ServerEntry> ) index );
     }
 
 
-    public abstract void rename( RenameOperationContext opContext ) throws Exception;
+    public final Index<String,ServerEntry> getUpdnIndex()
+    {
+        return store.getUpdnIndex();
+    }
 
 
-    public abstract void move( MoveOperationContext opContext ) throws Exception;
+    /**
+     * @org.apache.xbean.Property hidden="true"
+     */
+    public final void setUpdnIndexOn( Index<String,ServerEntry> index ) throws Exception
+    {
+        store.setUpdnIndex( ( Index<String,ServerEntry> ) index );
+    }
 
 
-    public abstract void moveAndRename( MoveAndRenameOperationContext opContext ) throws
Exception;
+    public final Index<String,ServerEntry> getNdnIndex()
+    {
+        return store.getNdnIndex();
+    }
 
 
-    public abstract void sync() throws Exception;
+    /**
+     * @org.apache.xbean.Property hidden="true"
+     */
+    public final void setNdnIndexOn( Index<String,ServerEntry> index ) throws Exception
+    {
+        store.setNdnIndex( ( Index<String,ServerEntry> ) index );
+    }
 
 
-    public abstract void destroy() throws Exception;
+    public final Iterator<String> getUserIndices()
+    {
+        return store.userIndices();
+    }
 
 
-    public abstract boolean isInitialized();
+    public final Iterator<String> getSystemIndices()
+    {
+        return store.systemIndices();
+    }
 
 
-    ////////////////////
-    // public abstract methods
+    public final boolean hasUserIndexOn( String id ) throws Exception
+    {
+        return store.hasUserIndexOn( id );
+    }
 
-    // ------------------------------------------------------------------------
-    // Index Operations 
-    // ------------------------------------------------------------------------
 
-    public abstract void addIndexOn( Index<Long,ServerEntry> index ) throws Exception;
+    public final boolean hasSystemIndexOn( String id ) throws Exception
+    {
+        return store.hasSystemIndexOn( id );
+    }
 
 
-    public abstract boolean hasUserIndexOn( String attribute ) throws Exception;
+    /**
+     * @see org.apache.directory.server.core.partition.impl.btree.XdbmPartition#getUserIndex(String)
+     */
+    public final Index<?,ServerEntry> getUserIndex( String id ) throws IndexNotFoundException
+    {
+        return store.getUserIndex( id );
+    }
 
 
-    public abstract boolean hasSystemIndexOn( String attribute ) throws Exception;
+    /**
+     * @see XdbmPartition#getEntryId(String)
+     */
+    public final Index<?,ServerEntry> getSystemIndex( String id ) throws IndexNotFoundException
+    {
+        return store.getSystemIndex( id );
+    }
 
 
-    public abstract Index<String,ServerEntry> getPresenceIndex();
+    public final Long getEntryId( String dn ) throws Exception
+    {
+        return store.getEntryId( dn );
+    }
 
 
-    /**
-     * Gets the Index mapping the Long primary keys of parents to the 
-     * Long primary keys of their children.
-     *
-     * @return the one level Index
-     */
-    public abstract Index<Long,ServerEntry> getOneLevelIndex();
+    public final String getEntryDn( Long id ) throws Exception
+    {
+        return store.getEntryDn( id );
+    }
 
 
-    /**
-     * Gets the Index mapping the Long primary keys of ancestors to the 
-     * Long primary keys of their descendants.
-     *
-     * @return the sub tree level Index
-     */
-    public abstract Index<Long,ServerEntry> getSubLevelIndex();
+    public final Long getParentId( String dn ) throws Exception
+    {
+        return store.getParentId( dn );
+    }
 
 
-    /**
-     * Gets the Index mapping user provided distinguished names of entries as 
-     * Strings to the BigInteger primary keys of entries.
-     *
-     * @return the user provided distinguished name Index
-     */
-    public abstract Index<String,ServerEntry> getUpdnIndex();
+    public final Long getParentId( Long childId ) throws Exception
+    {
+        return store.getParentId( childId );
+    }
 
 
-    /**
-     * Gets the Index mapping the normalized distinguished names of entries as
-     * Strings to the BigInteger primary keys of entries.  
-     *
-     * @return the normalized distinguished name Index
-     */
-    public abstract Index<String,ServerEntry> getNdnIndex();
+    public final String getEntryUpdn( Long id ) throws Exception
+    {
+        return store.getEntryUpdn( id );
+    }
 
 
-    /**
-     * Gets the alias index mapping parent entries with scope expanding aliases 
-     * children one level below them; this system index is used to dereference
-     * aliases on one/single level scoped searches.
-     * 
-     * @return the one alias index
-     */
-    public abstract Index<Long,ServerEntry> getOneAliasIndex();
+    public final String getEntryUpdn( String dn ) throws Exception
+    {
+        return store.getEntryUpdn( dn );
+    }
 
 
-    /**
-     * Gets the alias index mapping relative entries with scope expanding 
-     * alias descendents; this system index is used to dereference aliases on 
-     * subtree scoped searches.
-     * 
-     * @return the sub alias index
-     */
-    public abstract Index<Long,ServerEntry> getSubAliasIndex();
+    public final int count() throws Exception
+    {
+        return store.count();
+    }
 
+    
+    public final void add( AddOperationContext addContext ) throws Exception
+    {
+        store.add( addContext.getDn(), (ServerEntry)((ClonedServerEntry)addContext.getEntry()).getClonedEntry()
);
+    }
 
-    /**
-     * Gets the system index defined on the ALIAS_ATTRIBUTE which for LDAP would
-     * be the aliasedObjectName and for X.500 would be aliasedEntryName.
-     * 
-     * @return the index on the ALIAS_ATTRIBUTE
-     */
-    public abstract Index<String,ServerEntry> getAliasIndex();
 
+    public final ClonedServerEntry lookup( Long id ) throws Exception
+    {
+        return new ClonedServerEntry( store.lookup( id ) );
+    }
 
-    /**
-     * Sets the system index defined on the ALIAS_ATTRIBUTE which for LDAP would
-     * be the aliasedObjectName and for X.500 would be aliasedEntryName.
-     * 
-     * @org.apache.xbean.Property hidden="true"
-     * @param index the index on the ALIAS_ATTRIBUTE
-     * @throws Exception if there is a problem setting up the index
-     */
-    public abstract void setAliasIndexOn( Index<String,ServerEntry> index ) throws
Exception;
 
+    public final void delete( Long id ) throws Exception
+    {
+        store.delete( id );
+    }
 
-    /**
-     * Sets the attribute existance Index.
-     *
-     * @org.apache.xbean.Property hidden="true"
-     * @param index the attribute existance Index
-     * @throws Exception if there is a problem setting up the index
-     */
-    public abstract void setPresenceIndexOn( Index<String,ServerEntry> index ) throws
Exception;
 
+    public final IndexCursor<Long, ServerEntry> list( Long id ) throws Exception
+    {
+        return store.list( id );
+    }
 
-    /**
-     * Sets the one level Index.
-     *
-     * @org.apache.xbean.Property hidden="true"
-     * @param index the one level Index
-     * @throws Exception if there is a problem setting up the index
-     */
-    public abstract void setOneLevelIndexOn( Index<Long,ServerEntry> index ) throws
Exception;
 
-    // TODO - add sub level index setter
+    public final int getChildCount( Long id ) throws Exception
+    {
+        return store.getChildCount( id );
+    }
 
-    /**
-     * Sets the user provided distinguished name Index.
-     *
-     * @org.apache.xbean.Property hidden="true"
-     * @param index the updn Index
-     * @throws Exception if there is a problem setting up the index
-     */
-    public abstract void setUpdnIndexOn( Index<String,ServerEntry> index ) throws Exception;
 
+    public final LdapDN getSuffixDn()
+    {
+        return store.getSuffix();
+    }
 
-    /**
-     * Sets the normalized distinguished name Index.
-     *
-     * @org.apache.xbean.Property hidden="true"
-     * @param index the ndn Index
-     * @throws Exception if there is a problem setting up the index
-     */
-    public abstract void setNdnIndexOn( Index<String,ServerEntry> index ) throws Exception;
+    public final LdapDN getUpSuffixDn() throws Exception
+    {
+        return store.getUpSuffix();
+    }
 
 
-    /**
-     * Sets the alias index mapping parent entries with scope expanding aliases 
-     * children one level below them; this system index is used to dereference
-     * aliases on one/single level scoped searches.
-     * 
-     * @org.apache.xbean.Property hidden="true"
-     * @param index a one level alias index
-     * @throws Exception if there is a problem setting up the index
-     */
-    public abstract void setOneAliasIndexOn( Index<Long,ServerEntry> index ) throws
Exception;
+    public final void setProperty( String propertyName, String propertyValue ) throws Exception
+    {
+        store.setProperty( propertyName, propertyValue );
+    }
 
 
-    /**
-     * Sets the alias index mapping relative entries with scope expanding 
-     * alias descendents; this system index is used to dereference aliases on 
-     * subtree scoped searches.
-     * 
-     * @org.apache.xbean.Property hidden="true"
-     * @param index a subtree alias index
-     * @throws Exception if there is a problem setting up the index
-     */
-    public abstract void setSubAliasIndexOn( Index<Long,ServerEntry> index ) throws
Exception;
+    public final String getProperty( String propertyName ) throws Exception
+    {
+        return store.getProperty( propertyName );
+    }
+
+    
+    public final void modify( ModifyOperationContext modifyContext ) throws Exception
+    {
+        store.modify( modifyContext.getDn(), modifyContext.getModItems() );
+    }
 
+    public final void rename( RenameOperationContext renameContext ) throws Exception
+    {
+        store.rename( renameContext.getDn(), renameContext.getNewRdn(), renameContext.getDelOldDn()
);
+    }
 
-    public abstract Index<?,ServerEntry> getUserIndex( String attribute ) throws Exception;
 
+    public final void moveAndRename( MoveAndRenameOperationContext moveAndRenameContext )
throws Exception
+    {
+        store.move( moveAndRenameContext.getDn(), 
+            moveAndRenameContext.getParent(), 
+            moveAndRenameContext.getNewRdn(), 
+            moveAndRenameContext.getDelOldDn() );
+    }
 
-    public abstract Index<?,ServerEntry> getSystemIndex( String attribute ) throws
Exception;
 
+    public final void move( MoveOperationContext moveContext ) throws Exception
+    {
+        store.move( moveContext.getDn(), moveContext.getParent() );
+    }
 
-    public abstract Long getEntryId( String dn ) throws Exception;
 
+    public final void bind( LdapDN bindDn, byte[] credentials, List<String> mechanisms,
String saslAuthId ) throws Exception
+    {
+        if ( bindDn == null || credentials == null || mechanisms == null ||  saslAuthId ==
null )
+        {
+            // do nothing just using variables to prevent yellow lights : bad :)
+        }
+        
+        // does nothing
+        throw new LdapAuthenticationNotSupportedException(
+                "Bind requests only tunnel down into partitions if there are no authenticators
to handle the mechanism.\n"
+                        + "Check to see if you have correctly configured authenticators for
the server.",
+                ResultCodeEnum.AUTH_METHOD_NOT_SUPPORTED );
+    }
+    
 
-    public abstract String getEntryDn( Long id ) throws Exception;
+    public final void bind( BindOperationContext bindContext ) throws Exception
+    {
+        // does nothing
+        throw new LdapAuthenticationNotSupportedException(
+            "Bind requests only tunnel down into partitions if there are no authenticators
to handle the mechanism.\n"
+                + "Check to see if you have correctly configured authenticators for the server.",
+            ResultCodeEnum.AUTH_METHOD_NOT_SUPPORTED );
+    }
 
 
-    public abstract Long getParentId( String dn ) throws Exception;
+    public final void unbind( UnbindOperationContext unbindContext ) throws Exception
+    {
+    }
 
 
-    public abstract Long getParentId( Long childId ) throws Exception;
+    public Index<String, ServerEntry> getPresenceIndex()
+    {
+        return store.getPresenceIndex();
+    }
 
 
+    public Index<Long, ServerEntry> getSubLevelIndex()
+    {
+        return store.getSubLevelIndex();
+    }
+    
+    
     /**
-     * Gets the user provided distinguished name.
-     *
-     * @param id the entry id
-     * @return the user provided distinguished name
-     * @throws Exception if the updn index cannot be accessed
+     * @see Object#toString()
      */
-    public abstract String getEntryUpdn( Long id ) throws Exception;
+    public String toString()
+    {
+        return "Partition<" + getId() + ">"; 
+    }
+    
 
+    public void delete( DeleteOperationContext opContext ) throws Exception
+    {
+        LdapDN dn = opContext.getDn();
+        
+        Long id = getEntryId( dn.getNormName() );
 
-    /**
-     * Gets the user provided distinguished name.
-     *
-     * @param dn the normalized distinguished name
-     * @return the user provided distinguished name
-     * @throws Exception if the updn and ndn indices cannot be accessed
-     */
-    public abstract String getEntryUpdn( String dn ) throws Exception;
+        // don't continue if id is null
+        if ( id == null )
+        {
+            throw new LdapNameNotFoundException( "Could not find entry at '" + dn + "' to
delete it!" );
+        }
 
+        if ( getChildCount( id ) > 0 )
+        {
+            LdapContextNotEmptyException cnee = new LdapContextNotEmptyException( "[66] Cannot
delete entry " + dn
+                + " it has children!" );
+            cnee.setRemainingName( dn );
+            throw cnee;
+        }
 
-    public abstract ClonedServerEntry lookup( Long id ) throws Exception;
+        delete( id );
+    }
 
 
-    public abstract void delete( Long id ) throws Exception;
+    public EntryFilteringCursor list( ListOperationContext opContext ) throws Exception
+    {
+        return new BaseEntryFilteringCursor( new ServerEntryCursorAdaptor( this, 
+            list( getEntryId( opContext.getDn().getNormName() ) ) ), opContext );
+    }
 
 
-    public abstract IndexCursor<Long,ServerEntry> list( Long id ) throws Exception;
+    public EntryFilteringCursor search( SearchOperationContext opContext ) throws Exception
+    {
+        SearchControls searchCtls = opContext.getSearchControls();
+        IndexCursor<Long,ServerEntry> underlying;
 
+        underlying = searchEngine.cursor( 
+            opContext.getDn(),
+            opContext.getAliasDerefMode(),
+            opContext.getFilter(), 
+            searchCtls );
 
-    public abstract int getChildCount( Long id ) throws Exception;
+        return new BaseEntryFilteringCursor( new ServerEntryCursorAdaptor( this, underlying
), opContext );
+    }
 
 
-    public abstract void setProperty( String key, String value ) throws Exception;
+    public ClonedServerEntry lookup( LookupOperationContext opContext ) throws Exception
+    {
+        Long id = getEntryId( opContext.getDn().getNormName() );
+        
+        if ( id == null )
+        {
+            return null;
+        }
+        
+        ClonedServerEntry entry = lookup( id );
 
+        if ( ( opContext.getAttrsId() == null ) || ( opContext.getAttrsId().size() == 0 )
)
+        {
+            return entry;
+        }
 
-    public abstract String getProperty( String key ) throws Exception;
+        for ( AttributeType attributeType : ((ServerEntry)entry.getOriginalEntry()).getAttributeTypes()
)
+        {
+            if ( ! opContext.getAttrsId().contains( attributeType.getOid() ) )
+            {
+                entry.removeAttributes( attributeType );
+            }
+        }
 
+        return entry;
+    }
 
-    public abstract Iterator<String> getUserIndices();
 
+    public boolean hasEntry( EntryOperationContext opContext ) throws Exception
+    {
+        return null != getEntryId( opContext.getDn().getNormName() );
+    }
 
-    public abstract Iterator<String> getSystemIndices();
 
+    public final void destroy() throws Exception
+    {
+        store.destroy();
+    }
 
-    /**
-     * Gets the count of the total number of entries in the database.
-     *
-     * TODO shouldn't this be a BigInteger instead of an int? 
-     * 
-     * @return the number of entries in the database 
-     * @throws Exception if there is a failure to read the count
-     */
-    public abstract int count() throws Exception;
+
+    public final boolean isInitialized()
+    {
+        return store.isInitialized();
+    }
+
+
+    public final void sync() throws Exception
+    {
+        store.sync();
+    }
 }



Mime
View raw message