You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2012/04/29 13:12:49 UTC

svn commit: r1331896 - in /directory/apacheds/branches/index-work: jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/ xdbm-partition/src...

Author: elecharny
Date: Sun Apr 29 11:12:49 2012
New Revision: 1331896

URL: http://svn.apache.org/viewvc?rev=1331896&view=rev
Log:
Added a lookup( ID, DN ) method that save us the time needed to rebuild the DN, when we already have it. The provided DN will be injected into the found entry.

Modified:
    directory/apacheds/branches/index-work/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
    directory/apacheds/branches/index-work/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
    directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
    directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java

Modified: directory/apacheds/branches/index-work/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=1331896&r1=1331895&r2=1331896&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java (original)
+++ directory/apacheds/branches/index-work/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java Sun Apr 29 11:12:49 2012
@@ -222,7 +222,7 @@ public class JdbmStoreTest
 
         // lookup the context entry
         Long id = store2.getEntryId( suffixDn );
-        Entry lookup = store2.lookup( id );
+        Entry lookup = store2.lookup( id, suffixDn );
         assertEquals( 2, lookup.getDn().size() );
 
         // make sure all files are closed so that they can be deleted on Windows.
@@ -613,7 +613,7 @@ public class JdbmStoreTest
         Dn dn2 = new Dn( schemaManager, "sn=Ja\\+es,ou=Engineering,o=Good Times Co." );
         Long id = store.getEntryId( dn2 );
         assertNotNull( id );
-        Entry entry2 = store.lookup( id );
+        Entry entry2 = store.lookup( id, dn2 );
         assertEquals( "Ja+es", entry2.get( "sn" ).getString() );
     }
 
@@ -667,7 +667,7 @@ public class JdbmStoreTest
 
         Modification add = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attrib );
 
-        Entry lookedup = store.lookup( store.getEntryId( dn ) );
+        Entry lookedup = store.lookup( store.getEntryId( dn ), dn );
 
         store.modify( dn, add );
         assertTrue( lookedup.get( "sn" ).contains( attribVal ) );
@@ -686,7 +686,7 @@ public class JdbmStoreTest
 
         Modification add = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, attrib );
 
-        Entry lookedup = store.lookup( store.getEntryId( dn ) );
+        Entry lookedup = store.lookup( store.getEntryId( dn ), dn );
 
         assertEquals( "WAlkeR", lookedup.get( "sn" ).get().getString() ); // before replacing
 
@@ -711,7 +711,7 @@ public class JdbmStoreTest
 
         Modification add = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attrib );
 
-        Entry lookedup = store.lookup( store.getEntryId( dn ) );
+        Entry lookedup = store.lookup( store.getEntryId( dn ), dn );
 
         assertNotNull( lookedup.get( "sn" ).get() );
 
@@ -751,7 +751,7 @@ public class JdbmStoreTest
 
         Modification add = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, attrib );
 
-        Entry lookedup = store.lookup( store.getEntryId( dn ) );
+        Entry lookedup = store.lookup( store.getEntryId( dn ), dn );
 
         assertNull( lookedup.get( "ou" ) ); // before replacing
 

Modified: directory/apacheds/branches/index-work/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java?rev=1331896&r1=1331895&r2=1331896&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java (original)
+++ directory/apacheds/branches/index-work/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java Sun Apr 29 11:12:49 2012
@@ -271,7 +271,7 @@ public class LdifPartition extends Abstr
         }
 
         // Get the modified entry and store it in the context for post usage
-        Entry modifiedEntry = lookup( id );
+        Entry modifiedEntry = lookup( id, modifyContext.getDn() );
         modifyContext.setAlteredEntry( modifiedEntry );
 
         // just overwrite the existing file
@@ -302,7 +302,7 @@ public class LdifPartition extends Abstr
         super.move( moveContext );
 
         // Get the modified entry
-        Entry modifiedEntry = lookup( id );
+        Entry modifiedEntry = lookup( id, oldDn );
 
         try
         {
@@ -326,7 +326,7 @@ public class LdifPartition extends Abstr
         super.moveAndRename( moveAndRenameContext );
 
         // Get the modified entry and store it in the context for post usage
-        Entry modifiedEntry = lookup( id );
+        Entry modifiedEntry = lookup( id, oldDn );
         moveAndRenameContext.setModifiedEntry( modifiedEntry );
 
         try
@@ -352,7 +352,7 @@ public class LdifPartition extends Abstr
         super.rename( renameContext );
 
         // Get the modified entry and store it in the context for post usage
-        Entry modifiedEntry = lookup( id );
+        Entry modifiedEntry = lookup( id, oldDn );
         renameContext.setModifiedEntry( modifiedEntry );
 
         // Now move the potential children for the old entry
@@ -385,7 +385,6 @@ public class LdifPartition extends Abstr
         
         Long baseId = getEntryId( modifiedEntry.getDn() );
 
-
         ParentIdAndRdn<Long> parentIdAndRdn = getRdnIndex().reverseLookup( baseId ); 
         IndexEntry indexEntry = new ForwardIndexEntry();
         

Modified: directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java?rev=1331896&r1=1331895&r2=1331896&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java (original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java Sun Apr 29 11:12:49 2012
@@ -991,7 +991,7 @@ public abstract class AbstractBTreeParti
             return null;
         }
 
-        Entry entry = lookup( id );
+        Entry entry = lookup( id, lookupContext.getDn() );
 
         // Remove all the attributes if the NO_ATTRIBUTE flag is set and there is no requested attribute
         if ( lookupContext.hasNoAttribute()
@@ -1104,6 +1104,37 @@ public abstract class AbstractBTreeParti
     }
 
 
+    /**
+     * Get back an entry knowing its ID
+     *
+     * @param id The Entry ID we want to get back
+     * @return The found Entry, or null if not found
+     * @throws Exception If the lookup failed for any reason (except a not found entry)
+     */
+    public Entry lookup( ID id, Dn dn ) throws LdapException
+    {
+        try
+        {
+            Entry entry = master.get( id );
+
+            if ( entry != null )
+            {
+                // We have to store the DN in this entry
+                //Dn dn = buildEntryDn( id );
+                entry.setDn( dn );
+
+                return new ClonedServerEntry( entry );
+            }
+
+            return null;
+        }
+        catch ( Exception e )
+        {
+            throw new LdapOperationErrorException( e.getMessage(), e );
+        }
+    }
+
+
     //---------------------------------------------------------------------------------------------
     // The Modify operation
     //---------------------------------------------------------------------------------------------
@@ -1921,7 +1952,7 @@ public abstract class AbstractBTreeParti
         {
             ID id = getEntryId( entryContext.getDn() );
 
-            Entry entry = lookup( id );
+            Entry entry = lookup( id, entryContext.getDn() );
 
             return entry != null;
         }

Modified: directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java?rev=1331896&r1=1331895&r2=1331896&view=diff
==============================================================================
--- directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java (original)
+++ directory/apacheds/branches/index-work/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java Sun Apr 29 11:12:49 2012
@@ -357,6 +357,17 @@ public interface Store<E, ID extends Com
 
 
     /**
+     * Get back an entry knowing its ID
+     *
+     * @param id The Entry ID we want to get back
+     * @param dn The entry DN when we have it
+     * @return The found Entry, or null if not found
+     * @throws Exception If the lookup failed for any reason (except a not found entry)
+     */
+    Entry lookup( ID id, Dn dn ) throws Exception;
+
+
+    /**
      * Gets the count of immediate children of the given entry ID.
      *
      * @param id the entry ID