directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1141630 - in /directory/apacheds/branches/apacheds-no-reverse-index: jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ xdbm-partition/src/main/java/org/apache/directory/server/xdbm/
Date Thu, 30 Jun 2011 17:19:54 GMT
Author: elecharny
Date: Thu Jun 30 17:19:54 2011
New Revision: 1141630

URL: http://svn.apache.org/viewvc?rev=1141630&view=rev
Log:
o Replaced a getEntryDn method call by a lookup
o Deleted an invalid test
o Added some checks in the getParentIds() method
o Fixed the buildEntryDn() method

Modified:
    directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
    directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java

Modified: directory/apacheds/branches/apacheds-no-reverse-index/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/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=1141630&r1=1141629&r2=1141630&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
(original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
Thu Jun 30 17:19:54 2011
@@ -483,13 +483,13 @@ public class JdbmStoreTest
         Dn dn = new Dn( schemaManager, "o=Good Times Co." );
         assertEquals( 1L, ( long ) store.getEntryId( dn ) );
         assertEquals( 11, store.count() );
-        assertEquals( "o=Good Times Co.", store.getEntryDn( 1L ).getName() );
-        assertEquals( dn.getNormName(), store.getEntryDn( 1L ).getNormName() );
-        assertEquals( dn.getName(), store.getEntryDn( 1L ).getName() );
+        assertEquals( "o=Good Times Co.", store.lookup( 1L ).getDn().toString() );
+        assertEquals( dn.getNormName(), store.lookup( 1L ).getDn().getNormName() );
+        assertEquals( dn.getName(), store.lookup( 1L ).getDn().getName() );
 
         // note that the suffix entry returns 0 for it's parent which does not exist
-        assertEquals( 0L, ( long ) store.getParentId( store.getEntryId( dn ) ) );
-        assertNull( store.getParentId( 0L ) );
+        assertEquals( 0L, ( long ) store.getParentIds( dn ).get( 0 ) );
+        assertNull( store.getParentIds( Dn.EMPTY_DN ) );
 
         // should NOW be allowed
         store.delete( StoreUtils.DN1 );
@@ -665,17 +665,8 @@ public class JdbmStoreTest
         entry.add( "objectClass", "top", "person", "organizationalPerson" );
         entry.add( "ou", "Not Present" );
         entry.add( "cn", "Martin King" );
-        store.add( entry );
-    }
-
-
-    @Test(expected = LdapSchemaViolationException.class)
-    public void testAddWithoutObjectClass() throws Exception
-    {
-        Dn dn = new Dn( schemaManager, "cn=Martin King,ou=Sales,o=Good Times Co." );
-        Entry entry = new DefaultEntry( schemaManager, dn );
-        entry.add( "ou", "Sales" );
-        entry.add( "cn", "Martin King" );
+        entry.add( "entryCSN", new CsnFactory( 1 ).newInstance().toString() );
+        entry.add( "entryUUID", UUID.randomUUID().toString() );
         store.add( entry );
     }
 

Modified: directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java?rev=1141630&r1=1141629&r2=1141630&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
(original)
+++ directory/apacheds/branches/apacheds-no-reverse-index/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
Thu Jun 30 17:19:54 2011
@@ -792,6 +792,11 @@ public abstract class AbstractStore<E, I
      */
     public List<ID> getParentIds( Dn dn ) throws Exception
     {
+        if ( dn.size() == 0 )
+        {
+            return null;
+        }
+        
         // Just to be sure that the Dn is normalized
         if ( !dn.isSchemaAware() )
         {
@@ -816,14 +821,15 @@ public abstract class AbstractStore<E, I
         
         result.add( curEntryId );
 
-        while ( i < dnSize )
+        while ( i < dnSize - 1 )
         {
             currentRdn = new ParentIdAndRdn<ID>( curEntryId, dn.getRdn( dnSize - 1
- i ) );
             curEntryId = rdnIdx.forwardLookup( currentRdn );
 
             if ( curEntryId == null )
             {
-                break;
+                String message = "No parent for DN '" + dn + "', RDN '" + currentRdn.getRdns()[0]
+ "' cannot be found in the DIT.";
+                throw new LdapNoSuchObjectException( message );
             }
             
             result.add( curEntryId );
@@ -884,15 +890,7 @@ public abstract class AbstractStore<E, I
     {
         Entry entry = master.get( id );
 
-        if ( entry != null )
-        {
-            Dn dn = buildEntryDn( id );
-            entry.setDn( dn );
-            
-            return entry;
-        }
-
-        return null;
+        return entry;
     }
 
 
@@ -1553,36 +1551,43 @@ public abstract class AbstractStore<E, I
      * @return the normalized Dn of the entry
      * @throws Exception
      */
-    protected Dn buildEntryDn( ID id ) throws Exception
+    protected Dn buildEntryDn( Rdn rdn, ID id ) throws Exception
     {
+        if ( ( rdn == null ) || ( rdn.size() == 0 ) )
+        {
+            return Dn.EMPTY_DN;
+        }
+        
         ID parentId = id;
 
         List<Rdn> rdnList = new ArrayList<Rdn>();
         StringBuilder upName = new StringBuilder();
         String normName = "";
+        ParentIdAndRdn<ID> current = new ParentIdAndRdn<ID>( id, rdn );
 
+        
         do
         {
-            ParentIdAndRdn<ID> cur = rdnIdx.reverseLookup( parentId );
-            Rdn[] rdns = cur.getRdns();
-
-            for ( Rdn rdn : rdns )
+            Rdn[] rdns = current.getRdns();
+            
+            for ( Rdn curRdn : rdns )
             {
                 if ( rdnList.isEmpty() )
                 {
-                    normName = rdn.getNormName();
-                    upName.append( rdn.getName() );
+                    normName = curRdn.getNormName();
+                    upName.append( curRdn.getName() );
                 }
                 else
                 {
-                    normName = normName + "," + rdn.getNormName();
-                    upName.append( ',' ).append( rdn.getName() );
+                    normName = normName + "," + curRdn.getNormName();
+                    upName.append( ',' ).append( curRdn.getName() );
                 }
 
-                rdnList.add( rdn );
+                rdnList.add( curRdn );
             }
 
-            parentId = cur.getParentId();
+            parentId = current.getParentId();
+            current = new ParentIdAndRdn<ID>( parentId, rdns );
         }
         while ( !parentId.equals( getRootId() ) );
 



Mime
View raw message