directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r366690 [2/2] - in /directory/trunk: apacheds/src/main/java/org/apache/ldap/server/partition/ ldap-common/src/main/java/org/apache/ldap/common/message/ ldap-common/src/test/java/org/apache/ldap/common/message/ ldap-protocol/src/main/java/or...
Date Sat, 07 Jan 2006 07:19:21 GMT
Modified: directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/BindHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/BindHandler.java?rev=366690&r1=366689&r2=366690&view=diff
==============================================================================
--- directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/BindHandler.java
(original)
+++ directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/BindHandler.java
Fri Jan  6 23:18:44 2006
@@ -27,20 +27,19 @@
 
 import org.apache.ldap.common.exception.LdapException;
 import org.apache.ldap.common.message.BindRequest;
-import org.apache.ldap.common.message.BindResponse;
-import org.apache.ldap.common.message.BindResponseImpl;
 import org.apache.ldap.common.message.Control;
 import org.apache.ldap.common.message.LdapResult;
-import org.apache.ldap.common.message.LdapResultImpl;
 import org.apache.ldap.common.message.ResultCodeEnum;
 import org.apache.ldap.common.util.ExceptionUtils;
 import org.apache.ldap.common.util.StringTools;
 import org.apache.ldap.server.protocol.SessionRegistry;
 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.ldap.common.message.BindRequest}s.
  *
@@ -57,34 +56,20 @@
     {
         LdapContext ctx;
         BindRequest req = ( BindRequest ) request;
-        BindResponse resp = new BindResponseImpl( req.getMessageId() );
-        LdapResult result = new LdapResultImpl( resp );
-        resp.setLdapResult( result );
+        LdapResult result = req.getResultResponse().getLdapResult();
 
         Hashtable env = SessionRegistry.getSingleton().getEnvironment();
-//        StartupConfiguration cfg = ( StartupConfiguration ) Configuration.toConfiguration(
env );
         
         // if the bind request is not simple then we freak: no strong auth yet
         if ( ! req.isSimple() )
         {
             result.setResultCode( ResultCodeEnum.AUTHMETHODNOTSUPPORTED );
             result.setErrorMessage( "Only simple binds currently supported" );
-            session.write( resp );
+            session.write( req.getResultResponse() );
             return;
         }
 
-//        boolean allowAnonymousBinds = cfg.isAllowAnonymousAccess();
-//        boolean emptyCredentials = req.getCredentials() == null || req.getCredentials().length
== 0;
         boolean emptyDn = StringTools.isEmpty( req.getName() );
-//
-//        if ( emptyCredentials && emptyDn && ! allowAnonymousBinds )
-//        {
-//            result.setResultCode( ResultCodeEnum.INSUFFICIENTACCESSRIGHTS );
-//            String msg = "Bind failure: Anonymous binds have been disabled!";
-//            result.setErrorMessage( msg );
-//            session.write( resp );
-//            return;
-//        }
 
         // clone the environment first then add the required security settings
         String dn = ( emptyDn ? "" : req.getName() );
@@ -132,7 +117,6 @@
             }
 
             String msg = "Bind failed";
-
             if ( log.isDebugEnabled() )
             {
                 msg += ":\n" + ExceptionUtils.getStackTrace( e );
@@ -145,16 +129,16 @@
                       ( code == ResultCodeEnum.INVALIDDNSYNTAX ) ||
                       ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM ) ) )
             {
-                resp.getLdapResult().setMatchedDn( e.getResolvedName().toString() );
+                result.setMatchedDn( e.getResolvedName().toString() );
             }
             
             result.setErrorMessage( msg );
-            session.write( resp );
+            session.write( req.getResultResponse() );
             return;
         }
 
         SessionRegistry.getSingleton().setLdapContext( session, ctx );
         result.setResultCode( ResultCodeEnum.SUCCESS );
-        session.write( resp );
+        session.write( req.getResultResponse() );
     }
 }

Modified: directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/CompareHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/CompareHandler.java?rev=366690&r1=366689&r2=366690&view=diff
==============================================================================
--- directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/CompareHandler.java
(original)
+++ directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/CompareHandler.java
Fri Jan  6 23:18:44 2006
@@ -22,9 +22,7 @@
 
 import org.apache.ldap.common.exception.LdapException;
 import org.apache.ldap.common.message.CompareRequest;
-import org.apache.ldap.common.message.CompareResponse;
-import org.apache.ldap.common.message.CompareResponseImpl;
-import org.apache.ldap.common.message.LdapResultImpl;
+import org.apache.ldap.common.message.LdapResult;
 import org.apache.ldap.common.message.ResultCodeEnum;
 import org.apache.ldap.common.name.LdapName;
 import org.apache.ldap.common.util.ExceptionUtils;
@@ -32,6 +30,7 @@
 import org.apache.ldap.server.protocol.SessionRegistry;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.demux.MessageHandler;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,8 +48,7 @@
     public void messageReceived( IoSession session, Object request )
     {
         CompareRequest req = ( CompareRequest ) request;
-        CompareResponse resp = new CompareResponseImpl( req.getMessageId() );
-        resp.setLdapResult( new LdapResultImpl( resp ) );
+        LdapResult result = req.getResultResponse().getLdapResult();
 
         try
         {
@@ -60,11 +58,11 @@
             
             if ( newCtx.compare( name, req.getAttributeId(), req.getAssertionValue() ) )
             {
-                resp.getLdapResult().setResultCode( ResultCodeEnum.COMPARETRUE );
+                result.setResultCode( ResultCodeEnum.COMPARETRUE );
             }
             else
             {
-                resp.getLdapResult().setResultCode( ResultCodeEnum.COMPAREFALSE );
+                result.setResultCode( ResultCodeEnum.COMPAREFALSE );
             }
         }
         catch ( Exception e )
@@ -87,8 +85,8 @@
                 code = ResultCodeEnum.getBestEstimate( e, req.getType() );
             }
 
-            resp.getLdapResult().setResultCode( code );
-            resp.getLdapResult().setErrorMessage( msg );
+            result.setResultCode( code );
+            result.setErrorMessage( msg );
 
             if ( e instanceof NamingException )
             {
@@ -100,15 +98,15 @@
                           ( code == ResultCodeEnum.INVALIDDNSYNTAX ) ||
                           ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM ) ) )
                 {
-                    resp.getLdapResult().setMatchedDn( ne.getResolvedName().toString() );
+                    result.setMatchedDn( ne.getResolvedName().toString() );
                 }
             }
 
-            session.write( resp );
+            session.write( req.getResultResponse() );
             return;
         }
 
-        resp.getLdapResult().setMatchedDn( req.getName() );
-        session.write( resp );
+        result.setMatchedDn( req.getName() );
+        session.write( req.getResultResponse() );
     }
 }

Modified: directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/DeleteHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/DeleteHandler.java?rev=366690&r1=366689&r2=366690&view=diff
==============================================================================
--- directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/DeleteHandler.java
(original)
+++ directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/DeleteHandler.java
Fri Jan  6 23:18:44 2006
@@ -16,19 +16,19 @@
  */
 package org.apache.ldap.server.protocol.support;
 
+
 import javax.naming.NamingException;
 import javax.naming.directory.DirContext;
 
 import org.apache.ldap.common.exception.LdapException;
 import org.apache.ldap.common.message.DeleteRequest;
-import org.apache.ldap.common.message.DeleteResponse;
-import org.apache.ldap.common.message.DeleteResponseImpl;
-import org.apache.ldap.common.message.LdapResultImpl;
+import org.apache.ldap.common.message.LdapResult;
 import org.apache.ldap.common.message.ResultCodeEnum;
 import org.apache.ldap.common.util.ExceptionUtils;
 import org.apache.ldap.server.protocol.SessionRegistry;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.demux.MessageHandler;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -41,14 +41,12 @@
  */
 public class DeleteHandler implements MessageHandler
 {
-    private static final Logger LOG = LoggerFactory.getLogger( DeleteHandler.class );
-
+    private static final Logger log = LoggerFactory.getLogger( DeleteHandler.class );
 
     public void messageReceived( IoSession session, Object request )
     {
         DeleteRequest req = ( DeleteRequest ) request;
-        DeleteResponse resp = new DeleteResponseImpl( req.getMessageId() );
-        resp.setLdapResult( new LdapResultImpl( resp ) );
+        LdapResult result = req.getResultResponse().getLdapResult(); 
 
         try
         {
@@ -59,13 +57,12 @@
         {
             String msg = "failed to delete entry " + req.getName();
 
-            if ( LOG.isDebugEnabled() )
+            if ( log.isDebugEnabled() )
             {
                 msg += ":\n" + ExceptionUtils.getStackTrace( e );
             }
 
             ResultCodeEnum code;
-
             if( e instanceof LdapException )
             {
                 code = ( ( LdapException ) e ).getResultCode();
@@ -75,23 +72,22 @@
                 code = ResultCodeEnum.getBestEstimate( e, req.getType() );
             }
 
-            resp.getLdapResult().setResultCode( code );
-            resp.getLdapResult().setErrorMessage( msg );
-
+            result.setResultCode( code );
+            result.setErrorMessage( msg );
             if ( ( e.getResolvedName() != null ) &&
                     ( ( code == ResultCodeEnum.NOSUCHOBJECT ) ||
                       ( code == ResultCodeEnum.ALIASPROBLEM ) ||
                       ( code == ResultCodeEnum.INVALIDDNSYNTAX ) ||
                       ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM ) ) )
             {
-                resp.getLdapResult().setMatchedDn( e.getResolvedName().toString() );
+                result.setMatchedDn( e.getResolvedName().toString() );
             }
 
-            session.write( resp );
+            session.write( req.getResultResponse() );
             return;
         }
 
-        resp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
-        session.write( resp );
+        result.setResultCode( ResultCodeEnum.SUCCESS );
+        session.write( req.getResultResponse() );
     }
 }

Modified: directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ExtendedHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ExtendedHandler.java?rev=366690&r1=366689&r2=366690&view=diff
==============================================================================
--- directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ExtendedHandler.java
(original)
+++ directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ExtendedHandler.java
Fri Jan  6 23:18:44 2006
@@ -23,9 +23,7 @@
 
 import org.apache.ldap.common.message.ExtendedRequest;
 import org.apache.ldap.common.message.ExtendedResponse;
-import org.apache.ldap.common.message.ExtendedResponseImpl;
 import org.apache.ldap.common.message.LdapResult;
-import org.apache.ldap.common.message.LdapResultImpl;
 import org.apache.ldap.common.message.ResultCodeEnum;
 import org.apache.ldap.common.util.ExceptionUtils;
 import org.apache.ldap.server.protocol.ExtendedOperationHandler;
@@ -33,6 +31,7 @@
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.demux.MessageHandler;
 
+
 /**
  * A single reply handler for {@link org.apache.ldap.common.message.ExtendedRequest}s.
  *
@@ -42,6 +41,7 @@
 public class ExtendedHandler implements MessageHandler
 {
     private Map handlers = new HashMap();
+
     
     public ExtendedOperationHandler addHandler( ExtendedOperationHandler eoh )
     {
@@ -51,6 +51,7 @@
         }
     }
     
+    
     public ExtendedOperationHandler removeHandler( String oid )
     {
         synchronized( handlers )
@@ -59,54 +60,51 @@
         }
     }
     
+    
     public ExtendedOperationHandler getHandler( String oid )
     {
         return ( ExtendedOperationHandler ) handlers.get( oid );
     }
     
+    
     public Map getHandlerMap()
     {
         return Collections.unmodifiableMap( handlers );
     }
     
+    
     public void messageReceived( IoSession session, Object request )
     {
         ExtendedRequest req = ( ExtendedRequest ) request;
-        ExtendedResponse res = new ExtendedResponseImpl( req.getMessageId() );
-
         ExtendedOperationHandler handler = ( ExtendedOperationHandler ) handlers.get( req.getOid()
);
+
         if( handler == null )
         {
-            res.setLdapResult( new LdapResultImpl( res ) );
             // As long as no extended operations are implemented, send appropriate
             // error back to the client.
             String msg = "Unrecognized extended operation OID: " + req.getOid();
-            
-            LdapResult result = res.getLdapResult();        
+            LdapResult result = req.getResultResponse().getLdapResult();        
             result.setResultCode( ResultCodeEnum.PROTOCOLERROR );
             result.setErrorMessage( msg );
-            session.write( res );
+            session.write( req.getResultResponse() );
         }
         else
         {
             try
             {
-                handler.handleExtendedOperation(
-                        session,
-                        SessionRegistry.getSingleton(),
-                        req );
+                handler.handleExtendedOperation( session,
+                        SessionRegistry.getSingleton(), req );
             }
             catch( Exception e )
             {
-                LdapResult result = new LdapResultImpl( res );
+                LdapResult result = req.getResultResponse().getLdapResult();
                 result.setResultCode( ResultCodeEnum.UNAVAILABLE );
                 result.setErrorMessage(
                         "Extended operation handler for the specified OID (" +
                         req.getOid() + ") has failed to process your request:\n" +
                         ExceptionUtils.getStackTrace( e ) );
-                res.setLdapResult( result );
-                res.setResponse( new byte[ 0 ] );
-                session.write( res );
+                ( ( ExtendedResponse ) req.getResultResponse() ).setResponse( new byte[ 0
] );
+                session.write( req.getResultResponse() );
             }
         }
     }

Added: directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/HandlerUtil.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/HandlerUtil.java?rev=366690&view=auto
==============================================================================
--- directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/HandlerUtil.java
(added)
+++ directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/HandlerUtil.java
Fri Jan  6 23:18:44 2006
@@ -0,0 +1,26 @@
+package org.apache.ldap.server.protocol.support;
+
+
+public class HandlerUtil
+{
+    /*
+    public static void unsupportCriticalControls( ResultResponse resp )
+    {
+        resp.getLdapResult();
+        Request request = ( Request ) message;
+        if ( request.getControls().size() > 0 )
+        {
+            Iterator controls = request.getControls().iterator();
+            while ( controls.hasNext() )
+            {
+                Control control = ( Control ) controls.next();
+                if ( control.isCritical() && ! isSupported( control ) )
+                {
+                    
+                }
+            }
+        }
+        
+    }
+    */
+}

Propchange: directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/HandlerUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ModifyDnHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ModifyDnHandler.java?rev=366690&r1=366689&r2=366690&view=diff
==============================================================================
--- directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ModifyDnHandler.java
(original)
+++ directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ModifyDnHandler.java
Fri Jan  6 23:18:44 2006
@@ -16,15 +16,13 @@
  */
 package org.apache.ldap.server.protocol.support;
 
+
 import javax.naming.NamingException;
 import javax.naming.ldap.LdapContext;
 
 import org.apache.ldap.common.exception.LdapException;
 import org.apache.ldap.common.message.LdapResult;
-import org.apache.ldap.common.message.LdapResultImpl;
 import org.apache.ldap.common.message.ModifyDnRequest;
-import org.apache.ldap.common.message.ModifyDnResponse;
-import org.apache.ldap.common.message.ModifyDnResponseImpl;
 import org.apache.ldap.common.message.ResultCodeEnum;
 import org.apache.ldap.common.name.LdapName;
 import org.apache.ldap.common.util.ExceptionUtils;
@@ -32,12 +30,13 @@
 import org.apache.ldap.server.protocol.SessionRegistry;
 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.ldap.common.message.ModifyDnRequest}s.
+ * A single reply handler for {@link org.apache.ldap.common.message.ModifyDnRequest}s.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
@@ -46,23 +45,19 @@
 {
     private static final Logger LOG = LoggerFactory.getLogger( ModifyDnHandler.class );
 
-    public void messageReceived(IoSession session, Object request)
+    public void messageReceived( IoSession session, Object request )
     {
-        ModifyDnRequest req = (ModifyDnRequest) request;
-        ModifyDnResponse resp = new ModifyDnResponseImpl( req.getMessageId() );
-        resp.setLdapResult( new LdapResultImpl( resp ) );
+        ModifyDnRequest req = ( ModifyDnRequest ) request;
+        LdapResult result = req.getResultResponse().getLdapResult();
 
         System.out.println("req.getName() == [" + req.getName() +"]");
         if (req.getName() == null || req.getName().length() == 0)
         {
             // it is not allowed to modify the name of the Root DSE
-            
             String msg = "Modify DN is not allowed on Root DSE.";
-
-            LdapResult result = resp.getLdapResult();
             result.setResultCode( ResultCodeEnum.PROTOCOLERROR );
             result.setErrorMessage( msg );
-            session.write( resp );
+            session.write( req.getResultResponse() );
         }
         else
         {
@@ -78,7 +73,6 @@
                     LdapName newDn = null;
                     
                     String newSuperior = req.getNewSuperior();
-                    
                     if ( StringTools.isEmpty( newSuperior ) )
                     {
                     	newDn = (LdapName)oldDn.getPrefix( 1 );
@@ -88,7 +82,6 @@
                     	newDn = new LdapName( req.getNewSuperior() );
                     }
                     
-
                     if (req.getNewRdn() != null)
                     {
                         newDn.add( req.getNewRdn() );
@@ -111,14 +104,12 @@
             catch ( NamingException e )
             {
                 String msg = "failed to modify DN of entry " + req.getName();
-
                 if (LOG.isDebugEnabled())
                 {
                     msg += ":\n" + ExceptionUtils.getStackTrace( e );
                 }
 
                 ResultCodeEnum code;
-
                 if (e instanceof LdapException)
                 {
                     code = ((LdapException) e).getResultCode();
@@ -128,22 +119,21 @@
                     code = ResultCodeEnum.getBestEstimate( e, req.getType() );
                 }
 
-                resp.getLdapResult().setResultCode( code );
-                resp.getLdapResult().setErrorMessage( msg );
-
-                if ((e.getResolvedName() != null)
+                result.setResultCode( code );
+                result.setErrorMessage( msg );
+                if ( ( e.getResolvedName() != null )
                         && ((code == ResultCodeEnum.NOSUCHOBJECT) || (code == ResultCodeEnum.ALIASPROBLEM)
                                 || (code == ResultCodeEnum.INVALIDDNSYNTAX) || (code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM)))
                 {
-                    resp.getLdapResult().setMatchedDn( e.getResolvedName().toString() );
+                    result.setMatchedDn( e.getResolvedName().toString() );
                 }
 
-                session.write( resp );
+                session.write( req.getResultResponse() );
                 return;
             }
 
-            resp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
-            session.write( resp );
+            result.setResultCode( ResultCodeEnum.SUCCESS );
+            session.write( req.getResultResponse() );
         }
     }
 }

Modified: directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ModifyHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ModifyHandler.java?rev=366690&r1=366689&r2=366690&view=diff
==============================================================================
--- directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ModifyHandler.java
(original)
+++ directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/ModifyHandler.java
Fri Jan  6 23:18:44 2006
@@ -22,15 +22,14 @@
 import javax.naming.ldap.LdapContext;
 
 import org.apache.ldap.common.exception.LdapException;
-import org.apache.ldap.common.message.LdapResultImpl;
+import org.apache.ldap.common.message.LdapResult;
 import org.apache.ldap.common.message.ModifyRequest;
-import org.apache.ldap.common.message.ModifyResponse;
-import org.apache.ldap.common.message.ModifyResponseImpl;
 import org.apache.ldap.common.message.ResultCodeEnum;
 import org.apache.ldap.common.util.ExceptionUtils;
 import org.apache.ldap.server.protocol.SessionRegistry;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.handler.demux.MessageHandler;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -50,8 +49,7 @@
     public void messageReceived( IoSession session, Object request )
     {
         ModifyRequest req = ( ModifyRequest ) request;
-        ModifyResponse resp = new ModifyResponseImpl( req.getMessageId() );
-        resp.setLdapResult( new LdapResultImpl( resp ) );
+        LdapResult result = req.getResultResponse().getLdapResult();
 
         try
         {
@@ -62,7 +60,6 @@
         catch ( NamingException e )
         {
             String msg = "failed to modify entry " + req.getName();
-	    
             if ( LOG.isDebugEnabled() )
             {
                 msg += ":\n" + ExceptionUtils.getStackTrace( e );
@@ -78,24 +75,23 @@
                 code = ResultCodeEnum.getBestEstimate( e, req.getType() );
             }
 
-            resp.getLdapResult().setResultCode( code );
-            resp.getLdapResult().setErrorMessage( msg );
-
+            result.setResultCode( code );
+            result.setErrorMessage( msg );
             if ( ( e.getResolvedName() != null ) &&
                     ( ( code == ResultCodeEnum.NOSUCHOBJECT ) ||
                       ( code == ResultCodeEnum.ALIASPROBLEM ) ||
                       ( code == ResultCodeEnum.INVALIDDNSYNTAX ) ||
                       ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM ) ) )
             {
-                resp.getLdapResult().setMatchedDn( e.getResolvedName().toString() );
+                result.setMatchedDn( e.getResolvedName().toString() );
             }
 
-            session.write( resp );
+            session.write( req.getResultResponse() );
             return;
         }
 
-        resp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
-        session.write( resp );
+        result.setResultCode( ResultCodeEnum.SUCCESS );
+        session.write( req.getResultResponse() );
         return;
     }
 }

Modified: directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/PersistentSearchListener.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/PersistentSearchListener.java?rev=366690&r1=366689&r2=366690&view=diff
==============================================================================
--- directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/PersistentSearchListener.java
(original)
+++ directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/PersistentSearchListener.java
Fri Jan  6 23:18:44 2006
@@ -32,18 +32,17 @@
 import org.apache.ldap.common.message.AbandonableRequest;
 import org.apache.ldap.common.message.Control;
 import org.apache.ldap.common.message.EntryChangeControl;
-import org.apache.ldap.common.message.LdapResultImpl;
+import org.apache.ldap.common.message.LdapResult;
 import org.apache.ldap.common.message.PersistentSearchControl;
 import org.apache.ldap.common.message.ResultCodeEnum;
 import org.apache.ldap.common.message.SearchRequest;
-import org.apache.ldap.common.message.SearchResponseDone;
-import org.apache.ldap.common.message.SearchResponseDoneImpl;
 import org.apache.ldap.common.message.SearchResponseEntry;
 import org.apache.ldap.common.message.SearchResponseEntryImpl;
 import org.apache.ldap.common.util.ExceptionUtils;
 import org.apache.ldap.server.jndi.ServerLdapContext;
 import org.apache.ldap.server.protocol.SessionRegistry;
 import org.apache.mina.common.IoSession;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -139,9 +138,7 @@
             msg += ":\n" + req + ":\n" + ExceptionUtils.getStackTrace( evt.getException()
);
         }
 
-        SearchResponseDone resp = new SearchResponseDoneImpl( req.getMessageId() );
         ResultCodeEnum code = null;
-
         if( evt.getException() instanceof LdapException )
         {
             code = ( ( LdapException ) evt.getException() ).getResultCode();
@@ -151,20 +148,18 @@
             code = ResultCodeEnum.getBestEstimate( evt.getException(), req.getType() );
         }
 
-        resp.setLdapResult( new LdapResultImpl( resp ) );
-        resp.getLdapResult().setResultCode( code );
-        resp.getLdapResult().setErrorMessage( msg );
-
+        LdapResult result = req.getResultResponse().getLdapResult();
+        result.setResultCode( code );
+        result.setErrorMessage( msg );
         if ( ( evt.getException().getResolvedName() != null ) &&
                 ( ( code == ResultCodeEnum.NOSUCHOBJECT ) ||
                   ( code == ResultCodeEnum.ALIASPROBLEM ) ||
                   ( code == ResultCodeEnum.INVALIDDNSYNTAX ) ||
                   ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM ) ) )
         {
-            resp.getLdapResult().setMatchedDn( evt.getException().getResolvedName().toString()
);
+            result.setMatchedDn( evt.getException().getResolvedName().toString() );
         }
-
-        session.write( resp );
+        session.write( req.getResultResponse() );
     }
 
     

Modified: directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/SearchHandler.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/SearchHandler.java?rev=366690&r1=366689&r2=366690&view=diff
==============================================================================
--- directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/SearchHandler.java
(original)
+++ directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/SearchHandler.java
Fri Jan  6 23:18:44 2006
@@ -31,14 +31,13 @@
 import org.apache.ldap.common.exception.OperationAbandonedException;
 import org.apache.ldap.common.filter.PresenceNode;
 import org.apache.ldap.common.message.AbandonListener;
-import org.apache.ldap.common.message.LdapResultImpl;
+import org.apache.ldap.common.message.LdapResult;
 import org.apache.ldap.common.message.PersistentSearchControl;
 import org.apache.ldap.common.message.Response;
 import org.apache.ldap.common.message.ResultCodeEnum;
 import org.apache.ldap.common.message.ScopeEnum;
 import org.apache.ldap.common.message.SearchRequest;
 import org.apache.ldap.common.message.SearchResponseDone;
-import org.apache.ldap.common.message.SearchResponseDoneImpl;
 import org.apache.ldap.common.name.LdapName;
 import org.apache.ldap.common.util.ArrayUtils;
 import org.apache.ldap.common.util.ExceptionUtils;
@@ -176,13 +175,11 @@
 
             if ( isAnonymousUser && ! allowAnonymousBinds && ! isRootDSESearch
)
             {
-                SearchResponseDone resp = new SearchResponseDoneImpl( req.getMessageId()
);
-                LdapResultImpl result = new LdapResultImpl( resp );
-                resp.setLdapResult( result );
+                LdapResult result = req.getResultResponse().getLdapResult();
                 result.setResultCode( ResultCodeEnum.INSUFFICIENTACCESSRIGHTS );
                 String msg = "Bind failure: Anonymous binds have been disabled!";
                 result.setErrorMessage( msg );
-                session.write( resp );
+                session.write( req.getResultResponse() );
                 return;
             }
 
@@ -268,16 +265,12 @@
             else
             {
                 list.close();
-                SearchResponseDone resp = new SearchResponseDoneImpl( req.getMessageId()
);
-                resp.setLdapResult( new LdapResultImpl( resp ) );
-                resp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
-                Iterator it = Collections.singleton( resp ).iterator();
-
+                req.getResultResponse().getLdapResult().setResultCode( ResultCodeEnum.SUCCESS
);
+                Iterator it = Collections.singleton( req.getResultResponse() ).iterator();
                 while( it.hasNext() )
                 {
                     session.write( it.next() );
                 }
-
                 return;
             }
         }
@@ -306,9 +299,7 @@
                 msg += ":\n" + req + ":\n" + ExceptionUtils.getStackTrace( e );
             }
 
-            SearchResponseDone resp = new SearchResponseDoneImpl( req.getMessageId() );
             ResultCodeEnum code = null;
-
             if( e instanceof LdapException )
             {
                 code = ( ( LdapException ) e ).getResultCode();
@@ -318,9 +309,9 @@
                 code = ResultCodeEnum.getBestEstimate( e, req.getType() );
             }
 
-            resp.setLdapResult( new LdapResultImpl( resp ) );
-            resp.getLdapResult().setResultCode( code );
-            resp.getLdapResult().setErrorMessage( msg );
+            LdapResult result = req.getResultResponse().getLdapResult();
+            result.setResultCode( code );
+            result.setErrorMessage( msg );
 
             if ( ( e.getResolvedName() != null ) &&
                     ( ( code == ResultCodeEnum.NOSUCHOBJECT ) ||
@@ -328,10 +319,10 @@
                       ( code == ResultCodeEnum.INVALIDDNSYNTAX ) ||
                       ( code == ResultCodeEnum.ALIASDEREFERENCINGPROBLEM ) ) )
             {
-                resp.getLdapResult().setMatchedDn( e.getResolvedName().toString() );
+                result.setMatchedDn( e.getResolvedName().toString() );
             }
 
-            Iterator it = Collections.singleton( resp ).iterator();
+            Iterator it = Collections.singleton( req.getResultResponse() ).iterator();
             while( it.hasNext() )
             {
                 session.write( it.next() );

Modified: directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/SearchResponseIterator.java
URL: http://svn.apache.org/viewcvs/directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/SearchResponseIterator.java?rev=366690&r1=366689&r2=366690&view=diff
==============================================================================
--- directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/SearchResponseIterator.java
(original)
+++ directory/trunk/ldap-protocol/src/main/java/org/apache/ldap/server/protocol/support/SearchResponseIterator.java
Fri Jan  6 23:18:44 2006
@@ -25,17 +25,16 @@
 import javax.naming.directory.SearchResult;
 
 import org.apache.ldap.common.exception.LdapException;
-import org.apache.ldap.common.message.LdapResultImpl;
 import org.apache.ldap.common.message.ReferralImpl;
 import org.apache.ldap.common.message.ResultCodeEnum;
 import org.apache.ldap.common.message.SearchRequest;
 import org.apache.ldap.common.message.SearchResponseDone;
-import org.apache.ldap.common.message.SearchResponseDoneImpl;
 import org.apache.ldap.common.message.SearchResponseEntry;
 import org.apache.ldap.common.message.SearchResponseEntryImpl;
 import org.apache.ldap.common.message.SearchResponseReference;
 import org.apache.ldap.common.message.SearchResponseReferenceImpl;
 import org.apache.ldap.common.util.ExceptionUtils;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -184,8 +183,7 @@
                 {
                 }
 
-                respDone = new SearchResponseDoneImpl( req.getMessageId() );
-                respDone.setLdapResult( new LdapResultImpl( respDone ) );
+                respDone = ( SearchResponseDone ) req.getResultResponse();
                 respDone.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
                 prefetched = null;
                 return next;
@@ -270,15 +268,13 @@
     SearchResponseDone getResponse( SearchRequest req, NamingException e )
     {
         String msg = "failed on search operation";
-
         if ( log.isDebugEnabled() )
         {
             msg += ":\n" + req + ":\n" + ExceptionUtils.getStackTrace( e );
         }
 
-        SearchResponseDone resp = new SearchResponseDoneImpl( req.getMessageId() );
+        SearchResponseDone resp = ( SearchResponseDone ) req.getResultResponse();
         ResultCodeEnum code = null;
-
         if( e instanceof LdapException )
         {
             code = ( ( LdapException ) e ).getResultCode();
@@ -288,10 +284,8 @@
             code = ResultCodeEnum.getBestEstimate( e, req.getType() );
         }
 
-        resp.setLdapResult( new LdapResultImpl( resp ) );
         resp.getLdapResult().setResultCode( code );
         resp.getLdapResult().setErrorMessage( msg );
-
         if ( ( e.getResolvedName() != null ) &&
                 ( ( code == ResultCodeEnum.NOSUCHOBJECT ) ||
                   ( code == ResultCodeEnum.ALIASPROBLEM ) ||
@@ -300,7 +294,6 @@
         {
             resp.getLdapResult().setMatchedDn( e.getResolvedName().toString() );
         }
-
         return resp;
     }
 }



Mime
View raw message