directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r917183 - /directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractXdbmPartition.java
Date Sun, 28 Feb 2010 14:15:31 GMT
Author: kayyagari
Date: Sun Feb 28 14:15:31 2010
New Revision: 917183

URL: http://svn.apache.org/viewvc?rev=917183&view=rev
Log:
an efficient fix for DIRSERVER-1401

Modified:
    directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractXdbmPartition.java

Modified: directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractXdbmPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractXdbmPartition.java?rev=917183&r1=917182&r2=917183&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractXdbmPartition.java
(original)
+++ directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractXdbmPartition.java
Sun Feb 28 14:15:31 2010
@@ -38,6 +38,7 @@
 import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.name.RDN;
 
 
 /**
@@ -394,34 +395,35 @@
      */
     private void checkIsValidMove( LdapDN oldChildDn, LdapDN newParentDn ) throws Exception
     {
-        Long newParentId = getEntryId( newParentDn.toString() );
-        Long childId = getEntryId( oldChildDn.toString() );
-        Long oldParentId = getParentId( childId );
-        
-        if( childId.longValue() == newParentId.longValue() )
-        {
-            throw new LdapOperationNotSupportedException( "child entry DN cannot be same
as parent entry DN", ResultCodeEnum.UNWILLING_TO_PERFORM );
-        }
-
-        IndexCursor idxCursor = getSubLevelIndex().forwardCursor( childId );
         boolean invalid = false;
-        while( idxCursor.next() )
+
+        LdapDN newParentDNClone = ( LdapDN ) newParentDn.clone();
+        newParentDNClone.remove( newParentDNClone.size() - 1 );
+        
+        if( newParentDn.size() >= oldChildDn.size() )
         {
-            ForwardIndexEntry<Long, Long> fwdIdxEntry = ( ForwardIndexEntry<Long,
Long> ) idxCursor.get();
-            
-            if( fwdIdxEntry.getId().equals( newParentId ) )
+            for( int i=0; i < oldChildDn.size(); i++ )
             {
-                invalid = true;
-                break;
+                RDN nameRdn = oldChildDn.getRdn( i );
+                RDN ldapRdn = newParentDn.getRdn( i );
+
+                if ( nameRdn.compareTo( ldapRdn ) == 0 )
+                {
+                    invalid = true;
+                }
+                else
+                {
+                    invalid = false;
+                    break;
+                }
             }
         }
-
-        idxCursor.close();
         
-        if ( invalid )
+        if( invalid )
         {
             throw new LdapOperationNotSupportedException( "cannot place an entry below itself",
ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
+        
     }
 
     



Mime
View raw message