directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1527280 - in /directory/apacheds/trunk: core-api/src/main/java/org/apache/directory/server/core/api/entry/ ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/ xdbm-partition/src/main/java/org/apache/directory/serv...
Date Sun, 29 Sep 2013 07:56:08 GMT
Author: kayyagari
Date: Sun Sep 29 07:56:08 2013
New Revision: 1527280

URL: http://svn.apache.org/r1527280
Log:
o do not add entryDN attribute to the original entry (DIRSERVER-1902)
o filter entryDN attribute from cloned entry
o fixed a failing test that is trying to compare entryDN attributes

Modified:
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/entry/ServerEntryUtils.java
    directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/entry/ServerEntryUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/entry/ServerEntryUtils.java?rev=1527280&r1=1527279&r2=1527280&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/entry/ServerEntryUtils.java
(original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/entry/ServerEntryUtils.java
Sun Sep 29 07:56:08 2013
@@ -750,8 +750,11 @@ public class ServerEntryUtils
             return;
         }
 
+        // for special handling of entryDN attribute, see DIRSERVER-1902
         Entry originalEntry = ( ( ClonedServerEntry ) entry ).getOriginalEntry();
 
+        AttributeType entryDnType = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.ENTRY_DN_AT_OID
);
+        
         // First, remove all the attributes if we have the NoAtribute flag set to true
         if ( operationContext.isNoAttributes() )
         {
@@ -761,6 +764,8 @@ public class ServerEntryUtils
                 entry.remove( entry.get( attributeType ) );
             }
 
+            entry.removeAttributes( entryDnType );
+            
             return;
         }
 
@@ -789,6 +794,8 @@ public class ServerEntryUtils
                 }
             }
 
+            entry.removeAttributes( entryDnType );
+            
             return;
         }
 
@@ -817,6 +824,15 @@ public class ServerEntryUtils
                 }
             }
 
+            if ( !operationContext.contains( schemaManager, entryDnType ) )
+            {
+                entry.removeAttributes( entryDnType );
+            }
+            else if ( typesOnly )
+            {
+                entry.get( entryDnType ).clear();
+            }
+
             return;
         }
 
@@ -852,6 +868,15 @@ public class ServerEntryUtils
                     entry.get( attributeType ).clear();
                 }
             }
+            
+            if ( !operationContext.contains( schemaManager, entryDnType ) )
+            {
+                entry.removeAttributes( entryDnType );
+            }
+            else if ( typesOnly )
+            {
+                entry.get( entryDnType ).clear();
+            }
         }
     }
 }

Modified: directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java?rev=1527280&r1=1527279&r2=1527280&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java
(original)
+++ directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartitionTest.java
Sun Sep 29 07:56:08 2013
@@ -310,7 +310,13 @@ public class SingleFileLdifPartitionTest
 
         String id = partition.getEntryId( contextEntry.getDn() );
         assertNotNull( id );
-        assertEquals( contextEntry, partition.fetch( id ) );
+        
+        Entry fetched = partition.fetch( id );
+        
+        //remove the entryDn cause it is not present in the above hand made contextEntry
+        fetched.removeAttributes( SchemaConstants.ENTRY_DN_AT );
+        
+        assertEquals( contextEntry, fetched );
 
         RandomAccessFile file = new RandomAccessFile( new File( partition.getPartitionPath()
), "r" );
 
@@ -889,7 +895,13 @@ public class SingleFileLdifPartitionTest
         // search works fine
         String id = partition.getEntryId( contextEntry.getDn() );
         assertNotNull( id );
-        assertEquals( contextEntry, partition.fetch( id ) );
+
+        Entry fetched = partition.fetch( id );
+        
+        //remove the entryDn cause it is not present in the above hand made contextEntry
+        fetched.removeAttributes( SchemaConstants.ENTRY_DN_AT );
+        
+        assertEquals( contextEntry, fetched );
 
         RandomAccessFile file = new RandomAccessFile( new File( partition.getPartitionPath()
), "r" );
 

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=1527280&r1=1527279&r2=1527280&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
Sun Sep 29 07:56:08 2013
@@ -1140,10 +1140,13 @@ public abstract class AbstractBTreeParti
 
             if ( entry != null )
             {
+                entry.setDn( dn );
+                
+                entry = new ClonedServerEntry( entry );
+
                 // Replace the entry's DN with the provided one
                 Attribute entryDnAt = entry.get( ENTRY_DN_AT );
                 
-                // see DIRSERVER-1902
                 if ( entryDnAt == null )
                 {
                     entry.add( ENTRY_DN_AT, dn.getName() );
@@ -1153,10 +1156,8 @@ public abstract class AbstractBTreeParti
                     entryDnAt.clear();
                     entryDnAt.add( dn.getName() );
                 }
-                
-                entry.setDn( dn );
 
-                return new ClonedServerEntry( entry );
+                return entry;
             }
 
             try
@@ -1174,14 +1175,17 @@ public abstract class AbstractBTreeParti
                 // We have to store the DN in this entry
                 entry.setDn( dn );
 
+                // always store original entry in the cache
+                addToCache( id, entry );
+                
+                entry = new ClonedServerEntry( entry );
+                
                 if ( !entry.containsAttribute( ENTRY_DN_AT ) )
                 {
                     entry.add( ENTRY_DN_AT, dn.getName() );
                 }
 
-                addToCache( id, entry );
-
-                return new ClonedServerEntry( entry );
+                return entry;
             }
 
             return null;



Mime
View raw message