commits@directory.apache.org
[Top] [All Lists]

svn commit: r721928 - /directory/apacheds/branches/apacheds-mina2/core/s

Subject: svn commit: r721928 - /directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java
From:
Date: Sun, 30 Nov 2008 23:18:31 -0000
Author: elecharny
Date: Sun Nov 30 15:18:31 2008
New Revision: 721928

URL: http://svn.apache.org/viewvc?rev=721928&view=rev
Log:
The move, rename, moveAndRename operations didn't update the ReferralManager. 
Fixed.

Modified:
    
directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java

Modified: 
directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java
URL: 
http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java?rev=721928&r1=721927&r2=721928&view=diff
==============================================================================
--- 
directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java
 (original)
+++ 
directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java
 Sun Nov 30 15:18:31 2008
@@ -32,6 +32,9 @@
 import 
org.apache.directory.server.core.interceptor.context.DeleteOperationContext;
 import 
org.apache.directory.server.core.interceptor.context.LookupOperationContext;
 import 
org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
+import 
org.apache.directory.server.core.interceptor.context.MoveAndRenameOperationContext;
+import 
org.apache.directory.server.core.interceptor.context.MoveOperationContext;
+import 
org.apache.directory.server.core.interceptor.context.RenameOperationContext;
 import org.apache.directory.server.core.partition.PartitionNexus;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.server.schema.registries.Registries;
@@ -148,6 +151,14 @@
     
     static private boolean isReferral( ServerEntry entry ) throws 
NamingException
     {
+        // Check that the entry is not null, otherwise return FALSE.
+        // This is typically to cover the case where the entry has not 
+        // been added into the context because it does not exists.
+        if ( entry == null )
+        {
+            return false;
+        }
+        
         EntryAttribute oc = entry.get( SchemaConstants.OBJECT_CLASS_AT );
 
         if ( oc == null )
@@ -287,7 +298,9 @@
     }
 
 
-    /*
+    /**
+     * 
+     **/
     public void move( NextInterceptor next, MoveOperationContext opContext ) 
throws Exception
     {
         LdapDN oldName = opContext.getDn();
@@ -295,40 +308,56 @@
         LdapDN newName = ( LdapDN ) opContext.getParent().clone();
         newName.add( oldName.get( oldName.size() - 1 ) );
 
+        // Check if the entry is a referral itself
+        boolean isReferral = isReferral( opContext.getEntry() );
+
         next.move( opContext );
         
-        // Update the referralManager
-        LookupOperationContext lookupContext = new LookupOperationContext( 
opContext.getSession(), newName );
-        
-        ServerEntry newEntry = nexus.lookup( lookupContext );
-        
-        referralManager.lockWrite();
         
-        referralManager.addReferral( newEntry );
-        referralManager.removeReferral( opContext.getEntry() );
-        
-        referralManager.unlock();
+        if ( isReferral ) 
+        {
+            // Update the referralManager
+            LookupOperationContext lookupContext = new LookupOperationContext( 
opContext.getSession(), newName );
+            
+            ServerEntry newEntry = nexus.lookup( lookupContext );
+            
+            referralManager.lockWrite();
+            
+            referralManager.addReferral( newEntry );
+            referralManager.removeReferral( opContext.getEntry() );
+            
+            referralManager.unlock();
+        }
     }
 
 
+    /**
+     * 
+     **/
     public void moveAndRename( NextInterceptor next, 
MoveAndRenameOperationContext opContext ) throws Exception
     {
         LdapDN newName = ( LdapDN ) opContext.getParent().clone();
         newName.add( opContext.getNewRdn() );
 
+        // Check if the entry is a referral itself
+        boolean isReferral = isReferral( opContext.getEntry() );
+
         next.moveAndRename( opContext );
         
-        // Update the referralManager
-        LookupOperationContext lookupContext = new LookupOperationContext( 
opContext.getSession(), newName );
-        
-        ServerEntry newEntry = nexus.lookup( lookupContext );
-        
-        referralManager.lockWrite();
-        
-        referralManager.addReferral( newEntry );
-        referralManager.removeReferral( opContext.getEntry() );
-        
-        referralManager.unlock();
+        if ( isReferral ) 
+        {
+            // Update the referralManager
+            LookupOperationContext lookupContext = new LookupOperationContext( 
opContext.getSession(), newName );
+            
+            ServerEntry newEntry = nexus.lookup( lookupContext );
+            
+            referralManager.lockWrite();
+            
+            referralManager.addReferral( newEntry );
+            referralManager.removeReferral( opContext.getEntry() );
+            
+            referralManager.unlock();
+        }
     }
 
 
@@ -341,21 +370,27 @@
 
         newName.add( opContext.getNewRdn() );
 
+        // Check if the entry is a referral itself
+        boolean isReferral = isReferral( opContext.getEntry() );
+
         next.rename( opContext );
         
-        // Update the referralManager
-        LookupOperationContext lookupContext = new LookupOperationContext( 
opContext.getSession(), newName );
-        
-        ServerEntry newEntry = nexus.lookup( lookupContext );
-        
-        referralManager.lockWrite();
-        
-        referralManager.addReferral( newEntry );
-        referralManager.removeReferral( opContext.getEntry() );
-        
-        referralManager.unlock();
+        if ( isReferral ) 
+        {
+            // Update the referralManager
+            LookupOperationContext lookupContext = new LookupOperationContext( 
opContext.getSession(), newName );
+            
+            ServerEntry newEntry = nexus.lookup( lookupContext );
+            
+            referralManager.lockWrite();
+            
+            referralManager.addReferral( newEntry );
+            referralManager.removeReferral( opContext.getEntry() );
+            
+            referralManager.unlock();
+        }
     }
-    */
+    
 
     /**
      * Modify an entry in the server.


<Prev in Thread] Current Thread [Next in Thread>
  • svn commit: r721928 - /directory/apacheds/branches/apacheds-mina2/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java, elecharny <=