You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2010/04/26 13:17:20 UTC

svn commit: r938001 [1/2] - in /directory/apacheds/trunk: avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/ avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/ jdbm-partition/src/main/java/org/apache/di...

Author: seelmann
Date: Mon Apr 26 11:17:19 2010
New Revision: 938001

URL: http://svn.apache.org/viewvc?rev=938001&view=rev
Log:
o moved index initialization to AbstractStore class
o removed set<System>Index methods form Store and BTreePartition


Modified:
    directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlPartition.java
    directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
    directory/apacheds/trunk/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java
    directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
    directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
    directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
    directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
    directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/LdifPartitionTest.java
    directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
    directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
    directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractXdbmPartition.java
    directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/GenericIndex.java
    directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java

Modified: directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlPartition.java?rev=938001&r1=938000&r2=938001&view=diff
==============================================================================
--- directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlPartition.java (original)
+++ directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlPartition.java Mon Apr 26 11:17:19 2010
@@ -24,15 +24,13 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import org.apache.directory.server.constants.ApacheSchemaConstants;
-import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.server.xdbm.AbstractXdbmPartition;
+import org.apache.directory.server.xdbm.Index;
 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.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.entry.ServerEntry;
 
@@ -92,68 +90,14 @@ public class AvlPartition extends Abstra
 
         Set<Index<?, ServerEntry, Long>> userIndices = new HashSet<Index<?, ServerEntry, Long>>();
 
-        for ( AvlIndex<?, ServerEntry> obj : indexedAttributes )
+        for ( AvlIndex<?, ServerEntry> index : indexedAttributes )
         {
-            AvlIndex<?, ServerEntry> index;
-
-            if ( obj instanceof AvlIndex<?, ?> )
-            {
-                index = ( AvlIndex<?, ServerEntry> ) obj;
-            }
-            else
-            {
-                index = new AvlIndex<Object, ServerEntry>();
-                index.setAttributeId( obj.getAttributeId() );
-            }
-
             String oid = schemaManager.getAttributeTypeRegistry().getOidByName( index.getAttributeId() );
-
-            if ( SYS_INDEX_OIDS.contains( schemaManager.getAttributeTypeRegistry()
-                .getOidByName( index.getAttributeId() ) ) )
+            if(!index.getAttributeId().equals( oid ))
             {
-                if ( oid.equals( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ) )
-                {
-                    store.setAliasIndex( ( Index<String, ServerEntry, Long> ) index );
-                }
-                else if ( oid.equals( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID ) )
-                {
-                    store.setPresenceIndex( ( Index<String, ServerEntry, Long> ) index );
-                }
-                else if ( oid.equals( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID ) )
-                {
-                    store.setOneLevelIndex( ( Index<Long, ServerEntry, Long> ) index );
-                }
-                else if ( oid.equals( ApacheSchemaConstants.APACHE_N_DN_AT_OID ) )
-                {
-                    store.setNdnIndex( ( Index<String, ServerEntry, Long> ) index );
-                }
-                else if ( oid.equals( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID ) )
-                {
-                    store.setOneAliasIndex( ( Index<Long, ServerEntry, Long> ) index );
-                }
-                else if ( oid.equals( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID ) )
-                {
-                    store.setSubAliasIndex( ( Index<Long, ServerEntry, Long> ) index );
-                }
-                else if ( oid.equals( ApacheSchemaConstants.APACHE_UP_DN_AT_OID ) )
-                {
-                    store.setUpdnIndex( ( Index<String, ServerEntry, Long> ) index );
-                }
-                else if ( oid.equals( SchemaConstants.OBJECT_CLASS_AT_OID ) )
-                {
-                    store.addIndex( ( Index<String, ServerEntry, Long> ) index );
-                }
-                else
-                {
-                    throw new IllegalStateException( "Unrecognized system index " + oid );
-                }
+                index.setAttributeId( oid );
             }
-            else
-            {
-                userIndices.add( index );
-            }
-
-            store.setUserIndices( userIndices );
+            store.addIndex( index );
         }
 
         store.init( schemaManager );

Modified: directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java?rev=938001&r1=938000&r2=938001&view=diff
==============================================================================
--- directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java (original)
+++ directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java Mon Apr 26 11:17:19 2010
@@ -22,14 +22,8 @@ package org.apache.directory.server.core
 
 import java.io.File;
 import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
-import org.apache.directory.server.constants.ApacheSchemaConstants;
 import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.core.partition.impl.btree.LongComparator;
 import org.apache.directory.server.i18n.I18n;
@@ -37,7 +31,6 @@ import org.apache.directory.server.xdbm.
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.xdbm.IndexEntry;
-import org.apache.directory.server.xdbm.IndexNotFoundException;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.cursor.Cursor;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
@@ -46,7 +39,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.entry.ServerEntry;
 import org.apache.directory.shared.ldap.entry.StringValue;
 import org.apache.directory.shared.ldap.entry.Value;
-import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.exception.LdapNoSuchObjectException;
 import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
@@ -54,7 +46,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.name.RDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
-import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.SchemaManager;
 import org.apache.directory.shared.ldap.util.NamespaceTools;
 import org.slf4j.Logger;
@@ -83,45 +74,6 @@ public class AvlStore<E> extends Abstrac
     /** the master table storing entries by primary key */
     private AvlMasterTable<ServerEntry> master;
 
-    /** the normalized distinguished name index */
-    private AvlIndex<String, E> ndnIdx;
-
-    /** the user provided distinguished name index */
-    private AvlIndex<String, E> updnIdx;
-
-    /** the attribute existence index */
-    private AvlIndex<String, E> existenceIdx;
-
-    /** a system index on aliasedObjectName attribute */
-    private AvlIndex<String, E> aliasIdx;
-
-    /** a system index on the entries of descendants of root DN*/
-    private AvlIndex<Long, E> subLevelIdx;
-
-    /** the parent child relationship index */
-    private AvlIndex<Long, E> oneLevelIdx;
-
-    /** the one level scope alias index */
-    private AvlIndex<Long, E> oneAliasIdx;
-
-    /** the subtree scope alias index */
-    private AvlIndex<Long, E> subAliasIdx;
-
-    /** a system index on objectClass attribute*/
-    private AvlIndex<String, E> objectClassIdx;
-
-    /** a system index on entryCSN attribute */
-    private AvlIndex<String, E> entryCsnIdx;
-
-    /** a system index on entryUUID attribute */
-    private AvlIndex<String, E> entryUuidIdx;
-
-    /** a map of attributeType numeric ID to user userIndices */
-    private Map<String, AvlIndex<? extends Object, E>> userIndices = new HashMap<String, AvlIndex<? extends Object, E>>();
-
-    /** a map of attributeType numeric ID to system userIndices */
-    private Map<String, AvlIndex<? extends Object, E>> systemIndices = new HashMap<String, AvlIndex<? extends Object, E>>();
-
 
     /**
      * {@inheritDoc}
@@ -246,7 +198,7 @@ public class AvlStore<E> extends Abstrac
                 }
 
                 // Adds only those attributes that are indexed
-                existenceIdx.add( attributeOid, id );
+                presenceIdx.add( attributeOid, id );
             }
         }
 
@@ -257,22 +209,6 @@ public class AvlStore<E> extends Abstrac
     /**
      * {@inheritDoc}
      */
-    public void addIndex( Index<? extends Object, E, Long> index ) throws Exception
-    {
-        if ( index instanceof AvlIndex<?, ?> )
-        {
-            userIndices.put( index.getAttributeId(), ( AvlIndex<? extends Object, E> ) index );
-        }
-        else
-        {
-            userIndices.put( index.getAttributeId(), ( AvlIndex<? extends Object, E> ) convert( index ) );
-        }
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     public int count() throws Exception
     {
         return master.count();
@@ -332,7 +268,7 @@ public class AvlStore<E> extends Abstrac
                     ( ( AvlIndex ) index ).drop( value.get(), id );
                 }
 
-                existenceIdx.drop( attributeOid, id );
+                presenceIdx.drop( attributeOid, id );
             }
         }
 
@@ -353,15 +289,6 @@ public class AvlStore<E> extends Abstrac
     /**
      * {@inheritDoc}
      */
-    public Index<String, E, Long> getAliasIndex()
-    {
-        return aliasIdx;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     public int getChildCount( Long id ) throws Exception
     {
         return oneLevelIdx.count( id );
@@ -408,33 +335,6 @@ public class AvlStore<E> extends Abstrac
     /**
      * {@inheritDoc}
      */
-    public Index<String, E, Long> getNdnIndex()
-    {
-        return ndnIdx;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Index<Long, E, Long> getOneAliasIndex()
-    {
-        return oneAliasIdx;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Index<Long, E, Long> getOneLevelIndex()
-    {
-        return oneLevelIdx;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     public Long getParentId( String dn ) throws Exception
     {
         Long childId = ndnIdx.forwardLookup( dn );
@@ -454,15 +354,6 @@ public class AvlStore<E> extends Abstrac
     /**
      * {@inheritDoc}
      */
-    public Index<String, E, Long> getPresenceIndex()
-    {
-        return existenceIdx;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     public String getProperty( String propertyName ) throws Exception
     {
         return master.getProperty( propertyName );
@@ -471,145 +362,6 @@ public class AvlStore<E> extends Abstrac
 
     /**
      * {@inheritDoc}
-     */
-    public Index<Long, E, Long> getSubAliasIndex()
-    {
-        return subAliasIdx;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Index<Long, E, Long> getSubLevelIndex()
-    {
-        return subLevelIdx;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Index<?, E, Long> getSystemIndex( String id ) throws IndexNotFoundException
-    {
-        try
-        {
-            id = schemaManager.getAttributeTypeRegistry().getOidByName( id );
-        }
-        catch ( LdapException e )
-        {
-            LOG.error( I18n.err( I18n.ERR_1, id ), e.getLocalizedMessage() );
-            throw new IndexNotFoundException( I18n.err( I18n.ERR_1, id ), id, e );
-        }
-
-        if ( systemIndices.containsKey( id ) )
-        {
-            return systemIndices.get( id );
-        }
-
-        throw new IndexNotFoundException( I18n.err( I18n.ERR_2, id, id ) );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Index<?, E, Long> getIndex( String id ) throws IndexNotFoundException
-    {
-        try
-        {
-            id = schemaManager.getAttributeTypeRegistry().getOidByName( id );
-        }
-        catch ( LdapException e )
-        {
-            LOG.error( I18n.err( I18n.ERR_1, id ), e.getLocalizedMessage() );
-            throw new IndexNotFoundException( I18n.err( I18n.ERR_1, id ), id, e );
-        }
-
-        if ( userIndices.containsKey( id ) )
-        {
-            return userIndices.get( id );
-        }
-        if ( systemIndices.containsKey( id ) )
-        {
-            return systemIndices.get( id );
-        }
-
-        throw new IndexNotFoundException( I18n.err( I18n.ERR_2, id, id ) );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Index<String, E, Long> getUpdnIndex()
-    {
-        return updnIdx;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Index<? extends Object, E, Long> getUserIndex( String id ) throws IndexNotFoundException
-    {
-        try
-        {
-            id = schemaManager.getAttributeTypeRegistry().getOidByName( id );
-        }
-        catch ( LdapException e )
-        {
-            LOG.error( I18n.err( I18n.ERR_1, id ), e.getLocalizedMessage() );
-            throw new IndexNotFoundException( I18n.err( I18n.ERR_1, id ), id, e );
-        }
-
-        if ( userIndices.containsKey( id ) )
-        {
-            return userIndices.get( id );
-        }
-
-        throw new IndexNotFoundException( I18n.err( I18n.ERR_3, id, id ) );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Set<Index<? extends Object, E, Long>> getUserIndices()
-    {
-        return new HashSet<Index<? extends Object, E, Long>>( userIndices.values() );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean hasIndexOn( String id ) throws Exception
-    {
-        return hasUserIndexOn( id ) || hasSystemIndexOn( id );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean hasSystemIndexOn( String id ) throws Exception
-    {
-        return systemIndices.containsKey( id );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean hasUserIndexOn( String id ) throws Exception
-    {
-        return userIndices.containsKey( id );
-    }
-
-
-    /**
-     * {@inheritDoc}
      * TODO why this and initRegistries on Store interface ???
      */
     public void init( SchemaManager schemaManager ) throws Exception
@@ -622,11 +374,9 @@ public class AvlStore<E> extends Abstrac
         // Create the master table (the table containing all the entries)
         master = new AvlMasterTable<ServerEntry>( id, new LongComparator(), null, false );
 
-        suffixDn.normalize( schemaManager.getNormalizerMapping() );
         // -------------------------------------------------------------------
         // Initializes the user and system indices
         // -------------------------------------------------------------------
-
         setupSystemIndices();
         setupUserIndices();
 
@@ -635,155 +385,6 @@ public class AvlStore<E> extends Abstrac
     }
 
 
-    private void setupSystemIndices() throws Exception
-    {
-        // let's check and make sure the supplied indices are OK
-
-        if ( ndnIdx == null )
-        {
-            AttributeType attributeType = schemaManager
-                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_N_DN_AT_OID );
-            ndnIdx = new AvlIndex<String, E>();
-            ndnIdx.setAttributeId( ApacheSchemaConstants.APACHE_N_DN_AT_OID );
-            ndnIdx.initialize( attributeType );
-            systemIndices.put( ApacheSchemaConstants.APACHE_N_DN_AT_OID, ndnIdx );
-        }
-
-        if ( updnIdx == null )
-        {
-            AttributeType attributeType = schemaManager
-                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_UP_DN_AT_OID );
-            updnIdx = new AvlIndex<String, E>();
-            updnIdx.setAttributeId( ApacheSchemaConstants.APACHE_UP_DN_AT_OID );
-            updnIdx.initialize( attributeType );
-            systemIndices.put( ApacheSchemaConstants.APACHE_UP_DN_AT_OID, updnIdx );
-        }
-
-        if ( existenceIdx == null )
-        {
-            AttributeType attributeType = schemaManager
-                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID );
-            existenceIdx = new AvlIndex<String, E>();
-            existenceIdx.setAttributeId( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID );
-            existenceIdx.initialize( attributeType );
-            systemIndices.put( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID, existenceIdx );
-        }
-
-        if ( oneLevelIdx == null )
-        {
-            AttributeType attributeType = schemaManager
-                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID );
-            oneLevelIdx = new AvlIndex<Long, E>();
-            oneLevelIdx.setAttributeId( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID );
-            oneLevelIdx.initialize( attributeType );
-            systemIndices.put( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID, oneLevelIdx );
-        }
-
-        if ( oneAliasIdx == null )
-        {
-            AttributeType attributeType = schemaManager
-                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID );
-            oneAliasIdx = new AvlIndex<Long, E>();
-            oneAliasIdx.setAttributeId( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID );
-            oneAliasIdx.initialize( attributeType );
-            systemIndices.put( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID, oneAliasIdx );
-        }
-
-        if ( subAliasIdx == null )
-        {
-            AttributeType attributeType = schemaManager
-                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID );
-            subAliasIdx = new AvlIndex<Long, E>();
-            subAliasIdx.setAttributeId( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID );
-            subAliasIdx.initialize( attributeType );
-            systemIndices.put( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID, subAliasIdx );
-        }
-
-        if ( aliasIdx == null )
-        {
-            AttributeType attributeType = schemaManager
-                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_ALIAS_AT_OID );
-            aliasIdx = new AvlIndex<String, E>();
-            aliasIdx.setAttributeId( ApacheSchemaConstants.APACHE_ALIAS_AT_OID );
-            aliasIdx.initialize( attributeType );
-            systemIndices.put( ApacheSchemaConstants.APACHE_ALIAS_AT_OID, aliasIdx );
-        }
-
-        if ( subLevelIdx == null )
-        {
-            AttributeType attributeType = schemaManager
-                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID );
-            subLevelIdx = new AvlIndex<Long, E>();
-            subLevelIdx.setAttributeId( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID );
-            subLevelIdx.initialize( attributeType );
-            systemIndices.put( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID, subLevelIdx );
-        }
-
-        if ( entryCsnIdx == null )
-        {
-            AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.ENTRY_CSN_AT_OID );
-            entryCsnIdx = new AvlIndex<String, E>();
-            entryCsnIdx.setAttributeId( SchemaConstants.ENTRY_CSN_AT_OID );
-            entryCsnIdx.initialize( attributeType );
-            systemIndices.put( SchemaConstants.ENTRY_CSN_AT_OID, entryCsnIdx );
-        }
-
-        if ( entryUuidIdx == null )
-        {
-            AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.ENTRY_UUID_AT_OID );
-            entryUuidIdx = new AvlIndex<String, E>();
-            entryUuidIdx.setAttributeId( SchemaConstants.ENTRY_UUID_AT_OID );
-            entryUuidIdx.initialize( attributeType );
-            systemIndices.put( SchemaConstants.ENTRY_UUID_AT_OID, entryUuidIdx );
-        }
-
-        if ( objectClassIdx == null )
-        {
-            AttributeType attributeType = schemaManager
-                .lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT_OID );
-            objectClassIdx = new AvlIndex<String, E>();
-            objectClassIdx.setAttributeId( SchemaConstants.OBJECT_CLASS_AT_OID );
-            objectClassIdx.initialize( attributeType );
-            systemIndices.put( SchemaConstants.OBJECT_CLASS_AT_OID, objectClassIdx );
-        }
-
-    }
-
-
-    private void setupUserIndices() throws Exception
-    {
-        if ( userIndices != null && userIndices.size() > 0 )
-        {
-            Map<String, AvlIndex<? extends Object, E>> tmp = new HashMap<String, AvlIndex<? extends Object, E>>();
-
-            for ( AvlIndex<? extends Object, E> index : userIndices.values() )
-            {
-                String oid = schemaManager.getAttributeTypeRegistry().getOidByName( index.getAttributeId() );
-                AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( oid );
-
-                // Check that the attributeType has an EQUALITY matchingRule
-                MatchingRule mr = attributeType.getEquality();
-
-                if ( mr != null )
-                {
-                    index.initialize( schemaManager.lookupAttributeTypeRegistry( oid ) );
-                    tmp.put( oid, index );
-                }
-                else
-                {
-                    LOG.error( I18n.err( I18n.ERR_4, attributeType.getName() ) );
-                }
-            }
-
-            userIndices = tmp;
-        }
-        else
-        {
-            userIndices = new HashMap<String, AvlIndex<? extends Object, E>>();
-        }
-    }
-
-
     /**
      * {@inheritDoc}
      */
@@ -923,9 +524,9 @@ public class AvlStore<E> extends Abstrac
             }
 
             // If the attr didn't exist for this id add it to existence index
-            if ( !existenceIdx.forward( modsOid, id ) )
+            if ( !presenceIdx.forward( modsOid, id ) )
             {
-                existenceIdx.add( modsOid, id );
+                presenceIdx.add( modsOid, id );
             }
         }
 
@@ -991,7 +592,7 @@ public class AvlStore<E> extends Abstrac
              */
             if ( null == index.reverseLookup( id ) )
             {
-                existenceIdx.drop( modsOid, id );
+                presenceIdx.drop( modsOid, id );
             }
         }
 
@@ -1095,7 +696,7 @@ public class AvlStore<E> extends Abstrac
              */
             if ( null == index.reverseLookup( id ) )
             {
-                existenceIdx.drop( modsOid, id );
+                presenceIdx.drop( modsOid, id );
             }
         }
 
@@ -1328,9 +929,9 @@ public class AvlStore<E> extends Abstrac
                 ( ( Index ) index ).add( newNormValue, id );
 
                 // Make sure the altered entry shows the existence of the new attrib
-                if ( !existenceIdx.forward( newNormType, id ) )
+                if ( !presenceIdx.forward( newNormType, id ) )
                 {
-                    existenceIdx.add( newNormType, id );
+                    presenceIdx.add( newNormType, id );
                 }
             }
         }
@@ -1387,7 +988,7 @@ public class AvlStore<E> extends Abstrac
                          */
                         if ( null == index.reverseLookup( id ) )
                         {
-                            existenceIdx.drop( oldNormType, id );
+                            presenceIdx.drop( oldNormType, id );
                         }
                     }
                 }
@@ -1423,217 +1024,33 @@ public class AvlStore<E> extends Abstrac
     /**
      * {@inheritDoc}
      */
-    public void setAliasIndex( Index<String, E, Long> index ) throws Exception
-    {
-        protect( "aliasIndex" );
-        if ( index instanceof AvlIndex<?, ?> )
-        {
-            this.aliasIdx = ( AvlIndex<String, E> ) index;
-        }
-        else
-        {
-            this.aliasIdx = ( AvlIndex<String, E> ) convert( index );
-        }
-
-        // FIXME is this attribute ID or its OID
-        systemIndices.put( index.getAttributeId(), aliasIdx );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setNdnIndex( Index<String, E, Long> index ) throws Exception
-    {
-        protect( "ndnIndex" );
-        if ( index instanceof AvlIndex<?, ?> )
-        {
-            this.ndnIdx = ( AvlIndex<String, E> ) index;
-        }
-        else
-        {
-            this.ndnIdx = ( AvlIndex<String, E> ) convert( index );
-        }
-
-        systemIndices.put( index.getAttributeId(), ndnIdx );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setOneAliasIndex( Index<Long, E, Long> index ) throws Exception
-    {
-        protect( "oneAliasIndex" );
-        if ( index instanceof AvlIndex<?, ?> )
-        {
-            this.oneAliasIdx = ( AvlIndex<Long, E> ) index;
-        }
-        else
-        {
-            this.oneAliasIdx = ( AvlIndex<Long, E> ) convert( index );
-        }
-
-        systemIndices.put( index.getAttributeId(), oneAliasIdx );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setOneLevelIndex( Index<Long, E, Long> index ) throws Exception
-    {
-        protect( "oneLevelIndex" );
-        if ( index instanceof AvlIndex<?, ?> )
-        {
-            this.oneLevelIdx = ( AvlIndex<Long, E> ) index;
-        }
-        else
-        {
-            this.oneLevelIdx = ( AvlIndex<Long, E> ) convert( index );
-        }
-
-        systemIndices.put( index.getAttributeId(), oneLevelIdx );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setPresenceIndex( Index<String, E, Long> index ) throws Exception
-    {
-        protect( "presenceIndex" );
-        if ( index instanceof AvlIndex<?, ?> )
-        {
-            this.existenceIdx = ( AvlIndex<String, E> ) index;
-        }
-        else
-        {
-            this.existenceIdx = ( AvlIndex<String, E> ) convert( index );
-        }
-
-        systemIndices.put( index.getAttributeId(), existenceIdx );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     public void setProperty( String propertyName, String propertyValue ) throws Exception
     {
         master.setProperty( propertyName, propertyValue );
     }
 
 
-    /**
-     * {@inheritDoc}
-     */
-    public void setSubAliasIndex( Index<Long, E, Long> index ) throws Exception
-    {
-        protect( "subAliasIndex" );
-        if ( index instanceof AvlIndex<?, ?> )
-        {
-            this.subAliasIdx = ( AvlIndex<Long, E> ) index;
-        }
-        else
-        {
-            this.subAliasIdx = ( AvlIndex<Long, E> ) convert( index );
-        }
-
-        systemIndices.put( index.getAttributeId(), subAliasIdx );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setSubLevelIndex( Index<Long, E, Long> index ) throws Exception
-    {
-        protect( "subLevelIndex" );
-        if ( index instanceof AvlIndex<?, ?> )
-        {
-            this.subLevelIdx = ( AvlIndex<Long, E> ) index;
-        }
-        else
-        {
-            this.subLevelIdx = ( AvlIndex<Long, E> ) convert( index );
-        }
-
-        systemIndices.put( index.getAttributeId(), subLevelIdx );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setUpdnIndex( Index<String, E, Long> index ) throws Exception
+    @Override
+    protected Index<?, E, Long> convertAndInit( Index<?, E, Long> index ) throws Exception
     {
-        protect( "updnIndex" );
+        AvlIndex<?, E> avlIndex;
         if ( index instanceof AvlIndex<?, ?> )
         {
-            this.updnIdx = ( AvlIndex<String, E> ) index;
+            avlIndex = ( AvlIndex<?, E> ) index;
         }
         else
         {
-            this.updnIdx = ( AvlIndex<String, E> ) convert( index );
+            LOG.warn( "Supplied index {} is not a JdbmIndex.  "
+                + "Will create new JdbmIndex using copied configuration parameters.", index );
+            avlIndex = new AvlIndex( index.getAttributeId() );
         }
 
-        systemIndices.put( index.getAttributeId(), updnIdx );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setUserIndices( Set<Index<? extends Object, E, Long>> userIndices )
-    {
-        protect( "setUserIndices" );
-
-        for ( Index<? extends Object, E, Long> index : userIndices )
-        {
-            if ( index instanceof AvlIndex<?, ?> )
-            {
-                this.userIndices.put( index.getAttributeId(), ( AvlIndex<? extends Object, E> ) index );
-                continue;
-            }
+        avlIndex.initialize( schemaManager.lookupAttributeTypeRegistry( index.getAttributeId() ) );
 
-            LOG.warn( "Supplied index {} is not a AvlIndex.  "
-                + "Will create new AvlIndex using copied configuration parameters.", index );
-
-            AvlIndex<Object, E> avlIndex = ( AvlIndex<Object, E> ) convert( index );
-
-            this.userIndices.put( index.getAttributeId(), avlIndex );
-        }
-    }
-
-
-    private <K> AvlIndex<K, E> convert( Index<K, E, Long> index )
-    {
-        AvlIndex<K, E> avlIndex = new AvlIndex<K, E>();
-        avlIndex.setAttributeId( index.getAttributeId() );
         return avlIndex;
     }
 
 
-
-    /**
-     * {@inheritDoc}
-     */
-    public Iterator<String> systemIndices()
-    {
-        return systemIndices.keySet().iterator();
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Iterator<String> userIndices()
-    {
-        return userIndices.keySet().iterator();
-    }
-
-
     /**
      * Adds userIndices for an aliasEntry to be added to the database while checking
      * for constrained alias constructs like alias cycles and chaining.
@@ -1966,49 +1383,18 @@ public class AvlStore<E> extends Abstrac
 
 
     /**
-     * always returns 0 (zero), cause this is a inmemory store
+     * Always returns 0 (zero), cause this is a in-memory store
      */
+    @Override
     public int getCacheSize()
     {
         return 0;
     }
 
 
-    public Index<String, E, Long> getEntryCsnIndex()
-    {
-        return entryCsnIdx;
-    }
-
-
-    public Index<String, E, Long> getEntryUuidIndex()
-    {
-        return entryUuidIdx;
-    }
-
-
-    public Index<String, E, Long> getObjectClassIndex()
-    {
-        return objectClassIdx;
-    }
-
-
-    public void setEntryCsnIndex( Index<String, E, Long> index ) throws Exception
-    {
-        protect( "entryCsnIndex" );
-
-        if ( index instanceof AvlIndex<?, ?> )
-        {
-            this.entryCsnIdx = ( AvlIndex<String, E> ) index;
-        }
-        else
-        {
-            this.entryCsnIdx = ( AvlIndex<String, E> ) convert( index );
-        }
-
-        systemIndices.put( index.getAttributeId(), entryCsnIdx );
-    }
-
-
+    /**
+     * always returns null, cause this is a in-memory store
+     */
     @Override
     public File getPartitionDir()
     {
@@ -2017,45 +1403,16 @@ public class AvlStore<E> extends Abstrac
     }
 
 
+    /**
+     * always returns false, cause this is a in-memory store
+     */
+    @Override
     public boolean isSyncOnWrite()
     {
         return false;
     }
 
 
-    public void setObjectClassIndex( Index<String, E, Long> index )
-    {
-        protect( "objectClassIndex" );
-
-        if ( index instanceof AvlIndex<?, ?> )
-        {
-            this.objectClassIdx = ( AvlIndex<String, E> ) index;
-        }
-        else
-        {
-            objectClassIdx = convert( index );
-        }
-
-        systemIndices.put( index.getAttributeId(), objectClassIdx );
-    }
-
-
-    public void setEntryUuidIndex( Index<String, E, Long> index )
-    {
-        protect( "entryUuidIndex" );
-        if ( index instanceof AvlIndex<?, ?> )
-        {
-            this.entryUuidIdx = ( AvlIndex<String, E> ) index;
-        }
-        else
-        {
-            entryUuidIdx = convert( index );
-        }
-
-        systemIndices.put( index.getAttributeId(), entryUuidIdx );
-    }
-
-
     /**
      * @{inhertDoc}
      */

Modified: directory/apacheds/trunk/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java?rev=938001&r1=938000&r2=938001&view=diff
==============================================================================
--- directory/apacheds/trunk/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java (original)
+++ directory/apacheds/trunk/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java Mon Apr 26 11:17:19 2010
@@ -30,10 +30,8 @@ import static org.junit.Assert.fail;
 import java.io.File;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Set;
 import java.util.UUID;
 
 import javax.naming.directory.Attributes;
@@ -47,8 +45,8 @@ import org.apache.directory.server.xdbm.
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.csn.CsnFactory;
 import org.apache.directory.shared.ldap.cursor.Cursor;
-import org.apache.directory.shared.ldap.entry.DefaultModification;
 import org.apache.directory.shared.ldap.entry.DefaultEntryAttribute;
+import org.apache.directory.shared.ldap.entry.DefaultModification;
 import org.apache.directory.shared.ldap.entry.DefaultServerEntry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Modification;
@@ -156,21 +154,21 @@ public class AvlStoreTest
         store.setSyncOnWrite( true ); // for code coverage
 
         assertNull( store.getAliasIndex() );
-        store.setAliasIndex( new AvlIndex<String, Attributes>( "alias" ) );
+        store.addIndex( new AvlIndex<String, Attributes>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ) );
         assertNotNull( store.getAliasIndex() );
 
         assertEquals( 0, store.getCacheSize() );
 
         assertNull( store.getPresenceIndex() );
-        store.setPresenceIndex( new AvlIndex<String, Attributes>( "existence" ) );
+        store.addIndex( new AvlIndex<String, Attributes>( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID ) );
         assertNotNull( store.getPresenceIndex() );
 
         assertNull( store.getOneLevelIndex() );
-        store.setOneLevelIndex( new AvlIndex<Long, Attributes>( "hierarchy" ) );
+        store.addIndex( new AvlIndex<Long, Attributes>( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID ) );
         assertNotNull( store.getOneLevelIndex() );
 
         assertNull( store.getSubLevelIndex() );
-        store.setSubLevelIndex( new AvlIndex<Long, Attributes>( "sublevel" ) );
+        store.addIndex( new AvlIndex<Long, Attributes>( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID ) );
         assertNotNull( store.getSubLevelIndex() );
 
         assertNull( store.getId() );
@@ -178,15 +176,15 @@ public class AvlStoreTest
         assertEquals( "foo", store.getId() );
 
         assertNull( store.getNdnIndex() );
-        store.setNdnIndex( new AvlIndex<String, Attributes>( "ndn" ) );
+        store.addIndex( new AvlIndex<String, Attributes>( ApacheSchemaConstants.APACHE_N_DN_AT_OID ) );
         assertNotNull( store.getNdnIndex() );
 
         assertNull( store.getOneAliasIndex() );
-        store.setOneAliasIndex( new AvlIndex<Long, Attributes>( "oneAlias" ) );
+        store.addIndex( new AvlIndex<Long, Attributes>( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID ) );
         assertNotNull( store.getNdnIndex() );
 
         assertNull( store.getSubAliasIndex() );
-        store.setSubAliasIndex( new AvlIndex<Long, Attributes>( "subAlias" ) );
+        store.addIndex( new AvlIndex<Long, Attributes>( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID ) );
         assertNotNull( store.getSubAliasIndex() );
 
         assertNull( store.getSuffixDn() );
@@ -194,16 +192,14 @@ public class AvlStoreTest
         assertEquals( "dc=example,dc=com", store.getSuffixDn().getName() );
 
         assertNull( store.getUpdnIndex() );
-        store.setUpdnIndex( new AvlIndex<String, Attributes>( "updn" ) );
+        store.addIndex( new AvlIndex<String, Attributes>( ApacheSchemaConstants.APACHE_UP_DN_AT_OID ) );
         assertNotNull( store.getUpdnIndex() );
 
         assertNotNull( store.getSuffixDn() );
 
         assertEquals( 0, store.getUserIndices().size() );
-        Set<Index<?, Attributes, Long>> set = new HashSet<Index<?, Attributes, Long>>();
-        set.add( new AvlIndex<Object, Attributes>( "foo" ) );
-        store.setUserIndices( set );
-        assertEquals( set.size(), store.getUserIndices().size() );
+        store.addIndex( new AvlIndex<Object, Attributes>( "1.2.3.4" ) );
+        assertEquals( 1, store.getUserIndices().size() );
 
         assertNull( store.getPartitionDir() );
         store.setPartitionDir( new File( "." ) );
@@ -225,7 +221,7 @@ public class AvlStoreTest
         assertNotNull( store.getAliasIndex() );
         try
         {
-            store.setAliasIndex( new AvlIndex<String, ServerEntry>( "alias" ) );
+            store.addIndex( new AvlIndex<String, ServerEntry>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ) );
             fail();
         }
         catch ( IllegalStateException e )
@@ -237,7 +233,7 @@ public class AvlStoreTest
         assertNotNull( store.getPresenceIndex() );
         try
         {
-            store.setPresenceIndex( new AvlIndex<String, ServerEntry>( "existence" ) );
+            store.addIndex( new AvlIndex<String, ServerEntry>( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID ) );
             fail();
         }
         catch ( IllegalStateException e )
@@ -247,7 +243,7 @@ public class AvlStoreTest
         assertNotNull( store.getOneLevelIndex() );
         try
         {
-            store.setOneLevelIndex( new AvlIndex<Long, ServerEntry>( "hierarchy" ) );
+            store.addIndex( new AvlIndex<Long, ServerEntry>( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID ) );
             fail();
         }
         catch ( IllegalStateException e )
@@ -257,7 +253,7 @@ public class AvlStoreTest
         assertNotNull( store.getSubLevelIndex() );
         try
         {
-            store.setSubLevelIndex( new AvlIndex<Long, ServerEntry>( "sublevel" ) );
+            store.addIndex( new AvlIndex<Long, ServerEntry>( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID ) );
             fail();
         }
         catch ( IllegalStateException e )
@@ -277,7 +273,7 @@ public class AvlStoreTest
         assertNotNull( store.getNdnIndex() );
         try
         {
-            store.setNdnIndex( new AvlIndex<String, ServerEntry>( "ndn" ) );
+            store.addIndex( new AvlIndex<String, ServerEntry>( ApacheSchemaConstants.APACHE_N_DN_AT_OID ) );
             fail();
         }
         catch ( IllegalStateException e )
@@ -287,7 +283,7 @@ public class AvlStoreTest
         assertNotNull( store.getOneAliasIndex() );
         try
         {
-            store.setOneAliasIndex( new AvlIndex<Long, ServerEntry>( "oneAlias" ) );
+            store.addIndex( new AvlIndex<Long, ServerEntry>( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID ) );
             fail();
         }
         catch ( IllegalStateException e )
@@ -297,7 +293,7 @@ public class AvlStoreTest
         assertNotNull( store.getSubAliasIndex() );
         try
         {
-            store.setSubAliasIndex( new AvlIndex<Long, ServerEntry>( "subAlias" ) );
+            store.addIndex( new AvlIndex<Long, ServerEntry>( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID ) );
             fail();
         }
         catch ( IllegalStateException e )
@@ -317,7 +313,7 @@ public class AvlStoreTest
         assertNotNull( store.getUpdnIndex() );
         try
         {
-            store.setUpdnIndex( new AvlIndex<String, ServerEntry>( "updn" ) );
+            store.addIndex( new AvlIndex<String, ServerEntry>( ApacheSchemaConstants.APACHE_UP_DN_AT_OID ) );
             fail();
         }
         catch ( IllegalStateException e )
@@ -565,7 +561,7 @@ public class AvlStoreTest
     {
         Index nonAvlIndex = new GenericIndex( "ou", 10, new File( "." ) );
 
-        Method convertIndex = store.getClass().getDeclaredMethod( "convert", Index.class );
+        Method convertIndex = store.getClass().getDeclaredMethod( "convertAndInit", Index.class );
         convertIndex.setAccessible( true );
         Object obj = convertIndex.invoke( store, nonAvlIndex );
 

Modified: directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java?rev=938001&r1=938000&r2=938001&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java Mon Apr 26 11:17:19 2010
@@ -20,19 +20,14 @@
 package org.apache.directory.server.core.partition.impl.btree.jdbm;
 
 
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.directory.server.constants.ApacheSchemaConstants;
 import org.apache.directory.server.core.partition.Partition;
-import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.server.xdbm.AbstractXdbmPartition;
+import org.apache.directory.server.xdbm.Index;
 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.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.ServerEntry;
 
 
@@ -57,7 +52,6 @@ public class JdbmPartition extends Abstr
     }
 
 
-    @SuppressWarnings("unchecked")
     protected void doInit() throws Exception
     {
         store.setPartitionDir( getPartitionDir() );
@@ -86,79 +80,14 @@ public class JdbmPartition extends Abstr
         store.setSuffixDn( suffixDn );
         store.setPartitionDir( getPartitionDir() );
 
-        Set<Index<?, ServerEntry, Long>> userIndices = new HashSet<Index<?, ServerEntry, Long>>();
-
-        for ( Index<?, ServerEntry, Long> obj : getIndexedAttributes() )
+        for ( Index<?, ServerEntry, Long> index : getIndexedAttributes() )
         {
-            Index<?, ServerEntry, Long> index;
-
-            if ( obj instanceof JdbmIndex<?, ?> )
-            {
-                index = ( JdbmIndex<?, ServerEntry> ) obj;
-            }
-            else
-            {
-                index = new JdbmIndex<Object, ServerEntry>();
-                index.setAttributeId( obj.getAttributeId() );
-                index.setCacheSize( obj.getCacheSize() );
-                index.setWkDirPath( obj.getWkDirPath() );
-            }
-
             String oid = schemaManager.getAttributeTypeRegistry().getOidByName( index.getAttributeId() );
-
-            if ( SYS_INDEX_OIDS.contains( oid ) )
+            if ( !index.getAttributeId().equals( oid ) )
             {
-                if ( oid.equals( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ) )
-                {
-                    store.setAliasIndex( ( Index<String, ServerEntry, Long> ) index );
-                }
-                else if ( oid.equals( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID ) )
-                {
-                    store.setPresenceIndex( ( Index<String, ServerEntry, Long> ) index );
-                }
-                else if ( oid.equals( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID ) )
-                {
-                    store.setOneLevelIndex( ( Index<Long, ServerEntry, Long> ) index );
-                }
-                else if ( oid.equals( ApacheSchemaConstants.APACHE_N_DN_AT_OID ) )
-                {
-                    store.setNdnIndex( ( Index<String, ServerEntry, Long> ) index );
-                }
-                else if ( oid.equals( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID ) )
-                {
-                    store.setOneAliasIndex( ( Index<Long, ServerEntry, Long> ) index );
-                }
-                else if ( oid.equals( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID ) )
-                {
-                    store.setSubAliasIndex( ( Index<Long, ServerEntry, Long> ) index );
-                }
-                else if ( oid.equals( ApacheSchemaConstants.APACHE_UP_DN_AT_OID ) )
-                {
-                    store.setUpdnIndex( ( Index<String, ServerEntry, Long> ) index );
-                }
-                else if ( oid.equals( SchemaConstants.OBJECT_CLASS_AT_OID ) )
-                {
-                    store.setObjectClassIndex( ( Index<String, ServerEntry, Long> ) index );
-                }
-                else if ( oid.equals( SchemaConstants.ENTRY_CSN_AT_OID ) )
-                {
-                    store.setEntryCsnIndex( ( Index<String, ServerEntry, Long> ) index );
-                }
-                else if ( oid.equals( SchemaConstants.ENTRY_UUID_AT_OID ) )
-                {
-                    store.setEntryUuidIndex( ( Index<String, ServerEntry, Long> ) index );
-                }
-                else
-                {
-                    throw new IllegalStateException( "Unrecognized system index " + oid );
-                }
+                index.setAttributeId( oid );
             }
-            else
-            {
-                userIndices.add( index );
-            }
-
-            store.setUserIndices( userIndices );
+            store.addIndex( index );
         }
 
         store.init( schemaManager );

Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?rev=938001&r1=938000&r2=938001&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java (original)
+++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java Mon Apr 26 11:17:19 2010
@@ -22,12 +22,7 @@ package org.apache.directory.server.core
 
 import java.io.File;
 import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
 import jdbm.RecordManager;
 import jdbm.helper.MRU;
@@ -41,7 +36,6 @@ import org.apache.directory.server.xdbm.
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.xdbm.IndexEntry;
-import org.apache.directory.server.xdbm.IndexNotFoundException;
 import org.apache.directory.shared.ldap.MultiException;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.cursor.Cursor;
@@ -60,7 +54,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.name.RDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
-import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.SchemaManager;
 import org.apache.directory.shared.ldap.util.NamespaceTools;
 import org.slf4j.Logger;
@@ -78,41 +71,8 @@ public class JdbmStore<E> extends Abstra
     /** the master table storing entries by primary key */
     private JdbmMasterTable<ServerEntry> master;
 
-    /** a map of attributeType numeric ID to user userIndices */
-    private Map<String, Index<?, E, Long>> userIndices = new HashMap<String, Index<?, E, Long>>();
-
-    /** a map of attributeType numeric ID to system userIndices */
-    private Map<String, Index<?, E, Long>> systemIndices = new HashMap<String, Index<?, E, Long>>();
-
     /** the relative distinguished name index */
     private JdbmRdnIndex<RDN, Long> rdnIdx;
-    
-    /** the attribute presence index */
-    private JdbmIndex<String, E> presenceIdx;
-
-    /** a system index on aliasedObjectName attribute */
-    private JdbmIndex<String, E> aliasIdx;
-
-    /** a system index on the entries of descendants of root DN*/
-    private JdbmIndex<Long, E> subLevelIdx;
-
-    /** the parent child relationship index */
-    private JdbmIndex<Long, E> oneLevelIdx;
-
-    /** the one level scope alias index */
-    private JdbmIndex<Long, E> oneAliasIdx;
-
-    /** the subtree scope alias index */
-    private JdbmIndex<Long, E> subAliasIdx;
-
-    /** a system index on objectClass attribute*/
-    private JdbmIndex<String, E> objectClassIdx;
-
-    /** a system index on entryCSN attribute */
-    private JdbmIndex<String, E> entryCsnIdx;
-
-    /** a system index on entryUUID attribute */
-    private JdbmIndex<String, E> entryUuidIdx;
 
     /** Static declarations to avoid lookup all over the code */
     private static AttributeType OBJECT_CLASS_AT;
@@ -121,6 +81,8 @@ public class JdbmStore<E> extends Abstra
     private static AttributeType ALIASED_OBJECT_NAME_AT;
 
     private DN contextEntryDn;
+
+
     // ------------------------------------------------------------------------
     // C O N S T R U C T O R S
     // ------------------------------------------------------------------------
@@ -183,7 +145,6 @@ public class JdbmStore<E> extends Abstra
         // -------------------------------------------------------------------
         // Initializes the user and system indices
         // -------------------------------------------------------------------
-
         setupSystemIndices();
         setupUserIndices();
 
@@ -193,154 +154,16 @@ public class JdbmStore<E> extends Abstra
 
 
     @SuppressWarnings("unchecked")
-    private void setupSystemIndices() throws Exception
+    protected void setupSystemIndices() throws Exception
     {
-        if ( systemIndices.size() > 0 )
-        {
-            HashMap<String, Index<?, E, Long>> tmp = new HashMap<String, Index<?, E, Long>>();
-
-            for ( Index<?, E, Long> index : systemIndices.values() )
-            {
-                String oid = schemaManager.getAttributeTypeRegistry().getOidByName( index.getAttributeId() );
-                tmp.put( oid, index );
-                ( ( JdbmIndex ) index ).init( schemaManager, schemaManager.lookupAttributeTypeRegistry( oid ),
-                    partitionDir );
-            }
-            systemIndices = tmp;
-        }
-
         if ( rdnIdx == null )
         {
             rdnIdx = new JdbmRdnIndex<RDN, Long>();
             rdnIdx.setAttributeId( ApacheSchemaConstants.APACHE_RDN_AT_OID );
             systemIndices.put( ApacheSchemaConstants.APACHE_RDN_AT_OID, ( JdbmIndex ) rdnIdx );
-            rdnIdx.init( schemaManager, schemaManager
-                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_RDN_AT_OID ), partitionDir );
-        }
-        
-        if ( presenceIdx == null )
-        {
-            presenceIdx = new JdbmIndex<String, E>();
-            presenceIdx.setAttributeId( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID );
-            systemIndices.put( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID, presenceIdx );
-            presenceIdx.init( schemaManager, schemaManager
-                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID ), partitionDir );
-        }
-
-        if ( oneLevelIdx == null )
-        {
-            oneLevelIdx = new JdbmIndex<Long, E>();
-            oneLevelIdx.setAttributeId( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID );
-            systemIndices.put( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID, oneLevelIdx );
-            oneLevelIdx.init( schemaManager, schemaManager
-                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID ), partitionDir );
-        }
-
-        if ( oneAliasIdx == null )
-        {
-            oneAliasIdx = new JdbmIndex<Long, E>();
-            oneAliasIdx.setAttributeId( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID );
-            systemIndices.put( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID, oneAliasIdx );
-            oneAliasIdx.init( schemaManager, schemaManager
-                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID ), partitionDir );
-        }
-
-        if ( subAliasIdx == null )
-        {
-            subAliasIdx = new JdbmIndex<Long, E>();
-            subAliasIdx.setAttributeId( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID );
-            systemIndices.put( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID, subAliasIdx );
-            subAliasIdx.init( schemaManager, schemaManager
-                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID ), partitionDir );
-        }
-
-        if ( aliasIdx == null )
-        {
-            aliasIdx = new JdbmIndex<String, E>();
-            aliasIdx.setAttributeId( ApacheSchemaConstants.APACHE_ALIAS_AT_OID );
-            systemIndices.put( ApacheSchemaConstants.APACHE_ALIAS_AT_OID, aliasIdx );
-            aliasIdx.init( schemaManager, schemaManager
-                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ), partitionDir );
-        }
-
-        if ( subLevelIdx == null )
-        {
-            subLevelIdx = new JdbmIndex<Long, E>();
-            subLevelIdx.setAttributeId( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID );
-            systemIndices.put( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID, subLevelIdx );
-            subLevelIdx.init( schemaManager, schemaManager
-                .lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID ), partitionDir );
-        }
-
-        if ( entryCsnIdx == null )
-        {
-            entryCsnIdx = new JdbmIndex<String, E>();
-            entryCsnIdx.setAttributeId( SchemaConstants.ENTRY_CSN_AT_OID );
-            systemIndices.put( SchemaConstants.ENTRY_CSN_AT_OID, entryCsnIdx );
-            entryCsnIdx.init( schemaManager, schemaManager
-                .lookupAttributeTypeRegistry( SchemaConstants.ENTRY_CSN_AT_OID ), partitionDir );
         }
 
-        if ( entryUuidIdx == null )
-        {
-            entryUuidIdx = new JdbmIndex<String, E>();
-            entryUuidIdx.setAttributeId( SchemaConstants.ENTRY_UUID_AT_OID );
-            systemIndices.put( SchemaConstants.ENTRY_UUID_AT_OID, entryUuidIdx );
-            entryUuidIdx.init( schemaManager, schemaManager
-                .lookupAttributeTypeRegistry( SchemaConstants.ENTRY_UUID_AT_OID ), partitionDir );
-        }
-
-        if ( objectClassIdx == null )
-        {
-            objectClassIdx = new JdbmIndex<String, E>();
-            objectClassIdx.setAttributeId( SchemaConstants.OBJECT_CLASS_AT_OID );
-            systemIndices.put( SchemaConstants.OBJECT_CLASS_AT_OID, objectClassIdx );
-            objectClassIdx.init( schemaManager, schemaManager
-                .lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT_OID ), partitionDir );
-        }
-    }
-
-
-    @SuppressWarnings("unchecked")
-    private void setupUserIndices() throws Exception
-    {
-        if ( ( userIndices != null ) && ( userIndices.size() > 0 ) )
-        {
-            Map<String, Index<?, E, Long>> tmp = new HashMap<String, Index<?, E, Long>>();
-
-            for ( Index<?, E, Long> index : userIndices.values() )
-            {
-                String oid = schemaManager.getAttributeTypeRegistry().getOidByName( index.getAttributeId() );
-
-                if ( systemIndices.containsKey( oid ) )
-                {
-                    // Bypass some specific index for AttributeTypes like ObjectClass hich are already
-                    // present in the SystemIndices
-                    continue;
-                }
-                AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( oid );
-
-                // Check that the attributeType has an EQUALITY matchingRule
-                MatchingRule mr = attributeType.getEquality();
-
-                if ( mr != null )
-                {
-                    ( ( JdbmIndex ) index ).init( schemaManager, schemaManager.lookupAttributeTypeRegistry( oid ),
-                        partitionDir );
-                    tmp.put( oid, index );
-                }
-                else
-                {
-                    LOG.error( I18n.err( I18n.ERR_4, attributeType.getName() ) );
-                }
-            }
-
-            userIndices = tmp;
-        }
-        else
-        {
-            userIndices = new HashMap<String, Index<?, E, Long>>();
-        }
+        super.setupSystemIndices();
     }
 
 
@@ -433,7 +256,7 @@ public class JdbmStore<E> extends Abstra
         array.add( entryCsnIdx );
         array.add( entryUuidIdx );
         array.add( objectClassIdx );
-        
+
         // Sync all user defined userIndices
         for ( Index<?, E, Long> idx : array )
         {
@@ -441,7 +264,7 @@ public class JdbmStore<E> extends Abstra
         }
 
         rdnIdx.sync();
-        
+
         master.sync();
         recMan.commit();
     }
@@ -451,145 +274,27 @@ public class JdbmStore<E> extends Abstra
     // I N D E X   M E T H O D S
     // ------------------------------------------------------------------------
 
-    private <K> JdbmIndex<K, E> convertIndex( Index<K, E, Long> index )
+    protected Index<?, E, Long> convertAndInit( Index<?, E, Long> index ) throws Exception
     {
+        JdbmIndex<?, E> jdbmIndex;
         if ( index instanceof JdbmIndex<?, ?> )
         {
-            return ( JdbmIndex<K, E> ) index;
+            jdbmIndex = ( JdbmIndex<?, E> ) index;
         }
-
-        LOG.warn( "Supplied index {} is not a JdbmIndex.  "
-            + "Will create new JdbmIndex using copied configuration parameters.", index );
-        JdbmIndex<K, E> jdbmIndex = new JdbmIndex<K, E>( index.getAttributeId() );
-        jdbmIndex.setCacheSize( index.getCacheSize() );
-        jdbmIndex.setNumDupLimit( JdbmIndex.DEFAULT_DUPLICATE_LIMIT );
-        jdbmIndex.setWkDirPath( index.getWkDirPath() );
-        return jdbmIndex;
-    }
-
-
-    public void setUserIndices( Set<Index<?, E, Long>> userIndices )
-    {
-        protect( "userIndices" );
-        for ( Index<?, E, Long> index : userIndices )
+        else
         {
-            this.userIndices.put( index.getAttributeId(), convertIndex( index ) );
+            LOG.warn( "Supplied index {} is not a JdbmIndex.  "
+                + "Will create new JdbmIndex using copied configuration parameters.", index );
+            jdbmIndex = new JdbmIndex( index.getAttributeId() );
+            jdbmIndex.setCacheSize( index.getCacheSize() );
+            jdbmIndex.setNumDupLimit( JdbmIndex.DEFAULT_DUPLICATE_LIMIT );
+            jdbmIndex.setWkDirPath( index.getWkDirPath() );
         }
-    }
 
+        jdbmIndex.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( index.getAttributeId() ),
+            partitionDir );
 
-    public Set<Index<?, E, Long>> getUserIndices()
-    {
-        return new HashSet<Index<?, E, Long>>( userIndices.values() );
-    }
-
-
-    public void addIndex( Index<?, E, Long> index ) throws Exception
-    {
-        userIndices.put( index.getAttributeId(), convertIndex( index ) );
-    }
-
-
-    //------------------------------------------------------------------------
-    // System index
-    //------------------------------------------------------------------------
-    /**
-     * {@inheritDoc}
-     */
-    public Index<String, E, Long> getPresenceIndex()
-    {
-        return presenceIdx;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setPresenceIndex( Index<String, E, Long> index ) throws Exception
-    {
-        protect( "presenceIndex" );
-        presenceIdx = convertIndex( index );
-        systemIndices.put( index.getAttributeId(), presenceIdx );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Index<Long, E, Long> getOneLevelIndex()
-    {
-        return oneLevelIdx;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setOneLevelIndex( Index<Long, E, Long> index ) throws Exception
-    {
-        protect( "hierarchyIndex" );
-        oneLevelIdx = convertIndex( index );
-        systemIndices.put( index.getAttributeId(), oneLevelIdx );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Index<String, E, Long> getAliasIndex()
-    {
-        return aliasIdx;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setAliasIndex( Index<String, E, Long> index ) throws LdapException
-    {
-        protect( "aliasIndex" );
-        aliasIdx = convertIndex( index );
-        systemIndices.put( index.getAttributeId(), aliasIdx );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Index<Long, E, Long> getOneAliasIndex()
-    {
-        return oneAliasIdx;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setOneAliasIndex( Index<Long, E, Long> index ) throws LdapException
-    {
-        protect( "oneAliasIndex" );
-        oneAliasIdx = convertIndex( index );
-        systemIndices.put( index.getAttributeId(), oneAliasIdx );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Index<Long, E, Long> getSubAliasIndex()
-    {
-        return subAliasIdx;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setSubAliasIndex( Index<Long, E, Long> index ) throws LdapException
-    {
-        protect( "subAliasIndex" );
-        subAliasIdx = convertIndex( index );
-        systemIndices.put( index.getAttributeId(), subAliasIdx );
+        return jdbmIndex;
     }
 
 
@@ -600,15 +305,7 @@ public class JdbmStore<E> extends Abstra
     {
         // FIXME this method shouldn't be supported anymore after the
         // introduction of the RDN index, but keeping to minimise the number changes done to interface
-        return entryUuidIdx;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setUpdnIndex( Index<String, E, Long> index ) throws LdapException
-    {
+        return getEntryUuidIndex();
     }
 
 
@@ -618,195 +315,7 @@ public class JdbmStore<E> extends Abstra
     public Index<String, E, Long> getNdnIndex()
     {
         // FIXME should this be entryUuidIdx?
-        return entryCsnIdx;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setNdnIndex( Index<String, E, Long> index ) throws LdapException
-    {
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Index<Long, E, Long> getSubLevelIndex()
-    {
-        return subLevelIdx;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setSubLevelIndex( Index<Long, E, Long> index ) throws LdapException
-    {
-        protect( "subLevelIndex" );
-        subLevelIdx = convertIndex( index );
-        systemIndices.put( index.getAttributeId(), subLevelIdx );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Index<String, E, Long> getObjectClassIndex()
-    {
-        return objectClassIdx;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setObjectClassIndex( Index<String, E, Long> index ) throws LdapException
-    {
-        protect( "objectClassIndex" );
-        objectClassIdx = convertIndex( index );
-        systemIndices.put( index.getAttributeId(), objectClassIdx );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Index<String, E, Long> getEntryUuidIndex()
-    {
-        return entryUuidIdx;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setEntryUuidIndex( Index<String, E, Long> index ) throws LdapException
-    {
-        protect( "entryUuidIndex" );
-        entryUuidIdx = convertIndex( index );
-        systemIndices.put( index.getAttributeId(), entryUuidIdx );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public Index<String, E, Long> getEntryCsnIndex()
-    {
-        return entryCsnIdx;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public void setEntryCsnIndex( Index<String, E, Long> index ) throws LdapException
-    {
-        protect( "entryCsnIndex" );
-        entryCsnIdx = convertIndex( index );
-        systemIndices.put( index.getAttributeId(), entryCsnIdx );
-    }
-
-
-    public Iterator<String> userIndices()
-    {
-        return userIndices.keySet().iterator();
-    }
-
-
-    public Iterator<String> systemIndices()
-    {
-        return systemIndices.keySet().iterator();
-    }
-
-
-    public boolean hasIndexOn( String id ) throws LdapException
-    {
-        return hasUserIndexOn( id ) || hasSystemIndexOn( id );
-    }
-
-
-    public boolean hasUserIndexOn( String id ) throws LdapException
-    {
-        return userIndices.containsKey( schemaManager.getAttributeTypeRegistry().getOidByName( id ) );
-    }
-
-
-    public boolean hasSystemIndexOn( String id ) throws LdapException
-    {
-        return systemIndices.containsKey( schemaManager.getAttributeTypeRegistry().getOidByName( id ) );
-    }
-
-
-    public Index<?, E, Long> getIndex( String id ) throws IndexNotFoundException
-    {
-        try
-        {
-            id = schemaManager.getAttributeTypeRegistry().getOidByName( id );
-        }
-        catch ( LdapException e )
-        {
-            String msg = I18n.err( I18n.ERR_128, id );
-            LOG.error( msg, e );
-            throw new IndexNotFoundException( msg, id, e );
-        }
-
-        if ( userIndices.containsKey( id ) )
-        {
-            return userIndices.get( id );
-        }
-        if ( systemIndices.containsKey( id ) )
-        {
-            return systemIndices.get( id );
-        }
-
-        throw new IndexNotFoundException( I18n.err( I18n.ERR_3, id, id ) );
-    }
-
-
-    public Index<?, E, Long> getUserIndex( String id ) throws IndexNotFoundException
-    {
-        try
-        {
-            id = schemaManager.getAttributeTypeRegistry().getOidByName( id );
-        }
-        catch ( LdapException e )
-        {
-            String msg = I18n.err( I18n.ERR_128, id );
-            LOG.error( msg, e );
-            throw new IndexNotFoundException( msg, id, e );
-        }
-
-        if ( userIndices.containsKey( id ) )
-        {
-            return userIndices.get( id );
-        }
-
-        throw new IndexNotFoundException( I18n.err( I18n.ERR_3, id, id ) );
-    }
-
-
-    public Index<?, E, Long> getSystemIndex( String id ) throws IndexNotFoundException
-    {
-        try
-        {
-            id = schemaManager.getAttributeTypeRegistry().getOidByName( id );
-        }
-        catch ( LdapException e )
-        {
-            String msg = I18n.err( I18n.ERR_128, id );
-            LOG.error( msg, e );
-            throw new IndexNotFoundException( msg, id, e );
-        }
-
-        if ( systemIndices.containsKey( id ) )
-        {
-            return systemIndices.get( id );
-        }
-
-        throw new IndexNotFoundException( I18n.err( I18n.ERR_2, id, id ) );
+        return getEntryCsnIndex();
     }
 
 
@@ -815,34 +324,34 @@ public class JdbmStore<E> extends Abstra
      */
     public Long getEntryId( DN dn ) throws Exception
     {
-        if( !dn.isNormalized() )
+        if ( !dn.isNormalized() )
         {
             dn.normalize( schemaManager.getNormalizerMapping() );
         }
-        
+
         int dnSize = dn.size();
-        int i = suffixDn.size(); 
+        int i = suffixDn.size();
 
         RDN key = new RDN( suffixDn.getNormName() );
         key._setParentId( 0 );
-        
+
         Long curEntryId = rdnIdx.forwardLookup( key );
-        
-        for( ; i < dnSize; i++ )
+
+        for ( ; i < dnSize; i++ )
         {
             key = dn.getRdn( i );
             key._setParentId( curEntryId );
             curEntryId = rdnIdx.forwardLookup( key );
-            if( curEntryId == null )
+            if ( curEntryId == null )
             {
                 break;
             }
         }
-        
+
         return curEntryId;
     }
-    
-    
+
+
     /**
      * gives the normalized name of the DN of the entry identified by the given id
      * @param id the entry's id 
@@ -910,26 +419,26 @@ public class JdbmStore<E> extends Abstra
     {
         DN normDN = new DN( dn );
         normDN.normalize( schemaManager.getNormalizerMapping() );
-        
+
         int dnSize = normDN.size();
-        int i = suffixDn.size(); 
+        int i = suffixDn.size();
 
         RDN key = new RDN( suffixDn.getNormName() );
         key._setParentId( 0 );
 
         Long curEntryId = rdnIdx.forwardLookup( key );
-        
-        for( ; i < dnSize; i++ )
+
+        for ( ; i < dnSize; i++ )
         {
             key = normDN.getRdn( i );
             key._setParentId( curEntryId );
             curEntryId = rdnIdx.forwardLookup( key );
         }
-        
+
         return normDN;
     }
-    
-    
+
+
     /**
      * Gets the Long id of an entry's parent using the child entry's
      * normalized DN. Note that the suffix entry returns 0, which does not
@@ -944,12 +453,12 @@ public class JdbmStore<E> extends Abstra
     {
         DN normDN = new DN( dn );
         normDN.normalize( schemaManager.getNormalizerMapping() );
-        
-        if( suffixDn.equals( normDN ) )
+
+        if ( suffixDn.equals( normDN ) )
         {
             return 0L;
         }
-        
+
         normDN = buildEntryDn( dn );
         return normDN.getRdn()._getParentId();
     }
@@ -959,11 +468,11 @@ public class JdbmStore<E> extends Abstra
     {
         //return oneLevelIdx.reverseLookup( childId );
         RDN rdn = rdnIdx.reverseLookup( childId );
-        if( rdn == null )
+        if ( rdn == null )
         {
             return null;
         }
-        
+
         return rdn._getParentId();
     }
 
@@ -1257,7 +766,6 @@ public class JdbmStore<E> extends Abstra
             throw new IllegalStateException( I18n.err( I18n.ERR_218, entryDn.getNormName() ) );
         }
 
-        
         oneLevelIdx.add( parentId, id );
 
         // Update the EntryCsn index
@@ -1327,12 +835,12 @@ public class JdbmStore<E> extends Abstra
     public ServerEntry lookup( Long id ) throws Exception
     {
         ServerEntry se = ( ServerEntry ) master.get( id );
-        
-        if( se == null )
+
+        if ( se == null )
         {
             return null;
         }
-        
+
         se.setDn( buildEntryDn( id ) );
         return se;
     }
@@ -1883,7 +1391,7 @@ public class JdbmStore<E> extends Abstra
         // restore the parentId from the old RDN
         newRdn = newUpdn.getRdn();
         newRdn._setParentId( updn.getRdn()._getParentId() );
-        
+
         modifyDn( id, newUpdn, false ); // propagate dn changes
 
         // Update the current entry
@@ -1918,15 +1426,15 @@ public class JdbmStore<E> extends Abstra
     private void modifyDn( Long id, DN updn, boolean isMove ) throws Exception
     {
         String aliasTarget;
-        
+
         //updated the RDN index
         rdnIdx.drop( id );
-        if( !updn.isNormalized() )
+        if ( !updn.isNormalized() )
         {
             // just normalize the RDN alone
             updn.getRdn().normalize( schemaManager.getNormalizerMapping() );
         }
-        
+
         rdnIdx.add( updn.getRdn(), id );
 
         /* 
@@ -2030,12 +1538,12 @@ public class JdbmStore<E> extends Abstra
          * user provided RDN & the new parent's UPDN.  Basically add the child's
          * UpRdn String to the tail of the new parent's Updn Name.
          */
-        
+
         DN childUpdn = buildEntryDn( childId );
         RDN childRdn = childUpdn.getRdn( childUpdn.size() - 1 );
         childRdn._setParentId( newParentId );
         DN newUpdn = buildEntryDn( newParentId );
-        
+
         newUpdn.add( childRdn );
 
         // Call the modifyDn operation with the new updn

Modified: directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=938001&r1=938000&r2=938001&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java (original)
+++ directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java Mon Apr 26 11:17:19 2010
@@ -30,10 +30,8 @@ import static org.junit.Assert.fail;
 import java.io.File;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Set;
 import java.util.UUID;
 
 import javax.naming.directory.Attributes;
@@ -48,8 +46,8 @@ import org.apache.directory.server.xdbm.
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.csn.CsnFactory;
 import org.apache.directory.shared.ldap.cursor.Cursor;
-import org.apache.directory.shared.ldap.entry.DefaultModification;
 import org.apache.directory.shared.ldap.entry.DefaultEntryAttribute;
+import org.apache.directory.shared.ldap.entry.DefaultModification;
 import org.apache.directory.shared.ldap.entry.DefaultServerEntry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Modification;
@@ -214,7 +212,7 @@ public class JdbmStoreTest
         store.setSyncOnWrite( true ); // for code coverage
 
         assertNull( store.getAliasIndex() );
-        store.setAliasIndex( new JdbmIndex<String, Attributes>( "alias" ) );
+        store.addIndex( new JdbmIndex<String, Attributes>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ) );
         assertNotNull( store.getAliasIndex() );
 
         assertEquals( JdbmStore.DEFAULT_CACHE_SIZE, store.getCacheSize() );
@@ -222,15 +220,15 @@ public class JdbmStoreTest
         assertEquals( 24, store.getCacheSize() );
 
         assertNull( store.getPresenceIndex() );
-        store.setPresenceIndex( new JdbmIndex<String, Attributes>( "existence" ) );
+        store.addIndex( new JdbmIndex<String, Attributes>( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID ) );
         assertNotNull( store.getPresenceIndex() );
 
         assertNull( store.getOneLevelIndex() );
-        store.setOneLevelIndex( new JdbmIndex<Long, Attributes>( "hierarchy" ) );
+        store.addIndex( new JdbmIndex<Long, Attributes>( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID ) );
         assertNotNull( store.getOneLevelIndex() );
 
         assertNull( store.getSubLevelIndex() );
-        store.setSubLevelIndex( new JdbmIndex<Long, Attributes>( "sublevel" ) );
+        store.addIndex( new JdbmIndex<Long, Attributes>( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID ) );
         assertNotNull( store.getSubLevelIndex() );
 
         assertNull( store.getId() );
@@ -242,11 +240,11 @@ public class JdbmStoreTest
 //        assertNotNull( store.getNdnIndex() );
 
         assertNull( store.getOneAliasIndex() );
-        store.setOneAliasIndex( new JdbmIndex<Long, Attributes>( "oneAlias" ) );
+        store.addIndex( new JdbmIndex<Long, Attributes>( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID ) );
         assertNotNull( store.getOneAliasIndex() );
 
         assertNull( store.getSubAliasIndex() );
-        store.setSubAliasIndex( new JdbmIndex<Long, Attributes>( "subAlias" ) );
+        store.addIndex( new JdbmIndex<Long, Attributes>( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID ) );
         assertNotNull( store.getSubAliasIndex() );
 
         assertNull( store.getSuffixDn() );
@@ -256,10 +254,8 @@ public class JdbmStoreTest
         assertNotNull( store.getSuffixDn() );
 
         assertEquals( 0, store.getUserIndices().size() );
-        Set<Index<?, Attributes, Long>> set = new HashSet<Index<?, Attributes, Long>>();
-        set.add( new JdbmIndex<Object, Attributes>( "foo" ) );
-        store.setUserIndices( set );
-        assertEquals( set.size(), store.getUserIndices().size() );
+        store.addIndex( new JdbmIndex<Object, Attributes>( "1.2.3.4" ) );
+        assertEquals( 1, store.getUserIndices().size() );
 
         assertNull( store.getPartitionDir() );
         store.setPartitionDir( new File( "." ) );
@@ -281,7 +277,7 @@ public class JdbmStoreTest
         assertNotNull( store.getAliasIndex() );
         try
         {
-            store.setAliasIndex( new JdbmIndex<String, ServerEntry>( "alias" ) );
+            store.addIndex( new JdbmIndex<String, ServerEntry>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ) );
             fail();
         }
         catch ( IllegalStateException e )
@@ -300,7 +296,7 @@ public class JdbmStoreTest
         assertNotNull( store.getPresenceIndex() );
         try
         {
-            store.setPresenceIndex( new JdbmIndex<String, ServerEntry>( "existence" ) );
+            store.addIndex( new JdbmIndex<String, ServerEntry>( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID ) );
             fail();
         }
         catch ( IllegalStateException e )
@@ -310,7 +306,7 @@ public class JdbmStoreTest
         assertNotNull( store.getOneLevelIndex() );
         try
         {
-            store.setOneLevelIndex( new JdbmIndex<Long, ServerEntry>( "hierarchy" ) );
+            store.addIndex( new JdbmIndex<Long, ServerEntry>( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID ) );
             fail();
         }
         catch ( IllegalStateException e )
@@ -320,7 +316,7 @@ public class JdbmStoreTest
         assertNotNull( store.getSubLevelIndex() );
         try
         {
-            store.setSubLevelIndex( new JdbmIndex<Long, ServerEntry>( "sublevel" ) );
+            store.addIndex( new JdbmIndex<Long, ServerEntry>( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID ) );
             fail();
         }
         catch ( IllegalStateException e )
@@ -342,7 +338,7 @@ public class JdbmStoreTest
         assertNotNull( store.getOneAliasIndex() );
         try
         {
-            store.setOneAliasIndex( new JdbmIndex<Long, ServerEntry>( "oneAlias" ) );
+            store.addIndex( new JdbmIndex<Long, ServerEntry>( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID ) );
             fail();
         }
         catch ( IllegalStateException e )
@@ -352,7 +348,7 @@ public class JdbmStoreTest
         assertNotNull( store.getSubAliasIndex() );
         try
         {
-            store.setSubAliasIndex( new JdbmIndex<Long, ServerEntry>( "subAlias" ) );
+            store.addIndex( new JdbmIndex<Long, ServerEntry>( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID ) );
             fail();
         }
         catch ( IllegalStateException e )
@@ -369,9 +365,10 @@ public class JdbmStoreTest
         {
         }
 
+        
         Iterator<String> systemIndices = store.systemIndices();
 
-        for ( int ii = 0; ii < 10; ii++ )
+        for ( int ii = 0; ii < 12; ii++ )
         {
             assertTrue( systemIndices.hasNext() );
             assertNotNull( systemIndices.next() );
@@ -619,7 +616,7 @@ public class JdbmStoreTest
     {
         Index nonJdbmIndex = new GenericIndex( "ou", 10, new File( "." ) );
 
-        Method convertIndex = store.getClass().getDeclaredMethod( "convertIndex", Index.class );
+        Method convertIndex = store.getClass().getDeclaredMethod( "convertAndInit", Index.class );
         convertIndex.setAccessible( true );
         Object obj = convertIndex.invoke( store, nonJdbmIndex );
 

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=938001&r1=938000&r2=938001&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 Mon Apr 26 11:17:19 2010
@@ -961,41 +961,6 @@ public class LdifPartition extends BTree
 
 
     @Override
-    public void setAliasIndexOn( Index<String, ServerEntry, Long> index ) throws Exception
-    {
-        wrappedPartition.setAliasIndexOn( index );
-    }
-
-
-    @Override
-    public void setNdnIndexOn( Index<String, ServerEntry, Long> index ) throws Exception
-    {
-        wrappedPartition.setNdnIndexOn( index );
-    }
-
-
-    @Override
-    public void setOneAliasIndexOn( Index<Long, ServerEntry, Long> index ) throws Exception
-    {
-        wrappedPartition.setOneAliasIndexOn( index );
-    }
-
-
-    @Override
-    public void setOneLevelIndexOn( Index<Long, ServerEntry, Long> index ) throws Exception
-    {
-        wrappedPartition.setOneLevelIndexOn( index );
-    }
-
-
-    @Override
-    public void setPresenceIndexOn( Index<String, ServerEntry, Long> index ) throws Exception
-    {
-        wrappedPartition.setPresenceIndexOn( index );
-    }
-
-
-    @Override
     public void setProperty( String propertyName, String propertyValue ) throws Exception
     {
         wrappedPartition.setProperty( propertyName, propertyValue );
@@ -1010,20 +975,6 @@ public class LdifPartition extends BTree
 
 
     @Override
-    public void setSubAliasIndexOn( Index<Long, ServerEntry, Long> index ) throws Exception
-    {
-        wrappedPartition.setSubAliasIndexOn( index );
-    }
-
-
-    @Override
-    public void setUpdnIndexOn( Index<String, ServerEntry, Long> index ) throws Exception
-    {
-        wrappedPartition.setUpdnIndexOn( index );
-    }
-
-
-    @Override
     public void sync() throws Exception
     {
         wrappedPartition.sync();

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=938001&r1=938000&r2=938001&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 Mon Apr 26 11:17:19 2010
@@ -44,6 +44,7 @@ import org.apache.directory.server.core.
 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.normalization.FilterNormalizingVisitor;
 import org.apache.directory.server.core.partition.ldif.LdifPartition;
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
@@ -56,12 +57,14 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.filter.FilterParser;
 import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.name.DN;
+import org.apache.directory.shared.ldap.name.NameComponentNormalizer;
 import org.apache.directory.shared.ldap.name.RDN;
 import org.apache.directory.shared.ldap.schema.SchemaManager;
 import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schema.loader.ldif.LdifSchemaLoader;
 import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.ldap.schema.normalizers.ConcreteNameComponentNormalizer;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.junit.After;
 import org.junit.Before;
@@ -396,6 +399,9 @@ public class LdifPartitionTest
         dn.normalize( schemaManager.getNormalizerMapping() );
         searchCtx.setDn( dn );
         ExprNode filter = FilterParser.parse( "(ObjectClass=domain)" );
+        NameComponentNormalizer ncn = new ConcreteNameComponentNormalizer( schemaManager );
+        FilterNormalizingVisitor visitor = new FilterNormalizingVisitor( ncn, schemaManager );
+        filter.accept( visitor );
         searchCtx.setFilter( filter );
         searchCtx.setScope( SearchScope.SUBTREE );