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 2010/05/29 16:30:38 UTC

svn commit: r949396 [2/2] - in /directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core: ./ authz/ event/ exception/ normalization/ subtree/ trigger/

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java?rev=949396&r1=949395&r2=949396&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java Sat May 29 14:30:37 2010
@@ -66,87 +66,85 @@ public class EventInterceptor extends Ba
 {
     private final static Logger LOG = LoggerFactory.getLogger( EventInterceptor.class );
 
-    
     private List<RegistrationEntry> registrations = new CopyOnWriteArrayList<RegistrationEntry>();
     private DirectoryService ds;
     private FilterNormalizingVisitor filterNormalizer;
     private Evaluator evaluator;
     private ExecutorService executor;
-    
-    
+
+
     @Override
     public void init( DirectoryService ds ) throws Exception
     {
         LOG.info( "Initializing ..." );
         super.init( ds );
-        
+
         this.ds = ds;
         OidRegistry oidRegistry = ds.getSchemaManager().getGlobalOidRegistry();
         SchemaManager schemaManager = ds.getSchemaManager();
         NameComponentNormalizer ncn = new ConcreteNameComponentNormalizer( schemaManager );
         filterNormalizer = new FilterNormalizingVisitor( ncn, schemaManager );
         evaluator = new ExpressionEvaluator( oidRegistry, schemaManager );
-        executor = new ThreadPoolExecutor( 1, 10, 1000, TimeUnit.MILLISECONDS, 
-            new ArrayBlockingQueue<Runnable>( 100 ) );
-        
+        executor = new ThreadPoolExecutor( 1, 10, 1000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>( 100 ) );
+
         this.ds.setEventService( new DefaultEventService() );
         LOG.info( "Initialization complete." );
     }
 
-    
+
     private void fire( final OperationContext opContext, EventType type, final DirectoryListener listener )
     {
         switch ( type )
         {
             case ADD:
-                executor.execute( new Runnable() 
+                executor.execute( new Runnable()
                 {
                     public void run()
                     {
                         listener.entryAdded( ( AddOperationContext ) opContext );
                     }
-                });
+                } );
                 break;
             case DELETE:
-                executor.execute( new Runnable() 
+                executor.execute( new Runnable()
                 {
                     public void run()
                     {
                         listener.entryDeleted( ( DeleteOperationContext ) opContext );
                     }
-                });
+                } );
                 break;
             case MODIFY:
-                executor.execute( new Runnable() 
+                executor.execute( new Runnable()
                 {
                     public void run()
                     {
                         listener.entryModified( ( ModifyOperationContext ) opContext );
                     }
-                });
+                } );
                 break;
             case MOVE:
-                executor.execute( new Runnable() 
+                executor.execute( new Runnable()
                 {
                     public void run()
                     {
                         listener.entryMoved( ( MoveOperationContext ) opContext );
                     }
-                });
+                } );
                 break;
             case RENAME:
-                executor.execute( new Runnable() 
+                executor.execute( new Runnable()
                 {
                     public void run()
                     {
                         listener.entryRenamed( ( RenameOperationContext ) opContext );
                     }
-                });
+                } );
                 break;
         }
     }
-    
-    
+
+
     public void add( NextInterceptor next, final AddOperationContext opContext ) throws Exception
     {
         next.add( opContext );
@@ -190,8 +188,10 @@ public class EventInterceptor extends Ba
     public void modify( NextInterceptor next, final ModifyOperationContext opContext ) throws Exception
     {
         Entry oriEntry = opContext.lookup( opContext.getDn(), ByPassConstants.LOOKUP_BYPASS );
+        //        Entry oriEntry = opContext.getEntry();
+
         List<RegistrationEntry> selecting = getSelectingRegistrations( opContext.getDn(), oriEntry );
-        
+
         next.modify( opContext );
 
         if ( selecting.isEmpty() )
@@ -201,7 +201,7 @@ public class EventInterceptor extends Ba
 
         // Get the modified entry
         Entry alteredEntry = opContext.lookup( opContext.getDn(), ByPassConstants.LOOKUP_BYPASS );
-        opContext.setAlteredEntry( (ClonedServerEntry)alteredEntry );
+        opContext.setAlteredEntry( ( ClonedServerEntry ) alteredEntry );
 
         for ( final RegistrationEntry registration : selecting )
         {
@@ -217,7 +217,7 @@ public class EventInterceptor extends Ba
     {
         Entry oriEntry = opContext.lookup( opContext.getDn(), ByPassConstants.LOOKUP_BYPASS );
         List<RegistrationEntry> selecting = getSelectingRegistrations( opContext.getDn(), oriEntry );
-        
+
         next.rename( opContext );
 
         if ( selecting.isEmpty() )
@@ -227,8 +227,8 @@ public class EventInterceptor extends Ba
 
         // Get the modifed entry
         Entry alteredEntry = opContext.lookup( opContext.getNewDn(), ByPassConstants.LOOKUP_BYPASS );
-        opContext.setAlteredEntry( (ClonedServerEntry)alteredEntry );
-        
+        opContext.setAlteredEntry( ( ClonedServerEntry ) alteredEntry );
+
         for ( final RegistrationEntry registration : selecting )
         {
             if ( EventType.isRename( registration.getCriteria().getEventMask() ) )
@@ -250,19 +250,20 @@ public class EventInterceptor extends Ba
             return;
         }
 
-        opContext.setAlteredEntry( (ClonedServerEntry)opContext.lookup( opContext.getNewDn(), ByPassConstants.LOOKUP_BYPASS ) );
-        
+        opContext.setAlteredEntry( ( ClonedServerEntry ) opContext.lookup( opContext.getNewDn(),
+            ByPassConstants.LOOKUP_BYPASS ) );
+
         for ( final RegistrationEntry registration : selecting )
         {
             if ( EventType.isMoveAndRename( registration.getCriteria().getEventMask() ) )
             {
-                executor.execute( new Runnable() 
+                executor.execute( new Runnable()
                 {
                     public void run()
                     {
                         registration.getListener().entryMovedAndRenamed( opContext );
                     }
-                });
+                } );
             }
         }
     }
@@ -272,7 +273,7 @@ public class EventInterceptor extends Ba
     {
         Entry oriEntry = opContext.lookup( opContext.getDn(), ByPassConstants.LOOKUP_BYPASS );
         List<RegistrationEntry> selecting = getSelectingRegistrations( opContext.getDn(), oriEntry );
-        
+
         next.move( opContext );
 
         if ( selecting.isEmpty() )
@@ -288,8 +289,8 @@ public class EventInterceptor extends Ba
             }
         }
     }
-    
-    
+
+
     List<RegistrationEntry> getSelectingRegistrations( DN name, Entry entry ) throws Exception
     {
         if ( registrations.isEmpty() )
@@ -298,15 +299,16 @@ public class EventInterceptor extends Ba
         }
 
         List<RegistrationEntry> selecting = new ArrayList<RegistrationEntry>();
-        
+
         for ( RegistrationEntry registration : registrations )
         {
             NotificationCriteria criteria = registration.getCriteria();
-            
+
             DN base = criteria.getBase();
 
             // fix for DIRSERVER-1502
-            if( name.equals( base ) || name.isChildOf( base ) && evaluator.evaluate( criteria.getFilter(), base, entry ) )
+            if ( name.equals( base ) || name.isChildOf( base )
+                && evaluator.evaluate( criteria.getFilter(), base, entry ) )
             {
                 selecting.add( registration );
             }
@@ -314,13 +316,11 @@ public class EventInterceptor extends Ba
 
         return selecting;
     }
-    
-    
+
     // -----------------------------------------------------------------------
     // EventService Inner Class
     // -----------------------------------------------------------------------
-    
-    
+
     class DefaultEventService implements EventService
     {
         /*
@@ -331,7 +331,7 @@ public class EventInterceptor extends Ba
             registrations.add( new RegistrationEntry( listener ) );
         }
 
-        
+
         /*
          * Normalizes the criteria filter and the base.
          */
@@ -343,7 +343,7 @@ public class EventInterceptor extends Ba
             registrations.add( new RegistrationEntry( listener, criteria ) );
         }
 
-        
+
         public void removeListener( DirectoryListener listener )
         {
             for ( RegistrationEntry entry : registrations )

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java?rev=949396&r1=949395&r2=949396&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java Sat May 29 14:30:37 2010
@@ -47,10 +47,10 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.cursor.EmptyCursor;
+import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
-import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.exception.LdapAliasException;
 import org.apache.directory.shared.ldap.exception.LdapAttributeInUseException;
@@ -78,7 +78,6 @@ public class ExceptionInterceptor extend
     private DirectoryService directoryService;
     private DN subschemSubentryDn;
 
-    
     /**
      * A cache to store entries which are not aliases. 
      * It's a speedup, we will be able to avoid backend lookups.
@@ -96,13 +95,13 @@ public class ExceptionInterceptor extend
      * 
      * We need to be sure that frequently used DNs are always in cache, and not discarded.
      * We will use a LRU cache for this purpose. 
-     */ 
+     */
     private final LRUMap notAliasCache = new LRUMap( DEFAULT_CACHE_SIZE );
 
     /** Declare a default for this cache. 100 entries seems to be enough */
     private static final int DEFAULT_CACHE_SIZE = 100;
 
-    
+
     /**
      * Creates an interceptor that is also the exception handling service.
      */
@@ -125,70 +124,71 @@ public class ExceptionInterceptor extend
     {
     }
 
+
     /**
      * In the pre-invocation state this interceptor method checks to see if the entry to be added already exists.  If it
      * does an exception is raised.
      */
-    public void add( NextInterceptor nextInterceptor, AddOperationContext opContext )
-        throws Exception
+    public void add( NextInterceptor nextInterceptor, AddOperationContext opContext ) throws Exception
     {
         DN name = opContext.getDn();
-        
+
         if ( subschemSubentryDn.getNormName().equals( name.getNormName() ) )
         {
             throw new LdapEntryAlreadyExistsException( I18n.err( I18n.ERR_249 ) );
         }
-        
+
         // check if the entry already exists
         if ( nextInterceptor.hasEntry( new EntryOperationContext( opContext.getSession(), name ) ) )
         {
-            LdapEntryAlreadyExistsException ne = new LdapEntryAlreadyExistsException( I18n.err( I18n.ERR_250, name.getName() ) );
+            LdapEntryAlreadyExistsException ne = new LdapEntryAlreadyExistsException( I18n.err( I18n.ERR_250, name
+                .getName() ) );
             //ne.setResolvedName( new DN( name.getName() ) );
             throw ne;
         }
-        
-        DN suffix = nexus.getSuffix( new GetSuffixOperationContext( this.directoryService.getAdminSession(), 
-            name ) );
-        
+
+        DN suffix = nexus.getSuffix( new GetSuffixOperationContext( this.directoryService.getAdminSession(), name ) );
+
         // we're adding the suffix entry so just ignore stuff to mess with the parent
         if ( suffix.equals( name ) )
         {
             nextInterceptor.add( opContext );
             return;
         }
-        
+
         DN parentDn = ( DN ) name.clone();
         parentDn.remove( name.size() - 1 );
-        
+
         // check if we're trying to add to a parent that is an alias
         boolean notAnAlias;
-        
-        synchronized( notAliasCache )
+
+        synchronized ( notAliasCache )
         {
             notAnAlias = notAliasCache.containsKey( parentDn.getNormName() );
         }
-        
-        if ( ! notAnAlias )
+
+        if ( !notAnAlias )
         {
             // We don't know if the parent is an alias or not, so we will launch a 
             // lookup, and update the cache if it's not an alias
             Entry attrs;
-            
+
             try
             {
                 attrs = opContext.lookup( parentDn, ByPassConstants.LOOKUP_BYPASS );
             }
             catch ( Exception e )
             {
-                LdapNoSuchObjectException e2 = new LdapNoSuchObjectException( I18n.err( I18n.ERR_251, 
-                    parentDn.getName() ) );
+                LdapNoSuchObjectException e2 = new LdapNoSuchObjectException( I18n.err( I18n.ERR_251, parentDn
+                    .getName() ) );
                 //e2.setResolvedName( new DN( nexus.getMatchedName( 
-                  //  new GetMatchedNameOperationContext( opContext.getSession(), parentDn ) ).getName() ) );
+                //  new GetMatchedNameOperationContext( opContext.getSession(), parentDn ) ).getName() ) );
                 throw e2;
             }
-            
-            EntryAttribute objectClass = ((ClonedServerEntry)attrs).getOriginalEntry().get( SchemaConstants.OBJECT_CLASS_AT );
-            
+
+            EntryAttribute objectClass = ( ( ClonedServerEntry ) attrs ).getOriginalEntry().get(
+                SchemaConstants.OBJECT_CLASS_AT );
+
             if ( objectClass.contains( SchemaConstants.ALIAS_OC ) )
             {
                 String msg = I18n.err( I18n.ERR_252, name.getName() );
@@ -216,17 +216,17 @@ public class ExceptionInterceptor extend
     public void delete( NextInterceptor nextInterceptor, DeleteOperationContext opContext ) throws Exception
     {
         DN dn = opContext.getDn();
-        
+
         if ( dn.equals( subschemSubentryDn ) )
         {
-            throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM,
-                I18n.err( I18n.ERR_253, subschemSubentryDn ) );
+            throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, I18n.err( I18n.ERR_253,
+                subschemSubentryDn ) );
         }
-        
+
         nextInterceptor.delete( opContext );
 
         // Update the alias cache
-        synchronized( notAliasCache )
+        synchronized ( notAliasCache )
         {
             if ( notAliasCache.containsKey( dn.getNormName() ) )
             {
@@ -239,14 +239,15 @@ public class ExceptionInterceptor extend
     /**
      * Checks to see the base being searched exists, otherwise throws the appropriate LdapException.
      */
-    public EntryFilteringCursor list( NextInterceptor nextInterceptor, ListOperationContext opContext ) throws Exception
+    public EntryFilteringCursor list( NextInterceptor nextInterceptor, ListOperationContext opContext )
+        throws Exception
     {
         if ( opContext.getDn().getNormName().equals( subschemSubentryDn.getNormName() ) )
         {
             // there is nothing under the schema subentry
             return new BaseEntryFilteringCursor( new EmptyCursor<Entry>(), opContext );
         }
-        
+
         // check if entry to search exists
         String msg = "Attempt to search under non-existant entry: ";
         assertHasEntry( opContext, msg, opContext.getDn() );
@@ -261,30 +262,30 @@ public class ExceptionInterceptor extend
     public Entry lookup( NextInterceptor nextInterceptor, LookupOperationContext opContext ) throws Exception
     {
         DN dn = opContext.getDn();
-        
+
         if ( dn.equals( subschemSubentryDn ) )
         {
             return nexus.getRootDSE( null );
         }
-        
+
         Entry result = nextInterceptor.lookup( opContext );
-        
+
         if ( result == null )
         {
-            LdapNoSuchObjectException e = new LdapNoSuchObjectException( "Attempt to lookup non-existant entry: " + dn.getName() );
+            LdapNoSuchObjectException e = new LdapNoSuchObjectException( "Attempt to lookup non-existant entry: "
+                + dn.getName() );
 
             throw e;
         }
-        
-        return result; 
+
+        return result;
     }
 
 
     /**
      * Checks to see the entry being modified exists, otherwise throws the appropriate LdapException.
      */
-    public void modify( NextInterceptor nextInterceptor, ModifyOperationContext opContext )
-        throws Exception
+    public void modify( NextInterceptor nextInterceptor, ModifyOperationContext opContext ) throws Exception
     {
         // check if entry to modify exists
         String msg = "Attempt to modify non-existant entry: ";
@@ -296,10 +297,12 @@ public class ExceptionInterceptor extend
             nextInterceptor.modify( opContext );
             return;
         }
-        
-        assertHasEntry( opContext, msg, opContext.getDn() );
+
+        assertHasEntry( opContext, msg );
 
         Entry entry = opContext.lookup( opContext.getDn(), ByPassConstants.LOOKUP_BYPASS );
+        //         Entry entry = opContext.getEntry();
+
         List<Modification> items = opContext.getModItems();
 
         for ( Modification item : items )
@@ -311,12 +314,11 @@ public class ExceptionInterceptor extend
 
                 if ( entryAttr != null )
                 {
-                    for ( Value<?> value:modAttr )
+                    for ( Value<?> value : modAttr )
                     {
                         if ( entryAttr.contains( value ) )
                         {
-                            throw new LdapAttributeInUseException( I18n.err( I18n.ERR_254, value,
-                                modAttr.getId() ) );
+                            throw new LdapAttributeInUseException( I18n.err( I18n.ERR_254, value, modAttr.getId() ) );
                         }
                     }
                 }
@@ -328,7 +330,7 @@ public class ExceptionInterceptor extend
         // We will simply remove the DN from the NotAlias cache.
         // It would be smarter to check the modified attributes, but
         // it would also be more complex.
-        synchronized( notAliasCache )
+        synchronized ( notAliasCache )
         {
             if ( notAliasCache.containsKey( opContext.getDn().getNormName() ) )
             {
@@ -339,20 +341,20 @@ public class ExceptionInterceptor extend
         nextInterceptor.modify( opContext );
     }
 
+
     /**
      * Checks to see the entry being renamed exists, otherwise throws the appropriate LdapException.
      */
-    public void rename( NextInterceptor nextInterceptor, RenameOperationContext opContext )
-        throws Exception
+    public void rename( NextInterceptor nextInterceptor, RenameOperationContext opContext ) throws Exception
     {
         DN dn = opContext.getDn();
-        
+
         if ( dn.equals( subschemSubentryDn ) )
         {
-            throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, I18n.err( I18n.ERR_255, subschemSubentryDn,
-                    subschemSubentryDn ) );
+            throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, I18n.err( I18n.ERR_255,
+                subschemSubentryDn, subschemSubentryDn ) );
         }
-        
+
         // Check to see if the renamed entry exists
         if ( opContext.getEntry() == null )
         {
@@ -363,10 +365,10 @@ public class ExceptionInterceptor extend
             //ldnfe.setResolvedName( new DN( dn.getName() ) );
             throw ldnfe;
         }
-        
+
         // check to see if target entry exists
         DN newDn = opContext.getNewDn();
-        
+
         if ( nextInterceptor.hasEntry( new EntryOperationContext( opContext.getSession(), newDn ) ) )
         {
             LdapEntryAlreadyExistsException e;
@@ -376,7 +378,7 @@ public class ExceptionInterceptor extend
         }
 
         // Remove the previous entry from the notAnAlias cache
-        synchronized( notAliasCache )
+        synchronized ( notAliasCache )
         {
             if ( notAliasCache.containsKey( dn.getNormName() ) )
             {
@@ -396,13 +398,13 @@ public class ExceptionInterceptor extend
     {
         DN oriChildName = opContext.getDn();
         DN newParentName = opContext.getParent();
-        
+
         if ( oriChildName.getNormName().equalsIgnoreCase( subschemSubentryDn.getNormName() ) )
         {
-            throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, I18n.err( I18n.ERR_258, subschemSubentryDn,
-                    subschemSubentryDn ) );
+            throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, I18n.err( I18n.ERR_258,
+                subschemSubentryDn, subschemSubentryDn ) );
         }
-        
+
         // check if child to move exists
         String msg = "Attempt to move to non-existant parent: ";
         assertHasEntry( opContext, msg, oriChildName );
@@ -415,7 +417,7 @@ public class ExceptionInterceptor extend
         String rdn = oriChildName.get( oriChildName.size() - 1 );
         DN target = ( DN ) newParentName.clone();
         target.add( rdn );
-        
+
         if ( nextInterceptor.hasEntry( new EntryOperationContext( opContext.getSession(), target ) ) )
         {
             // we must calculate the resolved name using the user provided Rdn value
@@ -430,14 +432,14 @@ public class ExceptionInterceptor extend
         }
 
         // Remove the original entry from the NotAlias cache, if needed
-        synchronized( notAliasCache )
+        synchronized ( notAliasCache )
         {
             if ( notAliasCache.containsKey( oriChildName.getNormName() ) )
             {
                 notAliasCache.remove( oriChildName.getNormName() );
             }
         }
-                
+
         nextInterceptor.move( opContext );
     }
 
@@ -446,17 +448,18 @@ public class ExceptionInterceptor extend
      * Checks to see the entry being moved exists, and so does its parent, otherwise throws the appropriate
      * LdapException.
      */
-    public void moveAndRename( NextInterceptor nextInterceptor, MoveAndRenameOperationContext opContext ) throws Exception
+    public void moveAndRename( NextInterceptor nextInterceptor, MoveAndRenameOperationContext opContext )
+        throws Exception
     {
         DN oriChildName = opContext.getDn();
         DN parent = opContext.getParent();
 
         if ( oriChildName.getNormName().equalsIgnoreCase( subschemSubentryDn.getNormName() ) )
         {
-            throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, I18n.err( I18n.ERR_258, subschemSubentryDn,
-                    subschemSubentryDn ) );
+            throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, I18n.err( I18n.ERR_258,
+                subschemSubentryDn, subschemSubentryDn ) );
         }
-        
+
         // check if child to move exists
         String msg = "Attempt to move to non-existant parent: ";
         assertHasEntry( opContext, msg, oriChildName );
@@ -482,14 +485,14 @@ public class ExceptionInterceptor extend
         }
 
         // Remove the original entry from the NotAlias cache, if needed
-        synchronized( notAliasCache )
+        synchronized ( notAliasCache )
         {
             if ( notAliasCache.containsKey( oriChildName.getNormName() ) )
             {
                 notAliasCache.remove( oriChildName.getNormName() );
             }
         }
-        
+
         nextInterceptor.moveAndRename( opContext );
     }
 
@@ -497,19 +500,20 @@ public class ExceptionInterceptor extend
     /**
      * Checks to see the entry being searched exists, otherwise throws the appropriate LdapException.
      */
-    public EntryFilteringCursor search( NextInterceptor nextInterceptor, SearchOperationContext opContext ) throws Exception
+    public EntryFilteringCursor search( NextInterceptor nextInterceptor, SearchOperationContext opContext )
+        throws Exception
     {
         DN base = opContext.getDn();
 
         try
         {
-            EntryFilteringCursor cursor =  nextInterceptor.search( opContext );
-            
-            if ( ! cursor.next() && !base.isEmpty() && !( subschemSubentryDn.getNormName() ).equalsIgnoreCase( 
-                base.getNormName() ) )
+            EntryFilteringCursor cursor = nextInterceptor.search( opContext );
+
+            if ( !cursor.next() && !base.isEmpty()
+                && !( subschemSubentryDn.getNormName() ).equalsIgnoreCase( base.getNormName() ) )
             {
                 // We just check that the entry exists only if we didn't found any entry
-                assertHasEntry( opContext, "Attempt to search under non-existant entry:" , base );
+                assertHasEntry( opContext, "Attempt to search under non-existant entry:", opContext.getDn() );
             }
 
             return cursor;
@@ -517,7 +521,7 @@ public class ExceptionInterceptor extend
         catch ( Exception ne )
         {
             String msg = I18n.err( I18n.ERR_259 );
-            assertHasEntry( opContext, msg, base );
+            assertHasEntry( opContext, msg, opContext.getDn() );
             throw ne;
         }
     }
@@ -528,19 +532,53 @@ public class ExceptionInterceptor extend
      * used to set the before exception on the invocation - eventually the exception is thrown.
      *
      * @param msg        the message to prefix to the distinguished name for explanation
+     * @throws Exception if the entry does not exist
+     * @param nextInterceptor the next interceptor in the chain
+     */
+    private void assertHasEntry( OperationContext opContext, String msg ) throws Exception
+    {
+        DN dn = opContext.getDn();
+
+        if ( subschemSubentryDn.equals( dn ) )
+        {
+            return;
+        }
+
+        if ( opContext.getEntry() == null )
+        {
+            LdapNoSuchObjectException e;
+
+            if ( msg != null )
+            {
+                e = new LdapNoSuchObjectException( msg + dn.getName() );
+            }
+            else
+            {
+                e = new LdapNoSuchObjectException( dn.getName() );
+            }
+
+            throw e;
+        }
+    }
+
+
+    /**
+     * Asserts that an entry is present and as a side effect if it is not, creates a LdapNoSuchObjectException, which is
+     * used to set the before exception on the invocation - eventually the exception is thrown.
+     *
+     * @param msg        the message to prefix to the distinguished name for explanation
      * @param dn         the distinguished name of the entry that is asserted
      * @throws Exception if the entry does not exist
      * @param nextInterceptor the next interceptor in the chain
      */
-    private void assertHasEntry( OperationContext opContext, 
-        String msg, DN dn ) throws Exception
+    private void assertHasEntry( OperationContext opContext, String msg, DN dn ) throws Exception
     {
         if ( subschemSubentryDn.equals( dn ) )
         {
             return;
         }
-        
-        if ( ! opContext.hasEntry( dn, ByPassConstants.HAS_ENTRY_BYPASS ) )
+
+        if ( !opContext.hasEntry( dn, ByPassConstants.HAS_ENTRY_BYPASS ) )
         {
             LdapNoSuchObjectException e;
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java?rev=949396&r1=949395&r2=949396&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java Sat May 29 14:30:37 2010
@@ -45,8 +45,8 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
 import org.apache.directory.server.core.partition.DefaultPartitionNexus;
 import org.apache.directory.shared.ldap.cursor.EmptyCursor;
-import org.apache.directory.shared.ldap.entry.StringValue;
 import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.StringValue;
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.name.AVA;
@@ -86,18 +86,20 @@ public class NormalizationInterceptor ex
     /** The attributeType registry */
     private SchemaManager schemaManager;
 
+
     /**
      * Initialize the registries, normalizers. 
      */
     public void init( DirectoryService directoryService ) throws Exception
     {
         LOG.debug( "Initialiazing the NormalizationInterceptor" );
-        
+
         schemaManager = directoryService.getSchemaManager();
         NameComponentNormalizer ncn = new ConcreteNameComponentNormalizer( schemaManager );
         normVisitor = new FilterNormalizingVisitor( ncn, schemaManager );
     }
 
+
     /**
      * The destroy method does nothing
      */
@@ -105,6 +107,7 @@ public class NormalizationInterceptor ex
     {
     }
 
+
     // ------------------------------------------------------------------------
     // Normalize all Name based arguments for ContextPartition interface operations
     // ------------------------------------------------------------------------
@@ -126,12 +129,12 @@ public class NormalizationInterceptor ex
     public void delete( NextInterceptor nextInterceptor, DeleteOperationContext opContext ) throws Exception
     {
         DN dn = opContext.getDn();
-        
+
         if ( !dn.isNormalized() )
         {
             dn.normalize( schemaManager.getNormalizerMapping() );
         }
-        
+
         nextInterceptor.delete( opContext );
     }
 
@@ -141,7 +144,11 @@ public class NormalizationInterceptor ex
      */
     public void modify( NextInterceptor nextInterceptor, ModifyOperationContext opContext ) throws Exception
     {
-        opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
+        if ( !opContext.getDn().isNormalized() )
+        {
+            opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
+        }
+
         nextInterceptor.modify( opContext );
     }
 
@@ -167,7 +174,7 @@ public class NormalizationInterceptor ex
     public void move( NextInterceptor nextInterceptor, MoveOperationContext opContext ) throws Exception
     {
         opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
-        opContext.getParent().normalize( schemaManager.getNormalizerMapping());
+        opContext.getParent().normalize( schemaManager.getNormalizerMapping() );
         nextInterceptor.move( opContext );
     }
 
@@ -192,29 +199,31 @@ public class NormalizationInterceptor ex
     /**
      * {@inheritDoc}
      */
-    public EntryFilteringCursor search( NextInterceptor nextInterceptor, SearchOperationContext opContext ) throws Exception
+    public EntryFilteringCursor search( NextInterceptor nextInterceptor, SearchOperationContext opContext )
+        throws Exception
     {
         DN dn = opContext.getDn();
-        
+
         if ( !dn.isNormalized() )
         {
             dn.normalize( schemaManager.getNormalizerMapping() );
         }
 
         ExprNode filter = opContext.getFilter();
-        
+
         // Normalize the filter
         ExprNode result = ( ExprNode ) filter.accept( normVisitor );
 
         if ( result == null )
         {
-            LOG.warn( "undefined filter based on undefined attributeType not evaluted at all.  Returning empty enumeration." );
+            LOG
+                .warn( "undefined filter based on undefined attributeType not evaluted at all.  Returning empty enumeration." );
             return new BaseEntryFilteringCursor( new EmptyCursor<Entry>(), opContext );
         }
         else
         {
             opContext.setFilter( result );
-            
+
             // TODO Normalize the returned Attributes, storing the UP attributes to format the returned values.
             return nextInterceptor.search( opContext );
         }
@@ -234,13 +243,14 @@ public class NormalizationInterceptor ex
     /**
      * {@inheritDoc}
      */
-    public EntryFilteringCursor list( NextInterceptor nextInterceptor, ListOperationContext opContext ) throws Exception
+    public EntryFilteringCursor list( NextInterceptor nextInterceptor, ListOperationContext opContext )
+        throws Exception
     {
         opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
         return nextInterceptor.list( opContext );
     }
 
-    
+
     /**
      * {@inheritDoc}
      */
@@ -250,35 +260,35 @@ public class NormalizationInterceptor ex
         {
             return attrIds;
         }
-        
+
         String[] normalizedAttrIds = new String[attrIds.length];
         int pos = 0;
-        
-        for ( String id:attrIds )
+
+        for ( String id : attrIds )
         {
             String oid = schemaManager.lookupAttributeTypeRegistry( id ).getOid();
             normalizedAttrIds[pos++] = oid;
         }
-        
+
         return normalizedAttrIds;
     }
 
-    
+
     /**
      * {@inheritDoc}
      */
     public Entry lookup( NextInterceptor nextInterceptor, LookupOperationContext opContext ) throws Exception
     {
         opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
-        
+
         List<String> attrIds = opContext.getAttrsId();
-        
+
         if ( ( attrIds != null ) && ( attrIds.size() > 0 ) )
         {
             // We have to normalize the requested IDs
             opContext.setAttrsId( normalizeAttrsId( opContext.getAttrsIdArray() ) );
         }
-        
+
         return nextInterceptor.lookup( opContext );
     }
 
@@ -289,7 +299,8 @@ public class NormalizationInterceptor ex
     /**
      * {@inheritDoc}
      */
-    public DN getMatchedName ( NextInterceptor nextInterceptor, GetMatchedNameOperationContext opContext ) throws Exception
+    public DN getMatchedName( NextInterceptor nextInterceptor, GetMatchedNameOperationContext opContext )
+        throws Exception
     {
         opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
         return nextInterceptor.getMatchedName( opContext );
@@ -299,7 +310,7 @@ public class NormalizationInterceptor ex
     /**
      * {@inheritDoc}
      */
-    public DN getSuffix ( NextInterceptor nextInterceptor, GetSuffixOperationContext opContext ) throws Exception
+    public DN getSuffix( NextInterceptor nextInterceptor, GetSuffixOperationContext opContext ) throws Exception
     {
         opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
         return nextInterceptor.getSuffix( opContext );
@@ -312,23 +323,24 @@ public class NormalizationInterceptor ex
     public boolean compare( NextInterceptor next, CompareOperationContext opContext ) throws Exception
     {
         opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
-        
-        AttributeType at = opContext.getSession().getDirectoryService().getSchemaManager().lookupAttributeTypeRegistry( opContext.getOid() );
-        
+
+        AttributeType at = opContext.getSession().getDirectoryService().getSchemaManager().lookupAttributeTypeRegistry(
+            opContext.getOid() );
+
         if ( at.getSyntax().isHumanReadable() && ( opContext.getValue().isBinary() ) )
         {
             String value = opContext.getValue().getString();
             opContext.setValue( new StringValue( value ) );
         }
-        
+
         return next.compare( opContext );
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
-    public void bind( NextInterceptor next, BindOperationContext opContext )  throws Exception
+    public void bind( NextInterceptor next, BindOperationContext opContext ) throws Exception
     {
         opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
         next.bind( opContext );
@@ -338,7 +350,8 @@ public class NormalizationInterceptor ex
     /**
      * {@inheritDoc}
      */
-    public void addContextPartition( NextInterceptor next, AddContextPartitionOperationContext opContext ) throws Exception
+    public void addContextPartition( NextInterceptor next, AddContextPartitionOperationContext opContext )
+        throws Exception
     {
         opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
         next.addContextPartition( opContext );
@@ -348,7 +361,8 @@ public class NormalizationInterceptor ex
     /**
      * {@inheritDoc}
      */
-    public void removeContextPartition( NextInterceptor next, RemoveContextPartitionOperationContext opContext ) throws Exception
+    public void removeContextPartition( NextInterceptor next, RemoveContextPartitionOperationContext opContext )
+        throws Exception
     {
         opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
         next.removeContextPartition( opContext );

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java?rev=949396&r1=949395&r2=949396&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java Sat May 29 14:30:37 2010
@@ -56,13 +56,13 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.DefaultEntry;
-import org.apache.directory.shared.ldap.entry.DefaultModification;
 import org.apache.directory.shared.ldap.entry.DefaultEntryAttribute;
-import org.apache.directory.shared.ldap.entry.StringValue;
+import org.apache.directory.shared.ldap.entry.DefaultModification;
+import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
-import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.StringValue;
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeValueException;
 import org.apache.directory.shared.ldap.exception.LdapNoSuchAttributeException;
@@ -140,7 +140,8 @@ public class SubentryInterceptor extends
         oidRegistry = schemaManager.getGlobalOidRegistry();
 
         // setup various attribute type values
-        objectClassType = schemaManager.lookupAttributeTypeRegistry( schemaManager.getAttributeTypeRegistry().getOidByName( SchemaConstants.OBJECT_CLASS_AT ) );
+        objectClassType = schemaManager.lookupAttributeTypeRegistry( schemaManager.getAttributeTypeRegistry()
+            .getOidByName( SchemaConstants.OBJECT_CLASS_AT ) );
 
         ssParser = new SubtreeSpecificationParser( new NormalizerMappingResolver()
         {
@@ -161,20 +162,20 @@ public class SubentryInterceptor extends
             { SchemaConstants.SUBTREE_SPECIFICATION_AT, SchemaConstants.OBJECT_CLASS_AT } );
 
         // search each namingContext for subentries
-        for ( String suffix:suffixes )
+        for ( String suffix : suffixes )
         {
             DN suffixDn = new DN( suffix );
             suffixDn.normalize( schemaManager.getNormalizerMapping() );
 
             DN adminDn = new DN( ServerDNConstants.ADMIN_SYSTEM_DN_NORMALIZED );
             adminDn.normalize( schemaManager.getNormalizerMapping() );
-            CoreSession adminSession = new DefaultCoreSession( 
+            CoreSession adminSession = new DefaultCoreSession(
                 new LdapPrincipal( adminDn, AuthenticationLevel.STRONG ), directoryService );
 
-            SearchOperationContext searchOperationContext = new SearchOperationContext( adminSession, suffixDn,
-                filter, controls );
+            SearchOperationContext searchOperationContext = new SearchOperationContext( adminSession, suffixDn, filter,
+                controls );
             searchOperationContext.setAliasDerefMode( AliasDerefMode.NEVER_DEREF_ALIASES );
-            
+
             EntryFilteringCursor subentries = nexus.search( searchOperationContext );
 
             while ( subentries.next() )
@@ -210,8 +211,7 @@ public class SubentryInterceptor extends
 
         if ( oc == null )
         {
-            throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION,
-                I18n.err( I18n.ERR_305 ) );
+            throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION, I18n.err( I18n.ERR_305 ) );
         }
 
         if ( oc.contains( SchemaConstants.ACCESS_CONTROL_SUBENTRY_OC ) )
@@ -242,7 +242,6 @@ public class SubentryInterceptor extends
     // Methods/Code dealing with Subentry Visibility
     // -----------------------------------------------------------------------
 
-    
     public EntryFilteringCursor list( NextInterceptor nextInterceptor, ListOperationContext opContext )
         throws Exception
     {
@@ -257,7 +256,7 @@ public class SubentryInterceptor extends
     }
 
 
-    public EntryFilteringCursor search( NextInterceptor nextInterceptor, SearchOperationContext opContext ) 
+    public EntryFilteringCursor search( NextInterceptor nextInterceptor, SearchOperationContext opContext )
         throws Exception
     {
         EntryFilteringCursor cursor = nextInterceptor.search( opContext );
@@ -373,7 +372,8 @@ public class SubentryInterceptor extends
                     if ( operational == null )
                     {
                         operational = new DefaultEntryAttribute( SchemaConstants.COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT,
-                            schemaManager.lookupAttributeTypeRegistry( SchemaConstants.COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT ) );
+                            schemaManager
+                                .lookupAttributeTypeRegistry( SchemaConstants.COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT ) );
                         subentryAttrs.put( operational );
                     }
 
@@ -474,10 +474,10 @@ public class SubentryInterceptor extends
             controls.setReturningAttributes( new String[]
                 { SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.ALL_USER_ATTRIBUTES } );
 
-            SearchOperationContext searchOperationContext = new SearchOperationContext( addContext.getSession(), baseDn,
-                filter, controls );
+            SearchOperationContext searchOperationContext = new SearchOperationContext( addContext.getSession(),
+                baseDn, filter, controls );
             searchOperationContext.setAliasDerefMode( AliasDerefMode.NEVER_DEREF_ALIASES );
-            
+
             EntryFilteringCursor subentries = nexus.search( searchOperationContext );
 
             while ( subentries.next() )
@@ -488,8 +488,8 @@ public class SubentryInterceptor extends
 
                 if ( evaluator.evaluate( ss, apName, dn, candidate ) )
                 {
-                    nexus.modify( new ModifyOperationContext( addContext.getSession(), dn, 
-                        getOperationalModsForAdd( candidate, operational ) ) );
+                    nexus.modify( new ModifyOperationContext( addContext.getSession(), dn, getOperationalModsForAdd(
+                        candidate, operational ) ) );
                 }
             }
 
@@ -610,7 +610,8 @@ public class SubentryInterceptor extends
             DN baseDn = ( DN ) apName.clone();
             baseDn.addAll( ss.getBase() );
 
-            ExprNode filter = new PresenceNode( schemaManager.getAttributeTypeRegistry().getOidByName( SchemaConstants.OBJECT_CLASS_AT ) );
+            ExprNode filter = new PresenceNode( schemaManager.getAttributeTypeRegistry().getOidByName(
+                SchemaConstants.OBJECT_CLASS_AT ) );
             SearchControls controls = new SearchControls();
             controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
             controls.setReturningAttributes( new String[]
@@ -619,7 +620,7 @@ public class SubentryInterceptor extends
             SearchOperationContext searchOperationContext = new SearchOperationContext( opContext.getSession(), baseDn,
                 filter, controls );
             searchOperationContext.setAliasDerefMode( AliasDerefMode.NEVER_DEREF_ALIASES );
-            
+
             EntryFilteringCursor subentries = nexus.search( searchOperationContext );
 
             while ( subentries.next() )
@@ -630,8 +631,8 @@ public class SubentryInterceptor extends
 
                 if ( evaluator.evaluate( ss, apName, dn, candidate ) )
                 {
-                    nexus.modify( new ModifyOperationContext( opContext.getSession(), dn, 
-                        getOperationalModsForRemove( name, candidate ) ) );
+                    nexus.modify( new ModifyOperationContext( opContext.getSession(), dn, getOperationalModsForRemove(
+                        name, candidate ) ) );
                 }
             }
         }
@@ -664,7 +665,7 @@ public class SubentryInterceptor extends
         SearchOperationContext searchOperationContext = new SearchOperationContext( opContext.getSession(), name,
             filter, controls );
         searchOperationContext.setAliasDerefMode( AliasDerefMode.NEVER_DEREF_ALIASES );
-        
+
         EntryFilteringCursor aps = nexus.search( searchOperationContext );
 
         if ( aps.next() )
@@ -677,8 +678,7 @@ public class SubentryInterceptor extends
     }
 
 
-    private List<Modification> getModsOnEntryRdnChange( DN oldName, DN newName, Entry entry )
-        throws Exception
+    private List<Modification> getModsOnEntryRdnChange( DN oldName, DN newName, Entry entry ) throws Exception
     {
         List<Modification> modList = new ArrayList<Modification>();
 
@@ -755,7 +755,7 @@ public class SubentryInterceptor extends
     {
         DN name = opContext.getDn();
 
-        Entry entry = (Entry)opContext.getEntry().getClonedEntry();
+        Entry entry = ( Entry ) opContext.getEntry().getClonedEntry();
 
         EntryAttribute objectClasses = entry.get( objectClassType );
 
@@ -778,16 +778,17 @@ public class SubentryInterceptor extends
             next.rename( opContext );
 
             subentry = subentryCache.getSubentry( newNormName );
-            ExprNode filter = new PresenceNode( schemaManager.getAttributeTypeRegistry().getOidByName( SchemaConstants.OBJECT_CLASS_AT ) );
+            ExprNode filter = new PresenceNode( schemaManager.getAttributeTypeRegistry().getOidByName(
+                SchemaConstants.OBJECT_CLASS_AT ) );
             SearchControls controls = new SearchControls();
             controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
             controls.setReturningAttributes( new String[]
                 { SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.ALL_USER_ATTRIBUTES } );
-            
+
             SearchOperationContext searchOperationContext = new SearchOperationContext( opContext.getSession(), baseDn,
                 filter, controls );
             searchOperationContext.setAliasDerefMode( AliasDerefMode.NEVER_DEREF_ALIASES );
-            
+
             EntryFilteringCursor subentries = nexus.search( searchOperationContext );
 
             while ( subentries.next() )
@@ -796,11 +797,10 @@ public class SubentryInterceptor extends
                 DN dn = candidate.getDn();
                 dn.normalize( schemaManager.getNormalizerMapping() );
 
-
                 if ( evaluator.evaluate( ss, apName, dn, candidate ) )
                 {
-                    nexus.modify( new ModifyOperationContext( opContext.getSession(), dn, 
-                        getOperationalModsForReplace( name, newName, subentry, candidate ) ) );
+                    nexus.modify( new ModifyOperationContext( opContext.getSession(), dn, getOperationalModsForReplace(
+                        name, newName, subentry, candidate ) ) );
                 }
             }
         }
@@ -857,7 +857,8 @@ public class SubentryInterceptor extends
 
             subentry = subentryCache.getSubentry( newNormName );
 
-            ExprNode filter = new PresenceNode( schemaManager.getAttributeTypeRegistry().getOidByName( SchemaConstants.OBJECT_CLASS_AT ) );
+            ExprNode filter = new PresenceNode( schemaManager.getAttributeTypeRegistry().getOidByName(
+                SchemaConstants.OBJECT_CLASS_AT ) );
             SearchControls controls = new SearchControls();
             controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
             controls.setReturningAttributes( new String[]
@@ -866,7 +867,7 @@ public class SubentryInterceptor extends
             SearchOperationContext searchOperationContext = new SearchOperationContext( opContext.getSession(), baseDn,
                 filter, controls );
             searchOperationContext.setAliasDerefMode( AliasDerefMode.NEVER_DEREF_ALIASES );
-            
+
             EntryFilteringCursor subentries = nexus.search( searchOperationContext );
 
             while ( subentries.next() )
@@ -877,8 +878,8 @@ public class SubentryInterceptor extends
 
                 if ( evaluator.evaluate( ss, apName, dn, candidate ) )
                 {
-                    nexus.modify( new ModifyOperationContext( opContext.getSession(), dn, 
-                        getOperationalModsForReplace( oriChildName, newName, subentry, candidate ) ) );
+                    nexus.modify( new ModifyOperationContext( opContext.getSession(), dn, getOperationalModsForReplace(
+                        oriChildName, newName, subentry, candidate ) ) );
                 }
             }
         }
@@ -944,7 +945,7 @@ public class SubentryInterceptor extends
             SearchOperationContext searchOperationContext = new SearchOperationContext( opContext.getSession(), baseDn,
                 filter, controls );
             searchOperationContext.setAliasDerefMode( AliasDerefMode.NEVER_DEREF_ALIASES );
-            
+
             EntryFilteringCursor subentries = nexus.search( searchOperationContext );
 
             while ( subentries.next() )
@@ -955,8 +956,8 @@ public class SubentryInterceptor extends
 
                 if ( evaluator.evaluate( ss, apName, dn, candidate ) )
                 {
-                    nexus.modify( new ModifyOperationContext( opContext.getSession(), dn, 
-                        getOperationalModsForReplace( oriChildName, newName, subentry, candidate ) ) );
+                    nexus.modify( new ModifyOperationContext( opContext.getSession(), dn, getOperationalModsForReplace(
+                        oriChildName, newName, subentry, candidate ) ) );
                 }
             }
         }
@@ -1034,6 +1035,7 @@ public class SubentryInterceptor extends
         List<Modification> mods = opContext.getModItems();
 
         Entry entry = opContext.lookup( name, ByPassConstants.LOOKUP_BYPASS );
+        //        Entry entry = opContext.getEntry();
 
         Entry oldEntry = ( Entry ) entry.clone();
         EntryAttribute objectClasses = entry.get( objectClassType );
@@ -1073,16 +1075,17 @@ public class SubentryInterceptor extends
             apName.remove( apName.size() - 1 );
             DN oldBaseDn = ( DN ) apName.clone();
             oldBaseDn.addAll( ssOld.getBase() );
-            ExprNode filter = new PresenceNode( schemaManager.getAttributeTypeRegistry().getOidByName( SchemaConstants.OBJECT_CLASS_AT ) );
+            ExprNode filter = new PresenceNode( schemaManager.getAttributeTypeRegistry().getOidByName(
+                SchemaConstants.OBJECT_CLASS_AT ) );
             SearchControls controls = new SearchControls();
             controls.setSearchScope( SearchControls.SUBTREE_SCOPE );
             controls.setReturningAttributes( new String[]
                 { SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.ALL_USER_ATTRIBUTES } );
 
-            SearchOperationContext searchOperationContext = new SearchOperationContext( opContext.getSession(), oldBaseDn,
-                filter, controls );
+            SearchOperationContext searchOperationContext = new SearchOperationContext( opContext.getSession(),
+                oldBaseDn, filter, controls );
             searchOperationContext.setAliasDerefMode( AliasDerefMode.NEVER_DEREF_ALIASES );
-            
+
             EntryFilteringCursor subentries = nexus.search( searchOperationContext );
 
             while ( subentries.next() )
@@ -1093,8 +1096,8 @@ public class SubentryInterceptor extends
 
                 if ( evaluator.evaluate( ssOld, apName, dn, candidate ) )
                 {
-                    nexus.modify( new ModifyOperationContext( opContext.getSession(), dn, 
-                        getOperationalModsForRemove( name, candidate ) ) );
+                    nexus.modify( new ModifyOperationContext( opContext.getSession(), dn, getOperationalModsForRemove(
+                        name, candidate ) ) );
                 }
             }
 
@@ -1103,13 +1106,12 @@ public class SubentryInterceptor extends
             Entry operational = getSubentryOperatationalAttributes( name, subentry );
             DN newBaseDn = ( DN ) apName.clone();
             newBaseDn.addAll( ssNew.getBase() );
-            
-            searchOperationContext = new SearchOperationContext( opContext.getSession(), newBaseDn,
-                filter, controls );
+
+            searchOperationContext = new SearchOperationContext( opContext.getSession(), newBaseDn, filter, controls );
             searchOperationContext.setAliasDerefMode( AliasDerefMode.NEVER_DEREF_ALIASES );
-            
+
             subentries = nexus.search( searchOperationContext );
-            
+
             while ( subentries.next() )
             {
                 Entry candidate = subentries.get();
@@ -1118,8 +1120,8 @@ public class SubentryInterceptor extends
 
                 if ( evaluator.evaluate( ssNew, apName, dn, candidate ) )
                 {
-                    nexus.modify( new ModifyOperationContext( opContext.getSession(), dn, 
-                        getOperationalModsForAdd( candidate, operational ) ) );
+                    nexus.modify( new ModifyOperationContext( opContext.getSession(), dn, getOperationalModsForAdd(
+                        candidate, operational ) ) );
                 }
             }
         }
@@ -1146,8 +1148,8 @@ public class SubentryInterceptor extends
     // Utility Methods
     // -----------------------------------------------------------------------
 
-    private List<Modification> getOperationalModsForReplace( DN oldName, DN newName, Subentry subentry,
-        Entry entry ) throws Exception
+    private List<Modification> getOperationalModsForReplace( DN oldName, DN newName, Subentry subentry, Entry entry )
+        throws Exception
     {
         List<Modification> modList = new ArrayList<Modification>();
 
@@ -1307,8 +1309,7 @@ public class SubentryInterceptor extends
      * @return the set of modifications required to remove an entry's reference to
      * a subentry
      */
-    private List<Modification> getOperationalModsForRemove( DN subentryDn, Entry candidate )
-        throws Exception
+    private List<Modification> getOperationalModsForRemove( DN subentryDn, Entry candidate ) throws Exception
     {
         List<Modification> modList = new ArrayList<Modification>();
         String dn = subentryDn.getNormName();
@@ -1344,8 +1345,7 @@ public class SubentryInterceptor extends
      * @return the set of modifications needed to update the entry
      * @throws Exception if there are probelms accessing modification items
      */
-    public List<Modification> getOperationalModsForAdd( Entry entry, Entry operational )
-        throws Exception
+    public List<Modification> getOperationalModsForAdd( Entry entry, Entry operational ) throws Exception
     {
         List<Modification> modList = new ArrayList<Modification>();
 
@@ -1384,8 +1384,7 @@ public class SubentryInterceptor extends
      */
     public class HideSubentriesFilter implements EntryFilter
     {
-        public boolean accept( SearchingOperationContext operation, ClonedServerEntry entry )
-            throws Exception
+        public boolean accept( SearchingOperationContext operation, ClonedServerEntry entry ) throws Exception
         {
             String dn = entry.getDn().getNormName();
 
@@ -1416,8 +1415,7 @@ public class SubentryInterceptor extends
      */
     public class HideEntriesFilter implements EntryFilter
     {
-        public boolean accept( SearchingOperationContext operation, ClonedServerEntry entry )
-            throws Exception
+        public boolean accept( SearchingOperationContext operation, ClonedServerEntry entry ) throws Exception
         {
             String dn = entry.getDn().getNormName();
 
@@ -1442,8 +1440,7 @@ public class SubentryInterceptor extends
     }
 
 
-    private List<Modification> getModsOnEntryModification( DN name, Entry oldEntry, Entry newEntry )
-        throws Exception
+    private List<Modification> getModsOnEntryModification( DN name, Entry oldEntry, Entry newEntry ) throws Exception
     {
         List<Modification> modList = new ArrayList<Modification>();
 

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java?rev=949396&r1=949395&r2=949396&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java Sat May 29 14:30:37 2010
@@ -47,8 +47,8 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.subtree.SubentryInterceptor;
 import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
-import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.exception.LdapOperationErrorException;
 import org.apache.directory.shared.ldap.exception.LdapOtherException;
@@ -78,27 +78,28 @@ public class TriggerInterceptor extends 
 {
     /** the logger for this class */
     private static final Logger LOG = LoggerFactory.getLogger( TriggerInterceptor.class );
-    
+
     /** the entry trigger attribute string: entryTrigger */
     private static final String ENTRY_TRIGGER_ATTR = "entryTriggerSpecification";
 
     /** a triggerSpecCache that responds to add, delete, and modify attempts */
     private TriggerSpecCache triggerSpecCache;
-    
+
     /** a normalizing Trigger Specification parser */
     private TriggerSpecificationParser triggerParser;
-    
+
     /** */
     private InterceptorChain chain;
-    
+
     /** whether or not this interceptor is activated */
     private boolean enabled = true;
 
     /** a Trigger Execution Authorizer */
     private TriggerExecutionAuthorizer triggerExecutionAuthorizer = new SimpleTriggerExecutionAuthorizer();
-    
+
     private StoredProcExecutionManager manager;
 
+
     /**
      * Adds prescriptiveTrigger TriggerSpecificaitons to a collection of
      * TriggerSpeficaitions by accessing the triggerSpecCache.  The trigger
@@ -114,10 +115,10 @@ public class TriggerInterceptor extends 
      * @throws Exception if there are problems accessing attribute values
      * @param proxy the partition nexus proxy 
      */
-    private void addPrescriptiveTriggerSpecs( OperationContext opContext, List<TriggerSpecification> triggerSpecs, 
+    private void addPrescriptiveTriggerSpecs( OperationContext opContext, List<TriggerSpecification> triggerSpecs,
         DN dn, Entry entry ) throws Exception
     {
-        
+
         /*
          * If the protected entry is a subentry, then the entry being evaluated
          * for perscriptiveTriggerss is in fact the administrative entry.  By
@@ -131,24 +132,25 @@ public class TriggerInterceptor extends 
         {
             DN parentDn = ( DN ) dn.clone();
             parentDn.remove( dn.size() - 1 );
-            
+
             entry = opContext.lookup( parentDn, ByPassConstants.LOOKUP_BYPASS );
         }
 
         EntryAttribute subentries = entry.get( SchemaConstants.TRIGGER_EXECUTION_SUBENTRIES_AT );
-        
+
         if ( subentries == null )
         {
             return;
         }
-        
-        for ( Value<?> value:subentries )
+
+        for ( Value<?> value : subentries )
         {
             String subentryDn = value.getString();
             triggerSpecs.addAll( triggerSpecCache.getSubentryTriggerSpecs( subentryDn ) );
         }
     }
 
+
     /**
      * Adds the set of entryTriggers to a collection of trigger specifications.
      * The entryTrigger is parsed and tuples are generated on they fly then
@@ -161,13 +163,13 @@ public class TriggerInterceptor extends 
     private void addEntryTriggerSpecs( List<TriggerSpecification> triggerSpecs, Entry entry ) throws Exception
     {
         EntryAttribute entryTrigger = entry.get( ENTRY_TRIGGER_ATTR );
-        
+
         if ( entryTrigger == null )
         {
             return;
         }
 
-        for ( Value<?> value:entryTrigger )
+        for ( Value<?> value : entryTrigger )
         {
             String triggerString = value.getString();
             TriggerSpecification item;
@@ -186,7 +188,8 @@ public class TriggerInterceptor extends 
             triggerSpecs.add( item );
         }
     }
-    
+
+
     /**
      * Return a selection of trigger specifications for a certain type of trigger action time.
      * 
@@ -196,7 +199,8 @@ public class TriggerInterceptor extends 
      * @param ldapOperation the ldap operation being performed
      * @return the set of trigger specs for a trigger action 
      */
-    public Map<ActionTime, List<TriggerSpecification>> getActionTimeMappedTriggerSpecsForOperation( List<TriggerSpecification> triggerSpecs, LdapOperation ldapOperation )
+    public Map<ActionTime, List<TriggerSpecification>> getActionTimeMappedTriggerSpecsForOperation(
+        List<TriggerSpecification> triggerSpecs, LdapOperation ldapOperation )
     {
         List<TriggerSpecification> afterTriggerSpecs = new ArrayList<TriggerSpecification>();
         Map<ActionTime, List<TriggerSpecification>> triggerSpecMap = new HashMap<ActionTime, List<TriggerSpecification>>();
@@ -215,34 +219,33 @@ public class TriggerInterceptor extends 
                 }
             }
         }
-        
+
         triggerSpecMap.put( ActionTime.AFTER, afterTriggerSpecs );
-        
+
         return triggerSpecMap;
     }
-    
+
+
     ////////////////////////////////////////////////////////////////////////////
     // Interceptor Overrides
     ////////////////////////////////////////////////////////////////////////////
-    
+
     public void init( DirectoryService directoryService ) throws Exception
     {
         super.init( directoryService );
-        
+
         triggerSpecCache = new TriggerSpecCache( directoryService );
         final SchemaManager schemaManager = directoryService.getSchemaManager();
 
-        triggerParser = new TriggerSpecificationParser
-            ( new NormalizerMappingResolver()
-                {
-                    public Map<String, OidNormalizer> getNormalizerMapping() throws Exception
-                    {
-                        return schemaManager.getNormalizerMapping();
-                    }
-                }
-            );
+        triggerParser = new TriggerSpecificationParser( new NormalizerMappingResolver()
+        {
+            public Map<String, OidNormalizer> getNormalizerMapping() throws Exception
+            {
+                return schemaManager.getNormalizerMapping();
+            }
+        } );
         chain = directoryService.getInterceptorChain();
-        
+
         //StoredProcEngineConfig javaxScriptSPEngineConfig = new JavaxStoredProcEngineConfig();
         StoredProcEngineConfig javaSPEngineConfig = new JavaStoredProcEngineConfig();
         List<StoredProcEngineConfig> spEngineConfigs = new ArrayList<StoredProcEngineConfig>();
@@ -250,23 +253,23 @@ public class TriggerInterceptor extends 
         spEngineConfigs.add( javaSPEngineConfig );
         String spContainer = "ou=Stored Procedures,ou=system";
         manager = new StoredProcExecutionManager( spContainer, spEngineConfigs );
-        
+
         this.enabled = true; // TODO: Get this from the configuration if needed.
     }
 
-    
+
     public void add( NextInterceptor next, AddOperationContext addContext ) throws Exception
     {
         DN name = addContext.getDn();
         Entry entry = addContext.getEntry();
-        
+
         // Bypass trigger handling if the service is disabled.
         if ( !enabled )
         {
             next.add( addContext );
             return;
         }
-        
+
         // Gather supplementary data.
         StoredProcedureParameterInjector injector = new AddStoredProcedureParameterInjector( addContext, name, entry );
 
@@ -277,53 +280,53 @@ public class TriggerInterceptor extends 
         /**
          *  NOTE: We do not handle entryTriggerSpecs for ADD operation.
          */
-        
-        Map<ActionTime, List<TriggerSpecification>> triggerMap 
-            = getActionTimeMappedTriggerSpecsForOperation( triggerSpecs, LdapOperation.ADD );
-        
+
+        Map<ActionTime, List<TriggerSpecification>> triggerMap = getActionTimeMappedTriggerSpecsForOperation(
+            triggerSpecs, LdapOperation.ADD );
+
         next.add( addContext );
         triggerSpecCache.subentryAdded( name, entry );
-        
+
         // Fire AFTER Triggers.
         List<TriggerSpecification> afterTriggerSpecs = triggerMap.get( ActionTime.AFTER );
         executeTriggers( addContext, afterTriggerSpecs, injector );
     }
 
-    
+
     public void delete( NextInterceptor next, DeleteOperationContext deleteContext ) throws Exception
     {
         DN name = deleteContext.getDn();
-        
+
         // Bypass trigger handling if the service is disabled.
         if ( !enabled )
         {
             next.delete( deleteContext );
             return;
         }
-        
+
         // Gather supplementary data.
         Entry deletedEntry = deleteContext.getEntry();
-        
+
         StoredProcedureParameterInjector injector = new DeleteStoredProcedureParameterInjector( deleteContext, name );
 
         // Gather Trigger Specifications which apply to the entry being deleted.
         List<TriggerSpecification> triggerSpecs = new ArrayList<TriggerSpecification>();
         addPrescriptiveTriggerSpecs( deleteContext, triggerSpecs, name, deletedEntry );
         addEntryTriggerSpecs( triggerSpecs, deletedEntry );
-        
-        Map<ActionTime, List<TriggerSpecification>> triggerMap = 
-            getActionTimeMappedTriggerSpecsForOperation( triggerSpecs, LdapOperation.DELETE );
-        
+
+        Map<ActionTime, List<TriggerSpecification>> triggerMap = getActionTimeMappedTriggerSpecsForOperation(
+            triggerSpecs, LdapOperation.DELETE );
+
         next.delete( deleteContext );
-        
+
         triggerSpecCache.subentryDeleted( name, deletedEntry );
-        
+
         // Fire AFTER Triggers.
         List<TriggerSpecification> afterTriggerSpecs = triggerMap.get( ActionTime.AFTER );
         executeTriggers( deleteContext, afterTriggerSpecs, injector );
     }
-    
-    
+
+
     public void modify( NextInterceptor next, ModifyOperationContext opContext ) throws Exception
     {
         // Bypass trigger handling if the service is disabled.
@@ -332,46 +335,47 @@ public class TriggerInterceptor extends 
             next.modify( opContext );
             return;
         }
-        
+
         DN normName = opContext.getDn();
-        
+
         // Gather supplementary data.
         Entry modifiedEntry = opContext.lookup( normName, ByPassConstants.LOOKUP_BYPASS );
-        
+
         StoredProcedureParameterInjector injector = new ModifyStoredProcedureParameterInjector( opContext );
 
         // Gather Trigger Specifications which apply to the entry being modified.
         List<TriggerSpecification> triggerSpecs = new ArrayList<TriggerSpecification>();
         addPrescriptiveTriggerSpecs( opContext, triggerSpecs, normName, modifiedEntry );
         addEntryTriggerSpecs( triggerSpecs, modifiedEntry );
-        
-        Map<ActionTime, List<TriggerSpecification>> triggerMap = getActionTimeMappedTriggerSpecsForOperation( triggerSpecs, LdapOperation.MODIFY );
-        
+
+        Map<ActionTime, List<TriggerSpecification>> triggerMap = getActionTimeMappedTriggerSpecsForOperation(
+            triggerSpecs, LdapOperation.MODIFY );
+
         next.modify( opContext );
         triggerSpecCache.subentryModified( opContext, modifiedEntry );
-        
+
         // Fire AFTER Triggers.
         List<TriggerSpecification> afterTriggerSpecs = triggerMap.get( ActionTime.AFTER );
         executeTriggers( opContext, afterTriggerSpecs, injector );
     }
-    
+
 
     public void rename( NextInterceptor next, RenameOperationContext renameContext ) throws Exception
     {
         DN name = renameContext.getDn();
         RDN newRdn = renameContext.getNewRdn();
         boolean deleteOldRn = renameContext.getDelOldDn();
-        
+
         // Bypass trigger handling if the service is disabled.
         if ( !enabled )
         {
             next.rename( renameContext );
             return;
         }
-        
+
         // Gather supplementary data.        
-        Entry renamedEntry = (Entry)renameContext.getEntry().getClonedEntry();
-        
+        Entry renamedEntry = ( Entry ) renameContext.getEntry().getClonedEntry();
+
         // @TODO : To be completely reviewed !!!
         DN oldRDN = new DN( name.getRdn().getName() );
         DN oldSuperiorDN = ( DN ) name.clone();
@@ -380,29 +384,28 @@ public class TriggerInterceptor extends 
         DN oldDN = ( DN ) name.clone();
         DN newDN = ( DN ) name.clone();
         newDN.add( newRdn );
-        
-        StoredProcedureParameterInjector injector = new ModifyDNStoredProcedureParameterInjector(
-            renameContext, deleteOldRn, oldRDN, newRdn, oldSuperiorDN, newSuperiorDN, oldDN, newDN );
-        
+
+        StoredProcedureParameterInjector injector = new ModifyDNStoredProcedureParameterInjector( renameContext,
+            deleteOldRn, oldRDN, newRdn, oldSuperiorDN, newSuperiorDN, oldDN, newDN );
+
         // 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>> triggerMap = 
-            getActionTimeMappedTriggerSpecsForOperation( triggerSpecs, LdapOperation.MODIFYDN_RENAME );
-        
+
+        Map<ActionTime, List<TriggerSpecification>> triggerMap = getActionTimeMappedTriggerSpecsForOperation(
+            triggerSpecs, LdapOperation.MODIFYDN_RENAME );
+
         next.rename( renameContext );
         triggerSpecCache.subentryRenamed( name, newDN );
-        
+
         // Fire AFTER Triggers.
         List<TriggerSpecification> afterTriggerSpecs = triggerMap.get( ActionTime.AFTER );
         executeTriggers( renameContext, afterTriggerSpecs, injector );
     }
-    
-    
-    public void moveAndRename( NextInterceptor next, MoveAndRenameOperationContext opContext ) 
-        throws Exception
+
+
+    public void moveAndRename( NextInterceptor next, MoveAndRenameOperationContext opContext ) throws Exception
     {
         DN oriChildName = opContext.getDn();
         DN parent = opContext.getParent();
@@ -415,10 +418,10 @@ public class TriggerInterceptor extends 
             next.moveAndRename( opContext );
             return;
         }
-        
+
         // Gather supplementary data.        
         Entry movedEntry = opContext.lookup( oriChildName, ByPassConstants.LOOKUP_BYPASS );
-        
+
         DN oldRDN = new DN( oriChildName.getRdn().getName() );
         DN oldSuperiorDN = ( DN ) oriChildName.clone();
         oldSuperiorDN.remove( oldSuperiorDN.size() - 1 );
@@ -427,57 +430,57 @@ public class TriggerInterceptor extends 
         DN newDN = ( DN ) parent.clone();
         newDN.add( newRdn.getName() );
 
-        StoredProcedureParameterInjector injector = new ModifyDNStoredProcedureParameterInjector(
-            opContext, deleteOldRn, oldRDN, newRdn, oldSuperiorDN, newSuperiorDN, oldDN, newDN );
+        StoredProcedureParameterInjector injector = new ModifyDNStoredProcedureParameterInjector( opContext,
+            deleteOldRn, oldRDN, newRdn, oldSuperiorDN, newSuperiorDN, oldDN, newDN );
 
         // Gather Trigger Specifications which apply to the entry being exported.
         List<TriggerSpecification> exportTriggerSpecs = new ArrayList<TriggerSpecification>();
         addPrescriptiveTriggerSpecs( opContext, exportTriggerSpecs, oriChildName, 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.
-        Entry importedEntry = opContext.lookup( oriChildName, 
-            ByPassConstants.LOOKUP_EXCLUDING_OPR_ATTRS_BYPASS );
-        
+        Entry importedEntry = opContext.lookup( oriChildName, ByPassConstants.LOOKUP_EXCLUDING_OPR_ATTRS_BYPASS );
+
         // 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.
-        SubentryInterceptor subentryInterceptor = ( SubentryInterceptor ) chain.get( SubentryInterceptor.class.getName() );
+        SubentryInterceptor subentryInterceptor = ( SubentryInterceptor ) chain.get( SubentryInterceptor.class
+            .getName() );
         Entry fakeImportedEntry = subentryInterceptor.getSubentryAttributes( newDN, importedEntry );
-        
-        for ( EntryAttribute attribute:importedEntry )
+
+        for ( EntryAttribute 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( opContext, importTriggerSpecs, newDN, fakeImportedEntry );
-        
-        Map<ActionTime, List<TriggerSpecification>> exportTriggerMap = 
-            getActionTimeMappedTriggerSpecsForOperation( exportTriggerSpecs, LdapOperation.MODIFYDN_EXPORT );
-        
-        Map<ActionTime, List<TriggerSpecification>> importTriggerMap = 
-            getActionTimeMappedTriggerSpecsForOperation( importTriggerSpecs, LdapOperation.MODIFYDN_IMPORT );
-        
+
+        Map<ActionTime, List<TriggerSpecification>> exportTriggerMap = getActionTimeMappedTriggerSpecsForOperation(
+            exportTriggerSpecs, LdapOperation.MODIFYDN_EXPORT );
+
+        Map<ActionTime, List<TriggerSpecification>> importTriggerMap = getActionTimeMappedTriggerSpecsForOperation(
+            importTriggerSpecs, LdapOperation.MODIFYDN_IMPORT );
+
         next.moveAndRename( opContext );
         triggerSpecCache.subentryRenamed( oldDN, newDN );
-        
+
         // Fire AFTER Triggers.
         List<TriggerSpecification> afterExportTriggerSpecs = exportTriggerMap.get( ActionTime.AFTER );
         List<TriggerSpecification> afterImportTriggerSpecs = importTriggerMap.get( ActionTime.AFTER );
         executeTriggers( opContext, afterExportTriggerSpecs, injector );
         executeTriggers( opContext, afterImportTriggerSpecs, injector );
     }
-    
-    
+
+
     public void move( NextInterceptor next, MoveOperationContext opContext ) throws Exception
     {
         // Bypass trigger handling if the service is disabled.
@@ -486,13 +489,13 @@ public class TriggerInterceptor extends 
             next.move( opContext );
             return;
         }
-        
+
         DN oriChildName = opContext.getDn();
         DN newParentName = opContext.getParent();
-        
+
         // Gather supplementary data.        
         Entry movedEntry = opContext.lookup( oriChildName, ByPassConstants.LOOKUP_BYPASS );
-        
+
         DN oldRDN = new DN( oriChildName.getRdn().getName() );
         RDN newRDN = new RDN( oriChildName.getRdn().getName() );
         DN oldSuperiorDN = ( DN ) oriChildName.clone();
@@ -502,60 +505,62 @@ public class TriggerInterceptor extends 
         DN newDN = ( DN ) newParentName.clone();
         newDN.add( newRDN.getName() );
 
-        StoredProcedureParameterInjector injector = new ModifyDNStoredProcedureParameterInjector(
-            opContext, false, oldRDN, newRDN, oldSuperiorDN, newSuperiorDN, oldDN, newDN );
+        StoredProcedureParameterInjector injector = new ModifyDNStoredProcedureParameterInjector( opContext, false,
+            oldRDN, newRDN, oldSuperiorDN, newSuperiorDN, oldDN, newDN );
 
         // Gather Trigger Specifications which apply to the entry being exported.
         List<TriggerSpecification> exportTriggerSpecs = new ArrayList<TriggerSpecification>();
         addPrescriptiveTriggerSpecs( opContext, exportTriggerSpecs, oriChildName, 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.
-        Entry importedEntry = opContext.lookup( oriChildName, 
-            ByPassConstants.LOOKUP_EXCLUDING_OPR_ATTRS_BYPASS );
+        Entry importedEntry = opContext.lookup( oriChildName, ByPassConstants.LOOKUP_EXCLUDING_OPR_ATTRS_BYPASS );
 
         // 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.
-        SubentryInterceptor subentryInterceptor = ( SubentryInterceptor ) chain.get( SubentryInterceptor.class.getName() );
+        SubentryInterceptor subentryInterceptor = ( SubentryInterceptor ) chain.get( SubentryInterceptor.class
+            .getName() );
         Entry fakeImportedEntry = subentryInterceptor.getSubentryAttributes( newDN, importedEntry );
-        
-        for ( EntryAttribute attribute:importedEntry )
+
+        for ( EntryAttribute 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( opContext, importTriggerSpecs, newDN, fakeImportedEntry );
-        
-        Map<ActionTime, List<TriggerSpecification>> exportTriggerMap = getActionTimeMappedTriggerSpecsForOperation( exportTriggerSpecs, LdapOperation.MODIFYDN_EXPORT );
-        
-        Map<ActionTime, List<TriggerSpecification>> importTriggerMap = getActionTimeMappedTriggerSpecsForOperation( importTriggerSpecs, LdapOperation.MODIFYDN_IMPORT );
-        
+
+        Map<ActionTime, List<TriggerSpecification>> exportTriggerMap = getActionTimeMappedTriggerSpecsForOperation(
+            exportTriggerSpecs, LdapOperation.MODIFYDN_EXPORT );
+
+        Map<ActionTime, List<TriggerSpecification>> importTriggerMap = getActionTimeMappedTriggerSpecsForOperation(
+            importTriggerSpecs, LdapOperation.MODIFYDN_IMPORT );
+
         next.move( opContext );
         triggerSpecCache.subentryRenamed( oldDN, newDN );
-        
+
         // Fire AFTER Triggers.
         List<TriggerSpecification> afterExportTriggerSpecs = exportTriggerMap.get( ActionTime.AFTER );
         List<TriggerSpecification> afterImportTriggerSpecs = importTriggerMap.get( ActionTime.AFTER );
         executeTriggers( opContext, afterExportTriggerSpecs, injector );
         executeTriggers( opContext, afterImportTriggerSpecs, injector );
     }
-    
+
+
     ////////////////////////////////////////////////////////////////////////////
     // Utility Methods
     ////////////////////////////////////////////////////////////////////////////
-    
-    
-    private Object executeTriggers( OperationContext opContext, List<TriggerSpecification> triggerSpecs, 
+
+    private Object executeTriggers( OperationContext opContext, List<TriggerSpecification> triggerSpecs,
         StoredProcedureParameterInjector injector ) throws Exception
     {
         Object result = null;
@@ -572,7 +577,7 @@ public class TriggerInterceptor extends 
                 result = executeTrigger( opContext, triggerSpec, injector );
             }
         }
-        
+
         /**
          * If only one Trigger has been executed, returning its result
          * can make sense (as in INSTEADOF Search Triggers).
@@ -580,7 +585,8 @@ public class TriggerInterceptor extends 
         return result;
     }
 
-    private Object executeTrigger( OperationContext opContext, TriggerSpecification tsec, 
+
+    private Object executeTrigger( OperationContext opContext, TriggerSpecification tsec,
         StoredProcedureParameterInjector injector ) throws Exception
     {
         List<Object> returnValues = new ArrayList<Object>();
@@ -593,14 +599,14 @@ public class TriggerInterceptor extends 
             Object returnValue = executeProcedure( opContext, spSpec.getName(), values );
             returnValues.add( returnValue );
         }
-        
-        return returnValues; 
+
+        return returnValues;
     }
 
-    
+
     private Object executeProcedure( OperationContext opContext, String procedure, Object[] values ) throws Exception
     {
-        
+
         try
         {
             ClonedServerEntry spUnit = manager.findStoredProcUnit( opContext.getSession(), procedure );