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/11/12 19:24:43 UTC

svn commit: r1201297 [8/9] - in /directory/apacheds/branches/apacheds-txns: all/ apache-felix/ core-annotations/ core-api/ core-api/src/main/java/org/apache/directory/server/core/api/ core-api/src/main/java/org/apache/directory/server/core/api/intercep...

Modified: directory/apacheds/branches/apacheds-txns/interceptors/referral/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/interceptors/referral/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java?rev=1201297&r1=1201296&r2=1201297&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/interceptors/referral/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-txns/interceptors/referral/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java Sat Nov 12 18:24:38 2011
@@ -6,28 +6,27 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ * 
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ * 
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ * 
  */
 package org.apache.directory.server.core.referral;
 
 
 import javax.naming.Context;
 
-import org.apache.directory.server.core.shared.ReferralManagerImpl;
 import org.apache.directory.server.core.api.DirectoryService;
+import org.apache.directory.server.core.api.InterceptorEnum;
 import org.apache.directory.server.core.api.ReferralManager;
 import org.apache.directory.server.core.api.entry.ClonedServerEntry;
 import org.apache.directory.server.core.api.interceptor.BaseInterceptor;
-import org.apache.directory.server.core.api.interceptor.NextInterceptor;
 import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.DeleteOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.LookupOperationContext;
@@ -36,6 +35,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.api.interceptor.context.MoveOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.RenameOperationContext;
 import org.apache.directory.server.core.api.partition.PartitionNexus;
+import org.apache.directory.server.core.shared.ReferralManagerImpl;
 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;
@@ -53,9 +53,9 @@ import org.slf4j.LoggerFactory;
 
 
 /**
- * An service which is responsible referral handling behavoirs.  It manages 
+ * An service which is responsible referral handling behavoirs.  It manages
  * referral handling behavoir when the {@link Context#REFERRAL} is implicitly
- * or explicitly set to "ignore", when set to "throw" and when set to "follow". 
+ * or explicitly set to "ignore", when set to "throw" and when set to "follow".
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -140,7 +140,7 @@ public class ReferralInterceptor extends
     static private boolean isReferral( Entry entry ) throws LdapException
     {
         // Check that the entry is not null, otherwise return FALSE.
-        // This is typically to cover the case where the entry has not 
+        // 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 )
         {
@@ -192,6 +192,14 @@ public class ReferralInterceptor extends
         }
     }
 
+    /**
+     * Creates a new instance of a ReferralInterceptor.
+     */
+    public ReferralInterceptor()
+    {
+        super( InterceptorEnum.REFERRAL_INTERCEPTOR );
+    }
+
 
     public void init( DirectoryService directoryService ) throws LdapException
     {
@@ -203,7 +211,7 @@ public class ReferralInterceptor extends
         referralManager = new ReferralManagerImpl( directoryService );
         directoryService.setReferralManager( referralManager );
 
-        Value<?> subschemaSubentry = nexus.getRootDSE( null ).get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT ).get();
+        Value<?> subschemaSubentry = nexus.getRootDse( null ).get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT ).get();
         subschemaSubentryDn = directoryService.getDnFactory().create( subschemaSubentry.getString() );
     }
 
@@ -216,16 +224,19 @@ public class ReferralInterceptor extends
      * 
      * Case (1) is easy : we inject the entry into the server and we are done.
      * Case (2) is the same as case (1), but we have to update the referral manager.
-     * Case (3) is handled by the LdapProcotol handler, as we have to return a 
-     * LdapResult containing a list of this entry's parent's referrals URL, if the 
-     * ManageDSAIT control is not present, or the parent's entry if the control 
-     * is present. 
+     * Case (3) is handled by the LdapProcotol handler, as we have to return a
+     * LdapResult containing a list of this entry's parent's referrals URL, if the
+     * ManageDSAIT control is not present, or the parent's entry if the control
+     * is present.
      * 
      * Of course, if the entry already exists, nothing will be done, as we will get an
      * entryAlreadyExists error.
-     *  
+     * 
+     */
+    /**
+     * {@inheritDoc}
      */
-    public void add( NextInterceptor next, AddOperationContext addContext ) throws LdapException
+    public void add( AddOperationContext addContext ) throws LdapException
     {
         Entry entry = addContext.getEntry();
 
@@ -233,9 +244,9 @@ public class ReferralInterceptor extends
         boolean isReferral = isReferral( entry );
 
         // We add the entry into the server
-        next.add( addContext );
+        next( addContext );
 
-        // If the addition is successful, we update the referralManager 
+        // If the addition is successful, we update the referralManager
         if ( isReferral )
         {
             // We have to add it to the referralManager
@@ -255,12 +266,15 @@ public class ReferralInterceptor extends
      * (3) the entry is a referral
      * 
      * Case (1) is handled by removing the entry from the server
-     * In case (2), we return an exception build using the parent referral 
+     * In case (2), we return an exception build using the parent referral
      * For case(3), we remove the entry from the server and remove the referral
      * from the referral manager.
      * 
      * If the entry does not exist in the server, we will get a NoSuchObject error
      */
+    /**
+     * {@inheritDoc}
+     */
     public void delete( DeleteOperationContext deleteContext ) throws LdapException
     {
         // First delete the entry into the server
@@ -284,15 +298,61 @@ public class ReferralInterceptor extends
 
     /**
      * {@inheritDoc}
+     */
+    public void modify( ModifyOperationContext modifyContext ) throws LdapException
+    {
+        Dn dn = modifyContext.getDn();
+
+        // handle a normal modify without following referrals
+        next( modifyContext );
+
+        // Check if we are trying to modify the schema or the rootDSE,
+        // if so, we don't modify the referralManager
+        if ( dn.isEmpty() || dn.equals( subschemaSubentryDn ) )
+        {
+            // Do nothing
+            return;
+        }
+
+        // Update the referralManager. We have to read the entry again
+        // as it has been modified, before updating the ReferralManager
+        // TODO: this can be spare, as we already have the altered entry
+        // into the opContext, but for an unknow reason, this will fail
+        // on eferral tests...
+        LookupOperationContext lookupContext = new LookupOperationContext( modifyContext.getSession(), dn );
+        lookupContext.setAttrsId( SchemaConstants.ALL_ATTRIBUTES_ARRAY );
+
+        Entry newEntry = nexus.lookup( lookupContext );
+
+        // Update the referralManager.
+        // Check that we have the entry, just in case
+        // TODO : entries should be locked until the operation is done on it.
+        if ( newEntry != null )
+        {
+            referralManager.lockWrite();
+
+            if ( referralManager.isReferral( newEntry.getDn() ) )
+            {
+                referralManager.removeReferral( modifyContext.getEntry() );
+                referralManager.addReferral( newEntry );
+            }
+
+            referralManager.unlock();
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
      **/
-    public void move( NextInterceptor next, MoveOperationContext moveContext ) throws LdapException
+    public void move( MoveOperationContext moveContext ) throws LdapException
     {
         Dn newDn = moveContext.getNewDn();
 
         // Check if the entry is a referral itself
         boolean isReferral = isReferral( moveContext.getOriginalEntry() );
 
-        next.move( moveContext );
+        next( moveContext );
 
         if ( isReferral )
         {
@@ -310,12 +370,12 @@ public class ReferralInterceptor extends
     /**
      * {@inheritDoc}
      **/
-    public void moveAndRename( NextInterceptor next, MoveAndRenameOperationContext moveAndRenameContext ) throws LdapException
+    public void moveAndRename( MoveAndRenameOperationContext moveAndRenameContext ) throws LdapException
     {
         // Check if the entry is a referral itself
         boolean isReferral = isReferral( moveAndRenameContext.getOriginalEntry() );
 
-        next.moveAndRename( moveAndRenameContext );
+        next( moveAndRenameContext );
 
         if ( isReferral )
         {
@@ -335,12 +395,12 @@ public class ReferralInterceptor extends
     /**
      * {@inheritDoc}
      **/
-    public void rename( NextInterceptor next, RenameOperationContext renameContext ) throws LdapException
+    public void rename( RenameOperationContext renameContext ) throws LdapException
     {
         // Check if the entry is a referral itself
         boolean isReferral = isReferral( renameContext.getOriginalEntry() );
 
-        next.rename( renameContext );
+        next( renameContext );
 
         if ( isReferral )
         {
@@ -359,50 +419,4 @@ public class ReferralInterceptor extends
             referralManager.unlock();
         }
     }
-
-
-    /**
-     * Modify an entry in the server.
-     */
-    public void modify( NextInterceptor next, ModifyOperationContext modifyContext ) throws LdapException
-    {
-        Dn dn = modifyContext.getDn();
-
-        // handle a normal modify without following referrals
-        next.modify( modifyContext );
-
-        // Check if we are trying to modify the schema or the rootDSE,
-        // if so, we don't modify the referralManager
-        if ( dn.isEmpty() || dn.equals( subschemaSubentryDn ) )
-        {
-            // Do nothing
-            return;
-        }
-
-        // Update the referralManager. We have to read the entry again
-        // as it has been modified, before updating the ReferralManager
-        // TODO: this can be spare, as we already have the altered entry
-        // into the opContext, but for an unknow reason, this will fail
-        // on eferral tests...
-        LookupOperationContext lookupContext = new LookupOperationContext( modifyContext.getSession(), dn );
-        lookupContext.setAttrsId( SchemaConstants.ALL_ATTRIBUTES_ARRAY );
-
-        Entry newEntry = nexus.lookup( lookupContext );
-
-        // Update the referralManager.
-        // Check that we have the entry, just in case
-        // TODO : entries should be locked until the operation is done on it.
-        if ( newEntry != null )
-        {
-            referralManager.lockWrite();
-
-            if ( referralManager.isReferral( newEntry.getDn() ) )
-            {
-                referralManager.removeReferral( modifyContext.getEntry() );
-                referralManager.addReferral( newEntry );
-            }
-
-            referralManager.unlock();
-        }
-    }
 }

Propchange: directory/apacheds/branches/apacheds-txns/interceptors/schema/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Nov 12 18:24:38 2011
@@ -1 +1 @@
-/directory/apacheds/trunk/interceptors/schema:1183435-1200383
+/directory/apacheds/trunk/interceptors/schema:1183435-1201283

Modified: directory/apacheds/branches/apacheds-txns/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java?rev=1201297&r1=1201296&r2=1201297&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-txns/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java Sat Nov 12 18:24:38 2011
@@ -34,12 +34,12 @@ import javax.naming.directory.SearchCont
 
 import org.apache.directory.server.core.shared.SchemaService;
 import org.apache.directory.server.core.api.DirectoryService;
+import org.apache.directory.server.core.api.InterceptorEnum;
 import org.apache.directory.server.core.api.entry.ClonedServerEntry;
 import org.apache.directory.server.core.api.filtering.BaseEntryFilteringCursor;
 import org.apache.directory.server.core.api.filtering.EntryFilter;
 import org.apache.directory.server.core.api.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.api.interceptor.BaseInterceptor;
-import org.apache.directory.server.core.api.interceptor.NextInterceptor;
 import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.CompareOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.ListOperationContext;
@@ -135,9 +135,7 @@ public class SchemaInterceptor extends B
     /** The SubschemaSubentry Dn */
     private Dn subschemaSubentryDn;
 
-    /**
-     * the normalized name for the schema modification attributes
-     */
+    /** The normalized name for the schema modification attributes */
     private Dn schemaModificationAttributesDn;
 
     /** The schema manager */
@@ -158,6 +156,14 @@ public class SchemaInterceptor extends B
     /** A map used to store all the objectClasses allowed attributes (may + must) */
     private Map<String, List<AttributeType>> allowed;
 
+    /**
+     * Creates a new instance of a SchemaInterceptor.
+     */
+    public SchemaInterceptor()
+    {
+        super( InterceptorEnum.SCHEMA_INTERCEPTOR );
+    }
+
 
     /**
      * Initialize the Schema Service
@@ -183,7 +189,7 @@ public class SchemaInterceptor extends B
         schemaBaseDn = directoryService.getDnFactory().create( SchemaConstants.OU_SCHEMA );
 
         // stuff for dealing with subentries (garbage for now)
-        Value<?> subschemaSubentry = nexus.getRootDSE( null ).get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT ).get();
+        Value<?> subschemaSubentry = nexus.getRootDse( null ).get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT ).get();
         subschemaSubentryDn = directoryService.getDnFactory().create( subschemaSubentry.getString() );
         subschemaSubentryDn.apply( schemaManager );
         subschemaSubentryDnNorm = subschemaSubentryDn.getNormName();
@@ -370,38 +376,6 @@ public class SchemaInterceptor extends B
     }
 
 
-    public EntryFilteringCursor list( ListOperationContext listContext ) throws LdapException
-    {
-        EntryFilteringCursor cursor = next( listContext );
-        cursor.addEntryFilter( binaryAttributeFilter );
-
-        return cursor;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public boolean compare( CompareOperationContext compareContext ) throws LdapException
-    {
-        if ( IS_DEBUG )
-        {
-            LOG.debug( "Operation Context: {}", compareContext );
-        }
-
-        // Check that the requested AT exists
-        // complain if we do not recognize the attribute being compared
-        if ( !schemaManager.getAttributeTypeRegistry().contains( compareContext.getOid() ) )
-        {
-            throw new LdapInvalidAttributeTypeException( I18n.err( I18n.ERR_266, compareContext.getOid() ) );
-        }
-
-        boolean result = next( compareContext );
-
-        return result;
-    }
-
-
     /**
      * Remove all unknown attributes from the searchControls, to avoid an exception.
      *
@@ -630,122 +604,6 @@ public class SchemaInterceptor extends B
     }
 
 
-    public EntryFilteringCursor search( NextInterceptor nextInterceptor, SearchOperationContext searchContext ) throws LdapException
-    {
-        Dn base = searchContext.getDn();
-        SearchControls searchCtls = searchContext.getSearchControls();
-        ExprNode filter = searchContext.getFilter();
-
-        // We have to eliminate bad attributes from the request, accordingly
-        // to RFC 2251, chap. 4.5.1. Basically, all unknown attributes are removed
-        // from the list
-        if ( searchCtls.getReturningAttributes() != null )
-        {
-            filterAttributesToReturn( searchCtls );
-        }
-
-        // We also have to check the H/R flag for the filter attributes
-        checkFilter( filter );
-
-        String baseNormForm = ( base.isSchemaAware() ? base.getNormName() : base.getNormName() );
-
-        // Deal with the normal case : searching for a normal value (not subSchemaSubEntry)
-        if ( !subschemaSubentryDnNorm.equals( baseNormForm ) )
-        {
-            EntryFilteringCursor cursor = nextInterceptor.search( searchContext );
-
-            if ( searchCtls.getReturningAttributes() != null )
-            {
-                cursor.addEntryFilter( topFilter );
-                return cursor;
-            }
-
-            for ( EntryFilter ef : filters )
-            {
-                cursor.addEntryFilter( ef );
-            }
-
-            return cursor;
-        }
-
-        // The user was searching into the subSchemaSubEntry
-        // This kind of search _must_ be limited to OBJECT scope (the subSchemaSubEntry
-        // does not have any sub level)
-        if ( searchCtls.getSearchScope() == SearchControls.OBJECT_SCOPE )
-        {
-            // The filter can be an equality or a presence, but nothing else
-            if ( filter instanceof SimpleNode)
-            {
-                // We should get the value for the filter.
-                // only 'top' and 'subSchema' are valid values
-                SimpleNode node = ( SimpleNode ) filter;
-                String objectClass;
-
-                objectClass = node.getValue().getString();
-
-                String objectClassOid = null;
-
-                if ( schemaManager.getObjectClassRegistry().contains( objectClass ) )
-                {
-                    objectClassOid = schemaManager.lookupObjectClassRegistry( objectClass ).getOid();
-                }
-                else
-                {
-                    return new BaseEntryFilteringCursor( new EmptyCursor<Entry>(), searchContext );
-                }
-
-                AttributeType nodeAt = node.getAttributeType();
-
-                // see if node attribute is objectClass
-                if ( nodeAt.equals( OBJECT_CLASS_AT )
-                    && ( objectClassOid.equals( SchemaConstants.TOP_OC_OID ) || objectClassOid
-                        .equals( SchemaConstants.SUBSCHEMA_OC_OID ) ) && ( node instanceof EqualityNode ) )
-                {
-                    // call.setBypass( true );
-                    Entry serverEntry = SchemaService.getSubschemaEntry( directoryService, searchCtls.getReturningAttributes() );
-                    serverEntry.setDn( base );
-                    return new BaseEntryFilteringCursor( new SingletonCursor<Entry>( serverEntry ), searchContext );
-                }
-                else
-                {
-                    return new BaseEntryFilteringCursor( new EmptyCursor<Entry>(), searchContext );
-                }
-            }
-            else if ( filter instanceof PresenceNode )
-            {
-                PresenceNode node = ( PresenceNode ) filter;
-
-                // see if node attribute is objectClass
-                if ( node.getAttributeType().equals( OBJECT_CLASS_AT ) )
-                {
-                    // call.setBypass( true );
-                    Entry serverEntry = SchemaService.getSubschemaEntry( directoryService, searchCtls.getReturningAttributes() );
-                    serverEntry.setDn( base );
-                    EntryFilteringCursor cursor = new BaseEntryFilteringCursor(
-                        new SingletonCursor<Entry>( serverEntry ), searchContext );
-                    return cursor;
-                }
-            }
-        }
-
-        // In any case not handled previously, just return an empty result
-        return new BaseEntryFilteringCursor( new EmptyCursor<Entry>(), searchContext );
-    }
-
-
-    /**
-     * Search for an entry, using its Dn. Binary attributes and ObjectClass attribute are removed.
-     */
-    public Entry lookup( LookupOperationContext lookupContext ) throws LdapException
-    {
-        Entry result = next( lookupContext );
-
-        filterBinaryAttributes( result );
-
-        return result;
-    }
-
-
     private void getSuperiors( ObjectClass oc, Set<String> ocSeen, List<ObjectClass> result ) throws LdapException
     {
         for ( ObjectClass parent : oc.getSuperiors() )
@@ -925,63 +783,6 @@ public class SchemaInterceptor extends B
     }
 
 
-    public void rename( NextInterceptor next, RenameOperationContext renameContext ) throws LdapException
-    {
-        Dn oldDn = renameContext.getDn();
-        Rdn newRdn = renameContext.getNewRdn();
-        boolean deleteOldRn = renameContext.getDeleteOldRdn();
-        Entry entry = ((ClonedServerEntry)renameContext.getEntry()).getClonedEntry();
-
-        /*
-         *  Note: This is only a consistency checks, to the ensure that all
-         *  mandatory attributes are available after deleting the old Rdn.
-         *  The real modification is done in the XdbmStore class.
-         *  - TODO: this check is missing in the moveAndRename() method
-         */
-        if ( deleteOldRn )
-        {
-            Rdn oldRdn = oldDn.getRdn();
-
-            // Delete the old Rdn means we remove some attributes and values.
-            // We must make sure that after this operation all must attributes
-            // are still present in the entry.
-            for ( Ava atav : oldRdn)
-            {
-                AttributeType type = schemaManager.lookupAttributeTypeRegistry( atav.getUpType() );
-                entry.remove( type, atav.getUpValue() );
-            }
-
-            // Check that no operational attributes are removed
-            for ( Ava atav : oldRdn)
-            {
-                AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( atav.getUpType() );
-
-                if ( !attributeType.isUserModifiable() )
-                {
-                    throw new LdapNoPermissionException( "Cannot modify the attribute '" + atav.getUpType() + "'" );
-                }
-            }
-        }
-
-        for ( Ava atav : newRdn )
-        {
-            AttributeType type = schemaManager.lookupAttributeTypeRegistry( atav.getUpType() );
-
-            if ( !entry.contains( type, atav.getNormValue() ) )
-            {
-                entry.add( new DefaultAttribute( type, atav.getNormValue() ) );
-            }
-        }
-
-        // Substitute the Rdn and check if the new entry is correct
-        entry.setDn( renameContext.getNewDn() );
-
-        check( renameContext.getNewDn(), entry );
-
-        next.rename( renameContext );
-    }
-
-
     /**
      * Create a new attribute using the given values
      */
@@ -1180,82 +981,24 @@ public class SchemaInterceptor extends B
 
 
     /**
-     * {@inheritDoc}
+     * Filter the attributes by removing the ones which are not allowed
      */
-    public void modify( NextInterceptor next, ModifyOperationContext modifyContext ) throws LdapException
+    // This will suppress PMD.EmptyCatchBlock warnings in this method
+    @SuppressWarnings("PMD.EmptyCatchBlock")
+    private void filterAttributeTypes( SearchingOperationContext operation, Entry result )
     {
-        // A modification on a simple entry will be done in three steps :
-        // - get the original entry (it should already been in the context)
-        // - apply the modification on it
-        // - check that the entry is still correct
-        // - add the operational attributes (modifiersName/modifyTimeStamp)
-        // - store the modified entry on the backend.
-        //
-        // A modification done on the schema is a bit different, as there is two more
-        // steps
-        // - We have to update the registries
-        // - We have to modify the ou=schemaModifications entry
-        //
-
-        // First, check that the entry is either a subschemaSubentry or a schema element.
-        // This is the case if it's a child of cn=schema or ou=schema
-        Dn dn = modifyContext.getDn();
-
-        // Gets the stored entry on which the modification must be applied
-        if ( dn.equals( subschemaSubentryDn ) )
+        if ( operation.getReturningAttributes() == null )
         {
-            LOG.debug( "Modification attempt on schema subentry {}: \n{}", dn, modifyContext );
+            return;
+        }
 
-            // We can get rid of the modifiersName and modifyTimestamp, they are useless.
-            List<Modification> mods = modifyContext.getModItems();
-            List<Modification> cleanMods = new ArrayList<Modification>();
+        for ( AttributeTypeOptions attrOptions : operation.getReturningAttributes() )
+        {
+            Attribute attribute = result.get( attrOptions.getAttributeType() );
 
-            for ( Modification mod : mods )
+            if ( attrOptions.hasOption() )
             {
-                AttributeType at = ( ( DefaultModification ) mod ).getAttribute().getAttributeType();
-
-                if ( !MODIFIERS_NAME_AT.equals( at ) && !MODIFY_TIMESTAMP_AT.equals( at ) && !ENTRY_CSN_AT.equals( at ) )
-                {
-                    cleanMods.add( mod );
-                }
-            }
-
-            modifyContext.setModItems( cleanMods );
-
-            // Now that the entry has been modified, update the SSSE
-            schemaSubEntryManager.modifySchemaSubentry( modifyContext, modifyContext
-                .hasRequestControl( Cascade.OID ) );
-
-            return;
-        }
-
-        Entry entry = modifyContext.getEntry();
-        List<Modification> modifications = modifyContext.getModItems();
-        checkModifyEntry( dn, entry, modifications );
-
-        next.modify( modifyContext );
-    }
-
-
-    /**
-     * Filter the attributes by removing the ones which are not allowed
-     */
-    // This will suppress PMD.EmptyCatchBlock warnings in this method
-    @SuppressWarnings("PMD.EmptyCatchBlock")
-    private void filterAttributeTypes( SearchingOperationContext operation, Entry result )
-    {
-        if ( operation.getReturningAttributes() == null )
-        {
-            return;
-        }
-
-        for ( AttributeTypeOptions attrOptions : operation.getReturningAttributes() )
-        {
-            Attribute attribute = result.get( attrOptions.getAttributeType() );
-
-            if ( attrOptions.hasOption() )
-            {
-                for ( String option : attrOptions.getOptions() )
+                for ( String option : attrOptions.getOptions() )
                 {
                     if ( "binary".equalsIgnoreCase( option ) )
                     {
@@ -1479,7 +1222,10 @@ public class SchemaInterceptor extends B
     /**
      * Check that all the attributes exist in the schema for this entry.
      */
-    public void add( NextInterceptor next, AddOperationContext addContext ) throws LdapException
+    /**
+     * {@inheritDoc}
+     */
+    public void add( AddOperationContext addContext ) throws LdapException
     {
         Dn name = addContext.getDn();
         Entry entry = addContext.getEntry();
@@ -1494,7 +1240,7 @@ public class SchemaInterceptor extends B
 
             if ( entry.contains( OBJECT_CLASS_AT, SchemaConstants.META_SCHEMA_OC ) )
             {
-                next.add( addContext );
+                next( addContext );
 
                 if ( schemaManager.isSchemaLoaded( schemaName ) )
                 {
@@ -1507,7 +1253,7 @@ public class SchemaInterceptor extends B
                 // This is an ObjectClass addition
                 checkOcSuperior( addContext.getEntry() );
 
-                next.add( addContext );
+                next( addContext );
 
                 // Update the structures now that the schema element has been added
                 Schema schema = schemaManager.getLoadedSchema( schemaName );
@@ -1524,18 +1270,290 @@ public class SchemaInterceptor extends B
             else if ( entry.contains( OBJECT_CLASS_AT, SchemaConstants.META_ATTRIBUTE_TYPE_OC ) )
             {
                 // This is an AttributeType addition
-                next.add( addContext );
+                next( addContext );
             }
             else
             {
-                next.add( addContext );
+                next( addContext );
             }
 
         }
         else
         {
-            next.add( addContext );
+            next( addContext );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean compare( CompareOperationContext compareContext ) throws LdapException
+    {
+        if ( IS_DEBUG )
+        {
+            LOG.debug( "Operation Context: {}", compareContext );
+        }
+
+        // Check that the requested AT exists
+        // complain if we do not recognize the attribute being compared
+        if ( !schemaManager.getAttributeTypeRegistry().contains( compareContext.getOid() ) )
+        {
+            throw new LdapInvalidAttributeTypeException( I18n.err( I18n.ERR_266, compareContext.getOid() ) );
+        }
+
+        boolean result = next( compareContext );
+
+        return result;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public EntryFilteringCursor list( ListOperationContext listContext ) throws LdapException
+    {
+        EntryFilteringCursor cursor = next( listContext );
+        cursor.addEntryFilter( binaryAttributeFilter );
+
+        return cursor;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Entry lookup( LookupOperationContext lookupContext ) throws LdapException
+    {
+        Entry result = next( lookupContext );
+
+        filterBinaryAttributes( result );
+
+        return result;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void modify( ModifyOperationContext modifyContext ) throws LdapException
+    {
+        // A modification on a simple entry will be done in three steps :
+        // - get the original entry (it should already been in the context)
+        // - apply the modification on it
+        // - check that the entry is still correct
+        // - add the operational attributes (modifiersName/modifyTimeStamp)
+        // - store the modified entry on the backend.
+        //
+        // A modification done on the schema is a bit different, as there is two more
+        // steps
+        // - We have to update the registries
+        // - We have to modify the ou=schemaModifications entry
+        //
+
+        // First, check that the entry is either a subschemaSubentry or a schema element.
+        // This is the case if it's a child of cn=schema or ou=schema
+        Dn dn = modifyContext.getDn();
+
+        // Gets the stored entry on which the modification must be applied
+        if ( dn.equals( subschemaSubentryDn ) )
+        {
+            LOG.debug( "Modification attempt on schema subentry {}: \n{}", dn, modifyContext );
+
+            // We can get rid of the modifiersName and modifyTimestamp, they are useless.
+            List<Modification> mods = modifyContext.getModItems();
+            List<Modification> cleanMods = new ArrayList<Modification>();
+
+            for ( Modification mod : mods )
+            {
+                AttributeType at = ( ( DefaultModification ) mod ).getAttribute().getAttributeType();
+
+                if ( !MODIFIERS_NAME_AT.equals( at ) && !MODIFY_TIMESTAMP_AT.equals( at ) && !ENTRY_CSN_AT.equals( at ) )
+                {
+                    cleanMods.add( mod );
+                }
+            }
+
+            modifyContext.setModItems( cleanMods );
+
+            // Now that the entry has been modified, update the SSSE
+            schemaSubEntryManager.modifySchemaSubentry( modifyContext, modifyContext
+                .hasRequestControl( Cascade.OID ) );
+
+            return;
+        }
+
+        Entry entry = modifyContext.getEntry();
+        List<Modification> modifications = modifyContext.getModItems();
+        checkModifyEntry( dn, entry, modifications );
+
+        next( modifyContext );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void rename( RenameOperationContext renameContext ) throws LdapException
+    {
+        Dn oldDn = renameContext.getDn();
+        Rdn newRdn = renameContext.getNewRdn();
+        boolean deleteOldRn = renameContext.getDeleteOldRdn();
+        Entry entry = ((ClonedServerEntry)renameContext.getEntry()).getClonedEntry();
+
+        /*
+         *  Note: This is only a consistency checks, to the ensure that all
+         *  mandatory attributes are available after deleting the old Rdn.
+         *  The real modification is done in the XdbmStore class.
+         *  - TODO: this check is missing in the moveAndRename() method
+         */
+        if ( deleteOldRn )
+        {
+            Rdn oldRdn = oldDn.getRdn();
+
+            // Delete the old Rdn means we remove some attributes and values.
+            // We must make sure that after this operation all must attributes
+            // are still present in the entry.
+            for ( Ava atav : oldRdn)
+            {
+                AttributeType type = schemaManager.lookupAttributeTypeRegistry( atav.getUpType() );
+                entry.remove( type, atav.getUpValue() );
+            }
+
+            // Check that no operational attributes are removed
+            for ( Ava atav : oldRdn)
+            {
+                AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( atav.getUpType() );
+
+                if ( !attributeType.isUserModifiable() )
+                {
+                    throw new LdapNoPermissionException( "Cannot modify the attribute '" + atav.getUpType() + "'" );
+                }
+            }
+        }
+
+        for ( Ava atav : newRdn )
+        {
+            AttributeType type = schemaManager.lookupAttributeTypeRegistry( atav.getUpType() );
+
+            if ( !entry.contains( type, atav.getNormValue() ) )
+            {
+                entry.add( new DefaultAttribute( type, atav.getNormValue() ) );
+            }
+        }
+
+        // Substitute the Rdn and check if the new entry is correct
+        entry.setDn( renameContext.getNewDn() );
+
+        check( renameContext.getNewDn(), entry );
+
+        next( renameContext );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public EntryFilteringCursor search( SearchOperationContext searchContext ) throws LdapException
+    {
+        Dn base = searchContext.getDn();
+        SearchControls searchCtls = searchContext.getSearchControls();
+        ExprNode filter = searchContext.getFilter();
+
+        // We have to eliminate bad attributes from the request, accordingly
+        // to RFC 2251, chap. 4.5.1. Basically, all unknown attributes are removed
+        // from the list
+        if ( searchCtls.getReturningAttributes() != null )
+        {
+            filterAttributesToReturn( searchCtls );
+        }
+
+        // We also have to check the H/R flag for the filter attributes
+        checkFilter( filter );
+
+        String baseNormForm = ( base.isSchemaAware() ? base.getNormName() : base.getNormName() );
+
+        // Deal with the normal case : searching for a normal value (not subSchemaSubEntry)
+        if ( !subschemaSubentryDnNorm.equals( baseNormForm ) )
+        {
+            EntryFilteringCursor cursor = next( searchContext );
+
+            if ( searchCtls.getReturningAttributes() != null )
+            {
+                cursor.addEntryFilter( topFilter );
+                return cursor;
+            }
+
+            for ( EntryFilter ef : filters )
+            {
+                cursor.addEntryFilter( ef );
+            }
+
+            return cursor;
+        }
+
+        // The user was searching into the subSchemaSubEntry
+        // This kind of search _must_ be limited to OBJECT scope (the subSchemaSubEntry
+        // does not have any sub level)
+        if ( searchCtls.getSearchScope() == SearchControls.OBJECT_SCOPE )
+        {
+            // The filter can be an equality or a presence, but nothing else
+            if ( filter instanceof SimpleNode)
+            {
+                // We should get the value for the filter.
+                // only 'top' and 'subSchema' are valid values
+                SimpleNode node = ( SimpleNode ) filter;
+                String objectClass;
+
+                objectClass = node.getValue().getString();
+
+                String objectClassOid = null;
+
+                if ( schemaManager.getObjectClassRegistry().contains( objectClass ) )
+                {
+                    objectClassOid = schemaManager.lookupObjectClassRegistry( objectClass ).getOid();
+                }
+                else
+                {
+                    return new BaseEntryFilteringCursor( new EmptyCursor<Entry>(), searchContext );
+                }
+
+                AttributeType nodeAt = node.getAttributeType();
+
+                // see if node attribute is objectClass
+                if ( nodeAt.equals( OBJECT_CLASS_AT )
+                    && ( objectClassOid.equals( SchemaConstants.TOP_OC_OID ) || objectClassOid
+                        .equals( SchemaConstants.SUBSCHEMA_OC_OID ) ) && ( node instanceof EqualityNode ) )
+                {
+                    // call.setBypass( true );
+                    Entry serverEntry = SchemaService.getSubschemaEntry( directoryService, searchCtls.getReturningAttributes() );
+                    serverEntry.setDn( base );
+                    return new BaseEntryFilteringCursor( new SingletonCursor<Entry>( serverEntry ), searchContext );
+                }
+                else
+                {
+                    return new BaseEntryFilteringCursor( new EmptyCursor<Entry>(), searchContext );
+                }
+            }
+            else if ( filter instanceof PresenceNode )
+            {
+                PresenceNode node = ( PresenceNode ) filter;
+
+                // see if node attribute is objectClass
+                if ( node.getAttributeType().equals( OBJECT_CLASS_AT ) )
+                {
+                    // call.setBypass( true );
+                    Entry serverEntry = SchemaService.getSubschemaEntry( directoryService, searchCtls.getReturningAttributes() );
+                    serverEntry.setDn( base );
+                    EntryFilteringCursor cursor = new BaseEntryFilteringCursor(
+                        new SingletonCursor<Entry>( serverEntry ), searchContext );
+                    return cursor;
+                }
+            }
         }
+
+        // In any case not handled previously, just return an empty result
+        return new BaseEntryFilteringCursor( new EmptyCursor<Entry>(), searchContext );
     }
 
 

Modified: directory/apacheds/branches/apacheds-txns/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaLdifToPartitionExtractor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaLdifToPartitionExtractor.java?rev=1201297&r1=1201296&r2=1201297&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaLdifToPartitionExtractor.java (original)
+++ directory/apacheds/branches/apacheds-txns/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaLdifToPartitionExtractor.java Sat Nov 12 18:24:38 2011
@@ -32,7 +32,7 @@ import java.util.UUID;
 import java.util.regex.Pattern;
 
 import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
-import org.apache.directory.server.core.api.interceptor.context.EntryOperationContext;
+import org.apache.directory.server.core.api.interceptor.context.HasEntryOperationContext;
 import org.apache.directory.server.core.api.partition.Partition;
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
@@ -95,7 +95,7 @@ public class SchemaLdifToPartitionExtrac
         this.partition = partition;
 
         Dn dn = new Dn( schemaManager, SchemaConstants.OU_SCHEMA );
-        EntryOperationContext hasEntryContext = new EntryOperationContext( null, dn );
+        HasEntryOperationContext hasEntryContext = new HasEntryOperationContext( null, dn );
         if ( partition.hasEntry( hasEntryContext ) )
         {
             LOG.info( "Schema entry 'ou=schema' exists: extracted state set to true." );

Modified: directory/apacheds/branches/apacheds-txns/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryModifier.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryModifier.java?rev=1201297&r1=1201296&r2=1201297&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryModifier.java (original)
+++ directory/apacheds/branches/apacheds-txns/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryModifier.java Sat Nov 12 18:24:38 2011
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ * 
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ * 
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ * 
  */
 package org.apache.directory.server.core.schema;
 
@@ -26,6 +26,7 @@ import java.util.HashSet;
 import java.util.Set;
 
 import org.apache.directory.server.core.api.DnFactory;
+import org.apache.directory.server.core.api.InterceptorEnum;
 import org.apache.directory.server.core.api.interceptor.context.OperationContext;
 import org.apache.directory.shared.ldap.model.constants.MetaSchemaConstants;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
@@ -52,7 +53,7 @@ import org.apache.directory.shared.util.
 
 
 /**
- * Responsible for translating modify operations on the subschemaSubentry into 
+ * Responsible for translating modify operations on the subschemaSubentry into
  * operations against entries within the schema partition.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -64,11 +65,11 @@ public class SchemaSubentryModifier
     static
     {
         Set<String> c = new HashSet<String>();
-        c.add( "AuthenticationInterceptor" );
-        c.add( "AciAuthorizationInterceptor" );
-        c.add( "DefaultAuthorizationInterceptor" );
-        c.add( "ExceptionInterceptor" );
-        c.add( "SchemaInterceptor" );
+        c.add( InterceptorEnum.AUTHENTICATION_INTERCEPTOR.getName() );
+        c.add( InterceptorEnum.ACI_AUTHORIZATION_INTERCEPTOR.getName() );
+        c.add( InterceptorEnum.DEFAULT_AUTHORIZATION_INTERCEPTOR.getName() );
+        c.add( InterceptorEnum.EXCEPTION_INTERCEPTOR.getName() );
+        c.add( InterceptorEnum.SCHEMA_INTERCEPTOR.getName() );
         BYPASS = Collections.unmodifiableCollection( c );
     }
     
@@ -140,7 +141,7 @@ public class SchemaSubentryModifier
 
     public void add( OperationContext opContext, LdapComparatorDescription comparatorDescription ) throws LdapException
     {
-        String schemaName = getSchema( comparatorDescription );   
+        String schemaName = getSchema( comparatorDescription );
         Dn dn = dnFactory.create(
             "m-oid=" + comparatorDescription.getOid(),
             SchemaConstants.COMPARATORS_PATH,
@@ -149,7 +150,7 @@ public class SchemaSubentryModifier
         
         Entry entry = getEntry( dn, comparatorDescription );
 
-        opContext.add( (Entry)entry, BYPASS );
+        opContext.add( entry, BYPASS );
     }
     
     
@@ -158,13 +159,13 @@ public class SchemaSubentryModifier
         String schemaName = getSchema( normalizerDescription );
         Dn dn = dnFactory.create(
             "m-oid=" + normalizerDescription.getOid(),
-            SchemaConstants.NORMALIZERS_PATH , 
+            SchemaConstants.NORMALIZERS_PATH ,
             "cn=" + schemaName,
             SchemaConstants.OU_SCHEMA );
         
         Entry entry = getEntry( dn, normalizerDescription );
 
-        opContext.add( (Entry)entry, BYPASS );
+        opContext.add( entry, BYPASS );
     }
     
     
@@ -174,11 +175,11 @@ public class SchemaSubentryModifier
         Dn dn = dnFactory.create(
             "m-oid=" + syntaxCheckerDescription.getOid(),
             SchemaConstants.SYNTAX_CHECKERS_PATH,
-            "cn=" + schemaName, 
+            "cn=" + schemaName,
             SchemaConstants.OU_SCHEMA );
         
         Entry entry = getEntry( dn, syntaxCheckerDescription );
-        opContext.add( (Entry)entry, BYPASS );
+        opContext.add( entry, BYPASS );
     }
     
     
@@ -206,7 +207,7 @@ public class SchemaSubentryModifier
         Dn dn = dnFactory.create(
             "m-oid=" + normalizerDescription.getOid(),
             SchemaConstants.NORMALIZERS_PATH,
-            "cn=" + schemaName, 
+            "cn=" + schemaName,
             SchemaConstants.OU_SCHEMA );
         
         opContext.delete( dn );
@@ -217,7 +218,7 @@ public class SchemaSubentryModifier
     {
         String schemaName = getSchema( syntaxCheckerDescription );
         Dn dn = dnFactory.create(
-            "m-oid=" + syntaxCheckerDescription.getOid(), 
+            "m-oid=" + syntaxCheckerDescription.getOid(),
             SchemaConstants.SYNTAX_CHECKERS_PATH,
             "cn=" + schemaName,
             SchemaConstants.OU_SCHEMA );
@@ -242,8 +243,8 @@ public class SchemaSubentryModifier
     {
         Entry entry = new DefaultEntry( schemaManager, dn );
         
-        entry.put( SchemaConstants.OBJECT_CLASS_AT, 
-                    SchemaConstants.TOP_OC, 
+        entry.put( SchemaConstants.OBJECT_CLASS_AT,
+                    SchemaConstants.TOP_OC,
                     MetaSchemaConstants.META_TOP_OC,
                     MetaSchemaConstants.META_COMPARATOR_OC );
         
@@ -252,7 +253,7 @@ public class SchemaSubentryModifier
 
         if ( comparatorDescription.getBytecode() != null )
         {
-            entry.put( MetaSchemaConstants.M_BYTECODE_AT, 
+            entry.put( MetaSchemaConstants.M_BYTECODE_AT,
                 Base64.decode( comparatorDescription.getBytecode().toCharArray() ) );
         }
         
@@ -269,8 +270,8 @@ public class SchemaSubentryModifier
     {
         Entry entry = new DefaultEntry( schemaManager, dn );
 
-        entry.put( SchemaConstants.OBJECT_CLASS_AT, 
-            SchemaConstants.TOP_OC, 
+        entry.put( SchemaConstants.OBJECT_CLASS_AT,
+            SchemaConstants.TOP_OC,
             MetaSchemaConstants.META_TOP_OC,
             MetaSchemaConstants.META_NORMALIZER_OC );
         
@@ -279,7 +280,7 @@ public class SchemaSubentryModifier
 
         if ( normalizerDescription.getBytecode() != null )
         {
-            entry.put( MetaSchemaConstants.M_BYTECODE_AT, 
+            entry.put( MetaSchemaConstants.M_BYTECODE_AT,
                 Base64.decode( normalizerDescription.getBytecode().toCharArray() ) );
         }
         
@@ -292,7 +293,7 @@ public class SchemaSubentryModifier
     }
 
 
-    private String getSchema( SchemaObject desc ) 
+    private String getSchema( SchemaObject desc )
     {
         if ( desc.getExtensions().containsKey( MetaSchemaConstants.X_SCHEMA ) )
         {
@@ -307,8 +308,8 @@ public class SchemaSubentryModifier
     {
         Entry entry = new DefaultEntry( schemaManager, dn );
         
-        entry.put( SchemaConstants.OBJECT_CLASS_AT, 
-            SchemaConstants.TOP_OC, 
+        entry.put( SchemaConstants.OBJECT_CLASS_AT,
+            SchemaConstants.TOP_OC,
             MetaSchemaConstants.META_TOP_OC,
             MetaSchemaConstants.META_SYNTAX_CHECKER_OC );
 

Propchange: directory/apacheds/branches/apacheds-txns/interceptors/subtree/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Nov 12 18:24:38 2011
@@ -1 +1 @@
-/directory/apacheds/trunk/interceptors/subtree:1183435-1200383
+/directory/apacheds/trunk/interceptors/subtree:1183435-1201283

Modified: directory/apacheds/branches/apacheds-txns/interceptors/subtree/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/interceptors/subtree/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java?rev=1201297&r1=1201296&r2=1201297&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/interceptors/subtree/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-txns/interceptors/subtree/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java Sat Nov 12 18:24:38 2011
@@ -31,12 +31,12 @@ import org.apache.directory.server.const
 import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.api.CoreSession;
 import org.apache.directory.server.core.api.DirectoryService;
+import org.apache.directory.server.core.api.InterceptorEnum;
 import org.apache.directory.server.core.api.LdapPrincipal;
 import org.apache.directory.server.core.api.entry.ClonedServerEntry;
 import org.apache.directory.server.core.api.filtering.EntryFilter;
 import org.apache.directory.server.core.api.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.api.interceptor.BaseInterceptor;
-import org.apache.directory.server.core.api.interceptor.NextInterceptor;
 import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.DeleteOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.ListOperationContext;
@@ -119,7 +119,15 @@ public class SubentryInterceptor extends
         REMOVE,
         REPLACE
     }
-
+    
+    /**
+     * Creates a new instance of SubentryInterceptor
+     */
+    public SubentryInterceptor()
+    {
+        super( InterceptorEnum.SUBENTRY_INTERCEPTOR );
+    }
+    
 
     //-------------------------------------------------------------------------------------------
     // Search filter methods
@@ -849,7 +857,7 @@ public class SubentryInterceptor extends
     /**
      * {@inheritDoc}
      */
-    public void add( NextInterceptor next, AddOperationContext addContext ) throws LdapException
+    public void add( AddOperationContext addContext ) throws LdapException
     {
         Dn dn = addContext.getDn();
         Entry entry = addContext.getEntry();
@@ -860,7 +868,7 @@ public class SubentryInterceptor extends
             // get the name of the administrative point and its administrativeRole attributes
             // The AP must be the parent Dn, but we also have to check that the given Dn
             // is not the rootDSE or a NamingContext
-            if ( dn.isRootDSE() || isNamingContext( dn ) )
+            if ( dn.isRootDse() || isNamingContext( dn ) )
             {
                 // Not allowed : we can't get a parent in those cases
                 throw new LdapOtherException( "Cannot find an AdministrativePoint for " + dn );
@@ -894,7 +902,7 @@ public class SubentryInterceptor extends
             directoryService.getSubentryCache().addSubentry( dn, subentry );
 
             // Now inject the subentry into the backend
-            next.add( addContext );
+            next( addContext );
 
             /* ----------------------------------------------------------------
              * Find the baseDn for the subentry and use that to search the tree
@@ -964,7 +972,7 @@ public class SubentryInterceptor extends
             addContext.setEntry( entry );
 
             // Propagate the addition down to the backend.
-            next.add( addContext );
+            next( addContext );
         }
     }
 
@@ -1031,7 +1039,7 @@ public class SubentryInterceptor extends
     /**
      * {@inheritDoc}
      */
-    public void modify( NextInterceptor next, ModifyOperationContext modifyContext ) throws LdapException
+    public void modify( ModifyOperationContext modifyContext ) throws LdapException
     {
         Dn dn = modifyContext.getDn();
         List<Modification> modifications = modifyContext.getModItems();
@@ -1083,7 +1091,7 @@ public class SubentryInterceptor extends
             subentry.setAdministrativeRoles( getSubentryTypes( entry, modifications ) );
             directoryService.getSubentryCache().addSubentry( dn, subentry );
 
-            next.modify( modifyContext );
+            next( modifyContext );
 
             // search for all entries selected by the old SS and remove references to subentry
             Dn apName = dn.getParent();
@@ -1178,7 +1186,7 @@ public class SubentryInterceptor extends
         }
         else
         {
-            next.modify( modifyContext );
+            next( modifyContext );
 
             if ( !containsSubentryOC )
             {
@@ -1223,7 +1231,7 @@ public class SubentryInterceptor extends
      * @param moveContext The context containing all the needed informations to proceed
      * @throws LdapException If the move failed
      */
-    public void move( NextInterceptor next, MoveOperationContext moveContext ) throws LdapException
+    public void move( MoveOperationContext moveContext ) throws LdapException
     {
         Dn oldDn = moveContext.getDn();
         Dn newSuperiorDn = moveContext.getNewSuperior();
@@ -1252,7 +1260,7 @@ public class SubentryInterceptor extends
 
             directoryService.getSubentryCache().addSubentry( newName, subentry );
 
-            next.move( moveContext );
+            next( moveContext );
 
             subentry = directoryService.getSubentryCache().getSubentry( newName );
 
@@ -1316,7 +1324,7 @@ public class SubentryInterceptor extends
             }
 
             // Move the entry
-            next.move( moveContext );
+            next( moveContext );
 
             // calculate the new Dn now for use below to modify subentry operational
             // attributes contained within this regular entry with name changes
@@ -1332,7 +1340,10 @@ public class SubentryInterceptor extends
     }
 
 
-    public void moveAndRename( NextInterceptor next, MoveAndRenameOperationContext moveAndRenameContext ) throws LdapException
+    /**
+     * {@inheritDoc}
+     */
+    public void moveAndRename( MoveAndRenameOperationContext moveAndRenameContext ) throws LdapException
     {
         Dn oldDn = moveAndRenameContext.getDn();
         Dn newSuperiorDn = moveAndRenameContext.getNewSuperiorDn();
@@ -1353,7 +1364,7 @@ public class SubentryInterceptor extends
 
             directoryService.getSubentryCache().addSubentry( newName, subentry );
 
-            next.moveAndRename( moveAndRenameContext );
+            next( moveAndRenameContext );
 
             subentry = directoryService.getSubentryCache().getSubentry( newName );
 
@@ -1409,7 +1420,7 @@ public class SubentryInterceptor extends
                 throw new LdapSchemaViolationException( ResultCodeEnum.NOT_ALLOWED_ON_RDN, msg );
             }
 
-            next.moveAndRename( moveAndRenameContext );
+            next( moveAndRenameContext );
 
             // calculate the new Dn now for use below to modify subentry operational
             // attributes contained within this regular entry with name changes
@@ -1424,7 +1435,10 @@ public class SubentryInterceptor extends
     }
 
 
-    public void rename( NextInterceptor next, RenameOperationContext renameContext ) throws LdapException
+    /**
+     * {@inheritDoc}
+     */
+    public void rename( RenameOperationContext renameContext ) throws LdapException
     {
         Dn oldDn = renameContext.getDn();
 
@@ -1444,7 +1458,7 @@ public class SubentryInterceptor extends
             newName.apply( schemaManager );
 
             directoryService.getSubentryCache().addSubentry( newName, subentry );
-            next.rename( renameContext );
+            next( renameContext );
 
             subentry = directoryService.getSubentryCache().getSubentry( newName );
             ExprNode filter = new PresenceNode( OBJECT_CLASS_AT );
@@ -1499,7 +1513,7 @@ public class SubentryInterceptor extends
                 throw new LdapSchemaViolationException( ResultCodeEnum.NOT_ALLOWED_ON_RDN, msg );
             }
 
-            next.rename( renameContext );
+            next( renameContext );
 
             // calculate the new Dn now for use below to modify subentry operational
             // attributes contained within this regular entry with name changes
@@ -1518,9 +1532,9 @@ public class SubentryInterceptor extends
     /**
      * {@inheritDoc}
      */
-    public EntryFilteringCursor search( NextInterceptor nextInterceptor, SearchOperationContext searchContext ) throws LdapException
+    public EntryFilteringCursor search( SearchOperationContext searchContext ) throws LdapException
     {
-        EntryFilteringCursor cursor = nextInterceptor.search( searchContext );
+        EntryFilteringCursor cursor = next( searchContext );
 
         // object scope searches by default return subentries
         if ( searchContext.getScope() == SearchScope.OBJECT )

Propchange: directory/apacheds/branches/apacheds-txns/interceptors/trigger/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Nov 12 18:24:38 2011
@@ -1 +1 @@
-/directory/apacheds/trunk/interceptors/trigger:1183435-1200383
+/directory/apacheds/trunk/interceptors/trigger:1183435-1201283

Modified: directory/apacheds/branches/apacheds-txns/interceptors/trigger/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/interceptors/trigger/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java?rev=1201297&r1=1201296&r2=1201297&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/interceptors/trigger/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-txns/interceptors/trigger/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java Sat Nov 12 18:24:38 2011
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ * 
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ * 
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ * 
  */
 
 package org.apache.directory.server.core.trigger;
@@ -29,9 +29,9 @@ import java.util.Map;
 
 import org.apache.directory.server.core.api.CoreSession;
 import org.apache.directory.server.core.api.DirectoryService;
+import org.apache.directory.server.core.api.InterceptorEnum;
 import org.apache.directory.server.core.api.entry.ClonedServerEntry;
 import org.apache.directory.server.core.api.interceptor.BaseInterceptor;
-import org.apache.directory.server.core.api.interceptor.NextInterceptor;
 import org.apache.directory.server.core.api.interceptor.context.AddOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.DeleteOperationContext;
 import org.apache.directory.server.core.api.interceptor.context.LookupOperationContext;
@@ -92,11 +92,20 @@ public class TriggerInterceptor extends 
     private TriggerExecutionAuthorizer triggerExecutionAuthorizer = new SimpleTriggerExecutionAuthorizer();
 
     private StoredProcExecutionManager manager;
-    
+
     /** The SubentryUtils instance */
     private static SubentryUtils subentryUtils;
 
     /**
+     * Creates a new instance of a TriggerInterceptor.
+     */
+    public TriggerInterceptor()
+    {
+        super( InterceptorEnum.TRIGGER_INTERCEPTOR );
+    }
+    
+
+    /**
      * Adds prescriptiveTrigger TriggerSpecificaitons to a collection of
      * TriggerSpeficaitions by accessing the triggerSpecCache.  The trigger
      * specification cache is accessed for each trigger subentry associated
@@ -109,7 +118,7 @@ public class TriggerInterceptor extends 
      * @param dn the normalized distinguished name of the entry
      * @param entry the target entry that is considered as the trigger source
      * @throws Exception if there are problems accessing attribute values
-     * @param proxy the partition nexus proxy 
+     * @param proxy the partition nexus proxy
      */
     private void addPrescriptiveTriggerSpecs( OperationContext opContext, List<TriggerSpecification> triggerSpecs,
         Dn dn, Entry entry ) throws LdapException
@@ -131,7 +140,7 @@ public class TriggerInterceptor extends 
             CoreSession session = opContext.getSession();
             LookupOperationContext lookupContext = new LookupOperationContext( session, parentDn );
             lookupContext.setAttrsId( SchemaConstants.ALL_ATTRIBUTES_ARRAY );
-            
+
             entry = directoryService.getPartitionNexus().lookup( lookupContext );
         }
 
@@ -196,7 +205,7 @@ public class TriggerInterceptor extends 
      * 
      * @param triggerSpecs the trigger specifications
      * @param ldapOperation the ldap operation being performed
-     * @return the set of trigger specs for a trigger action 
+     * @return the set of trigger specs for a trigger action
      */
     public Map<ActionTime, List<TriggerSpecification>> getActionTimeMappedTriggerSpecsForOperation(
         List<TriggerSpecification> triggerSpecs, LdapOperation ldapOperation )
@@ -252,13 +261,16 @@ public class TriggerInterceptor extends 
         manager = new StoredProcExecutionManager( spContainer, spEngineConfigs );
 
         this.enabled = true; // TODO: Get this from the configuration if needed.
-        
+
         // Init the SubentryUtils instance
         subentryUtils = new SubentryUtils( directoryService );
     }
 
 
-    public void add( NextInterceptor next, AddOperationContext addContext ) throws LdapException
+    /**
+     * {@inheritDoc}
+     */
+    public void add( AddOperationContext addContext ) throws LdapException
     {
         Dn name = addContext.getDn();
         Entry entry = addContext.getEntry();
@@ -266,7 +278,7 @@ public class TriggerInterceptor extends 
         // Bypass trigger handling if the service is disabled.
         if ( !enabled )
         {
-            next.add( addContext );
+            next( addContext );
             return;
         }
 
@@ -284,7 +296,7 @@ public class TriggerInterceptor extends 
         Map<ActionTime, List<TriggerSpecification>> triggerMap = getActionTimeMappedTriggerSpecsForOperation(
             triggerSpecs, LdapOperation.ADD );
 
-        next.add( addContext );
+        next( addContext );
         triggerSpecCache.subentryAdded( name, entry );
 
         // Fire AFTER Triggers.
@@ -293,6 +305,9 @@ public class TriggerInterceptor extends 
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void delete( DeleteOperationContext deleteContext ) throws LdapException
     {
         Dn name = deleteContext.getDn();
@@ -327,12 +342,15 @@ public class TriggerInterceptor extends 
     }
 
 
-    public void modify( NextInterceptor next, ModifyOperationContext modifyContext ) throws LdapException
+    /**
+     * {@inheritDoc}
+     */
+    public void modify( ModifyOperationContext modifyContext ) throws LdapException
     {
         // Bypass trigger handling if the service is disabled.
         if ( !enabled )
         {
-            next.modify( modifyContext );
+            next( modifyContext );
             return;
         }
 
@@ -351,7 +369,7 @@ public class TriggerInterceptor extends 
         Map<ActionTime, List<TriggerSpecification>> triggerMap = getActionTimeMappedTriggerSpecsForOperation(
             triggerSpecs, LdapOperation.MODIFY );
 
-        next.modify( modifyContext );
+        next( modifyContext );
 
         triggerSpecCache.subentryModified( modifyContext, originalEntry );
 
@@ -361,51 +379,85 @@ public class TriggerInterceptor extends 
     }
 
 
-    public void rename( NextInterceptor next, RenameOperationContext renameContext ) throws LdapException
+    /**
+     * {@inheritDoc}
+     */
+    public void move( MoveOperationContext moveContext ) throws LdapException
     {
-        Dn name = renameContext.getDn();
-        Rdn newRdn = renameContext.getNewRdn();
-        boolean deleteOldRn = renameContext.getDeleteOldRdn();
-
         // Bypass trigger handling if the service is disabled.
         if ( !enabled )
         {
-            next.rename( renameContext );
+            next( moveContext );
             return;
         }
 
-        // Gather supplementary data.        
-        Entry renamedEntry = ((ClonedServerEntry)renameContext.getEntry()).getClonedEntry();
+        Rdn rdn = moveContext.getRdn();
+        Dn dn = moveContext.getDn();
+        Dn newDn = moveContext.getNewDn();
+        Dn oldSuperior = moveContext.getOldSuperior();
+        Dn newSuperior = moveContext.getNewSuperior();
 
-        // @TODO : To be completely reviewed !!!
-        Rdn oldRdn = name.getRdn();
-        Dn oldSuperiorDn = name.getParent();
-        Dn newSuperiorDn = oldSuperiorDn;
-        Dn oldDn = name;
-        Dn newDn = name;
-        newDn = newDn.add( newRdn );
+        // Gather supplementary data.
+        Entry movedEntry = moveContext.getOriginalEntry();
 
-        StoredProcedureParameterInjector injector = new ModifyDNStoredProcedureParameterInjector( renameContext,
-            deleteOldRn, oldRdn, newRdn, oldSuperiorDn, newSuperiorDn, oldDn, newDn);
+        //Rdn newRDN = dn.getRdn();
 
-        // Gather Trigger Specifications which apply to the entry being renamed.
-        List<TriggerSpecification> triggerSpecs = new ArrayList<TriggerSpecification>();
-        addPrescriptiveTriggerSpecs( renameContext, triggerSpecs, name, renamedEntry );
-        addEntryTriggerSpecs( triggerSpecs, renamedEntry );
+        StoredProcedureParameterInjector injector = new ModifyDNStoredProcedureParameterInjector( moveContext, false,
+            rdn, rdn, oldSuperior, newSuperior, dn, newDn );
 
-        Map<ActionTime, List<TriggerSpecification>> triggerMap = getActionTimeMappedTriggerSpecsForOperation(
-            triggerSpecs, LdapOperation.MODIFYDN_RENAME );
+        // Gather Trigger Specifications which apply to the entry being exported.
+        List<TriggerSpecification> exportTriggerSpecs = new ArrayList<TriggerSpecification>();
+        addPrescriptiveTriggerSpecs( moveContext, exportTriggerSpecs, dn, movedEntry );
+        addEntryTriggerSpecs( exportTriggerSpecs, movedEntry );
 
-        next.rename( renameContext );
-        triggerSpecCache.subentryRenamed( name, newDn);
+        // Get the entry again without operational attributes
+        // because access control subentry operational attributes
+        // will not be valid at the new location.
+        // This will certainly be fixed by the SubentryInterceptor,
+        // but after this service.
+        CoreSession session = moveContext.getSession();
+        LookupOperationContext lookupContext = new LookupOperationContext( session, dn, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
+
+        Entry importedEntry = directoryService.getPartitionNexus().lookup( lookupContext );
+
+        // As the target entry does not exist yet and so
+        // its subentry operational attributes are not there,
+        // we need to construct an entry to represent it
+        // at least with minimal requirements which are object class
+        // and access control subentry operational attributes.
+        Entry fakeImportedEntry = subentryUtils.getSubentryAttributes( newDn, importedEntry );
+
+        for ( Attribute attribute : importedEntry )
+        {
+            fakeImportedEntry.put( attribute );
+        }
+
+        // Gather Trigger Specifications which apply to the entry being imported.
+        // Note: Entry Trigger Specifications are not valid for Import.
+        List<TriggerSpecification> importTriggerSpecs = new ArrayList<TriggerSpecification>();
+        addPrescriptiveTriggerSpecs( moveContext, importTriggerSpecs, newDn, fakeImportedEntry );
+
+        Map<ActionTime, List<TriggerSpecification>> exportTriggerMap = getActionTimeMappedTriggerSpecsForOperation(
+            exportTriggerSpecs, LdapOperation.MODIFYDN_EXPORT );
+
+        Map<ActionTime, List<TriggerSpecification>> importTriggerMap = getActionTimeMappedTriggerSpecsForOperation(
+            importTriggerSpecs, LdapOperation.MODIFYDN_IMPORT );
+
+        next( moveContext );
+        triggerSpecCache.subentryRenamed( dn, newDn );
 
         // Fire AFTER Triggers.
-        List<TriggerSpecification> afterTriggerSpecs = triggerMap.get( ActionTime.AFTER );
-        executeTriggers( renameContext, afterTriggerSpecs, injector );
+        List<TriggerSpecification> afterExportTriggerSpecs = exportTriggerMap.get( ActionTime.AFTER );
+        List<TriggerSpecification> afterImportTriggerSpecs = importTriggerMap.get( ActionTime.AFTER );
+        executeTriggers( moveContext, afterExportTriggerSpecs, injector );
+        executeTriggers( moveContext, afterImportTriggerSpecs, injector );
     }
 
 
-    public void moveAndRename( NextInterceptor next, MoveAndRenameOperationContext moveAndRenameContext ) throws LdapException
+    /**
+     * {@inheritDoc}
+     */
+    public void moveAndRename( MoveAndRenameOperationContext moveAndRenameContext ) throws LdapException
     {
         Dn oldDn = moveAndRenameContext.getDn();
         Dn newSuperiorDn = moveAndRenameContext.getNewSuperiorDn();
@@ -415,11 +467,11 @@ public class TriggerInterceptor extends 
         // Bypass trigger handling if the service is disabled.
         if ( !enabled )
         {
-            next.moveAndRename( moveAndRenameContext );
+            next( moveAndRenameContext );
             return;
         }
 
-        // Gather supplementary data.        
+        // Gather supplementary data.
         Entry movedEntry = moveAndRenameContext.getOriginalEntry();
 
         Rdn oldRdn = oldDn.getRdn();
@@ -468,7 +520,7 @@ public class TriggerInterceptor extends 
         Map<ActionTime, List<TriggerSpecification>> importTriggerMap = getActionTimeMappedTriggerSpecsForOperation(
             importTriggerSpecs, LdapOperation.MODIFYDN_IMPORT );
 
-        next.moveAndRename( moveAndRenameContext );
+        next( moveAndRenameContext );
         triggerSpecCache.subentryRenamed( oldDN, newDn);
 
         // Fire AFTER Triggers.
@@ -482,75 +534,47 @@ public class TriggerInterceptor extends 
     /**
      * {@inheritDoc}
      */
-    public void move( NextInterceptor next, MoveOperationContext moveContext ) throws LdapException
+    public void rename( RenameOperationContext renameContext ) throws LdapException
     {
+        Dn name = renameContext.getDn();
+        Rdn newRdn = renameContext.getNewRdn();
+        boolean deleteOldRn = renameContext.getDeleteOldRdn();
+
         // Bypass trigger handling if the service is disabled.
         if ( !enabled )
         {
-            next.move( moveContext );
+            next( renameContext );
             return;
         }
 
-        Rdn rdn = moveContext.getRdn();
-        Dn dn = moveContext.getDn();
-        Dn newDn = moveContext.getNewDn();
-        Dn oldSuperior = moveContext.getOldSuperior();
-        Dn newSuperior = moveContext.getNewSuperior();
-
-        // Gather supplementary data.        
-        Entry movedEntry = moveContext.getOriginalEntry();
-
-        //Rdn newRDN = dn.getRdn();
-
-        StoredProcedureParameterInjector injector = new ModifyDNStoredProcedureParameterInjector( moveContext, false,
-            rdn, rdn, oldSuperior, newSuperior, dn, newDn );
-
-        // Gather Trigger Specifications which apply to the entry being exported.
-        List<TriggerSpecification> exportTriggerSpecs = new ArrayList<TriggerSpecification>();
-        addPrescriptiveTriggerSpecs( moveContext, exportTriggerSpecs, dn, movedEntry );
-        addEntryTriggerSpecs( exportTriggerSpecs, movedEntry );
-
-        // Get the entry again without operational attributes
-        // because access control subentry operational attributes
-        // will not be valid at the new location.
-        // This will certainly be fixed by the SubentryInterceptor,
-        // but after this service.
-        CoreSession session = moveContext.getSession();
-        LookupOperationContext lookupContext = new LookupOperationContext( session, dn, SchemaConstants.ALL_USER_ATTRIBUTES_ARRAY );
-
-        Entry importedEntry = directoryService.getPartitionNexus().lookup( lookupContext );
-
-        // As the target entry does not exist yet and so
-        // its subentry operational attributes are not there,
-        // we need to construct an entry to represent it
-        // at least with minimal requirements which are object class
-        // and access control subentry operational attributes.
-        Entry fakeImportedEntry = subentryUtils.getSubentryAttributes( newDn, importedEntry );
+        // Gather supplementary data.
+        Entry renamedEntry = ((ClonedServerEntry)renameContext.getEntry()).getClonedEntry();
 
-        for ( Attribute attribute : importedEntry )
-        {
-            fakeImportedEntry.put( attribute );
-        }
+        // @TODO : To be completely reviewed !!!
+        Rdn oldRdn = name.getRdn();
+        Dn oldSuperiorDn = name.getParent();
+        Dn newSuperiorDn = oldSuperiorDn;
+        Dn oldDn = name;
+        Dn newDn = name;
+        newDn = newDn.add( newRdn );
 
-        // Gather Trigger Specifications which apply to the entry being imported.
-        // Note: Entry Trigger Specifications are not valid for Import.
-        List<TriggerSpecification> importTriggerSpecs = new ArrayList<TriggerSpecification>();
-        addPrescriptiveTriggerSpecs( moveContext, importTriggerSpecs, newDn, fakeImportedEntry );
+        StoredProcedureParameterInjector injector = new ModifyDNStoredProcedureParameterInjector( renameContext,
+            deleteOldRn, oldRdn, newRdn, oldSuperiorDn, newSuperiorDn, oldDn, newDn);
 
-        Map<ActionTime, List<TriggerSpecification>> exportTriggerMap = getActionTimeMappedTriggerSpecsForOperation(
-            exportTriggerSpecs, LdapOperation.MODIFYDN_EXPORT );
+        // Gather Trigger Specifications which apply to the entry being renamed.
+        List<TriggerSpecification> triggerSpecs = new ArrayList<TriggerSpecification>();
+        addPrescriptiveTriggerSpecs( renameContext, triggerSpecs, name, renamedEntry );
+        addEntryTriggerSpecs( triggerSpecs, renamedEntry );
 
-        Map<ActionTime, List<TriggerSpecification>> importTriggerMap = getActionTimeMappedTriggerSpecsForOperation(
-            importTriggerSpecs, LdapOperation.MODIFYDN_IMPORT );
+        Map<ActionTime, List<TriggerSpecification>> triggerMap = getActionTimeMappedTriggerSpecsForOperation(
+            triggerSpecs, LdapOperation.MODIFYDN_RENAME );
 
-        next.move( moveContext );
-        triggerSpecCache.subentryRenamed( dn, newDn );
+        next( renameContext );
+        triggerSpecCache.subentryRenamed( name, newDn);
 
         // Fire AFTER Triggers.
-        List<TriggerSpecification> afterExportTriggerSpecs = exportTriggerMap.get( ActionTime.AFTER );
-        List<TriggerSpecification> afterImportTriggerSpecs = importTriggerMap.get( ActionTime.AFTER );
-        executeTriggers( moveContext, afterExportTriggerSpecs, injector );
-        executeTriggers( moveContext, afterImportTriggerSpecs, injector );
+        List<TriggerSpecification> afterTriggerSpecs = triggerMap.get( ActionTime.AFTER );
+        executeTriggers( renameContext, afterTriggerSpecs, injector );
     }
 
 
@@ -589,7 +613,7 @@ public class TriggerInterceptor extends 
     {
         List<Object> returnValues = new ArrayList<Object>();
         List<SPSpec> spSpecs = tsec.getSPSpecs();
-        
+
         for ( SPSpec spSpec : spSpecs )
         {
             List<Object> arguments = new ArrayList<Object>();
@@ -609,7 +633,7 @@ public class TriggerInterceptor extends 
         {
             Entry spUnit = manager.findStoredProcUnit( opContext.getSession(), procedure );
             StoredProcEngine engine = manager.getStoredProcEngineInstance( spUnit );
-            
+
             return engine.invokeProcedure( opContext.getSession(), procedure, values );
         }
         catch ( Exception e )

Propchange: directory/apacheds/branches/apacheds-txns/jdbm/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Nov 12 18:24:38 2011
@@ -5,5 +5,5 @@
 /directory/apacheds/branches/apacheds-kerberos-codec-2.0/jdbm:1040956-1043765
 /directory/apacheds/branches/milestones/jdbm:1072812-1075328
 /directory/apacheds/trunk/interceptors/jdbm:1183435-1186974
-/directory/apacheds/trunk/jdbm:1066126-1067785,1068026-1072718,1072800-1075329,1177661-1186962
+/directory/apacheds/trunk/jdbm:1066126-1067785,1068026-1072718,1072800-1075329,1177661-1201283
 /directory/studio/trunk/jdbm:1067786-1067997

Propchange: directory/apacheds/branches/apacheds-txns/jdbm-partition/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Nov 12 18:24:38 2011
@@ -5,5 +5,5 @@
 /directory/apacheds/branches/apacheds-kerberos-codec-2.0/jdbm-partition:1040956-1043765
 /directory/apacheds/branches/milestones/jdbm-partition:1072812-1075328
 /directory/apacheds/trunk/interceptors/jdbm-partition:1183435-1186974
-/directory/apacheds/trunk/jdbm-partition:1066126-1067785,1068026-1072718,1072800-1075329,1177661-1186962
+/directory/apacheds/trunk/jdbm-partition:1066126-1067785,1068026-1072718,1072800-1075329,1177661-1201283
 /directory/studio/trunk/jdbm-partition:1067786-1067997

Propchange: directory/apacheds/branches/apacheds-txns/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Nov 12 18:24:38 2011
@@ -9,5 +9,5 @@
 /directory/apacheds/branches/milestones/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree:1072812-1075328
 /directory/apacheds/branches/xdbm-refactoring/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree:945827-946347
 /directory/apacheds/trunk/interceptors/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree:1183435-1186974
-/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree:498338-580500,806623-894866*,1066126-1067785,1068026-1072718,1072800-1075329,1177661-1186962
+/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree:498338-580500,806623-894866*,1066126-1067785,1068026-1072718,1072800-1075329,1177661-1201283
 /directory/studio/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree:1067786-1067997

Propchange: directory/apacheds/branches/apacheds-txns/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/PartitionTreeTest.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Nov 12 18:24:38 2011
@@ -9,5 +9,5 @@
 /directory/apacheds/branches/milestones/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/PartitionTreeTest.java:1072812-1075328
 /directory/apacheds/branches/xdbm-refactoring/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/PartitionTreeTest.java:945827-946347
 /directory/apacheds/trunk/interceptors/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/PartitionTreeTest.java:1183435-1186974
-/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/PartitionTreeTest.java:498338-580500,806623-894866,1066126-1067785,1068026-1072718,1072800-1075329,1177661-1186962
+/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/PartitionTreeTest.java:498338-580500,806623-894866,1066126-1067785,1068026-1072718,1072800-1075329,1177661-1201283
 /directory/studio/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/PartitionTreeTest.java:1067786-1067997

Propchange: directory/apacheds/branches/apacheds-txns/kerberos-codec/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Nov 12 18:24:38 2011
@@ -7,5 +7,5 @@
 /directory/apacheds/branches/milestones/kerberos-codec:1072812-1075328
 /directory/apacheds/branches/xdbm-refactoring/kerberos-codec:945827-946347
 /directory/apacheds/trunk/interceptors/kerberos-codec:1183435-1186974
-/directory/apacheds/trunk/kerberos-codec:1066126-1067785,1068026-1072718,1072800-1075329,1177661-1186962
+/directory/apacheds/trunk/kerberos-codec:1066126-1067785,1068026-1072718,1072800-1075329,1177661-1201283
 /directory/studio/trunk/kerberos-codec:1067786-1067997

Propchange: directory/apacheds/branches/apacheds-txns/kerberos-codec/src/main/java/org/apache/directory/server/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Nov 12 18:24:38 2011
@@ -4,5 +4,5 @@
 /directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/server:1040956-1043765
 /directory/apacheds/branches/milestones/kerberos-codec/src/main/java/org/apache/directory/server:1072812-1075328
 /directory/apacheds/trunk/interceptors/kerberos-codec/src/main/java/org/apache/directory/server:1183435-1186974
-/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server:1066126-1067785,1068026-1072718,1072800-1075329,1177661-1186962
+/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server:1066126-1067785,1068026-1072718,1072800-1075329,1177661-1201283
 /directory/studio/trunk/kerberos-codec/src/main/java/org/apache/directory/server:1067786-1067997

Propchange: directory/apacheds/branches/apacheds-txns/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/protocol/codec/KerberosProtocolCodecFactory.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Nov 12 18:24:38 2011
@@ -4,4 +4,5 @@
 /directory/apacheds/branches/milestones/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolCodecFactory.java:1072812-1075328
 /directory/apacheds/trunk/interceptors/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/protocol/codec/KerberosProtocolCodecFactory.java:1183435-1186974
 /directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolCodecFactory.java:1066126-1067785,1068026-1072718,1072800-1075329
+/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/protocol/codec/KerberosProtocolCodecFactory.java:1181278-1201283
 /directory/studio/trunk/kerberos-codec/src/main/java/org/apache/directory/server/kerberos/protocol/KerberosProtocolCodecFactory.java:1067786-1067997

Propchange: directory/apacheds/branches/apacheds-txns/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PaDataType.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Nov 12 18:24:38 2011
@@ -4,5 +4,5 @@
 /directory/apacheds/branches/apacheds-kerberos-codec-2.0/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PaDataType.java:1040956-1043765
 /directory/apacheds/branches/milestones/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PaDataType.java:1072812-1075328
 /directory/apacheds/trunk/interceptors/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PaDataType.java:1183435-1186974
-/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PaDataType.java:1066126-1067785,1068026-1072718,1072800-1075329,1177661-1186962
+/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PaDataType.java:1066126-1067785,1068026-1072718,1072800-1075329,1177661-1201283
 /directory/studio/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/PaDataType.java:1067786-1067997

Propchange: directory/apacheds/branches/apacheds-txns/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/SamType.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Nov 12 18:24:38 2011
@@ -3,5 +3,5 @@
 /directory/apacheds/branches/apacheds-dnfactory-experiment/kerberos-shared/src/main/java/org/apache/directory/server/kerberos/shared/messages/value/types/SamType.java:980138-980936
 /directory/apacheds/branches/milestones/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/SamType.java:1072812-1075328
 /directory/apacheds/trunk/interceptors/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/SamType.java:1183435-1186974
-/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/SamType.java:1066126-1067785,1068026-1072718,1072800-1075329,1177661-1186962
+/directory/apacheds/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/SamType.java:1066126-1067785,1068026-1072718,1072800-1075329,1177661-1201283
 /directory/studio/trunk/kerberos-codec/src/main/java/org/apache/directory/shared/kerberos/codec/types/SamType.java:1067786-1067997