directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r946798 - in /directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core: DefaultOperationManager.java authz/AciAuthorizationInterceptor.java exception/ExceptionInterceptor.java referral/ReferralInterceptor.java
Date Thu, 20 May 2010 21:32:36 GMT
Author: elecharny
Date: Thu May 20 21:32:36 2010
New Revision: 946798

URL: http://svn.apache.org/viewvc?rev=946798&view=rev
Log:
Speed up the delete operation by removing useless calls to lookup(), entry existence, child
existence.
Minor refactoring done

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.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=946798&r1=946797&r2=946798&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
Thu May 20 21:32:36 2010
@@ -396,7 +396,7 @@ public class DefaultOperationManager imp
             if ( parentEntry != null )
             {
                 // We have found a parent referral for the current DN 
-                DN childDn = (DN)dn.getSuffix( parentEntry.getDn().size() );
+                DN childDn = dn.getSuffix( parentEntry.getDn().size() );
     
                 if ( directoryService.getReferralManager().isReferral( dn ) )
                 {

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java?rev=946798&r1=946797&r2=946798&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
Thu May 20 21:32:36 2010
@@ -495,42 +495,47 @@ public class AciAuthorizationInterceptor
 
     public void delete( NextInterceptor next, DeleteOperationContext deleteContext ) throws
Exception
     {
+        CoreSession session = deleteContext.getSession();
+        
         // bypass authz code if we are disabled
-        if ( ! deleteContext.getSession().getDirectoryService().isAccessControlEnabled()
)
+        if ( ! session.getDirectoryService().isAccessControlEnabled() )
         {
             next.delete( deleteContext );
             return;
         }
 
-        DN name = deleteContext.getDn();
-        LdapPrincipal principal = deleteContext.getSession().getEffectivePrincipal();
+        DN dn = deleteContext.getDn();
+        LdapPrincipal principal = session.getEffectivePrincipal();
         DN principalDn = principal.getDN();
 
-        Entry entry = deleteContext.lookup( name, ByPassConstants.LOOKUP_BYPASS );
+        Entry entry = deleteContext.getEntry();
 
-        protectCriticalEntries( name );
+        protectCriticalEntries( dn );
 
         // bypass authz code but manage caches if operation is performed by the admin
         if ( isPrincipalAnAdministrator( principalDn ) )
         {
             next.delete( deleteContext );
-            tupleCache.subentryDeleted( name, entry );
-            groupCache.groupDeleted( name, entry );
+            
+            tupleCache.subentryDeleted( dn, entry );
+            groupCache.groupDeleted( dn, entry );
+            
             return;
         }
 
         Set<DN> userGroups = groupCache.getGroups( principalDn.getNormName() );
         Collection<ACITuple> tuples = new HashSet<ACITuple>();
-        addPerscriptiveAciTuples( deleteContext, tuples, name, ((ClonedServerEntry)entry).getOriginalEntry()
);
+        addPerscriptiveAciTuples( deleteContext, tuples, dn, ((ClonedServerEntry)entry).getOriginalEntry()
);
         addEntryAciTuples( tuples, entry );
-        addSubentryAciTuples( deleteContext, tuples, name, entry );
+        addSubentryAciTuples( deleteContext, tuples, dn, entry );
 
         engine.checkPermission( schemaManager, deleteContext, userGroups, principalDn, 
-            principal.getAuthenticationLevel(), name, null, null, REMOVE_PERMS, tuples, entry,
null );
+            principal.getAuthenticationLevel(), dn, null, null, REMOVE_PERMS, tuples, entry,
null );
 
         next.delete( deleteContext );
-        tupleCache.subentryDeleted( name, entry );
-        groupCache.groupDeleted( name, entry );
+        
+        tupleCache.subentryDeleted( dn, entry );
+        groupCache.groupDeleted( dn, entry );
     }
 
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java?rev=946798&r1=946797&r2=946798&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
Thu May 20 21:32:36 2010
@@ -54,7 +54,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.exception.LdapAliasException;
 import org.apache.directory.shared.ldap.exception.LdapAttributeInUseException;
-import org.apache.directory.shared.ldap.exception.LdapContextNotEmptyException;
 import org.apache.directory.shared.ldap.exception.LdapEntryAlreadyExistsException;
 import org.apache.directory.shared.ldap.exception.LdapNoSuchObjectException;
 import org.apache.directory.shared.ldap.exception.LdapUnwillingToPerformException;
@@ -216,45 +215,24 @@ public class ExceptionInterceptor extend
      */
     public void delete( NextInterceptor nextInterceptor, DeleteOperationContext opContext
) throws Exception
     {
-        DN name = opContext.getDn();
+        DN dn = opContext.getDn();
         
-        if ( name.getNormName().equalsIgnoreCase( subschemSubentryDn.getNormName() ) )
+        if ( dn.equals( subschemSubentryDn ) )
         {
             throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM,
                 I18n.err( I18n.ERR_253, subschemSubentryDn ) );
         }
         
-        // check if entry to delete exists
-        String msg = "Attempt to delete non-existant entry: ";
-        assertHasEntry( opContext, msg, name );
-
-        // check if entry to delete has children (only leaves can be deleted)
-        boolean hasChildren = false;
-        EntryFilteringCursor list = nextInterceptor.list( new ListOperationContext( opContext.getSession(),
name ) );
-        
-        if ( list.next() )
-        {
-            hasChildren = true;
-        }
-
-        list.close();
-        
-        if ( hasChildren )
-        {
-            LdapContextNotEmptyException e = new LdapContextNotEmptyException();
-            //e.setResolvedName( new DN( name.getName() ) );
-            throw e;
-        }
+        nextInterceptor.delete( opContext );
 
+        // Update the alias cache
         synchronized( notAliasCache )
         {
-            if ( notAliasCache.containsKey( name.getNormName() ) )
+            if ( notAliasCache.containsKey( dn.getNormName() ) )
             {
-                notAliasCache.remove( name.getNormName() );
+                notAliasCache.remove( dn.getNormName() );
             }
         }
-        
-        nextInterceptor.delete( opContext );
     }
 
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java?rev=946798&r1=946797&r2=946798&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java
Thu May 20 21:32:36 2010
@@ -270,11 +270,11 @@ public class ReferralInterceptor extends
      */
     public void delete( NextInterceptor next, DeleteOperationContext opContext ) throws Exception
     {
-        Entry entry = opContext.getEntry();
-
         // First delete the entry into the server
         next.delete( opContext );
         
+        Entry entry = opContext.getEntry();
+
         // Check if the entry exists and is a referral itself
         // If so, we have to update the referralManager
         if ( ( entry != null ) && isReferral( entry ) )



Mime
View raw message