You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2011/01/11 16:55:32 UTC

svn commit: r1057706 - in /directory/apacheds/branches/apacheds-AP: core-api/src/main/java/org/apache/directory/server/core/interceptor/ core-api/src/main/java/org/apache/directory/server/core/partition/ core/src/main/java/org/apache/directory/server/c...

Author: elecharny
Date: Tue Jan 11 15:55:32 2011
New Revision: 1057706

URL: http://svn.apache.org/viewvc?rev=1057706&view=rev
Log:
o Bypassing the CollectiveAttribte when doing a Lookup inside the server
o When we do a lookup operation on a non existing entry, the Partition layer is now handling the case and throw a LdapNoSuchObjectException
o Cleanup many if (entry==null) in interceptors, now that the partition is throwing a LdapNoSuchObjectException
o Many fixes in SubentryInterceptor, mainly handling the removal of UUID references when the subentry has been deleted
o Avoided a lookup in triggerInterceptor

Modified:
    directory/apacheds/branches/apacheds-AP/core-api/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java
    directory/apacheds/branches/apacheds-AP/core-api/src/main/java/org/apache/directory/server/core/partition/ByPassConstants.java
    directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java
    directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
    directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
    directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
    directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
    directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
    directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/trigger/ModifyStoredProcedureParameterInjector.java

Modified: directory/apacheds/branches/apacheds-AP/core-api/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core-api/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java?rev=1057706&r1=1057705&r2=1057706&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core-api/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java (original)
+++ directory/apacheds/branches/apacheds-AP/core-api/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java Tue Jan 11 15:55:32 2011
@@ -571,9 +571,10 @@ public class InterceptorChain
             // We have to use the admin session here, otherwise we may have
             // trouble reading the entry due to insufficient access rights
             CoreSession adminSession = opContext.getSession().getDirectoryService().getAdminSession();
+            LookupOperationContext lookupContext = new LookupOperationContext( adminSession, opContext.getDn(), SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES_ARRAY );
+            lookupContext.setByPassed( ByPassConstants.LOOKUP_BYPASS );
 
-            Entry foundEntry = adminSession
-                .lookup( opContext.getDn(), SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES_ARRAY );
+            Entry foundEntry = directoryService.getOperationManager().lookup( lookupContext );
 
             if ( foundEntry != null )
             {
@@ -1114,6 +1115,7 @@ public class InterceptorChain
                     }
                     catch ( Throwable e )
                     {
+                        e.printStackTrace();
                         throwInterceptorException( interceptor, e );
                         throw new InternalError(); // Should be unreachable
                     }

Modified: directory/apacheds/branches/apacheds-AP/core-api/src/main/java/org/apache/directory/server/core/partition/ByPassConstants.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core-api/src/main/java/org/apache/directory/server/core/partition/ByPassConstants.java?rev=1057706&r1=1057705&r2=1057706&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core-api/src/main/java/org/apache/directory/server/core/partition/ByPassConstants.java (original)
+++ directory/apacheds/branches/apacheds-AP/core-api/src/main/java/org/apache/directory/server/core/partition/ByPassConstants.java Tue Jan 11 15:55:32 2011
@@ -80,10 +80,12 @@ public class ByPassConstants
     static
     {
         Collection<String> c = new HashSet<String>();
+        c.add( "org.apache.directory.server.core.normalization.AdministrativePointInterceptor" );
         c.add( "org.apache.directory.server.core.normalization.NormalizationInterceptor" );
         c.add( "org.apache.directory.server.core.authn.AuthenticationInterceptor" );
         c.add( "org.apache.directory.server.core.authz.AciAuthorizationInterceptor" );
         c.add( "org.apache.directory.server.core.authz.DefaultAuthorizationInterceptor" );
+        c.add( "org.apache.directory.server.core.collective.CollectiveAttributeInterceptor" );
         c.add( "org.apache.directory.server.core.referral.ReferralInterceptor" );
         c.add( "org.apache.directory.server.core.changelog.ChangeLogInterceptor" );
         c.add( "org.apache.directory.server.core.operational.OperationalAttributeInterceptor" );
@@ -95,6 +97,7 @@ public class ByPassConstants
         LOOKUP_BYPASS = Collections.unmodifiableCollection( c );
 
         c = new HashSet<String>();
+        c.add( "org.apache.directory.server.core.normalization.AdministrativePointInterceptor" );
         c.add( "org.apache.directory.server.core.normalization.NormalizationInterceptor" );
         c.add( "org.apache.directory.server.core.authn.AuthenticationInterceptor" );
         c.add( "org.apache.directory.server.core.authz.AciAuthorizationInterceptor" );

Modified: directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java?rev=1057706&r1=1057705&r2=1057706&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java Tue Jan 11 15:55:32 2011
@@ -154,11 +154,6 @@ public class CollectiveAttributeIntercep
     {
         Entry result = nextInterceptor.lookup( lookupContext );
 
-        if ( result == null )
-        {
-            return null;
-        }
-
         // Adding the collective attributes if any
         if ( ( lookupContext.getAttrsId() == null ) || ( lookupContext.getAttrsId().size() == 0 ) )
         {
@@ -339,8 +334,7 @@ public class CollectiveAttributeIntercep
      */
     private void addCollectiveAttributes( OperationContext opContext, Entry entry, String[] retAttrs ) throws LdapException
     {
-        EntryAttribute collectiveAttributeSubentries = ( ( ClonedServerEntry ) entry ).getOriginalEntry().get(
-            COLLECTIVE_ATTRIBUTE_SUBENTRIES_UUID_AT );
+        EntryAttribute collectiveAttributeSubentries = entry.get( COLLECTIVE_ATTRIBUTE_SUBENTRIES_UUID_AT );
 
         /*
          * If there are no collective attribute subentries referenced then we 

Modified: directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java?rev=1057706&r1=1057705&r2=1057706&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java Tue Jan 11 15:55:32 2011
@@ -267,17 +267,7 @@ public class ExceptionInterceptor extend
             return nexus.getRootDSE( null );
         }
 
-        Entry result = nextInterceptor.lookup( lookupContext );
-
-        if ( result == null )
-        {
-            LdapNoSuchObjectException e = new LdapNoSuchObjectException( "Attempt to lookup non-existant entry: "
-                + dn.getName() );
-
-            throw e;
-        }
-
-        return result;
+        return nextInterceptor.lookup( lookupContext );
     }
 
 

Modified: directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java?rev=1057706&r1=1057705&r2=1057706&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java Tue Jan 11 15:55:32 2011
@@ -380,11 +380,6 @@ public class OperationalAttributeInterce
     {
         Entry result = nextInterceptor.lookup( lookupContext );
 
-        if ( result == null )
-        {
-            return null;
-        }
-
         if ( lookupContext.getAttrsId() == null )
         {
             filterOperationalAttributes( result );

Modified: directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java?rev=1057706&r1=1057705&r2=1057706&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java (original)
+++ directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java Tue Jan 11 15:55:32 2011
@@ -621,7 +621,19 @@ public class DefaultPartitionNexus exten
         }
 
         Partition backend = getPartition( dn );
-        return backend.lookup( lookupContext );
+        Entry entry = backend.lookup( lookupContext );
+
+        if ( entry == null )
+        {
+            LdapNoSuchObjectException e = new LdapNoSuchObjectException( "Attempt to lookup non-existant entry: "
+                + dn.getName() );
+
+            throw e;
+        }
+        else
+        {
+            return ( ClonedServerEntry ) entry;
+        }
     }
 
 

Modified: directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java?rev=1057706&r1=1057705&r2=1057706&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java Tue Jan 11 15:55:32 2011
@@ -759,11 +759,6 @@ public class SchemaInterceptor extends B
     {
         Entry result = nextInterceptor.lookup( lookupContext );
 
-        if ( result == null )
-        {
-            return null;
-        }
-
         filterBinaryAttributes( result );
 
         return result;

Modified: directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java?rev=1057706&r1=1057705&r2=1057706&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java Tue Jan 11 15:55:32 2011
@@ -699,7 +699,7 @@ public class SubentryInterceptor extends
         List<Modification> modificationTes = updateEntry( entry, directoryService.getTriggerExecutionAPCache(), TRIGGER_EXECUTION_SEQ_NUMBER_AT, TRIGGER_EXECUTION_SUBENTRIES_UUID_AT );
         List<Modification> modifications = null;
         
-        if ( ( modificationAcs != null ) || ( modificationCas != null ) || ( modificationSss != null ) || (modificationTes != null ) )
+        if ( ( modificationAcs != null ) || ( modificationCas != null ) || ( modificationSss != null ) || ( modificationTes != null ) )
         {
             modifications = new ArrayList<Modification>();
             
@@ -746,7 +746,6 @@ public class SubentryInterceptor extends
         DN entryDn = entry.getDn();
         List<Modification> modifications = null;
         
-        
         DnNode<AdministrativePoint> apNode = apCache.getParentWithElement( entryDn );
         
         if ( apNode != null )
@@ -827,6 +826,17 @@ public class SubentryInterceptor extends
 
                     modifications.add( subentryUuiMod );
                 }
+                else
+                {
+                    // We may have to remove UUID refs from the entry
+                    if ( entry.containsAttribute( subentryUuidAT ) )
+                    {
+                        EntryAttribute newSubentryUuidAT = new DefaultEntryAttribute( subentryUuidAT );
+                        Modification subentryUuiMod = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, newSubentryUuidAT );
+
+                        modifications.add( subentryUuiMod );
+                    }
+                }
             }
         }
 
@@ -1871,7 +1881,7 @@ public class SubentryInterceptor extends
     /**
      * Inject the seqNumbers in an AP
      */
-    private long updateAPSeqNumbers( DN apDn, Entry entry, Subentry[] subentries ) throws LdapException
+    private long updateAPSeqNumbers( OperationEnum operation, DN apDn, Entry entry, Subentry[] subentries ) throws LdapException
     {
         long seqNumber = directoryService.getNewApSeqNumber();
         String seqNumberStr = Long.toString( seqNumber );
@@ -1915,11 +1925,20 @@ public class SubentryInterceptor extends
             Modification modification = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, newSeqNumber );
             modifications.add( modification );
 
-            // Get back the subentry entryUUID and store it in the subentry
-            String subentryUuid = entry.get( SchemaConstants.ENTRY_UUID_AT ).getString();
-            subentry.setUuid( subentryUuid );
-            adminPoint.addSubentry( subentry );
-            adminPoint.setSeqNumber( seqNumber );
+            // Get back the subentry entryUUID and store it in the subentry if this is an addition
+            switch ( operation )
+            {
+                case ADD :
+                    String subentryUuid = entry.get( SchemaConstants.ENTRY_UUID_AT ).getString();
+                    subentry.setUuid( subentryUuid );
+                    adminPoint.addSubentry( subentry );
+                    adminPoint.setSeqNumber( seqNumber );
+                    break;
+                    
+                case REMOVE :
+                    adminPoint.setSeqNumber( seqNumber );
+                    break;
+            }
         }
         
         // Inject the seqNumbers into the parent AP
@@ -2195,7 +2214,7 @@ public class SubentryInterceptor extends
                 next.add( addContext );
                     
                 // Update the seqNumber and update the parent AP
-                updateAPSeqNumbers( apDn, entry, subentries );
+                updateAPSeqNumbers( OperationEnum.ADD, apDn, entry, subentries );
                 
                 // Update the subentry cache
                 for ( Subentry subentry : subentries )
@@ -2226,6 +2245,9 @@ public class SubentryInterceptor extends
     }
     
     
+    /**
+     * Remove the subentry from the associated AP, and update the AP seqNumber
+     */
     private void deleteAPSubentry(DnNode<AdministrativePoint> cache, DN apDn, Subentry subentry )
     {
         AdministrativePoint adminPoint = cache.getElement( apDn );
@@ -2324,13 +2346,14 @@ public class SubentryInterceptor extends
                         
                 }
 
-                // And cleanup the subentry cache
+                // Cleanup the subentry cache
                 directoryService.getSubentryCache().removeSubentry( dn );
+                
             }
             
             // And finally, update the parent AP SeqNumber for each role the subentry manage
             //Set<AdministrativeRoleEnum> subentryRoles = subentry.getAdministrativeRoles();
-            updateAPSeqNumbers( apDn, entry, subentries );
+            updateAPSeqNumbers( OperationEnum.REMOVE, apDn, entry, subentries );
         }
         else
         {
@@ -2805,8 +2828,11 @@ public class SubentryInterceptor extends
 
             for ( Subentry subentry : subentries )
             {
-                subentry.setCn( newCn );
-                directoryService.getSubentryCache().addSubentry( newDn, subentry );
+                if ( subentry != null )
+                {
+                    subentry.setCn( newCn );
+                    directoryService.getSubentryCache().addSubentry( newDn, subentry );
+                }
             }
         }
         else

Modified: directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/trigger/ModifyStoredProcedureParameterInjector.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/trigger/ModifyStoredProcedureParameterInjector.java?rev=1057706&r1=1057705&r2=1057706&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/trigger/ModifyStoredProcedureParameterInjector.java (original)
+++ directory/apacheds/branches/apacheds-AP/core/src/main/java/org/apache/directory/server/core/trigger/ModifyStoredProcedureParameterInjector.java Tue Jan 11 15:55:32 2011
@@ -47,7 +47,7 @@ public class ModifyStoredProcedureParame
         super( opContext );
         modifiedEntryName = opContext.getDn();
         modifications = opContext.getModItems();
-        this.oldEntry = getEntry( opContext );
+        this.oldEntry = opContext.getOriginalEntry();
         Map<Class<?>, MicroInjector> injectors = super.getInjectors();
         injectors.put( StoredProcedureParameter.Modify_OBJECT.class, $objectInjector );
         injectors.put( StoredProcedureParameter.Modify_MODIFICATION.class, $modificationInjector );