directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1200918 - in /directory/apacheds/trunk: core-api/src/main/java/org/apache/directory/server/core/api/invocation/ core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java
Date Fri, 11 Nov 2011 15:31:38 GMT
Author: kayyagari
Date: Fri Nov 11 15:31:37 2011
New Revision: 1200918

URL: http://svn.apache.org/viewvc?rev=1200918&view=rev
Log:
o removed the InvocationStack and updated the operation manager

Removed:
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/api/invocation/
Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java?rev=1200918&r1=1200917&r2=1200918&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java Fri Nov 11 15:31:37 2011
@@ -44,7 +44,6 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.api.interceptor.context.RenameOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.SearchOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.UnbindOperationContext;
-import org.apache.directory.server.core.api.invocation.InvocationStack;
 import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.entry.Attribute;
@@ -280,54 +279,46 @@ public class DefaultOperationManager imp
         LOG_CHANGES.debug( ">> AddOperation : {}", addContext );
 
         ensureStarted();
-        push( addContext );
 
-        try
+        // Normalize the addContext Dn
+        Dn dn = addContext.getDn();
+        dn.apply( directoryService.getSchemaManager() );
+        
+        // We have to deal with the referral first
+        directoryService.getReferralManager().lockRead();
+        
+        if ( directoryService.getReferralManager().hasParentReferral( dn ) )
         {
-            // Normalize the addContext Dn
-            Dn dn = addContext.getDn();
-            dn.apply( directoryService.getSchemaManager() );
-
-            // We have to deal with the referral first
-            directoryService.getReferralManager().lockRead();
-
-            if ( directoryService.getReferralManager().hasParentReferral( dn ) )
+            Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
+            Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
+            
+            // Depending on the Context.REFERRAL property value, we will throw
+            // a different exception.
+            if ( addContext.isReferralIgnored() )
             {
-                Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
-                Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-
-                // Depending on the Context.REFERRAL property value, we will throw
-                // a different exception.
-                if ( addContext.isReferralIgnored() )
-                {
-                    directoryService.getReferralManager().unlock();
-
-                    LdapPartialResultException exception = buildLdapPartialResultException( childDn );
-                    throw exception;
-                }
-                else
-                {
-                    // Unlock the referral manager
-                    directoryService.getReferralManager().unlock();
-
-                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                    throw exception;
-                }
+                directoryService.getReferralManager().unlock();
+                
+                LdapPartialResultException exception = buildLdapPartialResultException( childDn );
+                throw exception;
             }
             else
             {
-                // Unlock the ReferralManager
+                // Unlock the referral manager
                 directoryService.getReferralManager().unlock();
-
-                // Call the Add method
-                Interceptor head = directoryService.getInterceptor( addContext.getNextInterceptor() );
-
-                head.add( addContext );
+                
+                LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                throw exception;
             }
         }
-        finally
+        else
         {
-            pop();
+            // Unlock the ReferralManager
+            directoryService.getReferralManager().unlock();
+            
+            // Call the Add method
+            Interceptor head = directoryService.getInterceptor( addContext.getNextInterceptor() );
+            
+            head.add( addContext );
         }
 
         LOG.debug( "<< AddOperation successful" );
@@ -343,21 +334,13 @@ public class DefaultOperationManager imp
         LOG.debug( ">> BindOperation : {}", bindContext );
 
         ensureStarted();
-        push( bindContext );
-
-        try
-        {
-            // Call the Delete method
-            Interceptor head = directoryService.getInterceptor( bindContext.getNextInterceptor() );
 
-            head.bind( bindContext );
-        }
-        finally
-        {
-            pop();
+        // Call the Delete method
+        Interceptor head = directoryService.getInterceptor( bindContext.getNextInterceptor() );
+        
+        head.bind( bindContext );
 
-            LOG.debug( "<< BindOperation successful" );
-        }
+        LOG.debug( "<< BindOperation successful" );
     }
 
 
@@ -369,78 +352,71 @@ public class DefaultOperationManager imp
         LOG.debug( ">> CompareOperation : {}", compareContext );
 
         ensureStarted();
-        push( compareContext );
-
-        try
-        {
-            // Normalize the compareContext Dn
-            Dn dn = compareContext.getDn();
-            dn.apply( directoryService.getSchemaManager() );
-
-            // We have to deal with the referral first
-            directoryService.getReferralManager().lockRead();
-
-            // Check if we have an ancestor for this Dn
-            Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
-
-            if ( parentEntry != null )
+        // Normalize the compareContext Dn
+        Dn dn = compareContext.getDn();
+        dn.apply( directoryService.getSchemaManager() );
+        
+        // We have to deal with the referral first
+        directoryService.getReferralManager().lockRead();
+        
+        // Check if we have an ancestor for this Dn
+        Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
+        
+        if ( parentEntry != null )
+        {
+            // We have found a parent referral for the current Dn
+            Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
+            
+            if ( directoryService.getReferralManager().isReferral( dn ) )
+            {
+                // This is a referral. We can delete it if the ManageDsaIt flag is true
+                // Otherwise, we just throw a LdapReferralException
+                if ( !compareContext.isReferralIgnored() )
+                {
+                    // Throw a Referral Exception
+                    // Unlock the referral manager
+                    directoryService.getReferralManager().unlock();
+                    
+                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                    throw exception;
+                }
+            }
+            else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
             {
-                // We have found a parent referral for the current Dn
-                Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-
-                if ( directoryService.getReferralManager().isReferral( dn ) )
+                // Depending on the Context.REFERRAL property value, we will throw
+                // a different exception.
+                if ( compareContext.isReferralIgnored() )
                 {
-                    // This is a referral. We can delete it if the ManageDsaIt flag is true
-                    // Otherwise, we just throw a LdapReferralException
-                    if ( !compareContext.isReferralIgnored() )
-                    {
-                        // Throw a Referral Exception
-                        // Unlock the referral manager
-                        directoryService.getReferralManager().unlock();
-
-                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                        throw exception;
-                    }
-                }
-                else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
-                {
-                    // Depending on the Context.REFERRAL property value, we will throw
-                    // a different exception.
-                    if ( compareContext.isReferralIgnored() )
-                    {
-                        directoryService.getReferralManager().unlock();
-
-                        LdapPartialResultException exception = buildLdapPartialResultException( childDn );
-                        throw exception;
-                    }
-                    else
-                    {
-                        // Unlock the referral manager
-                        directoryService.getReferralManager().unlock();
-
-                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                        throw exception;
-                    }
+                    directoryService.getReferralManager().unlock();
+                    
+                    LdapPartialResultException exception = buildLdapPartialResultException( childDn );
+                    throw exception;
+                }
+                else
+                {
+                    // Unlock the referral manager
+                    directoryService.getReferralManager().unlock();
+                    
+                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                    throw exception;
                 }
             }
-
-            // Unlock the ReferralManager
-            directoryService.getReferralManager().unlock();
-
-            // populate the context with the old entry
-            compareContext.setOriginalEntry( getOriginalEntry( compareContext ) );
-
-            // Call the Compare method
-            Interceptor head = directoryService.getInterceptor( compareContext.getNextInterceptor() );
-
-            return head.compare( compareContext );
-        }
-        finally
-        {
-            pop();
-
-            LOG.debug( "<< CompareOperation successful" );
         }
+        
+        // Unlock the ReferralManager
+        directoryService.getReferralManager().unlock();
+        
+        // populate the context with the old entry
+        compareContext.setOriginalEntry( getOriginalEntry( compareContext ) );
+        
+        // Call the Compare method
+        Interceptor head = directoryService.getInterceptor( compareContext.getNextInterceptor() );
+        
+        boolean result = head.compare( compareContext );
+
+        LOG.debug( "<< CompareOperation successful" );
+        
+        return result;
     }
 
 
@@ -453,77 +429,69 @@ public class DefaultOperationManager imp
         LOG_CHANGES.debug( ">> DeleteOperation : {}", deleteContext );
 
         ensureStarted();
-        push( deleteContext );
-
-        try
-        {
-            // Normalize the deleteContext Dn
-            Dn dn = deleteContext.getDn();
-            dn.apply( directoryService.getSchemaManager() );
-
-            // We have to deal with the referral first
-            directoryService.getReferralManager().lockRead();
-
-            Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
 
-            if ( parentEntry != null )
+        // Normalize the deleteContext Dn
+        Dn dn = deleteContext.getDn();
+        dn.apply( directoryService.getSchemaManager() );
+        
+        // We have to deal with the referral first
+        directoryService.getReferralManager().lockRead();
+        
+        Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
+        
+        if ( parentEntry != null )
+        {
+            // We have found a parent referral for the current Dn
+            Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
+            
+            if ( directoryService.getReferralManager().isReferral( dn ) )
+            {
+                // This is a referral. We can delete it if the ManageDsaIt flag is true
+                // Otherwise, we just throw a LdapReferralException
+                if ( !deleteContext.isReferralIgnored() )
+                {
+                    // Throw a Referral Exception
+                    // Unlock the referral manager
+                    directoryService.getReferralManager().unlock();
+                    
+                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                    throw exception;
+                }
+            }
+            else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
             {
-                // We have found a parent referral for the current Dn
-                Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-
-                if ( directoryService.getReferralManager().isReferral( dn ) )
+                // We can't delete an entry which has an ancestor referral
+                
+                // Depending on the Context.REFERRAL property value, we will throw
+                // a different exception.
+                if ( deleteContext.isReferralIgnored() )
                 {
-                    // This is a referral. We can delete it if the ManageDsaIt flag is true
-                    // Otherwise, we just throw a LdapReferralException
-                    if ( !deleteContext.isReferralIgnored() )
-                    {
-                        // Throw a Referral Exception
-                        // Unlock the referral manager
-                        directoryService.getReferralManager().unlock();
-
-                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                        throw exception;
-                    }
-                }
-                else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
-                {
-                    // We can't delete an entry which has an ancestor referral
-
-                    // Depending on the Context.REFERRAL property value, we will throw
-                    // a different exception.
-                    if ( deleteContext.isReferralIgnored() )
-                    {
-                        directoryService.getReferralManager().unlock();
-
-                        LdapPartialResultException exception = buildLdapPartialResultException( childDn );
-                        throw exception;
-                    }
-                    else
-                    {
-                        // Unlock the referral manager
-                        directoryService.getReferralManager().unlock();
-
-                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                        throw exception;
-                    }
+                    directoryService.getReferralManager().unlock();
+                    
+                    LdapPartialResultException exception = buildLdapPartialResultException( childDn );
+                    throw exception;
+                }
+                else
+                {
+                    // Unlock the referral manager
+                    directoryService.getReferralManager().unlock();
+                    
+                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                    throw exception;
                 }
             }
-
-            // Unlock the ReferralManager
-            directoryService.getReferralManager().unlock();
-
-            // populate the context with the old entry
-            eagerlyPopulateFields( deleteContext );
-
-            // Call the Delete method
-            Interceptor head = directoryService.getInterceptor( deleteContext.getNextInterceptor() );
-
-            head.delete( deleteContext );
-        }
-        finally
-        {
-            pop();
         }
+        
+        // Unlock the ReferralManager
+        directoryService.getReferralManager().unlock();
+        
+        // populate the context with the old entry
+        eagerlyPopulateFields( deleteContext );
+        
+        // Call the Delete method
+        Interceptor head = directoryService.getInterceptor( deleteContext.getNextInterceptor() );
+        
+        head.delete( deleteContext );
 
         LOG.debug( "<< DeleteOperation successful" );
         LOG_CHANGES.debug( "<< DeleteOperation successful" );
@@ -538,20 +506,14 @@ public class DefaultOperationManager imp
         LOG.debug( ">> GetRootDSEOperation : {}", getRootDseContext );
 
         ensureStarted();
-        push( getRootDseContext );
 
-        try
-        {
-            Interceptor head = directoryService.getInterceptor( getRootDseContext.getNextInterceptor() );
-
-            return head.getRootDSE( getRootDseContext );
-        }
-        finally
-        {
-            pop();
-
-            LOG.debug( "<< getRootDSEOperation successful" );
-        }
+        Interceptor head = directoryService.getInterceptor( getRootDseContext.getNextInterceptor() );
+        
+        Entry root = head.getRootDSE( getRootDseContext );
+        
+        LOG.debug( "<< getRootDSEOperation successful" );
+        
+        return root;
     }
 
 
@@ -563,20 +525,14 @@ public class DefaultOperationManager imp
         LOG.debug( ">> hasEntryOperation : {}", hasEntryContext );
 
         ensureStarted();
-        push( hasEntryContext );
-
-        try
-        {
-            Interceptor head = directoryService.getInterceptor( hasEntryContext.getNextInterceptor() );
 
-            return head.hasEntry( hasEntryContext );
-        }
-        finally
-        {
-            pop();
-
-            LOG.debug( "<< HasEntryOperation successful" );
-        }
+        Interceptor head = directoryService.getInterceptor( hasEntryContext.getNextInterceptor() );
+        
+        boolean result = head.hasEntry( hasEntryContext );
+        
+        LOG.debug( "<< HasEntryOperation successful" );
+        
+        return result;
     }
 
 
@@ -588,20 +544,14 @@ public class DefaultOperationManager imp
         LOG.debug( ">> ListOperation : {}", listContext );
 
         ensureStarted();
-        push( listContext );
-
-        try
-        {
-            Interceptor head = directoryService.getInterceptor( listContext.getNextInterceptor() );
-
-            return head.list( listContext );
-        }
-        finally
-        {
-            pop();
 
-            LOG.debug( "<< ListOperation successful" );
-        }
+        Interceptor head = directoryService.getInterceptor( listContext.getNextInterceptor() );
+        
+        EntryFilteringCursor cursor = head.list( listContext );
+        
+        LOG.debug( "<< ListOperation successful" );
+        
+        return cursor;
     }
 
 
@@ -613,20 +563,14 @@ public class DefaultOperationManager imp
         LOG.debug( ">> LookupOperation : {}", lookupContext );
 
         ensureStarted();
-        push( lookupContext );
-
-        try
-        {
-            Interceptor head = directoryService.getInterceptor( lookupContext.getNextInterceptor() );
 
-            return head.lookup( lookupContext );
-        }
-        finally
-        {
-            pop();
-
-            LOG.debug( "<< LookupOperation successful" );
-        }
+        Interceptor head = directoryService.getInterceptor( lookupContext.getNextInterceptor() );
+        
+        Entry entry = head.lookup( lookupContext );
+        
+        LOG.debug( "<< LookupOperation successful" );
+        
+        return entry;
     }
 
 
@@ -639,89 +583,81 @@ public class DefaultOperationManager imp
         LOG_CHANGES.debug( ">> ModifyOperation : {}", modifyContext );
 
         ensureStarted();
-        push( modifyContext );
-
-        try
-        {
-            // Normalize the modifyContext Dn
-            Dn dn = modifyContext.getDn();
-            dn.apply( directoryService.getSchemaManager() );
-
-            ReferralManager referralManager = directoryService.getReferralManager();
 
-            // We have to deal with the referral first
-            referralManager.lockRead();
-
-            // Check if we have an ancestor for this Dn
-            Entry parentEntry = referralManager.getParentReferral( dn );
-
-            if ( parentEntry != null )
+        // Normalize the modifyContext Dn
+        Dn dn = modifyContext.getDn();
+        dn.apply( directoryService.getSchemaManager() );
+        
+        ReferralManager referralManager = directoryService.getReferralManager();
+        
+        // We have to deal with the referral first
+        referralManager.lockRead();
+        
+        // Check if we have an ancestor for this Dn
+        Entry parentEntry = referralManager.getParentReferral( dn );
+        
+        if ( parentEntry != null )
+        {
+            if ( referralManager.isReferral( dn ) )
+            {
+                // This is a referral. We can delete it if the ManageDsaIt flag is true
+                // Otherwise, we just throw a LdapReferralException
+                if ( !modifyContext.isReferralIgnored() )
+                {
+                    // Throw a Referral Exception
+                    // Unlock the referral manager
+                    referralManager.unlock();
+                    
+                    // We have found a parent referral for the current Dn
+                    Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
+                    
+                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                    throw exception;
+                }
+            }
+            else if ( referralManager.hasParentReferral( dn ) )
             {
-                if ( referralManager.isReferral( dn ) )
+                // We can't delete an entry which has an ancestor referral
+                
+                // Depending on the Context.REFERRAL property value, we will throw
+                // a different exception.
+                if ( modifyContext.isReferralIgnored() )
                 {
-                    // This is a referral. We can delete it if the ManageDsaIt flag is true
-                    // Otherwise, we just throw a LdapReferralException
-                    if ( !modifyContext.isReferralIgnored() )
-                    {
-                        // Throw a Referral Exception
-                        // Unlock the referral manager
-                        referralManager.unlock();
-
-                        // We have found a parent referral for the current Dn
-                        Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-
-                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                        throw exception;
-                    }
+                    referralManager.unlock();
+                    
+                    // We have found a parent referral for the current Dn
+                    Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
+                    
+                    LdapPartialResultException exception = buildLdapPartialResultException( childDn );
+                    throw exception;
                 }
-                else if ( referralManager.hasParentReferral( dn ) )
+                else
                 {
-                    // We can't delete an entry which has an ancestor referral
-
-                    // Depending on the Context.REFERRAL property value, we will throw
-                    // a different exception.
-                    if ( modifyContext.isReferralIgnored() )
-                    {
-                        referralManager.unlock();
-
-                        // We have found a parent referral for the current Dn
-                        Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-
-                        LdapPartialResultException exception = buildLdapPartialResultException( childDn );
-                        throw exception;
-                    }
-                    else
-                    {
-                        // Unlock the referral manager
-                        referralManager.unlock();
-
-                        // We have found a parent referral for the current Dn
-                        Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-
-                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                        throw exception;
-                    }
+                    // Unlock the referral manager
+                    referralManager.unlock();
+                    
+                    // We have found a parent referral for the current Dn
+                    Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
+                    
+                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                    throw exception;
                 }
             }
-
-            // Unlock the ReferralManager
-            referralManager.unlock();
-
-            // populate the context with the old entry
-            eagerlyPopulateFields( modifyContext );
-
-            // Call the Modify method
-            Interceptor head = directoryService.getInterceptor( modifyContext.getNextInterceptor() );
-
-            head.modify( modifyContext );
         }
-        finally
-        {
-            pop();
+        
+        // Unlock the ReferralManager
+        referralManager.unlock();
+        
+        // populate the context with the old entry
+        eagerlyPopulateFields( modifyContext );
+        
+        // Call the Modify method
+        Interceptor head = directoryService.getInterceptor( modifyContext.getNextInterceptor() );
+        
+        head.modify( modifyContext );
 
-            LOG.debug( "<< ModifyOperation successful" );
-            LOG_CHANGES.debug( "<< ModifyOperation successful" );
-        }
+        LOG.debug( "<< ModifyOperation successful" );
+        LOG_CHANGES.debug( "<< ModifyOperation successful" );
     }
 
 
@@ -734,101 +670,93 @@ public class DefaultOperationManager imp
         LOG_CHANGES.debug( ">> MoveOperation : {}", moveContext );
 
         ensureStarted();
-        push( moveContext );
-
-        try
-        {
-            // Normalize the moveContext Dn
-            Dn dn = moveContext.getDn();
-            dn.apply( directoryService.getSchemaManager() );
-
-            // Normalize the moveContext superior Dn
-            Dn newSuperiorDn = moveContext.getNewSuperior();
-            newSuperiorDn.apply( directoryService.getSchemaManager() );
-
-            // We have to deal with the referral first
-            directoryService.getReferralManager().lockRead();
 
-            // Check if we have an ancestor for this Dn
-            Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
-
-            if ( parentEntry != null )
+        // Normalize the moveContext Dn
+        Dn dn = moveContext.getDn();
+        dn.apply( directoryService.getSchemaManager() );
+        
+        // Normalize the moveContext superior Dn
+        Dn newSuperiorDn = moveContext.getNewSuperior();
+        newSuperiorDn.apply( directoryService.getSchemaManager() );
+        
+        // We have to deal with the referral first
+        directoryService.getReferralManager().lockRead();
+        
+        // Check if we have an ancestor for this Dn
+        Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
+        
+        if ( parentEntry != null )
+        {
+            // We have found a parent referral for the current Dn
+            Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
+            
+            if ( directoryService.getReferralManager().isReferral( dn ) )
+            {
+                // This is a referral. We can delete it if the ManageDsaIt flag is true
+                // Otherwise, we just throw a LdapReferralException
+                if ( !moveContext.isReferralIgnored() )
+                {
+                    // Throw a Referral Exception
+                    // Unlock the referral manager
+                    directoryService.getReferralManager().unlock();
+                    
+                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                    throw exception;
+                }
+            }
+            else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
             {
-                // We have found a parent referral for the current Dn
-                Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-
-                if ( directoryService.getReferralManager().isReferral( dn ) )
+                // We can't delete an entry which has an ancestor referral
+                
+                // Depending on the Context.REFERRAL property value, we will throw
+                // a different exception.
+                if ( moveContext.isReferralIgnored() )
                 {
-                    // This is a referral. We can delete it if the ManageDsaIt flag is true
-                    // Otherwise, we just throw a LdapReferralException
-                    if ( !moveContext.isReferralIgnored() )
-                    {
-                        // Throw a Referral Exception
-                        // Unlock the referral manager
-                        directoryService.getReferralManager().unlock();
-
-                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                        throw exception;
-                    }
+                    directoryService.getReferralManager().unlock();
+                    
+                    LdapPartialResultException exception = buildLdapPartialResultException( childDn );
+                    throw exception;
                 }
-                else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
+                else
                 {
-                    // We can't delete an entry which has an ancestor referral
-
-                    // Depending on the Context.REFERRAL property value, we will throw
-                    // a different exception.
-                    if ( moveContext.isReferralIgnored() )
-                    {
-                        directoryService.getReferralManager().unlock();
-
-                        LdapPartialResultException exception = buildLdapPartialResultException( childDn );
-                        throw exception;
-                    }
-                    else
-                    {
-                        // Unlock the referral manager
-                        directoryService.getReferralManager().unlock();
-
-                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                        throw exception;
-                    }
+                    // Unlock the referral manager
+                    directoryService.getReferralManager().unlock();
+                    
+                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                    throw exception;
                 }
             }
-
-            // Now, check the destination
-            // If he parent Dn is a referral, or has a referral ancestor, we have to issue a AffectMultipleDsas result
-            // as stated by RFC 3296 Section 5.6.2
-            if ( directoryService.getReferralManager().isReferral( newSuperiorDn )
-                || directoryService.getReferralManager().hasParentReferral( newSuperiorDn ) )
-            {
-                // Unlock the referral manager
-                directoryService.getReferralManager().unlock();
-
-                LdapAffectMultipleDsaException exception = new LdapAffectMultipleDsaException();
-                //exception.setRemainingName( dn );
-
-                throw exception;
-            }
-
-            // Unlock the ReferralManager
-            directoryService.getReferralManager().unlock();
-
-            Entry originalEntry = getOriginalEntry( moveContext );
-
-            moveContext.setOriginalEntry( originalEntry );
-
-            // Call the Move method
-            Interceptor head = directoryService.getInterceptor( moveContext.getNextInterceptor() );
-
-            head.move( moveContext );
         }
-        finally
+        
+        // Now, check the destination
+        // If he parent Dn is a referral, or has a referral ancestor, we have to issue a AffectMultipleDsas result
+        // as stated by RFC 3296 Section 5.6.2
+        if ( directoryService.getReferralManager().isReferral( newSuperiorDn )
+            || directoryService.getReferralManager().hasParentReferral( newSuperiorDn ) )
         {
-            pop();
-
-            LOG.debug( "<< MoveOperation successful" );
-            LOG_CHANGES.debug( "<< MoveOperation successful" );
-        }
+            // Unlock the referral manager
+            directoryService.getReferralManager().unlock();
+            
+            LdapAffectMultipleDsaException exception = new LdapAffectMultipleDsaException();
+            //exception.setRemainingName( dn );
+            
+            throw exception;
+        }
+        
+        // Unlock the ReferralManager
+        directoryService.getReferralManager().unlock();
+        
+        Entry originalEntry = getOriginalEntry( moveContext );
+        
+        moveContext.setOriginalEntry( originalEntry );
+        
+        // Call the Move method
+        Interceptor head = directoryService.getInterceptor( moveContext.getNextInterceptor() );
+        
+        head.move( moveContext );
+        
+        LOG.debug( "<< MoveOperation successful" );
+        LOG_CHANGES.debug( "<< MoveOperation successful" );
     }
 
 
@@ -841,102 +769,94 @@ public class DefaultOperationManager imp
         LOG_CHANGES.debug( ">> MoveAndRenameOperation : {}", moveAndRenameContext );
 
         ensureStarted();
-        push( moveAndRenameContext );
-
-        try
-        {
-            // Normalize the moveAndRenameContext Dn
-            Dn dn = moveAndRenameContext.getDn();
-            dn.apply( directoryService.getSchemaManager() );
-
-            // We have to deal with the referral first
-            directoryService.getReferralManager().lockRead();
-
-            // Check if we have an ancestor for this Dn
-            Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
 
-            if ( parentEntry != null )
+        // Normalize the moveAndRenameContext Dn
+        Dn dn = moveAndRenameContext.getDn();
+        dn.apply( directoryService.getSchemaManager() );
+        
+        // We have to deal with the referral first
+        directoryService.getReferralManager().lockRead();
+        
+        // Check if we have an ancestor for this Dn
+        Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
+        
+        if ( parentEntry != null )
+        {
+            // We have found a parent referral for the current Dn
+            Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
+            
+            if ( directoryService.getReferralManager().isReferral( dn ) )
+            {
+                // This is a referral. We can delete it if the ManageDsaIt flag is true
+                // Otherwise, we just throw a LdapReferralException
+                if ( !moveAndRenameContext.isReferralIgnored() )
+                {
+                    // Throw a Referral Exception
+                    // Unlock the referral manager
+                    directoryService.getReferralManager().unlock();
+                    
+                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                    throw exception;
+                }
+            }
+            else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
             {
-                // We have found a parent referral for the current Dn
-                Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-
-                if ( directoryService.getReferralManager().isReferral( dn ) )
+                // We can't delete an entry which has an ancestor referral
+                
+                // Depending on the Context.REFERRAL property value, we will throw
+                // a different exception.
+                if ( moveAndRenameContext.isReferralIgnored() )
                 {
-                    // This is a referral. We can delete it if the ManageDsaIt flag is true
-                    // Otherwise, we just throw a LdapReferralException
-                    if ( !moveAndRenameContext.isReferralIgnored() )
-                    {
-                        // Throw a Referral Exception
-                        // Unlock the referral manager
-                        directoryService.getReferralManager().unlock();
-
-                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                        throw exception;
-                    }
+                    directoryService.getReferralManager().unlock();
+                    
+                    LdapPartialResultException exception = buildLdapPartialResultException( childDn );
+                    throw exception;
                 }
-                else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
+                else
                 {
-                    // We can't delete an entry which has an ancestor referral
-
-                    // Depending on the Context.REFERRAL property value, we will throw
-                    // a different exception.
-                    if ( moveAndRenameContext.isReferralIgnored() )
-                    {
-                        directoryService.getReferralManager().unlock();
-
-                        LdapPartialResultException exception = buildLdapPartialResultException( childDn );
-                        throw exception;
-                    }
-                    else
-                    {
-                        // Unlock the referral manager
-                        directoryService.getReferralManager().unlock();
-
-                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                        throw exception;
-                    }
+                    // Unlock the referral manager
+                    directoryService.getReferralManager().unlock();
+                    
+                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                    throw exception;
                 }
             }
-
-            // Now, check the destination
-            // Normalize the moveAndRenameContext Dn
-            Dn newSuperiorDn = moveAndRenameContext.getNewSuperiorDn();
-            newSuperiorDn.apply( directoryService.getSchemaManager() );
-
-            // If he parent Dn is a referral, or has a referral ancestor, we have to issue a AffectMultipleDsas result
-            // as stated by RFC 3296 Section 5.6.2
-            if ( directoryService.getReferralManager().isReferral( newSuperiorDn )
-                || directoryService.getReferralManager().hasParentReferral( newSuperiorDn ) )
-            {
-                // Unlock the referral manager
-                directoryService.getReferralManager().unlock();
-
-                // The parent Dn is a referral, we have to issue a AffectMultipleDsas result
-                // as stated by RFC 3296 Section 5.6.2
-                LdapAffectMultipleDsaException exception = new LdapAffectMultipleDsaException();
-                //exception.setRemainingName( dn );
-
-                throw exception;
-            }
-
-            // Unlock the ReferralManager
-            directoryService.getReferralManager().unlock();
-
-            moveAndRenameContext.setOriginalEntry( getOriginalEntry( moveAndRenameContext ) );
-            moveAndRenameContext.setModifiedEntry( moveAndRenameContext.getOriginalEntry().clone() );
-
-            // Call the MoveAndRename method
-            Interceptor head = directoryService.getInterceptor( moveAndRenameContext.getNextInterceptor() );
-
-            head.moveAndRename( moveAndRenameContext );
         }
-        finally
+        
+        // Now, check the destination
+        // Normalize the moveAndRenameContext Dn
+        Dn newSuperiorDn = moveAndRenameContext.getNewSuperiorDn();
+        newSuperiorDn.apply( directoryService.getSchemaManager() );
+        
+        // If he parent Dn is a referral, or has a referral ancestor, we have to issue a AffectMultipleDsas result
+        // as stated by RFC 3296 Section 5.6.2
+        if ( directoryService.getReferralManager().isReferral( newSuperiorDn )
+            || directoryService.getReferralManager().hasParentReferral( newSuperiorDn ) )
         {
-            pop();
-
-            LOG.debug( "<< MoveAndRenameOperation successful" );
-            LOG_CHANGES.debug( "<< MoveAndRenameOperation successful" );
-        }
+            // Unlock the referral manager
+            directoryService.getReferralManager().unlock();
+            
+            // The parent Dn is a referral, we have to issue a AffectMultipleDsas result
+            // as stated by RFC 3296 Section 5.6.2
+            LdapAffectMultipleDsaException exception = new LdapAffectMultipleDsaException();
+            //exception.setRemainingName( dn );
+            
+            throw exception;
+        }
+        
+        // Unlock the ReferralManager
+        directoryService.getReferralManager().unlock();
+        
+        moveAndRenameContext.setOriginalEntry( getOriginalEntry( moveAndRenameContext ) );
+        moveAndRenameContext.setModifiedEntry( moveAndRenameContext.getOriginalEntry().clone() );
+        
+        // Call the MoveAndRename method
+        Interceptor head = directoryService.getInterceptor( moveAndRenameContext.getNextInterceptor() );
+        
+        head.moveAndRename( moveAndRenameContext );
+        
+        LOG.debug( "<< MoveAndRenameOperation successful" );
+        LOG_CHANGES.debug( "<< MoveAndRenameOperation successful" );
     }
 
 
@@ -949,94 +869,86 @@ public class DefaultOperationManager imp
         LOG_CHANGES.debug( ">> RenameOperation : {}", renameContext );
 
         ensureStarted();
-        push( renameContext );
-
-        try
-        {
-            // Normalize the renameContext Dn
-            Dn dn = renameContext.getDn();
-            dn.apply( directoryService.getSchemaManager() );
 
-            // Inject the newDn into the operation context
-            // Inject the new Dn into the context
-            if ( !dn.isEmpty() )
-            {
-                Dn newDn = dn.getParent();
-                newDn = newDn.add( renameContext.getNewRdn() );
-                renameContext.setNewDn( newDn );
+        // Normalize the renameContext Dn
+        Dn dn = renameContext.getDn();
+        dn.apply( directoryService.getSchemaManager() );
+        
+        // Inject the newDn into the operation context
+        // Inject the new Dn into the context
+        if ( !dn.isEmpty() )
+        {
+            Dn newDn = dn.getParent();
+            newDn = newDn.add( renameContext.getNewRdn() );
+            renameContext.setNewDn( newDn );
+        }
+        
+        // We have to deal with the referral first
+        directoryService.getReferralManager().lockRead();
+        
+        // Check if we have an ancestor for this Dn
+        Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
+        
+        if ( parentEntry != null )
+        {
+            // We have found a parent referral for the current Dn
+            Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
+            
+            if ( directoryService.getReferralManager().isReferral( dn ) )
+            {
+                // This is a referral. We can delete it if the ManageDsaIt flag is true
+                // Otherwise, we just throw a LdapReferralException
+                if ( !renameContext.isReferralIgnored() )
+                {
+                    // Throw a Referral Exception
+                    // Unlock the referral manager
+                    directoryService.getReferralManager().unlock();
+                    
+                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                    throw exception;
+                }
             }
-
-            // We have to deal with the referral first
-            directoryService.getReferralManager().lockRead();
-
-            // Check if we have an ancestor for this Dn
-            Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
-
-            if ( parentEntry != null )
+            else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
             {
-                // We have found a parent referral for the current Dn
-                Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-
-                if ( directoryService.getReferralManager().isReferral( dn ) )
+                // We can't delete an entry which has an ancestor referral
+                
+                // Depending on the Context.REFERRAL property value, we will throw
+                // a different exception.
+                if ( renameContext.isReferralIgnored() )
+                {
+                    directoryService.getReferralManager().unlock();
+                    
+                    LdapPartialResultException exception = buildLdapPartialResultException( childDn );
+                    throw exception;
+                }
+                else
                 {
-                    // This is a referral. We can delete it if the ManageDsaIt flag is true
-                    // Otherwise, we just throw a LdapReferralException
-                    if ( !renameContext.isReferralIgnored() )
-                    {
-                        // Throw a Referral Exception
-                        // Unlock the referral manager
-                        directoryService.getReferralManager().unlock();
-
-                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                        throw exception;
-                    }
-                }
-                else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
-                {
-                    // We can't delete an entry which has an ancestor referral
-
-                    // Depending on the Context.REFERRAL property value, we will throw
-                    // a different exception.
-                    if ( renameContext.isReferralIgnored() )
-                    {
-                        directoryService.getReferralManager().unlock();
-
-                        LdapPartialResultException exception = buildLdapPartialResultException( childDn );
-                        throw exception;
-                    }
-                    else
-                    {
-                        // Unlock the referral manager
-                        directoryService.getReferralManager().unlock();
-
-                        LdapReferralException exception = buildReferralException( parentEntry, childDn );
-                        throw exception;
-                    }
+                    // Unlock the referral manager
+                    directoryService.getReferralManager().unlock();
+                    
+                    LdapReferralException exception = buildReferralException( parentEntry, childDn );
+                    throw exception;
                 }
             }
-
-            // Unlock the ReferralManager
-            directoryService.getReferralManager().unlock();
-
-            // Call the rename method
-            // populate the context with the old entry
-            eagerlyPopulateFields( renameContext );
-            Entry originalEntry = getOriginalEntry( renameContext );
-            renameContext.setOriginalEntry( originalEntry );
-            renameContext.setModifiedEntry( originalEntry.clone() );
-
-            // Call the Rename method
-            Interceptor head = directoryService.getInterceptor( renameContext.getNextInterceptor() );
-
-            head.rename( renameContext );
-        }
-        finally
-        {
-            pop();
-
-            LOG.debug( "<< RenameOperation successful" );
-            LOG_CHANGES.debug( "<< RenameOperation successful" );
         }
+        
+        // Unlock the ReferralManager
+        directoryService.getReferralManager().unlock();
+        
+        // Call the rename method
+        // populate the context with the old entry
+        eagerlyPopulateFields( renameContext );
+        Entry originalEntry = getOriginalEntry( renameContext );
+        renameContext.setOriginalEntry( originalEntry );
+        renameContext.setModifiedEntry( originalEntry.clone() );
+        
+        // Call the Rename method
+        Interceptor head = directoryService.getInterceptor( renameContext.getNextInterceptor() );
+        
+        head.rename( renameContext );
+        
+        LOG.debug( "<< RenameOperation successful" );
+        LOG_CHANGES.debug( "<< RenameOperation successful" );
     }
 
 
@@ -1048,79 +960,73 @@ public class DefaultOperationManager imp
         LOG.debug( ">> SearchOperation : {}", searchContext );
 
         ensureStarted();
-        push( searchContext );
-
-        try
-        {
-            // Normalize the searchContext Dn
-            Dn dn = searchContext.getDn();
-            dn.apply( directoryService.getSchemaManager() );
 
-            // We have to deal with the referral first
-            directoryService.getReferralManager().lockRead();
-
-            // Check if we have an ancestor for this Dn
-            Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
-
-            if ( parentEntry != null )
+        // Normalize the searchContext Dn
+        Dn dn = searchContext.getDn();
+        dn.apply( directoryService.getSchemaManager() );
+        
+        // We have to deal with the referral first
+        directoryService.getReferralManager().lockRead();
+        
+        // Check if we have an ancestor for this Dn
+        Entry parentEntry = directoryService.getReferralManager().getParentReferral( dn );
+        
+        if ( parentEntry != null )
+        {
+            // We have found a parent referral for the current Dn
+            Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
+            
+            if ( directoryService.getReferralManager().isReferral( dn ) )
+            {
+                // This is a referral. We can return it if the ManageDsaIt flag is true
+                // Otherwise, we just throw a LdapReferralException
+                if ( !searchContext.isReferralIgnored() )
+                {
+                    // Throw a Referral Exception
+                    // Unlock the referral manager
+                    directoryService.getReferralManager().unlock();
+                    
+                    LdapReferralException exception = buildReferralExceptionForSearch( parentEntry, childDn,
+                        searchContext.getScope() );
+                    throw exception;
+                }
+            }
+            else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
             {
-                // We have found a parent referral for the current Dn
-                Dn childDn = dn.getDescendantOf( parentEntry.getDn() );
-
-                if ( directoryService.getReferralManager().isReferral( dn ) )
+                // We can't search an entry which has an ancestor referral
+                
+                // Depending on the Context.REFERRAL property value, we will throw
+                // a different exception.
+                if ( searchContext.isReferralIgnored() )
+                {
+                    directoryService.getReferralManager().unlock();
+                    
+                    LdapPartialResultException exception = buildLdapPartialResultException( childDn );
+                    throw exception;
+                }
+                else
                 {
-                    // This is a referral. We can return it if the ManageDsaIt flag is true
-                    // Otherwise, we just throw a LdapReferralException
-                    if ( !searchContext.isReferralIgnored() )
-                    {
-                        // Throw a Referral Exception
-                        // Unlock the referral manager
-                        directoryService.getReferralManager().unlock();
-
-                        LdapReferralException exception = buildReferralExceptionForSearch( parentEntry, childDn,
-                            searchContext.getScope() );
-                        throw exception;
-                    }
-                }
-                else if ( directoryService.getReferralManager().hasParentReferral( dn ) )
-                {
-                    // We can't search an entry which has an ancestor referral
-
-                    // Depending on the Context.REFERRAL property value, we will throw
-                    // a different exception.
-                    if ( searchContext.isReferralIgnored() )
-                    {
-                        directoryService.getReferralManager().unlock();
-
-                        LdapPartialResultException exception = buildLdapPartialResultException( childDn );
-                        throw exception;
-                    }
-                    else
-                    {
-                        // Unlock the referral manager
-                        directoryService.getReferralManager().unlock();
-
-                        LdapReferralException exception = buildReferralExceptionForSearch( parentEntry, childDn,
-                            searchContext.getScope() );
-                        throw exception;
-                    }
+                    // Unlock the referral manager
+                    directoryService.getReferralManager().unlock();
+                    
+                    LdapReferralException exception = buildReferralExceptionForSearch( parentEntry, childDn,
+                        searchContext.getScope() );
+                    throw exception;
                 }
             }
-
-            // Unlock the ReferralManager
-            directoryService.getReferralManager().unlock();
-
-            // Call the Search method
-            Interceptor head = directoryService.getInterceptor( searchContext.getNextInterceptor() );
-
-            return head.search( searchContext );
-        }
-        finally
-        {
-            pop();
-
-            LOG.debug( "<< SearchOperation successful" );
         }
+        
+        // Unlock the ReferralManager
+        directoryService.getReferralManager().unlock();
+        
+        // Call the Search method
+        Interceptor head = directoryService.getInterceptor( searchContext.getNextInterceptor() );
+        
+        EntryFilteringCursor cursor = head.search( searchContext );
+        
+        LOG.debug( "<< SearchOperation successful" );
+        
+        return cursor;
     }
 
 
@@ -1132,7 +1038,6 @@ public class DefaultOperationManager imp
         LOG.debug( ">> UnbindOperation : {}", unbindContext );
 
         ensureStarted();
-        push( unbindContext );
 
         try
         {
@@ -1143,7 +1048,6 @@ public class DefaultOperationManager imp
         }
         finally
         {
-            pop();
         }
 
         LOG.debug( "<< UnbindOperation successful" );
@@ -1157,20 +1061,4 @@ public class DefaultOperationManager imp
             throw new LdapServiceUnavailableException( ResultCodeEnum.UNAVAILABLE, I18n.err( I18n.ERR_316 ) );
         }
     }
-
-
-    private void pop()
-    {
-        // TODO - need to remove Context caller and PartitionNexusProxy from Invocations
-        InvocationStack stack = InvocationStack.getInstance();
-        stack.pop();
-    }
-
-
-    private void push( OperationContext opContext )
-    {
-        // TODO - need to remove Context caller and PartitionNexusProxy from Invocations
-        InvocationStack stack = InvocationStack.getInstance();
-        stack.push( opContext );
-    }
 }



Mime
View raw message