directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1460779 - in /directory/apacheds/trunk: jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ service-builder/src/m...
Date Mon, 25 Mar 2013 17:48:37 GMT
Author: elecharny
Date: Mon Mar 25 17:48:36 2013
New Revision: 1460779

URL: http://svn.apache.org/r1460779
Log:
o The Alias index now contains DN instead of a String
o Added a DnSerializer and comparator to manage the Alias index
o Unconditionally replace the Entry's DN when we pull the entry from the Master table (it
was containing the RDN before)
o Exposed the SchemaManager in the EvaluatorBuilder class


Added:
    directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DnSerializer.java
    directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DnSerializerComparator.java
    directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDnIndex.java
Modified:
    directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java
    directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
    directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/builder/ServiceBuilder.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java
    directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java

Added: directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DnSerializer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DnSerializer.java?rev=1460779&view=auto
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DnSerializer.java
(added)
+++ directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DnSerializer.java
Mon Mar 25 17:48:36 2013
@@ -0,0 +1,127 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.core.partition.impl.btree.jdbm;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+
+import jdbm.helper.Serializer;
+
+import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.ldap.model.schema.SchemaManager;
+import org.apache.directory.server.i18n.I18n;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Serialize and deserialize a Dn.
+ * </br></br>
+ * <b>This class must *not* be used outside of the server.</b>
+ *  
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DnSerializer implements Serializer
+{
+    /** The serialVersionUID */
+    private static final long serialVersionUID = 1L;
+
+    /** the logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( DnSerializer.class );
+
+    /**
+     * Speedup for logs
+     */
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
+
+    /** The schemaManager reference */
+    private transient SchemaManager schemaManager;
+
+
+    /**
+     * Creates a new instance of DnSerializer.
+     * 
+     * @param schemaManager The reference to the global schemaManager
+     */
+    public DnSerializer( SchemaManager schemaManager )
+    {
+        this.schemaManager = schemaManager;
+    }
+
+
+    /**
+     * <p>
+     * 
+     * This is the place where we serialize Dn
+     * <p>
+     */
+    public byte[] serialize( Object object ) throws IOException
+    {
+        Dn dn = ( Dn ) object;
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutput out = new ObjectOutputStream( baos );
+
+        // First, the Dn
+        dn.writeExternal( out );
+
+        out.flush();
+
+        if ( IS_DEBUG )
+        {
+            LOG.debug( ">------------------------------------------------" );
+            LOG.debug( "Serialized " + dn );
+        }
+
+        return baos.toByteArray();
+    }
+
+
+    /**
+     *  Deserialize a Dn.
+     *  
+     *  @param bytes the byte array containing the serialized Dn
+     *  @return An instance of a Dn object 
+     *  @throws IOException if we can't deserialize the Dn
+     */
+    public Object deserialize( byte[] bytes ) throws IOException
+    {
+        ObjectInputStream in = new ObjectInputStream( new ByteArrayInputStream( bytes ) );
+
+        try
+        {
+            Dn dn = new Dn();
+
+            dn.readExternal( in );
+
+            return dn;
+        }
+        catch ( ClassNotFoundException cnfe )
+        {
+            LOG.error( I18n.err( I18n.ERR_134, cnfe.getLocalizedMessage() ) );
+            throw new IOException( cnfe.getLocalizedMessage() );
+        }
+    }
+}

Added: directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DnSerializerComparator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DnSerializerComparator.java?rev=1460779&view=auto
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DnSerializerComparator.java
(added)
+++ directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DnSerializerComparator.java
Mon Mar 25 17:48:36 2013
@@ -0,0 +1,72 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.core.partition.impl.btree.jdbm;
+
+
+import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.ldap.model.schema.comparators.SerializableComparator;
+
+
+/**
+ * A comparator used to compare {@link Dn} stored in the Dn index.
+ *  
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DnSerializerComparator extends SerializableComparator<Dn>
+{
+    /** The serialVersionUID */
+    private static final long serialVersionUID = 1L;
+
+
+    /**
+     * Creates a new instance of DnSerializer.
+     * 
+     * @param schemaManager The reference to the global schemaManager
+     */
+    public DnSerializerComparator( String oid )
+    {
+        super( oid );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public int compare( Dn dn1, Dn dn2 )
+    {
+        if ( dn1 == null )
+        {
+            if ( dn2 == null )
+            {
+                return 0;
+            }
+
+            return -1;
+        }
+
+        if ( dn2 == null )
+        {
+            return 1;
+        }
+
+        return dn1.getNormName().compareTo( dn2.getNormName() );
+    }
+}

Added: directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDnIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDnIndex.java?rev=1460779&view=auto
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDnIndex.java
(added)
+++ directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmDnIndex.java
Mon Mar 25 17:48:36 2013
@@ -0,0 +1,143 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+
+package org.apache.directory.server.core.partition.impl.btree.jdbm;
+
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import javax.naming.NamingException;
+
+import jdbm.helper.MRU;
+import jdbm.recman.BaseRecordManager;
+import jdbm.recman.CacheRecordManager;
+import jdbm.recman.TransactionManager;
+
+import org.apache.directory.api.ldap.model.entry.Entry;
+import org.apache.directory.api.ldap.model.name.Dn;
+import org.apache.directory.api.ldap.model.schema.AttributeType;
+import org.apache.directory.api.ldap.model.schema.MatchingRule;
+import org.apache.directory.api.ldap.model.schema.SchemaManager;
+import org.apache.directory.api.ldap.model.schema.comparators.UuidComparator;
+import org.apache.directory.server.i18n.I18n;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * A special index which stores DN objects.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class JdbmDnIndex extends JdbmIndex<Dn, Entry>
+{
+
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( JdbmDnIndex.class );
+
+
+    public JdbmDnIndex( String oid )
+    {
+        super( oid, true );
+        initialized = false;
+    }
+
+
+    public void init( SchemaManager schemaManager, AttributeType attributeType ) throws IOException
+    {
+        LOG.debug( "Initializing an Index for attribute '{}'", attributeType.getName() );
+
+        this.attributeType = attributeType;
+
+        if ( attributeId == null )
+        {
+            setAttributeId( attributeType.getName() );
+        }
+
+        if ( this.wkDirPath == null )
+        {
+            NullPointerException e = new NullPointerException( "The index working directory
has not be set" );
+
+            e.printStackTrace();
+            throw e;
+        }
+
+        String path = new File( this.wkDirPath, attributeType.getOid() ).getAbsolutePath();
+
+        //System.out.println( "IDX Created index " + path )
+        BaseRecordManager base = new BaseRecordManager( path );
+        TransactionManager transactionManager = base.getTransactionManager();
+        transactionManager.setMaximumTransactionsInLog( 2000 );
+
+        recMan = new CacheRecordManager( base, new MRU( cacheSize ) );
+
+        try
+        {
+            initTables( schemaManager );
+        }
+        catch ( IOException e )
+        {
+            // clean up
+            close();
+            throw e;
+        }
+
+        // finally write a text file in the format <OID>-<attribute-name>.txt
+        FileWriter fw = new FileWriter( new File( path + "-" + attributeType.getName() +
".txt" ) );
+
+        // write the AttributeType description
+        fw.write( attributeType.toString() );
+        fw.close();
+
+        initialized = true;
+    }
+
+
+    /**
+     * Initializes the forward and reverse tables used by this Index.
+     * 
+     * @param schemaManager The server schemaManager
+     * @throws IOException if we cannot initialize the forward and reverse
+     * tables
+     * @throws NamingException
+     */
+    private void initTables( SchemaManager schemaManager ) throws IOException
+    {
+        MatchingRule mr = attributeType.getEquality();
+
+        if ( mr == null )
+        {
+            throw new IOException( I18n.err( I18n.ERR_574, attributeType.getName() ) );
+        }
+
+        DnSerializerComparator comp = new DnSerializerComparator( mr.getOid() );
+
+        UuidComparator.INSTANCE.setSchemaManager( schemaManager );
+
+        DnSerializer dnSerializer = new DnSerializer( schemaManager );
+
+        forward = new JdbmTable<Dn, String>( schemaManager, attributeType.getOid()
+ FORWARD_BTREE,
+            recMan, comp, dnSerializer, UuidSerializer.INSTANCE );
+        reverse = new JdbmTable<String, Dn>( schemaManager, attributeType.getOid()
+ REVERSE_BTREE,
+            recMan, UuidComparator.INSTANCE, UuidSerializer.INSTANCE, dnSerializer );
+    }
+}

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=1460779&r1=1460778&r2=1460779&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 Mar 25 17:48:36 2013
@@ -427,6 +427,10 @@ public class JdbmPartition extends Abstr
         {
             jdbmIndex = ( JdbmRdnIndex ) index;
         }
+        else if ( index instanceof JdbmDnIndex )
+        {
+            jdbmIndex = ( JdbmDnIndex ) index;
+        }
         else if ( index instanceof JdbmIndex<?, ?> )
         {
             jdbmIndex = ( JdbmIndex<?, Entry> ) index;
@@ -514,6 +518,12 @@ public class JdbmPartition extends Abstr
             jdbmIndex.setAttributeId( ApacheSchemaConstants.APACHE_RDN_AT_OID );
             jdbmIndex.setNumDupLimit( JdbmIndex.DEFAULT_DUPLICATE_LIMIT );
         }
+        else if ( oid.equals( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ) )
+        {
+            jdbmIndex = new JdbmDnIndex( ApacheSchemaConstants.APACHE_ALIAS_AT_OID );
+            jdbmIndex.setAttributeId( ApacheSchemaConstants.APACHE_ALIAS_AT_OID );
+            jdbmIndex.setNumDupLimit( JdbmIndex.DEFAULT_DUPLICATE_LIMIT );
+        }
         else
         {
             jdbmIndex = new JdbmIndex( oid, withReverse );

Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=1460779&r1=1460778&r2=1460779&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
(original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
Mon Mar 25 17:48:36 2013
@@ -248,7 +248,7 @@ public class JdbmStoreTest
         jdbmPartition.setSyncOnWrite( true ); // for code coverage
 
         assertNull( jdbmPartition.getAliasIndex() );
-        Index<String, Entry, String> index = new JdbmIndex<String, Entry>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID,
+        Index<Dn, Entry, String> index = new JdbmIndex<Dn, Entry>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID,
             true );
         ( ( Store ) jdbmPartition ).addIndex( index );
         assertNotNull( jdbmPartition.getAliasIndex() );
@@ -309,7 +309,7 @@ public class JdbmStoreTest
         assertNotNull( store.getAliasIndex() );
         try
         {
-            store.addIndex( new JdbmIndex<String, Entry>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID,
true ) );
+            store.addIndex( new JdbmIndex<Dn, Entry>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID,
true ) );
             fail();
         }
         catch ( IllegalStateException e )

Modified: directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/builder/ServiceBuilder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/builder/ServiceBuilder.java?rev=1460779&r1=1460778&r2=1460779&view=diff
==============================================================================
--- directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/builder/ServiceBuilder.java
(original)
+++ directory/apacheds/trunk/service-builder/src/main/java/org/apache/directory/server/config/builder/ServiceBuilder.java
Mon Mar 25 17:48:36 2013
@@ -87,6 +87,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.changelog.DefaultChangeLog;
 import org.apache.directory.server.core.journal.DefaultJournal;
 import org.apache.directory.server.core.journal.DefaultJournalStore;
+import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmDnIndex;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmRdnIndex;
@@ -1155,6 +1156,11 @@ public class ServiceBuilder
         {
             index = new JdbmRdnIndex();
         }
+        else if ( jdbmIndexBean.getIndexAttributeId().equalsIgnoreCase( ApacheSchemaConstants.APACHE_ALIAS_AT
) ||
+            jdbmIndexBean.getIndexAttributeId().equalsIgnoreCase( ApacheSchemaConstants.APACHE_ALIAS_AT_OID
) )
+        {
+            index = new JdbmDnIndex( ApacheSchemaConstants.APACHE_ALIAS_AT_OID );
+        }
         else
         {
             index = new JdbmIndex<String, Entry>( jdbmIndexBean.getIndexAttributeId(),
hasReverse );

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java?rev=1460779&r1=1460778&r2=1460779&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
Mon Mar 25 17:48:36 2013
@@ -148,7 +148,7 @@ public abstract class AbstractBTreeParti
     protected Index<String, Entry, String> entryCsnIdx;
 
     /** a system index on aliasedObjectName attribute */
-    protected Index<String, Entry, String> aliasIdx;
+    protected Index<Dn, Entry, String> aliasIdx;
 
     /** the subtree scope alias index */
     protected Index<String, Entry, String> subAliasIdx;
@@ -303,7 +303,7 @@ public abstract class AbstractBTreeParti
 
         if ( getAliasIndex() == null )
         {
-            Index<String, Entry, String> index = createSystemIndex( ApacheSchemaConstants.APACHE_ALIAS_AT_OID,
+            Index<Dn, Entry, String> index = createSystemIndex( ApacheSchemaConstants.APACHE_ALIAS_AT_OID,
                 partitionPath, WITH_REVERSE );
             addIndex( index );
         }
@@ -356,7 +356,7 @@ public abstract class AbstractBTreeParti
         rdnIdx = ( Index<ParentIdAndRdn, Entry, String> ) systemIndices
             .get( ApacheSchemaConstants.APACHE_RDN_AT_OID );
         presenceIdx = ( Index<String, Entry, String> ) systemIndices.get( ApacheSchemaConstants.APACHE_PRESENCE_AT_OID
);
-        aliasIdx = ( Index<String, Entry, String> ) systemIndices.get( ApacheSchemaConstants.APACHE_ALIAS_AT_OID
);
+        aliasIdx = ( Index<Dn, Entry, String> ) systemIndices.get( ApacheSchemaConstants.APACHE_ALIAS_AT_OID
);
         oneAliasIdx = ( Index<String, Entry, String> ) systemIndices
             .get( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID );
         subAliasIdx = ( Index<String, Entry, String> ) systemIndices
@@ -697,7 +697,7 @@ public abstract class AbstractBTreeParti
             if ( objectClass.contains( SchemaConstants.ALIAS_OC ) )
             {
                 Attribute aliasAttr = entry.get( ALIASED_OBJECT_NAME_AT );
-                addAliasIndices( id, entryDn, aliasAttr.getString() );
+                addAliasIndices( id, entryDn, new Dn( schemaManager, aliasAttr.getString()
) );
             }
 
             // Update the EntryCsn index
@@ -1125,11 +1125,8 @@ public abstract class AbstractBTreeParti
 
             if ( entry != null )
             {
-                // We have to store the DN in this entry, if it has no DN yet
-                if ( !dn.equals( entry.getDn() ) )
-                {
-                    entry.setDn( dn );
-                }
+                // We have to store the DN in this entry
+                entry.setDn( dn );
 
                 if ( !entry.containsAttribute( ENTRY_DN_AT ) )
                 {
@@ -1291,7 +1288,7 @@ public abstract class AbstractBTreeParti
         if ( modsOid.equals( SchemaConstants.ALIASED_OBJECT_NAME_AT_OID ) )
         {
             Dn ndn = getEntryDn( id );
-            addAliasIndices( id, ndn, mods.getString() );
+            addAliasIndices( id, ndn, new Dn( schemaManager, mods.getString() ) );
         }
     }
 
@@ -1402,7 +1399,7 @@ public abstract class AbstractBTreeParti
         if ( modsOid.equals( aliasAttributeOid ) && mods.size() > 0 )
         {
             Dn entryDn = getEntryDn( id );
-            addAliasIndices( id, entryDn, mods.getString() );
+            addAliasIndices( id, entryDn, new Dn( schemaManager, mods.getString() ) );
         }
     }
 
@@ -1649,10 +1646,11 @@ public abstract class AbstractBTreeParti
          * aliasTarget is used as a marker to tell us if we're moving an
          * alias.  If it is null then the moved entry is not an alias.
          */
-        String aliasTarget = aliasIdx.reverseLookup( entryId );
+        Dn aliasTarget = aliasIdx.reverseLookup( entryId );
 
         if ( null != aliasTarget )
         {
+            aliasTarget.apply( schemaManager );
             addAliasIndices( entryId, buildEntryDn( entryId ), aliasTarget );
         }
 
@@ -1838,10 +1836,11 @@ public abstract class AbstractBTreeParti
          * aliasTarget is used as a marker to tell us if we're moving an
          * alias.  If it is null then the moved entry is not an alias.
          */
-        String aliasTarget = aliasIdx.reverseLookup( entryId );
+        Dn aliasTarget = aliasIdx.reverseLookup( entryId );
 
         if ( null != aliasTarget )
         {
+            aliasTarget.apply( schemaManager );
             addAliasIndices( entryId, buildEntryDn( entryId ), aliasTarget );
         }
     }
@@ -2399,9 +2398,9 @@ public abstract class AbstractBTreeParti
      * {@inheritDoc}
      */
     @SuppressWarnings("unchecked")
-    public Index<String, Entry, String> getAliasIndex()
+    public Index<Dn, Entry, String> getAliasIndex()
     {
-        return ( Index<String, Entry, String> ) systemIndices.get( ApacheSchemaConstants.APACHE_ALIAS_AT_OID
);
+        return ( Index<Dn, Entry, String> ) systemIndices.get( ApacheSchemaConstants.APACHE_ALIAS_AT_OID
);
     }
 
 
@@ -2516,16 +2515,12 @@ public abstract class AbstractBTreeParti
      * not allowed due to chaining or cycle formation.
      * @throws Exception if the wrappedCursor btrees cannot be altered
      */
-    protected void addAliasIndices( String aliasId, Dn aliasDn, String aliasTarget ) throws
Exception
+    protected void addAliasIndices( String aliasId, Dn aliasDn, Dn aliasTarget ) throws Exception
     {
-        Dn normalizedAliasTargetDn; // Name value of aliasedObjectName
         String targetId; // Id of the aliasedObjectName
         Dn ancestorDn; // Name of an alias entry relative
         String ancestorId; // Id of an alias entry relative
 
-        // Access aliasedObjectName, normalize it and generate the Name
-        normalizedAliasTargetDn = new Dn( schemaManager, aliasTarget );
-
         /*
          * Check For Aliases External To Naming Context
          *
@@ -2534,7 +2529,7 @@ public abstract class AbstractBTreeParti
          * need to point it out to the user instead of saying the target
          * does not exist when it potentially could outside of this upSuffix.
          */
-        if ( !normalizedAliasTargetDn.isDescendantOf( suffixDn ) )
+        if ( !aliasTarget.isDescendantOf( suffixDn ) )
         {
             String msg = I18n.err( I18n.ERR_225, suffixDn.getName() );
             LdapAliasDereferencingException e = new LdapAliasDereferencingException( msg
);
@@ -2543,7 +2538,7 @@ public abstract class AbstractBTreeParti
         }
 
         // L O O K U P   T A R G E T   I D
-        targetId = getEntryId( normalizedAliasTargetDn );
+        targetId = getEntryId( aliasTarget );
 
         /*
          * Check For Target Existence
@@ -2579,7 +2574,7 @@ public abstract class AbstractBTreeParti
         }
 
         // Add the alias to the simple alias index
-        aliasIdx.add( normalizedAliasTargetDn.getNormName(), aliasId );
+        aliasIdx.add( aliasTarget, aliasId );
 
         /*
          * Handle One Level Scope Alias Index
@@ -2592,7 +2587,7 @@ public abstract class AbstractBTreeParti
         ancestorId = getEntryId( ancestorDn );
 
         // check if alias parent and aliased entry are the same
-        Dn normalizedAliasTargetParentDn = normalizedAliasTargetDn.getParent();
+        Dn normalizedAliasTargetParentDn = aliasTarget.getParent();
 
         if ( !aliasDn.isDescendantOf( normalizedAliasTargetParentDn ) )
         {
@@ -2611,7 +2606,7 @@ public abstract class AbstractBTreeParti
          */
         while ( !ancestorDn.equals( suffixDn ) && null != ancestorId )
         {
-            if ( !normalizedAliasTargetDn.isDescendantOf( ancestorDn ) )
+            if ( !aliasTarget.isDescendantOf( ancestorDn ) )
             {
                 subAliasIdx.add( ancestorId, targetId );
             }
@@ -2633,8 +2628,9 @@ public abstract class AbstractBTreeParti
      */
     protected void dropAliasIndices( String aliasId ) throws Exception
     {
-        String targetDn = aliasIdx.reverseLookup( aliasId );
-        String targetId = getEntryId( new Dn( schemaManager, targetDn ) );
+        Dn targetDn = aliasIdx.reverseLookup( aliasId );
+        targetDn.apply( schemaManager );
+        String targetId = getEntryId( targetDn );
 
         if ( targetId == null )
         {
@@ -2704,8 +2700,9 @@ public abstract class AbstractBTreeParti
      */
     protected void dropAliasIndices( String aliasId, Dn movedBase ) throws Exception
     {
-        String targetDn = aliasIdx.reverseLookup( aliasId );
-        String targetId = getEntryId( new Dn( schemaManager, targetDn ) );
+        Dn targetDn = aliasIdx.reverseLookup( aliasId );
+        targetDn.apply( schemaManager );
+        String targetId = getEntryId( targetDn );
         Dn aliasDn = getEntryDn( aliasId );
 
         /*

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java?rev=1460779&r1=1460778&r2=1460779&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
Mon Mar 25 17:48:36 2013
@@ -173,7 +173,7 @@ public interface Store
     /**
      * @return The Alias system index
      */
-    Index<String, Entry, String> getAliasIndex();
+    Index<Dn, Entry, String> getAliasIndex();
 
 
     /**

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java?rev=1460779&r1=1460778&r2=1460779&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java
Mon Mar 25 17:48:36 2013
@@ -416,11 +416,12 @@ public class CursorBuilder
             // we will dereference the alias
             if ( searchResult.isDerefAlways() || searchResult.isDerefInSearching() )
             {
-                String aliasedDn = db.getAliasIndex().reverseLookup( uuid );
+                Dn aliasedDn = db.getAliasIndex().reverseLookup( uuid );
 
                 if ( aliasedDn != null )
                 {
-                    String aliasedId = db.getEntryId( new Dn( searchResult.getSchemaManager(),
aliasedDn ) );
+                    aliasedDn.apply( evaluatorBuilder.getSchemaManager() );
+                    String aliasedId = db.getEntryId( aliasedDn );
 
                     // This is an alias. Add it to the set of candidates to process, if it's
not already
                     // present in the candidate set 
@@ -503,11 +504,12 @@ public class CursorBuilder
             // we will dereference the alias
             if ( searchResult.isDerefAlways() || searchResult.isDerefInSearching() )
             {
-                String aliasedDn = db.getAliasIndex().reverseLookup( uuid );
+                Dn aliasedDn = db.getAliasIndex().reverseLookup( uuid );
 
                 if ( aliasedDn != null )
                 {
-                    String aliasedId = db.getEntryId( new Dn( searchResult.getSchemaManager(),
aliasedDn ) );
+                    aliasedDn.apply( evaluatorBuilder.getSchemaManager() );
+                    String aliasedId = db.getEntryId( aliasedDn );
 
                     // This is an alias. Add it to the set of candidates to process, if it's
not already
                     // present in the candidate set 
@@ -518,7 +520,7 @@ public class CursorBuilder
 
                         ScopeNode newScopeNode = new ScopeNode(
                             node.getDerefAliases(),
-                            new Dn( searchResult.getSchemaManager(), aliasedDn ),
+                            aliasedDn,
                             aliasedId,
                             node.getScope() );
 

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java?rev=1460779&r1=1460778&r2=1460779&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
Mon Mar 25 17:48:36 2013
@@ -144,7 +144,7 @@ public class DefaultSearchEngine impleme
         // --------------------------------------------------------------------
         // Determine the effective base with aliases
         // --------------------------------------------------------------------
-        String aliasedBase = db.getAliasIndex().reverseLookup( baseId );
+        Dn aliasedBase = db.getAliasIndex().reverseLookup( baseId );
         Dn effectiveBase = baseDn;
         String effectiveBaseId = baseId;
 
@@ -155,7 +155,7 @@ public class DefaultSearchEngine impleme
              * finding the base, or always then we set the effective base to the alias target
              * got from the alias index.
              */
-            effectiveBase = new Dn( schemaManager, aliasedBase );
+            effectiveBase = aliasedBase.apply( schemaManager );
             effectiveBaseId = db.getEntryId( effectiveBase );
         }
 

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java?rev=1460779&r1=1460778&r2=1460779&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java
Mon Mar 25 17:48:36 2013
@@ -203,4 +203,13 @@ public class EvaluatorBuilder
 
         return evaluators;
     }
+
+
+    /**
+     * @return the schemaManager
+     */
+    public SchemaManager getSchemaManager()
+    {
+        return schemaManager;
+    }
 }

Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java?rev=1460779&r1=1460778&r2=1460779&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlPartitionTest.java
Mon Mar 25 17:48:36 2013
@@ -161,7 +161,7 @@ public class AvlPartitionTest
         avlPartition.setSyncOnWrite( true ); // for code coverage
 
         assertNull( avlPartition.getAliasIndex() );
-        avlPartition.addIndex( new AvlIndex<String, Entry>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID
) );
+        avlPartition.addIndex( new AvlIndex<Dn, Entry>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID
) );
         assertNotNull( avlPartition.getAliasIndex() );
 
         assertEquals( 0, avlPartition.getCacheSize() );
@@ -217,7 +217,7 @@ public class AvlPartitionTest
 
         try
         {
-            partition.addIndex( new AvlIndex<String, Entry>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID
) );
+            partition.addIndex( new AvlIndex<Dn, Entry>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID
) );
             //fail();
         }
         catch ( IllegalStateException e )



Mime
View raw message