directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r582712 [2/3] - in /directory: apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/ apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ apacheds/branches/bigbang...
Date Mon, 08 Oct 2007 05:54:47 GMT
Copied: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyHandler.java (from r582695, directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyHandler.java?p2=directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyHandler.java&p1=directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java&r1=582695&r2=582712&rev=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyHandler.java Sun Oct  7 22:54:38 2007
@@ -36,27 +36,25 @@
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
 /**
- * A single reply handler for {@link org.apache.directory.shared.ldap.message.ModifyRequest}s.
+ * A single reply handler for {@link ModifyRequest}s.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ModifyHandler extends AbstractLdapHandler implements MessageHandler
+public class DefaultModifyHandler extends ModifyHandler
 {
-    private static final Logger log = LoggerFactory.getLogger( ModifyHandler.class );
+    private static final Logger LOG = LoggerFactory.getLogger( ModifyHandler.class );
 
     /** Speedup for logs */
-    private static final boolean IS_DEBUG = log.isDebugEnabled();
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
 
-    public void messageReceived( IoSession session, Object request ) throws Exception
+    public void modifyMessageReceived( IoSession session, ModifyRequest req ) throws Exception
     {
-        ModifyRequest req = ( ModifyRequest ) request;
         LdapResult result = req.getResultResponse().getLdapResult();
 
         try
@@ -70,7 +68,7 @@
             {
                 ctx.addToEnvironment( Context.REFERRAL, "throw" );
             }
-            
+
             // Inject controls into the context
             setRequestControls( ctx, req );
 
@@ -78,11 +76,12 @@
             if ( req.getModificationItems() != null )
             {
             	int nbItems = req.getModificationItems().size();
-            	
+
             	if ( nbItems != 0 )
             	{
             		ModificationItemImpl[] mods = new ModificationItemImpl[nbItems];
-            		ctx.modifyAttributes( req.getName(), req.getModificationItems().toArray( mods ) );
+                    //noinspection SuspiciousToArrayCall
+                    ctx.modifyAttributes( req.getName(), req.getModificationItems().toArray( mods ) );
             	}
             	else
             	{
@@ -93,7 +92,7 @@
             {
             	// What should we do if we don't have any modification ???
             }
-            
+
             result.setResultCode( ResultCodeEnum.SUCCESS );
             req.getResultResponse().addAll( ctx.getResponseControls() );
             session.write( req.getResultResponse() );
@@ -116,7 +115,7 @@
         catch ( NamingException e )
         {
             String msg = "failed to modify entry " + req.getName() + ": " + e.getMessage();
-            
+
             if ( IS_DEBUG )
             {
                 msg += ":\n" + ExceptionUtils.getStackTrace( e );
@@ -134,7 +133,7 @@
 
             result.setResultCode( code );
             result.setErrorMessage( msg );
-            
+
             if ( ( e.getResolvedName() != null )
                 && ( ( code == ResultCodeEnum.NO_SUCH_OBJECT ) || ( code == ResultCodeEnum.ALIAS_PROBLEM )
                     || ( code == ResultCodeEnum.INVALID_DN_SYNTAX ) || ( code == ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM ) ) )
@@ -145,4 +144,4 @@
             session.write( req.getResultResponse() );
         }
     }
-}
+}
\ No newline at end of file

Propchange: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultModifyHandler.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Oct  7 22:54:38 2007
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id

Copied: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultSearchHandler.java (from r582695, directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultSearchHandler.java?p2=directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultSearchHandler.java&p1=directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java&r1=582695&r2=582712&rev=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultSearchHandler.java Sun Oct  7 22:54:38 2007
@@ -41,21 +41,11 @@
 import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.exception.OperationAbandonedException;
 import org.apache.directory.shared.ldap.filter.PresenceNode;
-import org.apache.directory.shared.ldap.message.AbandonListener;
-import org.apache.directory.shared.ldap.message.LdapResult;
-import org.apache.directory.shared.ldap.message.ManageDsaITControl;
-import org.apache.directory.shared.ldap.message.PersistentSearchControl;
-import org.apache.directory.shared.ldap.message.ReferralImpl;
-import org.apache.directory.shared.ldap.message.Response;
-import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.message.ScopeEnum;
-import org.apache.directory.shared.ldap.message.SearchRequest;
-import org.apache.directory.shared.ldap.message.SearchResponseDone;
+import org.apache.directory.shared.ldap.message.*;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.ArrayUtils;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -66,45 +56,44 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class SearchHandler extends AbstractLdapHandler implements MessageHandler
+public class DefaultSearchHandler extends SearchHandler
 {
-    //TM private static long cumul = 0L;
-    //TM private static long count = 0;
-    //TM private static Object lock = new Object();
-
-    private static final Logger log = LoggerFactory.getLogger( SearchHandler.class );
+    private static final Logger LOG = LoggerFactory.getLogger( SearchHandler.class );
     private static final String DEREFALIASES_KEY = JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES;
 
     /** Speedup for logs */
-    private static final boolean IS_DEBUG = log.isDebugEnabled();
+    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
 
     /**
      * Builds the JNDI search controls for a SearchRequest.
-     *  
+     *
      * @param req the search request.
      * @param ids the ids to return
      * @return the SearchControls to use with the ApacheDS server side JNDI provider
+     * @param isAdmin whether or not user is an admin
+     * @param maxSize the maximum size for the search in # of entries returned
+     * @param maxTime the maximum length of time for the search in seconds
      */
     private SearchControls getSearchControls( SearchRequest req, String[] ids, boolean isAdmin, int maxSize, int maxTime )
     {
         // prepare all the search controls
         SearchControls controls = new SearchControls();
-        
+
         // take the minimum of system limit with request specified value
         if ( isAdmin )
         {
             controls.setCountLimit( req.getSizeLimit() );
-            
+
             // The setTimeLimit needs a number of milliseconds
             // when the search control is expressed in seconds
             int timeLimit = req.getTimeLimit();
-            
-            // Just check that we are not exceeding the maximum for a long 
+
+            // Just check that we are not exceeding the maximum for a long
             if ( timeLimit > Integer.MAX_VALUE / 1000 )
             {
                 timeLimit = 0;
             }
-            
+
             // The maximum time we can wait is around 24 days ...
             // Is it enough ? ;)
             controls.setTimeLimit( timeLimit * 1000 );
@@ -114,7 +103,7 @@
             controls.setCountLimit( Math.min( req.getSizeLimit(), maxSize ) );
             controls.setTimeLimit( Math.min( req.getTimeLimit(), maxTime ) );
         }
-        
+
         controls.setSearchScope( req.getScope().getValue() );
         controls.setReturningObjFlag( req.getTypesOnly() );
         controls.setReturningAttributes( ids );
@@ -125,7 +114,7 @@
 
     /**
      * Determines if a search request is on the RootDSE of the server.
-     * 
+     *
      * @param req the request issued
      * @return true if the search is on the RootDSE false otherwise
      */
@@ -145,17 +134,16 @@
     /**
      * Main message handing method for search requests.
      */
-    public void messageReceived( IoSession session, Object request ) throws Exception
+    public void searchMessageReceived( IoSession session, SearchRequest req ) throws Exception
     {
         LdapConfiguration cfg = ( LdapConfiguration ) session.getAttribute(  LdapConfiguration.class.toString() );
 
     	if ( IS_DEBUG )
     	{
-    		log.debug( "Message received:  {}", request.toString() );
+    		LOG.debug( "Message received:  {}", req.toString() );
     	}
 
     	ServerLdapContext ctx;
-        SearchRequest req = ( SearchRequest ) request;
         NamingEnumeration list = null;
         String[] ids = null;
         Collection<String> retAttrs = new HashSet<String>();
@@ -182,12 +170,12 @@
             // ===============================================================
 
             boolean isRootDSESearch = isRootDSESearch( req );
-            
+
             // bypass checks to disallow anonymous binds for search on RootDSE with base obj scope
             if ( isRootDSESearch )
             {
                 LdapContext unknown = SessionRegistry.getSingleton().getLdapContextOnRootDSEAccess( session, null );
-                
+
                 if ( !( unknown instanceof ServerLdapContext ) )
                 {
                     ctx = ( ServerLdapContext ) unknown.lookup( "" );
@@ -201,7 +189,7 @@
             else
             {
                 LdapContext unknown = SessionRegistry.getSingleton().getLdapContext( session, null, true );
-                
+
                 if ( !( unknown instanceof ServerLdapContext ) )
                 {
                     ctx = ( ServerLdapContext ) unknown.lookup( "" );
@@ -211,12 +199,12 @@
                     ctx = ( ServerLdapContext ) unknown;
                 }
             }
-            
+
             // Inject controls into the context
             setRequestControls( ctx, req );
 
             ctx.addToEnvironment( DEREFALIASES_KEY, req.getDerefAliases() );
-            
+
             if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
             {
                 ctx.addToEnvironment( Context.REFERRAL, "ignore" );
@@ -246,7 +234,7 @@
                 //TM {
                 //TM     cumul += (t1 - t0);
                 //TM     count++;
-                //TM    
+                //TM
                 //TM     if ( count % 1000L == 0)
                 //TM     {
                 //TM         System.out.println( "Search cost : " + (cumul/count) );
@@ -264,7 +252,7 @@
             int maxSize = cfg.getMaxSizeLimit();
             int maxTime = cfg.getMaxTimeLimit();
 
-            SearchControls controls = null;
+            SearchControls controls;
             if ( isAnonymousUser )
             {
                 controls = getSearchControls( req, ids, false, maxSize, maxTime );
@@ -278,8 +266,8 @@
             {
                 controls = getSearchControls( req, ids, false, maxSize, maxTime );
             }
-            
-            
+
+
             // ===============================================================
             // Handle psearch differently
             // ===============================================================
@@ -310,29 +298,29 @@
                             {
                                 // ok if normal search beforehand failed somehow quickly abandon psearch
                                 ResultCodeEnum rcode = ( ( SearchResponseDone ) resp ).getLdapResult().getResultCode();
-                                
+
                                 if ( rcode != ResultCodeEnum.SUCCESS )
                                 {
                                     session.write( resp );
                                     //TM long t1 = System.nanoTime();
-                                    //TM  
+                                    //TM
                                     //TM synchronized( lock )
                                     //TM {
                                     //TM     cumul += (t1 - t0);
                                     //TM     count++;
-                                    //TM     
+                                    //TM
                                     //TM     if ( count % 1000L == 0)
                                     //TM     {
                                     //TM         System.out.println( "Search cost : " + (cumul/count) );
                                     //TM         cumul = 0L;
                                     //TM     }
                                     //TM }
-                                    
+
                                     return;
                                 }
                                 // if search was fine then we returned all entries so now
                                 // instead of returning the DONE response we break from the
-                                // loop and user the notification listener to send back 
+                                // loop and user the notification listener to send back
                                 // notificationss to the client in never ending search
                                 else
                                     break;
@@ -345,7 +333,7 @@
                     }
                 }
 
-                // now we process entries for ever as they change 
+                // now we process entries for ever as they change
                 PersistentSearchListener handler = new PersistentSearchListener( ctx, session, req );
                 ctx.addNamingListener( req.getBase(), req.getFilter().toString(), controls, handler );
                 //TM long t1 = System.nanoTime();
@@ -353,7 +341,7 @@
                 //TM {
                 //TM     cumul += (t1 - t0);
                 //TM     count++;
-                //TM     
+                //TM
                 //TM     if ( count % 1000L == 0)
                 //TM     {
                 //TM         System.out.println( "Search cost : " + (cumul/count) );
@@ -368,8 +356,8 @@
             // ===============================================================
 
             /*
-             * Iterate through all search results building and sending back responses 
-             * for each search result returned.  
+             * Iterate through all search results building and sending back responses
+             * for each search result returned.
              */
             list = ctx.search( req.getBase(), req.getFilter(), controls );
             if ( list instanceof AbandonListener )
@@ -384,44 +372,15 @@
                 {
                     session.write( it.next() );
                 }
-                //TM long t1 = System.nanoTime();
-                //TM synchronized( lock )
-                //TM {
-                //TM     cumul += (t1 - t0);
-                //TM     count++;
-                //TM     
-                //TM     if ( count % 1000L == 0)
-                //TM     {
-                //TM         System.out.println( "Search cost : " + (cumul/count) );
-                //TM         cumul = 0L;
-                //TM     }
-                //TM }
-
-                return;
             }
             else
             {
                 list.close();
                 req.getResultResponse().getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
-                Iterator it = Collections.singleton( req.getResultResponse() ).iterator();
-                while ( it.hasNext() )
+                for ( ResultResponse resultResponse : Collections.singleton( req.getResultResponse() ) )
                 {
-                    session.write( it.next() );
+                    session.write( resultResponse );
                 }
-                //TM long t1 = System.nanoTime();
-                //TM synchronized( lock )
-                //TM {
-                //TM     cumul += (t1 - t0);
-                //TM     count++;
-                //TM     
-                //TM     if ( count % 1000L == 0)
-                //TM     {
-                //TM         System.out.println( "Search cost : " + (cumul/count) );
-                //TM         cumul = 0L;
-                //TM     }
-                //TM }
-
-                return;
             }
         }
         catch ( ReferralException e )
@@ -440,60 +399,33 @@
             while ( e.skipReferral() );
             session.write( req.getResultResponse() );
             SessionRegistry.getSingleton().removeOutstandingRequest( session, req.getMessageId() );
-            //TM long t1 = System.nanoTime();
-            //TM synchronized( lock )
-            //TM {
-            //TM    cumul += (t1 - t0);
-            //TM    count++;
-            //TM     
-            //TM     if ( count % 1000L == 0)
-            //TM     {
-            //TM         System.out.println( "Search cost : " + (cumul/count) );
-            //TM         cumul = 0L;
-            //TM     }
-            //TM }
-
-            return;
         }
         catch ( NamingException e )
         {
             /*
              * From RFC 2251 Section 4.11:
-             * 
-             * In the event that a server receives an Abandon Request on a Search  
+             *
+             * In the event that a server receives an Abandon Request on a Search
              * operation in the midst of transmitting responses to the Search, that
              * server MUST cease transmitting entry responses to the abandoned
              * request immediately, and MUST NOT send the SearchResultDone. Of
              * course, the server MUST ensure that only properly encoded LDAPMessage
-             * PDUs are transmitted. 
-             * 
+             * PDUs are transmitted.
+             *
              * SO DON'T SEND BACK ANYTHING!!!!!
              */
             if ( e instanceof OperationAbandonedException )
             {
-                //TM long t1 = System.nanoTime();
-                //TM synchronized( lock )
-                //TM {
-                //TM     cumul += (t1 - t0);
-                //TM     count++;
-                //TM     
-                //TM     if ( count % 1000L == 0)
-                //TM     {
-                //TM         System.out.println( "Search cost : " + (cumul/count) );
-                //TM         cumul = 0L;
-                //TM     }
-                //TM }
-
                 return;
             }
 
             String msg = "failed on search operation: " + e.getMessage();
-            if ( log.isDebugEnabled() )
+            if ( LOG.isDebugEnabled() )
             {
                 msg += ":\n" + req + ":\n" + ExceptionUtils.getStackTrace( e );
             }
 
-            ResultCodeEnum code = null;
+            ResultCodeEnum code;
             if ( e instanceof LdapException )
             {
                 code = ( ( LdapException ) e ).getResultCode();
@@ -514,10 +446,9 @@
                 result.setMatchedDn( (LdapDN)e.getResolvedName() );
             }
 
-            Iterator it = Collections.singleton( req.getResultResponse() ).iterator();
-            while ( it.hasNext() )
+            for ( ResultResponse resultResponse : Collections.singleton( req.getResultResponse() ) )
             {
-                session.write( it.next() );
+                session.write( resultResponse );
             }
             SessionRegistry.getSingleton().removeOutstandingRequest( session, req.getMessageId() );
         }
@@ -531,9 +462,9 @@
                 }
                 catch ( NamingException e )
                 {
-                    log.error( "failed on list.close()", e );
+                    LOG.error( "failed on list.close()", e );
                 }
             }
         }
     }
-}
+}
\ No newline at end of file

Propchange: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultSearchHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultSearchHandler.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Oct  7 22:54:38 2007
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id

Copied: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultUnbindHandler.java (from r582695, directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java)
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultUnbindHandler.java?p2=directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultUnbindHandler.java&p1=directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java&r1=582695&r2=582712&rev=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultUnbindHandler.java Sun Oct  7 22:54:38 2007
@@ -20,16 +20,16 @@
 package org.apache.directory.server.ldap.support;
 
 
-import javax.naming.NamingException;
-import javax.naming.ldap.LdapContext;
-
 import org.apache.directory.server.core.jndi.ServerLdapContext;
 import org.apache.directory.server.ldap.SessionRegistry;
+import org.apache.directory.shared.ldap.message.UnbindRequest;
 import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.naming.NamingException;
+import javax.naming.ldap.LdapContext;
+
 
 /**
  * A no reply protocol handler implementation for LDAP {@link
@@ -38,12 +38,12 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class UnbindHandler implements MessageHandler
+public class DefaultUnbindHandler extends UnbindHandler
 {
-    private static final Logger log = LoggerFactory.getLogger( UnbindHandler.class );
+    private static final Logger LOG = LoggerFactory.getLogger( UnbindHandler.class );
 
 
-    public void messageReceived( IoSession session, Object request ) throws Exception
+    public void unbindMessageReceived( IoSession session, UnbindRequest request ) throws Exception
     {
         SessionRegistry registry = SessionRegistry.getSingleton();
 
@@ -64,7 +64,7 @@
         }
         catch ( NamingException e )
         {
-            log.error( "failed to unbind session properly", e );
+            LOG.error( "failed to unbind session properly", e );
         }
     }
-}
+}
\ No newline at end of file

Propchange: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultUnbindHandler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultUnbindHandler.java
------------------------------------------------------------------------------
--- svn:keywords (added)
+++ svn:keywords Sun Oct  7 22:54:38 2007
@@ -0,0 +1,4 @@
+Rev
+Revision
+Date
+Id

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java?rev=582712&r1=582711&r2=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DeleteHandler.java Sun Oct  7 22:54:38 2007
@@ -20,24 +20,9 @@
 package org.apache.directory.server.ldap.support;
 
 
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.ReferralException;
-import javax.naming.ldap.LdapContext;
-
-import org.apache.directory.server.ldap.SessionRegistry;
-import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.message.DeleteRequest;
-import org.apache.directory.shared.ldap.message.LdapResult;
-import org.apache.directory.shared.ldap.message.ManageDsaITControl;
-import org.apache.directory.shared.ldap.message.ReferralImpl;
-import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.demux.MessageHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -46,82 +31,13 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class DeleteHandler extends AbstractLdapHandler implements MessageHandler
+public abstract class DeleteHandler extends AbstractLdapHandler implements MessageHandler
 {
-    private static final Logger log = LoggerFactory.getLogger( DeleteHandler.class );
+    protected abstract void deleteMessageReceived( IoSession session, DeleteRequest deleteRequest ) throws Exception;
 
-    /** Speedup for logs */
-    private static final boolean IS_DEBUG = log.isDebugEnabled();
 
-    public void messageReceived( IoSession session, Object request ) throws Exception
+    public final void messageReceived( IoSession ioSession, Object o ) throws Exception
     {
-        DeleteRequest req = ( DeleteRequest ) request;
-        LdapResult result = req.getResultResponse().getLdapResult();
-
-        try
-        {
-            LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, true );
-            if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
-            {
-                ctx.addToEnvironment( Context.REFERRAL, "ignore" );
-            }
-            else
-            {
-                ctx.addToEnvironment( Context.REFERRAL, "throw" );
-            }
-            
-            // Inject controls into the context
-            setRequestControls( ctx, req );
-
-            ctx.destroySubcontext( req.getName() );
-            result.setResultCode( ResultCodeEnum.SUCCESS );
-            req.getResultResponse().addAll( ctx.getResponseControls() );
-            session.write( req.getResultResponse() );
-        }
-        catch ( ReferralException e )
-        {
-            ReferralImpl refs = new ReferralImpl();
-            result.setReferral( refs );
-            result.setResultCode( ResultCodeEnum.REFERRAL );
-            result.setErrorMessage( "Encountered referral attempting to handle delete request." );
-            /* coming up null causing a NPE */
-            // result.setMatchedDn( e.getResolvedName().toString() );
-            do
-            {
-                refs.addLdapUrl( ( String ) e.getReferralInfo() );
-            }
-            while ( e.skipReferral() );
-            session.write( req.getResultResponse() );
-        }
-        catch ( NamingException e )
-        {
-            String msg = "failed to delete entry " + req.getName() + ": " + e.getMessage();
-
-            if ( IS_DEBUG )
-            {
-                msg += ":\n" + ExceptionUtils.getStackTrace( e );
-            }
-
-            ResultCodeEnum code;
-            if ( e instanceof LdapException )
-            {
-                code = ( ( LdapException ) e ).getResultCode();
-            }
-            else
-            {
-                code = ResultCodeEnum.getBestEstimate( e, req.getType() );
-            }
-
-            result.setResultCode( code );
-            result.setErrorMessage( msg );
-            if ( ( e.getResolvedName() != null )
-                && ( ( code == ResultCodeEnum.NO_SUCH_OBJECT ) || ( code == ResultCodeEnum.ALIAS_PROBLEM )
-                    || ( code == ResultCodeEnum.INVALID_DN_SYNTAX ) || ( code == ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM ) ) )
-            {
-                result.setMatchedDn( (LdapDN)e.getResolvedName() );
-            }
-
-            session.write( req.getResultResponse() );
-        }
+        deleteMessageReceived( ioSession, ( DeleteRequest ) o );
     }
 }

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ExtendedHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ExtendedHandler.java?rev=582712&r1=582711&r2=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ExtendedHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ExtendedHandler.java Sun Oct  7 22:54:38 2007
@@ -25,12 +25,7 @@
 import java.util.Map;
 
 import org.apache.directory.server.ldap.ExtendedOperationHandler;
-import org.apache.directory.server.ldap.SessionRegistry;
 import org.apache.directory.shared.ldap.message.ExtendedRequest;
-import org.apache.directory.shared.ldap.message.ExtendedResponse;
-import org.apache.directory.shared.ldap.message.LdapResult;
-import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.demux.MessageHandler;
 
@@ -41,12 +36,12 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ExtendedHandler extends AbstractLdapHandler implements MessageHandler
+public abstract class ExtendedHandler extends AbstractLdapHandler implements MessageHandler
 {
-    private Map<String, ExtendedOperationHandler> handlers = new HashMap<String, ExtendedOperationHandler>();
+    private final Map<String, ExtendedOperationHandler> handlers = new HashMap<String, ExtendedOperationHandler>();
 
 
-    public ExtendedOperationHandler addHandler( ExtendedOperationHandler eoh )
+    public final ExtendedOperationHandler addHandler( ExtendedOperationHandler eoh )
     {
         synchronized ( handlers )
         {
@@ -55,7 +50,7 @@
     }
 
 
-    public ExtendedOperationHandler removeHandler( String oid )
+    public final ExtendedOperationHandler removeHandler( String oid )
     {
         synchronized ( handlers )
         {
@@ -64,49 +59,24 @@
     }
 
 
-    public ExtendedOperationHandler getHandler( String oid )
+    public final ExtendedOperationHandler getHandler( String oid )
     {
         return handlers.get( oid );
     }
 
 
-    public Map getHandlerMap()
+    public final Map<String,ExtendedOperationHandler> getHandlerMap()
     {
         return Collections.unmodifiableMap( handlers );
     }
 
 
-    public void messageReceived( IoSession session, Object request ) throws Exception
+    public final void messageReceived( IoSession session, Object request ) throws Exception
     {
-        ExtendedRequest req = ( ExtendedRequest ) request;
-        ExtendedOperationHandler handler = handlers.get( req.getOid() );
-
-        if ( handler == null )
-        {
-            // As long as no extended operations are implemented, send appropriate
-            // error back to the client.
-            String msg = "Unrecognized extended operation EXTENSION_OID: " + req.getOid();
-            LdapResult result = req.getResultResponse().getLdapResult();
-            result.setResultCode( ResultCodeEnum.PROTOCOL_ERROR );
-            result.setErrorMessage( msg );
-            session.write( req.getResultResponse() );
-        }
-        else
-        {
-            try
-            {
-                handler.handleExtendedOperation( session, SessionRegistry.getSingleton(), req );
-            }
-            catch ( Exception e )
-            {
-                LdapResult result = req.getResultResponse().getLdapResult();
-                result.setResultCode( ResultCodeEnum.OTHER );
-                result.setErrorMessage( "Extended operation handler for the specified EXTENSION_OID (" + req.getOid()
-                    + ") has failed to process your request:\n" + ExceptionUtils.getStackTrace( e ) );
-                ExtendedResponse resp = ( ExtendedResponse ) req.getResultResponse();
-                resp.setResponse( new byte[0] );
-                session.write( req.getResultResponse() );
-            } 
-        }
+        extendedMessageReceived( session, ( ExtendedRequest ) request );
     }
+
+
+    protected abstract void extendedMessageReceived( IoSession session, ExtendedRequest extendedRequest )
+            throws Exception;
 }

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java?rev=582712&r1=582711&r2=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyDnHandler.java Sun Oct  7 22:54:38 2007
@@ -20,25 +20,9 @@
 package org.apache.directory.server.ldap.support;
 
  
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.ReferralException;
-import javax.naming.ldap.LdapContext;
-
-import org.apache.directory.server.ldap.SessionRegistry;
-import org.apache.directory.shared.ldap.constants.JndiPropertyConstants;
-import org.apache.directory.shared.ldap.exception.LdapException;
-import org.apache.directory.shared.ldap.message.LdapResult;
-import org.apache.directory.shared.ldap.message.ManageDsaITControl;
 import org.apache.directory.shared.ldap.message.ModifyDnRequest;
-import org.apache.directory.shared.ldap.message.ReferralImpl;
-import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.demux.MessageHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -47,13 +31,8 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ModifyDnHandler extends AbstractLdapHandler implements MessageHandler
+public abstract class ModifyDnHandler extends AbstractLdapHandler implements MessageHandler
 {
-    private static final Logger log = LoggerFactory.getLogger( ModifyDnHandler.class );
-
-    /** Speedup for logs */
-    private static final boolean IS_DEBUG = log.isDebugEnabled();
-
     /**
      * Deal with a ModifyDN request received from a client.
      * 
@@ -70,125 +49,11 @@
      * - newSuperior : this is a move operation. The entry is removed from its
      * current location, and created in the new one.
      */
-    public void messageReceived( IoSession session, Object request ) throws Exception
+    public final void messageReceived( IoSession session, Object request ) throws Exception
     {
-        ModifyDnRequest req = ( ModifyDnRequest ) request;
-        LdapResult result = req.getResultResponse().getLdapResult();
-
-        if ( IS_DEBUG )
-        {
-            log.debug( "req.getName() == [{}]", req.getName() );
-        }
-
-        if ( req.getName().isEmpty() )
-        {
-            // it is not allowed to modify the name of the Root DSE
-            String msg = "Modify DN is not allowed on Root DSE.";
-            result.setResultCode( ResultCodeEnum.PROTOCOL_ERROR );
-            result.setErrorMessage( msg );
-            session.write( req.getResultResponse() );
-        }
-        else
-        {
-            try
-            {
-                LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, true );
-                
-                if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
-                {
-                    ctx.addToEnvironment( Context.REFERRAL, "ignore" );
-                }
-                else
-                {
-                    ctx.addToEnvironment( Context.REFERRAL, "throw" );
-                }
-                
-                // Inject controls into the context
-                setRequestControls( ctx, req );
-                
-                String deleteRDN = String.valueOf( req.getDeleteOldRdn() );
-                ctx.addToEnvironment( JndiPropertyConstants.JNDI_LDAP_DELETE_RDN, deleteRDN );
-
-                LdapDN newSuperior = req.getNewSuperior();
-
-                if ( ( newSuperior != null ) && ( !newSuperior.isEmpty() ) )
-                {
-                    LdapDN oldDn = req.getName();
-                    LdapDN newDn = null;
-
-                    newDn = newSuperior;
-
-                    if ( req.getNewRdn() != null )
-                    {
-                        newDn.add( req.getNewRdn() );
-                    }
-                    else
-                    {
-                        newDn.add( oldDn.getRdn() );
-                    }
-
-                    ctx.rename( req.getName(), newDn );
-                }
-                else
-                {
-                    LdapDN newDn = ( LdapDN ) req.getName().clone();
-                    newDn.remove( newDn.size() - 1 );
-                    newDn.add( req.getNewRdn() );
-                    ctx.rename( req.getName(), newDn );
-                }
-
-                req.getResultResponse().addAll( ctx.getResponseControls() );
-                result.setResultCode( ResultCodeEnum.SUCCESS );
-                session.write( req.getResultResponse() );
-            }
-            catch ( ReferralException e )
-            {
-                ReferralImpl refs = new ReferralImpl();
-                result.setReferral( refs );
-                result.setResultCode( ResultCodeEnum.REFERRAL );
-                result.setErrorMessage( "Encountered referral attempting to handle modifyDn request." );
-                result.setMatchedDn( (LdapDN)e.getResolvedName() );
-
-                do
-                {
-                    refs.addLdapUrl( ( String ) e.getReferralInfo() );
-                }
-                while ( e.skipReferral() );
-                
-                session.write( req.getResultResponse() );
-            }
-            catch ( NamingException e )
-            {
-                String msg = "failed to modify DN of entry " + req.getName() + ": " + e.getMessage();
-                
-                if ( IS_DEBUG )
-                {
-                    msg += ":\n" + ExceptionUtils.getStackTrace( e );
-                }
-
-                ResultCodeEnum code;
-                
-                if ( e instanceof LdapException )
-                {
-                    code = ( ( LdapException ) e ).getResultCode();
-                }
-                else
-                {
-                    code = ResultCodeEnum.getBestEstimate( e, req.getType() );
-                }
+        modifyDnMessageReceived( session, ( ModifyDnRequest ) request );
+    }
 
-                result.setResultCode( code );
-                result.setErrorMessage( msg );
-                
-                if ( ( e.getResolvedName() != null )
-                    && ( ( code == ResultCodeEnum.NO_SUCH_OBJECT ) || ( code == ResultCodeEnum.ALIAS_PROBLEM )
-                        || ( code == ResultCodeEnum.INVALID_DN_SYNTAX ) || ( code == ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM ) ) )
-                {
-                    result.setMatchedDn( (LdapDN)e.getResolvedName() );
-                }
 
-                session.write( req.getResultResponse() );
-            }
-        }
-    }
+    protected abstract void modifyDnMessageReceived( IoSession session, ModifyDnRequest modifyDnRequest ) throws Exception;
 }

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java?rev=582712&r1=582711&r2=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/ModifyHandler.java Sun Oct  7 22:54:38 2007
@@ -20,25 +20,9 @@
 package org.apache.directory.server.ldap.support;
 
 
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.ReferralException;
-import javax.naming.ldap.LdapContext;
-
-import org.apache.directory.server.ldap.SessionRegistry;
-import org.apache.directory.shared.ldap.exception.LdapException;
-import org.apache.directory.shared.ldap.message.LdapResult;
-import org.apache.directory.shared.ldap.message.ManageDsaITControl;
-import org.apache.directory.shared.ldap.message.ModificationItemImpl;
 import org.apache.directory.shared.ldap.message.ModifyRequest;
-import org.apache.directory.shared.ldap.message.ReferralImpl;
-import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.demux.MessageHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -47,102 +31,13 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ModifyHandler extends AbstractLdapHandler implements MessageHandler
+public abstract class ModifyHandler extends AbstractLdapHandler implements MessageHandler
 {
-    private static final Logger log = LoggerFactory.getLogger( ModifyHandler.class );
-
-    /** Speedup for logs */
-    private static final boolean IS_DEBUG = log.isDebugEnabled();
-
-    public void messageReceived( IoSession session, Object request ) throws Exception
+    public final void messageReceived( IoSession session, Object request ) throws Exception
     {
-        ModifyRequest req = ( ModifyRequest ) request;
-        LdapResult result = req.getResultResponse().getLdapResult();
-
-        try
-        {
-            LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, true );
-            if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
-            {
-                ctx.addToEnvironment( Context.REFERRAL, "ignore" );
-            }
-            else
-            {
-                ctx.addToEnvironment( Context.REFERRAL, "throw" );
-            }
-            
-            // Inject controls into the context
-            setRequestControls( ctx, req );
-
-            // Process the modifications
-            if ( req.getModificationItems() != null )
-            {
-            	int nbItems = req.getModificationItems().size();
-            	
-            	if ( nbItems != 0 )
-            	{
-            		ModificationItemImpl[] mods = new ModificationItemImpl[nbItems];
-            		ctx.modifyAttributes( req.getName(), req.getModificationItems().toArray( mods ) );
-            	}
-            	else
-            	{
-            		 // What should we do if we don't have any modification ???
-            	}
-            }
-            else
-            {
-            	// What should we do if we don't have any modification ???
-            }
-            
-            result.setResultCode( ResultCodeEnum.SUCCESS );
-            req.getResultResponse().addAll( ctx.getResponseControls() );
-            session.write( req.getResultResponse() );
-        }
-        catch ( ReferralException e )
-        {
-            ReferralImpl refs = new ReferralImpl();
-            result.setReferral( refs );
-            result.setResultCode( ResultCodeEnum.REFERRAL );
-            result.setErrorMessage( "Encountered referral attempting to handle modify request." );
-            /* coming up null causing a NPE */
-            // result.setMatchedDn( e.getResolvedName().toString() );
-            do
-            {
-                refs.addLdapUrl( ( String ) e.getReferralInfo() );
-            }
-            while ( e.skipReferral() );
-            session.write( req.getResultResponse() );
-        }
-        catch ( NamingException e )
-        {
-            String msg = "failed to modify entry " + req.getName() + ": " + e.getMessage();
-            
-            if ( IS_DEBUG )
-            {
-                msg += ":\n" + ExceptionUtils.getStackTrace( e );
-            }
-
-            ResultCodeEnum code;
-            if ( e instanceof LdapException )
-            {
-                code = ( ( LdapException ) e ).getResultCode();
-            }
-            else
-            {
-                code = ResultCodeEnum.getBestEstimate( e, req.getType() );
-            }
+        modifyMessageReceived( session, ( ModifyRequest ) request );
+    }
 
-            result.setResultCode( code );
-            result.setErrorMessage( msg );
-            
-            if ( ( e.getResolvedName() != null )
-                && ( ( code == ResultCodeEnum.NO_SUCH_OBJECT ) || ( code == ResultCodeEnum.ALIAS_PROBLEM )
-                    || ( code == ResultCodeEnum.INVALID_DN_SYNTAX ) || ( code == ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM ) ) )
-            {
-                result.setMatchedDn( (LdapDN)e.getResolvedName() );
-            }
 
-            session.write( req.getResultResponse() );
-        }
-    }
+    protected abstract void modifyMessageReceived( IoSession session, ModifyRequest modifyRequest ) throws Exception;
 }

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java?rev=582712&r1=582711&r2=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/SearchHandler.java Sun Oct  7 22:54:38 2007
@@ -20,44 +20,9 @@
 package org.apache.directory.server.ldap.support;
 
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-
-import javax.naming.Context;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.ReferralException;
-import javax.naming.directory.SearchControls;
-import javax.naming.ldap.LdapContext;
-
-import org.apache.directory.server.core.jndi.ServerLdapContext;
-import org.apache.directory.server.core.partition.PartitionNexus;
-import org.apache.directory.server.ldap.LdapConfiguration;
-import org.apache.directory.server.ldap.SessionRegistry;
-import org.apache.directory.shared.ldap.constants.JndiPropertyConstants;
-import org.apache.directory.shared.ldap.constants.SchemaConstants;
-import org.apache.directory.shared.ldap.exception.LdapException;
-import org.apache.directory.shared.ldap.exception.OperationAbandonedException;
-import org.apache.directory.shared.ldap.filter.PresenceNode;
-import org.apache.directory.shared.ldap.message.AbandonListener;
-import org.apache.directory.shared.ldap.message.LdapResult;
-import org.apache.directory.shared.ldap.message.ManageDsaITControl;
-import org.apache.directory.shared.ldap.message.PersistentSearchControl;
-import org.apache.directory.shared.ldap.message.ReferralImpl;
-import org.apache.directory.shared.ldap.message.Response;
-import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.message.ScopeEnum;
 import org.apache.directory.shared.ldap.message.SearchRequest;
-import org.apache.directory.shared.ldap.message.SearchResponseDone;
-import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.util.ArrayUtils;
-import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.demux.MessageHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -66,474 +31,16 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class SearchHandler extends AbstractLdapHandler implements MessageHandler
+public abstract class SearchHandler extends AbstractLdapHandler implements MessageHandler
 {
-    //TM private static long cumul = 0L;
-    //TM private static long count = 0;
-    //TM private static Object lock = new Object();
-
-    private static final Logger log = LoggerFactory.getLogger( SearchHandler.class );
-    private static final String DEREFALIASES_KEY = JndiPropertyConstants.JNDI_LDAP_DAP_DEREF_ALIASES;
-
-    /** Speedup for logs */
-    private static final boolean IS_DEBUG = log.isDebugEnabled();
-
-    /**
-     * Builds the JNDI search controls for a SearchRequest.
-     *  
-     * @param req the search request.
-     * @param ids the ids to return
-     * @return the SearchControls to use with the ApacheDS server side JNDI provider
-     */
-    private SearchControls getSearchControls( SearchRequest req, String[] ids, boolean isAdmin, int maxSize, int maxTime )
-    {
-        // prepare all the search controls
-        SearchControls controls = new SearchControls();
-        
-        // take the minimum of system limit with request specified value
-        if ( isAdmin )
-        {
-            controls.setCountLimit( req.getSizeLimit() );
-            
-            // The setTimeLimit needs a number of milliseconds
-            // when the search control is expressed in seconds
-            int timeLimit = req.getTimeLimit();
-            
-            // Just check that we are not exceeding the maximum for a long 
-            if ( timeLimit > Integer.MAX_VALUE / 1000 )
-            {
-                timeLimit = 0;
-            }
-            
-            // The maximum time we can wait is around 24 days ...
-            // Is it enough ? ;)
-            controls.setTimeLimit( timeLimit * 1000 );
-        }
-        else
-        {
-            controls.setCountLimit( Math.min( req.getSizeLimit(), maxSize ) );
-            controls.setTimeLimit( Math.min( req.getTimeLimit(), maxTime ) );
-        }
-        
-        controls.setSearchScope( req.getScope().getValue() );
-        controls.setReturningObjFlag( req.getTypesOnly() );
-        controls.setReturningAttributes( ids );
-        controls.setDerefLinkFlag( true );
-        return controls;
-    }
-
-
-    /**
-     * Determines if a search request is on the RootDSE of the server.
-     * 
-     * @param req the request issued
-     * @return true if the search is on the RootDSE false otherwise
-     */
-    private static boolean isRootDSESearch( SearchRequest req )
-    {
-        boolean isBaseIsRoot = req.getBase().isEmpty();
-        boolean isBaseScope = req.getScope() == ScopeEnum.BASE_OBJECT;
-        boolean isRootDSEFilter = false;
-        if ( req.getFilter() instanceof PresenceNode )
-        {
-            isRootDSEFilter = ( ( PresenceNode ) req.getFilter() ).getAttribute().equalsIgnoreCase( SchemaConstants.OBJECT_CLASS_AT );
-        }
-        return isBaseIsRoot && isBaseScope && isRootDSEFilter;
-    }
-
-
     /**
      * Main message handing method for search requests.
      */
-    public void messageReceived( IoSession session, Object request ) throws Exception
+    public final void messageReceived( IoSession session, Object request ) throws Exception
     {
-        LdapConfiguration cfg = ( LdapConfiguration ) session.getAttribute(  LdapConfiguration.class.toString() );
-
-    	if ( IS_DEBUG )
-    	{
-    		log.debug( "Message received:  {}", request.toString() );
-    	}
-
-    	ServerLdapContext ctx;
-        SearchRequest req = ( SearchRequest ) request;
-        NamingEnumeration list = null;
-        String[] ids = null;
-        Collection<String> retAttrs = new HashSet<String>();
-        retAttrs.addAll( req.getAttributes() );
-
-        // add the search request to the registry of outstanding requests for this session
-        SessionRegistry.getSingleton().addOutstandingRequest( session, req );
-
-        // check the attributes to see if a referral's ref attribute is included
-        if ( retAttrs.size() > 0 && !retAttrs.contains( SchemaConstants.REF_AT ) )
-        {
-            retAttrs.add( SchemaConstants.REF_AT );
-            ids = retAttrs.toArray( ArrayUtils.EMPTY_STRING_ARRAY );
-        }
-        else if ( retAttrs.size() > 0 )
-        {
-            ids = retAttrs.toArray( ArrayUtils.EMPTY_STRING_ARRAY );
-        }
-
-        try
-        {
-            // ===============================================================
-            // Find session context
-            // ===============================================================
-
-            boolean isRootDSESearch = isRootDSESearch( req );
-            
-            // bypass checks to disallow anonymous binds for search on RootDSE with base obj scope
-            if ( isRootDSESearch )
-            {
-                LdapContext unknown = SessionRegistry.getSingleton().getLdapContextOnRootDSEAccess( session, null );
-                
-                if ( !( unknown instanceof ServerLdapContext ) )
-                {
-                    ctx = ( ServerLdapContext ) unknown.lookup( "" );
-                }
-                else
-                {
-                    ctx = ( ServerLdapContext ) unknown;
-                }
-            }
-            // all those search operations are subject to anonymous bind checks when anonymous binda are disallowed
-            else
-            {
-                LdapContext unknown = SessionRegistry.getSingleton().getLdapContext( session, null, true );
-                
-                if ( !( unknown instanceof ServerLdapContext ) )
-                {
-                    ctx = ( ServerLdapContext ) unknown.lookup( "" );
-                }
-                else
-                {
-                    ctx = ( ServerLdapContext ) unknown;
-                }
-            }
-            
-            // Inject controls into the context
-            setRequestControls( ctx, req );
-
-            ctx.addToEnvironment( DEREFALIASES_KEY, req.getDerefAliases() );
-            
-            if ( req.getControls().containsKey( ManageDsaITControl.CONTROL_OID ) )
-            {
-                ctx.addToEnvironment( Context.REFERRAL, "ignore" );
-            }
-            else
-            {
-                ctx.addToEnvironment( Context.REFERRAL, "throw-finding-base" );
-            }
-
-            // ===============================================================
-            // Handle annonymous binds
-            // ===============================================================
-
-            boolean allowAnonymousBinds = cfg.isAllowAnonymousAccess();
-            boolean isAnonymousUser = ctx.getPrincipal().getName().trim().equals( "" );
-
-            if ( isAnonymousUser && !allowAnonymousBinds && !isRootDSESearch )
-            {
-                LdapResult result = req.getResultResponse().getLdapResult();
-                result.setResultCode( ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS );
-                String msg = "Bind failure: Anonymous binds have been disabled!";
-                result.setErrorMessage( msg );
-                session.write( req.getResultResponse() );
-                //TM long t1 = System.nanoTime();
-                //TM
-                //TM synchronized (lock)
-                //TM {
-                //TM     cumul += (t1 - t0);
-                //TM     count++;
-                //TM    
-                //TM     if ( count % 1000L == 0)
-                //TM     {
-                //TM         System.out.println( "Search cost : " + (cumul/count) );
-                //TM         cumul = 0L;
-                //TM     }
-                //TM }
-                return;
-            }
-
-
-            // ===============================================================
-            // Set search limits differently based on user's identity
-            // ===============================================================
-
-            int maxSize = cfg.getMaxSizeLimit();
-            int maxTime = cfg.getMaxTimeLimit();
-
-            SearchControls controls = null;
-            if ( isAnonymousUser )
-            {
-                controls = getSearchControls( req, ids, false, maxSize, maxTime );
-            }
-            else if ( ctx.getPrincipal().getName()
-                .trim().equals( PartitionNexus.ADMIN_PRINCIPAL_NORMALIZED ) )
-            {
-                controls = getSearchControls( req, ids, true, maxSize, maxTime );
-            }
-            else
-            {
-                controls = getSearchControls( req, ids, false, maxSize, maxTime );
-            }
-            
-            
-            // ===============================================================
-            // Handle psearch differently
-            // ===============================================================
-
-            PersistentSearchControl psearchControl = ( PersistentSearchControl ) req.getControls().get(
-                PersistentSearchControl.CONTROL_OID );
-            if ( psearchControl != null )
-            {
-                // there are no limits for psearch processing
-                controls.setCountLimit( 0 );
-                controls.setTimeLimit( 0 );
-
-                if ( !psearchControl.isChangesOnly() )
-                {
-                    list = ctx.search( req.getBase(), req.getFilter(),
-                        controls );
-                    if ( list instanceof AbandonListener )
-                    {
-                        req.addAbandonListener( ( AbandonListener ) list );
-                    }
-                    if ( list.hasMore() )
-                    {
-                        Iterator it = new SearchResponseIterator( req, ctx, list, controls.getSearchScope(), session );
-                        while ( it.hasNext() )
-                        {
-                            Response resp = ( Response ) it.next();
-                            if ( resp instanceof SearchResponseDone )
-                            {
-                                // ok if normal search beforehand failed somehow quickly abandon psearch
-                                ResultCodeEnum rcode = ( ( SearchResponseDone ) resp ).getLdapResult().getResultCode();
-                                
-                                if ( rcode != ResultCodeEnum.SUCCESS )
-                                {
-                                    session.write( resp );
-                                    //TM long t1 = System.nanoTime();
-                                    //TM  
-                                    //TM synchronized( lock )
-                                    //TM {
-                                    //TM     cumul += (t1 - t0);
-                                    //TM     count++;
-                                    //TM     
-                                    //TM     if ( count % 1000L == 0)
-                                    //TM     {
-                                    //TM         System.out.println( "Search cost : " + (cumul/count) );
-                                    //TM         cumul = 0L;
-                                    //TM     }
-                                    //TM }
-                                    
-                                    return;
-                                }
-                                // if search was fine then we returned all entries so now
-                                // instead of returning the DONE response we break from the
-                                // loop and user the notification listener to send back 
-                                // notificationss to the client in never ending search
-                                else
-                                    break;
-                            }
-                            else
-                            {
-                                session.write( resp );
-                            }
-                        }
-                    }
-                }
-
-                // now we process entries for ever as they change 
-                PersistentSearchListener handler = new PersistentSearchListener( ctx, session, req );
-                ctx.addNamingListener( req.getBase(), req.getFilter().toString(), controls, handler );
-                //TM long t1 = System.nanoTime();
-                //TM synchronized( lock )
-                //TM {
-                //TM     cumul += (t1 - t0);
-                //TM     count++;
-                //TM     
-                //TM     if ( count % 1000L == 0)
-                //TM     {
-                //TM         System.out.println( "Search cost : " + (cumul/count) );
-                //TM         cumul = 0L;
-                //TM     }
-                //TM }
-                return;
-            }
-
-            // ===============================================================
-            // Handle regular search requests from here down
-            // ===============================================================
-
-            /*
-             * Iterate through all search results building and sending back responses 
-             * for each search result returned.  
-             */
-            list = ctx.search( req.getBase(), req.getFilter(), controls );
-            if ( list instanceof AbandonListener )
-            {
-                req.addAbandonListener( ( AbandonListener ) list );
-            }
-
-            if ( list.hasMore() )
-            {
-                Iterator it = new SearchResponseIterator( req, ctx, list, controls.getSearchScope(), session );
-                while ( it.hasNext() )
-                {
-                    session.write( it.next() );
-                }
-                //TM long t1 = System.nanoTime();
-                //TM synchronized( lock )
-                //TM {
-                //TM     cumul += (t1 - t0);
-                //TM     count++;
-                //TM     
-                //TM     if ( count % 1000L == 0)
-                //TM     {
-                //TM         System.out.println( "Search cost : " + (cumul/count) );
-                //TM         cumul = 0L;
-                //TM     }
-                //TM }
-
-                return;
-            }
-            else
-            {
-                list.close();
-                req.getResultResponse().getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
-                Iterator it = Collections.singleton( req.getResultResponse() ).iterator();
-                while ( it.hasNext() )
-                {
-                    session.write( it.next() );
-                }
-                //TM long t1 = System.nanoTime();
-                //TM synchronized( lock )
-                //TM {
-                //TM     cumul += (t1 - t0);
-                //TM     count++;
-                //TM     
-                //TM     if ( count % 1000L == 0)
-                //TM     {
-                //TM         System.out.println( "Search cost : " + (cumul/count) );
-                //TM         cumul = 0L;
-                //TM     }
-                //TM }
-
-                return;
-            }
-        }
-        catch ( ReferralException e )
-        {
-            LdapResult result = req.getResultResponse().getLdapResult();
-            ReferralImpl refs = new ReferralImpl();
-            result.setReferral( refs );
-            result.setResultCode( ResultCodeEnum.REFERRAL );
-            result.setErrorMessage( "Encountered referral attempting to handle add request." );
-            /* coming up null causing a NPE */
-            // result.setMatchedDn( e.getResolvedName().toString() );
-            do
-            {
-                refs.addLdapUrl( ( String ) e.getReferralInfo() );
-            }
-            while ( e.skipReferral() );
-            session.write( req.getResultResponse() );
-            SessionRegistry.getSingleton().removeOutstandingRequest( session, req.getMessageId() );
-            //TM long t1 = System.nanoTime();
-            //TM synchronized( lock )
-            //TM {
-            //TM    cumul += (t1 - t0);
-            //TM    count++;
-            //TM     
-            //TM     if ( count % 1000L == 0)
-            //TM     {
-            //TM         System.out.println( "Search cost : " + (cumul/count) );
-            //TM         cumul = 0L;
-            //TM     }
-            //TM }
-
-            return;
-        }
-        catch ( NamingException e )
-        {
-            /*
-             * From RFC 2251 Section 4.11:
-             * 
-             * In the event that a server receives an Abandon Request on a Search  
-             * operation in the midst of transmitting responses to the Search, that
-             * server MUST cease transmitting entry responses to the abandoned
-             * request immediately, and MUST NOT send the SearchResultDone. Of
-             * course, the server MUST ensure that only properly encoded LDAPMessage
-             * PDUs are transmitted. 
-             * 
-             * SO DON'T SEND BACK ANYTHING!!!!!
-             */
-            if ( e instanceof OperationAbandonedException )
-            {
-                //TM long t1 = System.nanoTime();
-                //TM synchronized( lock )
-                //TM {
-                //TM     cumul += (t1 - t0);
-                //TM     count++;
-                //TM     
-                //TM     if ( count % 1000L == 0)
-                //TM     {
-                //TM         System.out.println( "Search cost : " + (cumul/count) );
-                //TM         cumul = 0L;
-                //TM     }
-                //TM }
-
-                return;
-            }
-
-            String msg = "failed on search operation: " + e.getMessage();
-            if ( log.isDebugEnabled() )
-            {
-                msg += ":\n" + req + ":\n" + ExceptionUtils.getStackTrace( e );
-            }
-
-            ResultCodeEnum code = null;
-            if ( e instanceof LdapException )
-            {
-                code = ( ( LdapException ) e ).getResultCode();
-            }
-            else
-            {
-                code = ResultCodeEnum.getBestEstimate( e, req.getType() );
-            }
-
-            LdapResult result = req.getResultResponse().getLdapResult();
-            result.setResultCode( code );
-            result.setErrorMessage( msg );
+        searchMessageReceived( session, ( SearchRequest ) request );
+    }
 
-            if ( ( e.getResolvedName() != null )
-                && ( ( code == ResultCodeEnum.NO_SUCH_OBJECT ) || ( code == ResultCodeEnum.ALIAS_PROBLEM )
-                    || ( code == ResultCodeEnum.INVALID_DN_SYNTAX ) || ( code == ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM ) ) )
-            {
-                result.setMatchedDn( (LdapDN)e.getResolvedName() );
-            }
 
-            Iterator it = Collections.singleton( req.getResultResponse() ).iterator();
-            while ( it.hasNext() )
-            {
-                session.write( it.next() );
-            }
-            SessionRegistry.getSingleton().removeOutstandingRequest( session, req.getMessageId() );
-        }
-        finally
-        {
-            if ( list != null )
-            {
-                try
-                {
-                    list.close();
-                }
-                catch ( NamingException e )
-                {
-                    log.error( "failed on list.close()", e );
-                }
-            }
-        }
-    }
+    public abstract void searchMessageReceived( IoSession session, SearchRequest searchRequest ) throws Exception;
 }

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java?rev=582712&r1=582711&r2=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/UnbindHandler.java Sun Oct  7 22:54:38 2007
@@ -20,15 +20,9 @@
 package org.apache.directory.server.ldap.support;
 
 
-import javax.naming.NamingException;
-import javax.naming.ldap.LdapContext;
-
-import org.apache.directory.server.core.jndi.ServerLdapContext;
-import org.apache.directory.server.ldap.SessionRegistry;
+import org.apache.directory.shared.ldap.message.UnbindRequest;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.demux.MessageHandler;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -38,33 +32,13 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class UnbindHandler implements MessageHandler
+public abstract class UnbindHandler implements MessageHandler
 {
-    private static final Logger log = LoggerFactory.getLogger( UnbindHandler.class );
-
-
-    public void messageReceived( IoSession session, Object request ) throws Exception
+    public final void messageReceived( IoSession session, Object request ) throws Exception
     {
-        SessionRegistry registry = SessionRegistry.getSingleton();
+        unbindMessageReceived( session, ( UnbindRequest ) request );
+    }
 
-        try
-        {
-            LdapContext ctx = SessionRegistry.getSingleton().getLdapContext( session, null, false );
 
-            if ( ctx != null )
-            {
-                if ( ctx instanceof ServerLdapContext && ( ( ServerLdapContext ) ctx ).getService().isStarted() )
-                {
-                    ( ( ServerLdapContext ) ctx ).ldapUnbind();
-                }
-                ctx.close();
-            }
-            registry.terminateSession( session );
-            registry.remove( session );
-        }
-        catch ( NamingException e )
-        {
-            log.error( "failed to unbind session properly", e );
-        }
-    }
+    protected abstract void unbindMessageReceived( IoSession session, UnbindRequest unbindRequest ) throws Exception;
 }

Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/test/java/org/apache/directory/server/ldap/LdapProtocolProviderTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/test/java/org/apache/directory/server/ldap/LdapProtocolProviderTest.java?rev=582712&r1=582711&r2=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-ldap/src/test/java/org/apache/directory/server/ldap/LdapProtocolProviderTest.java (original)
+++ directory/apacheds/branches/bigbang/protocol-ldap/src/test/java/org/apache/directory/server/ldap/LdapProtocolProviderTest.java Sun Oct  7 22:54:38 2007
@@ -23,14 +23,11 @@
 import junit.framework.TestCase;
 import org.apache.directory.server.core.DefaultDirectoryService;
 import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.ldap.support.ExtendedHandler;
+import org.apache.directory.server.ldap.support.*;
 import org.apache.directory.shared.ldap.NotImplementedException;
 import org.apache.directory.shared.ldap.exception.LdapNamingException;
 import org.apache.directory.shared.ldap.message.*;
 import org.apache.mina.common.IoSession;
-import org.apache.mina.handler.demux.MessageHandler;
-
-import java.util.Hashtable;
 
 
 /**
@@ -52,8 +49,7 @@
     public void testDefaultOperation() throws LdapNamingException
     {
         DirectoryService directoryService = new DefaultDirectoryService();
-        LdapProtocolProvider provider = new LdapProtocolProvider( directoryService,
-                new LdapConfiguration(), new Hashtable<String,Object>() );
+        LdapProtocolProvider provider = new LdapProtocolProvider( directoryService, new LdapConfiguration() );
         assertNotNull( provider.getCodecFactory() );
         assertEquals( provider.getName(), LdapProtocolProvider.SERVICE_NAME );
     }
@@ -68,111 +64,94 @@
      */
     public void testAlternativeConfiguration() throws LdapNamingException
     {
-        Hashtable<String,Object> props = new Hashtable<String,Object>();
-
-        props.put( AbandonRequest.class.getName(), BogusAbandonHandler.class.getName() );
-        props.put( AbandonRequestImpl.class.getName(), BogusAbandonHandler.class.getName() );
-
-        props.put( AddRequest.class.getName(), BogusAddHandler.class.getName() );
-        props.put( AddRequestImpl.class.getName(), BogusAddHandler.class.getName() );
-
-        props.put( BindRequest.class.getName(), BogusBindHandler.class.getName() );
-        props.put( BindRequestImpl.class.getName(), BogusBindHandler.class.getName() );
-
-        props.put( CompareRequest.class.getName(), BogusCompareHandler.class.getName() );
-        props.put( CompareRequestImpl.class.getName(), BogusCompareHandler.class.getName() );
-
-        props.put( DeleteRequest.class.getName(), BogusDeleteHandler.class.getName() );
-        props.put( DeleteRequestImpl.class.getName(), BogusDeleteHandler.class.getName() );
-
-        props.put( ExtendedRequest.class.getName(), ExtendedHandler.class.getName() );
-        props.put( ExtendedRequestImpl.class.getName(), ExtendedHandler.class.getName() );
-
-        props.put( ModifyRequest.class.getName(), BogusModifyHandler.class.getName() );
-        props.put( ModifyRequestImpl.class.getName(), BogusModifyHandler.class.getName() );
-
-        props.put( ModifyDnRequest.class.getName(), BogusModifyDnHandler.class.getName() );
-        props.put( ModifyDnRequestImpl.class.getName(), BogusModifyDnHandler.class.getName() );
-
-        props.put( SearchRequest.class.getName(), BogusSearchHandler.class.getName() );
-        props.put( SearchRequestImpl.class.getName(), BogusSearchHandler.class.getName() );
-
-        props.put( UnbindRequest.class.getName(), BogusUnbindHandler.class.getName() );
-        props.put( UnbindRequestImpl.class.getName(), BogusUnbindHandler.class.getName() );
-
         DirectoryService directoryService = new DefaultDirectoryService();
-        LdapProtocolProvider provider = new LdapProtocolProvider( directoryService, new LdapConfiguration(), props );
+        LdapProtocolProvider provider = new LdapProtocolProvider( directoryService, new LdapConfiguration() );
+        provider.setAbandonHandler( new BogusAbandonHandler() );
+        provider.setAddHandler( new BogusAddHandler() );
+        provider.setBindHandler( new BogusBindHandler() );
+        provider.setCompareHandler( new BogusCompareHandler() );
+        provider.setDeleteHandler( new BogusDeleteHandler() );
+        provider.setModifyDnHandler( new BogusModifyDnHandler() );
+        provider.setModifyHandler( new BogusModifyHandler() );
+        provider.setSearchHandler( new BogusSearchHandler() );
+        provider.setUnbindHandler( new BogusUnbindHandler() );
+
         assertNotNull( provider.getCodecFactory() );
         assertEquals( provider.getName(), LdapProtocolProvider.SERVICE_NAME );
     }
 
-    public static class BogusAbandonHandler implements MessageHandler
+    public static class BogusAbandonHandler extends AbandonHandler
     {
-        public void messageReceived( IoSession session, Object request )
+        public void abandonMessageReceived( IoSession session, AbandonRequest request )
         {
             throw new NotImplementedException( "handler not implemented!" );
         }
     }
 
-    public static class BogusUnbindHandler implements MessageHandler
+    public static class BogusUnbindHandler extends UnbindHandler
     {
-        public void messageReceived( IoSession session, Object request )
+        public void unbindMessageReceived( IoSession session, UnbindRequest request )
         {
             throw new NotImplementedException( "handler not implemented!" );
         }
     }
 
-    public static class BogusAddHandler implements MessageHandler
+    public static class BogusAddHandler extends AddHandler
     {
-        public void messageReceived( IoSession session, Object request )
+        public void addMessageReceived( IoSession session, AddRequest request )
         {
             throw new NotImplementedException( "handler not implemented!" );
         }
     }
 
-    public static class BogusBindHandler implements MessageHandler
+    public static class BogusBindHandler extends BindHandler
     {
-        public void messageReceived( IoSession session, Object request )
+        public void setDirectoryService( DirectoryService directoryService )
+        {
+        }
+
+
+        public void bindMessageReceived( IoSession session, BindRequest request )
         {
             throw new NotImplementedException( "handler not implemented!" );
         }
     }
 
-    public static class BogusCompareHandler implements MessageHandler
+    public static class BogusCompareHandler extends CompareHandler
     {
-        public void messageReceived( IoSession session, Object request )
+        public void compareMessageReceived( IoSession session, CompareRequest request )
         {
             throw new NotImplementedException( "handler not implemented!" );
         }
     }
 
-    public static class BogusDeleteHandler implements MessageHandler
+    public static class BogusDeleteHandler extends  DeleteHandler
     {
-        public void messageReceived( IoSession session, Object request )
+        public void deleteMessageReceived( IoSession session, DeleteRequest request )
         {
             throw new NotImplementedException( "handler not implemented!" );
         }
     }
 
-    public static class BogusModifyDnHandler implements MessageHandler
+    public static class BogusModifyDnHandler extends  ModifyDnHandler
     {
-        public void messageReceived( IoSession session, Object request )
+        public void modifyDnMessageReceived( IoSession session, ModifyDnRequest request )
         {
             throw new NotImplementedException( "handler not implemented!" );
         }
     }
 
-    public static class BogusModifyHandler implements MessageHandler
+    public static class BogusModifyHandler extends ModifyHandler
     {
-        public void messageReceived( IoSession session, Object request )
+        public void modifyMessageReceived( IoSession session, ModifyRequest request )
         {
             throw new NotImplementedException( "handler not implemented!" );
         }
     }
 
-    public static class BogusSearchHandler implements MessageHandler
+    public static class BogusSearchHandler extends SearchHandler
     {
-        public void messageReceived( IoSession session, Object request )
+        public void searchMessageReceived( IoSession session, SearchRequest request )
         {
             throw new NotImplementedException( "handler not implemented!" );
         }

Modified: directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java?rev=582712&r1=582711&r2=582712&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java (original)
+++ directory/apacheds/branches/bigbang/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java Sun Oct  7 22:54:38 2007
@@ -160,8 +160,8 @@
         
         if ( enableNetworking )
         {
-            startLDAP( environment );
-            startLDAPS( environment );
+            startLDAP();
+            startLDAPS();
             startKerberos();
             startChangePassword();
             startNTP();
@@ -656,9 +656,8 @@
      * Starts up the LDAP protocol provider to service LDAP requests
      *
      * @throws NamingException if there are problems starting the LDAP provider
-     * @param env the environment
      */
-    private void startLDAP( Hashtable<String,Object> env ) throws NamingException
+    private void startLDAP() throws NamingException
     {
         // Skip if disabled
         if ( ! ldapConfiguration.isEnabled() )
@@ -667,7 +666,7 @@
         }
 
         DefaultIoFilterChainBuilder chain = new DefaultIoFilterChainBuilder();
-        startLDAP0( ldapConfiguration, env, ldapConfiguration.getIpPort(), chain );
+        startLDAP0( ldapConfiguration, ldapConfiguration.getIpPort(), chain );
     }
 
 
@@ -675,9 +674,8 @@
      * Starts up the LDAPS protocol provider to service LDAPS requests
      *
      * @throws NamingException if there are problems starting the LDAPS provider
-     * @param env the JNDI environment
      */
-    private void startLDAPS( Hashtable<String,Object> env ) throws NamingException
+    private void startLDAPS() throws NamingException
     {
         // Skip if disabled
         if ( !( ldapsConfiguration.isEnabled() && ldapsConfiguration.isEnableLdaps() ) )
@@ -691,15 +689,15 @@
         IoFilterChainBuilder chain = LdapsInitializer.init( certPasswordChars, storePath );
         ldapsStarted = true;
 
-        startLDAP0( ldapsConfiguration, env, ldapsConfiguration.getIpPort(), chain );
+        startLDAP0( ldapsConfiguration, ldapsConfiguration.getIpPort(), chain );
     }
 
 
-    private void startLDAP0( LdapConfiguration ldapConfig, Hashtable<String,Object> env, int port, IoFilterChainBuilder chainBuilder )
+    private void startLDAP0( LdapConfiguration ldapConfig, int port, IoFilterChainBuilder chainBuilder )
         throws LdapNamingException, LdapConfigurationException
     {
         // Register all extended operation handlers.
-        LdapProtocolProvider protocolProvider = new LdapProtocolProvider( directoryService, ldapConfig, env );
+        LdapProtocolProvider protocolProvider = new LdapProtocolProvider( directoryService, ldapConfig );
 
         for ( ExtendedOperationHandler h : ldapConfig.getExtendedOperationHandlers() )
         {

Modified: directory/shared/branches/bigbang/asn1-codec/src/main/java/org/apache/directory/shared/asn1/codec/Asn1CodecDecoder.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/asn1-codec/src/main/java/org/apache/directory/shared/asn1/codec/Asn1CodecDecoder.java?rev=582712&r1=582711&r2=582712&view=diff
==============================================================================
--- directory/shared/branches/bigbang/asn1-codec/src/main/java/org/apache/directory/shared/asn1/codec/Asn1CodecDecoder.java (original)
+++ directory/shared/branches/bigbang/asn1-codec/src/main/java/org/apache/directory/shared/asn1/codec/Asn1CodecDecoder.java Sun Oct  7 22:54:38 2007
@@ -19,7 +19,7 @@
  */
 package org.apache.directory.shared.asn1.codec;
 
-import org.apache.directory.shared.asn1.codec.DecoderException;
+
 import org.apache.directory.shared.asn1.codec.stateful.DecoderCallback;
 import org.apache.directory.shared.asn1.codec.stateful.StatefulDecoder;
 import org.apache.mina.common.ByteBuffer;
@@ -27,6 +27,7 @@
 import org.apache.mina.filter.codec.ProtocolDecoderAdapter;
 import org.apache.mina.filter.codec.ProtocolDecoderOutput;
 
+
 /**
  * Adapts {@link StatefulDecoder} to MINA <tt>ProtocolDecoder</tt>
  * 
@@ -35,23 +36,23 @@
  */
 public class Asn1CodecDecoder extends ProtocolDecoderAdapter
 {
-
     private final StatefulDecoder decoder;
-
     private final DecoderCallbackImpl callback = new DecoderCallbackImpl();
 
+
     public Asn1CodecDecoder( StatefulDecoder decoder )
     {
         decoder.setCallback( callback );
         this.decoder = decoder;
     }
 
-    public void decode( IoSession session, ByteBuffer in,
-                        ProtocolDecoderOutput out ) throws DecoderException
+
+    public void decode( IoSession session, ByteBuffer in, ProtocolDecoderOutput out ) throws DecoderException
     {
         callback.decOut = out;
         decoder.decode( in.buf() );
     }
+
 
     private class DecoderCallbackImpl implements DecoderCallback
     {



Mime
View raw message