directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r984746 - in /directory: clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/ shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/ shared/...
Date Thu, 12 Aug 2010 12:44:17 GMT
Author: elecharny
Date: Thu Aug 12 12:44:17 2010
New Revision: 984746

URL: http://svn.apache.org/viewvc?rev=984746&view=rev
Log:
Removed the ModifyResponseCodec class

Removed:
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modify/ModifyResponseCodec.java
Modified:
    directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapProtocolEncoder.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/DeleteResponseImpl.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModifyResponseImpl.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalModifyResponse.java
    directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyResponseTest.java

Modified: directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java?rev=984746&r1=984745&r2=984746&view=diff
==============================================================================
--- directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
(original)
+++ directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
Thu Aug 12 12:44:17 2010
@@ -99,7 +99,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.extended.ExtendedRequestCodec;
 import org.apache.directory.shared.ldap.codec.intermediate.IntermediateResponseCodec;
 import org.apache.directory.shared.ldap.codec.modify.ModifyRequestCodec;
-import org.apache.directory.shared.ldap.codec.modify.ModifyResponseCodec;
 import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNRequestCodec;
 import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNResponseCodec;
 import org.apache.directory.shared.ldap.codec.search.Filter;
@@ -131,6 +130,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalExtendedResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalLdapResult;
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
+import org.apache.directory.shared.ldap.message.internal.InternalModifyResponse;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.name.RDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
@@ -1764,42 +1764,9 @@ public class LdapNetworkConnection exten
 
                     break;
 
-            }
-        }
-        else
-        {
-            LdapMessageCodec response = ( LdapMessageCodec ) message;
-            LOG.debug( "-------> {} Message received <-------", response );
-            int messageId = response.getMessageId();
-
-            // this check is necessary to prevent adding an abandoned operation's
-            // result(s) to corresponding queue
-            ResponseFuture<? extends Response> responseFuture = peekFromFutureMap(
messageId );
-
-            if ( responseFuture == null )
-            {
-                LOG.info( "There is no future associated with the messageId {}, ignoring
the message", messageId );
-                return;
-            }
-
-            switch ( response.getMessageType() )
-            {
-                case INTERMEDIATE_RESPONSE:
-                    IntermediateResponseCodec intermediateResponseCodec = ( IntermediateResponseCodec
) response;
-                    intermediateResponseCodec.setMessageId( messageId );
-                    intermediateResponseCodec.addControls( response.getControls() );
-
-                    setIResponse( intermediateResponseCodec, responseFuture );
-
-                    break;
-
                 case MODIFY_RESPONSE:
                     // Transform the response
-                    ModifyResponseCodec modRespCodec = ( ModifyResponseCodec ) response;
-                    modRespCodec.setMessageId( messageId );
-                    modRespCodec.addControls( response.getControls() );
-
-                    ModifyResponse modifyResp = convert( modRespCodec );
+                    ModifyResponse modifyResponse = convert( ( InternalModifyResponse ) response
);
 
                     ModifyFuture modifyFuture = ( ModifyFuture ) responseFuture;
 
@@ -1811,26 +1778,55 @@ public class LdapNetworkConnection exten
 
                     if ( LOG.isDebugEnabled() )
                     {
-                        if ( modifyResp.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS
)
+                        if ( modifyResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS
)
                         {
                             // Everything is fine, return the response
-                            LOG.debug( "ModifyFuture successful : {}", modifyResp );
+                            LOG.debug( "ModifyFuture successful : {}", modifyResponse );
                         }
                         else
                         {
                             // We have had an error
-                            LOG.debug( "ModifyFuture failed : {}", modifyResp );
+                            LOG.debug( "ModifyFuture failed : {}", modifyResponse );
                         }
                     }
 
                     // Store the response into the future
-                    modifyFuture.set( modifyResp );
+                    modifyFuture.set( modifyResponse );
 
                     // Remove the future from the map
                     removeFromFutureMaps( messageId );
 
                     break;
 
+            }
+        }
+        else
+        {
+            LdapMessageCodec response = ( LdapMessageCodec ) message;
+            LOG.debug( "-------> {} Message received <-------", response );
+            int messageId = response.getMessageId();
+
+            // this check is necessary to prevent adding an abandoned operation's
+            // result(s) to corresponding queue
+            ResponseFuture<? extends Response> responseFuture = peekFromFutureMap(
messageId );
+
+            if ( responseFuture == null )
+            {
+                LOG.info( "There is no future associated with the messageId {}, ignoring
the message", messageId );
+                return;
+            }
+
+            switch ( response.getMessageType() )
+            {
+                case INTERMEDIATE_RESPONSE:
+                    IntermediateResponseCodec intermediateResponseCodec = ( IntermediateResponseCodec
) response;
+                    intermediateResponseCodec.setMessageId( messageId );
+                    intermediateResponseCodec.addControls( response.getControls() );
+
+                    setIResponse( intermediateResponseCodec, responseFuture );
+
+                    break;
+
                 case MODIFYDN_RESPONSE:
                     // Transform the response
                     ModifyDNResponseCodec modDnRespCodec = ( ModifyDNResponseCodec ) response;
@@ -2121,21 +2117,6 @@ public class LdapNetworkConnection exten
 
 
     /**
-     * converts the ModifyResponseCodec to ModifyResponse.
-     */
-    private ModifyResponse convert( ModifyResponseCodec modRespCodec )
-    {
-        ModifyResponse modResponse = new ModifyResponse();
-
-        modResponse.setMessageId( modRespCodec.getMessageId() );
-        modResponse.setLdapResult( convert( modRespCodec.getLdapResult() ) );
-        addControls( modRespCodec, modResponse );
-
-        return modResponse;
-    }
-
-
-    /**
      * {@inheritDoc}
      */
     public ModifyDnResponse rename( String entryDn, String newRdn ) throws LdapException
@@ -2897,6 +2878,21 @@ public class LdapNetworkConnection exten
 
 
     /**
+     * converts the InternalModifyResponse to ModifyResponse object.
+     */
+    private ModifyResponse convert( InternalModifyResponse internalModifyResponse )
+    {
+        ModifyResponse response = new ModifyResponse();
+
+        response.setMessageId( internalModifyResponse.getMessageId() );
+        response.setLdapResult( convert( internalModifyResponse.getLdapResult() ) );
+        addControls( internalModifyResponse, response );
+
+        return response;
+    }
+
+
+    /**
      * {@inheritDoc}
      */
     public ExtendedResponse extended( String oid ) throws LdapException

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java?rev=984746&r1=984745&r2=984746&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java
Thu Aug 12 12:44:17 2010
@@ -30,7 +30,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.extended.ExtendedRequestCodec;
 import org.apache.directory.shared.ldap.codec.intermediate.IntermediateResponseCodec;
 import org.apache.directory.shared.ldap.codec.modify.ModifyRequestCodec;
-import org.apache.directory.shared.ldap.codec.modify.ModifyResponseCodec;
 import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNRequestCodec;
 import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNResponseCodec;
 import org.apache.directory.shared.ldap.codec.search.SearchRequestCodec;
@@ -49,6 +48,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalDeleteResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalExtendedResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
+import org.apache.directory.shared.ldap.message.internal.InternalModifyResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalUnbindRequest;
 import org.apache.directory.shared.ldap.message.spi.BinaryAttributeDetector;
 
@@ -310,9 +310,9 @@ public class LdapMessageContainer extend
     /**
      * @return Returns the ModifyResponse stored in the container
      */
-    public ModifyResponseCodec getModifyResponse()
+    public InternalModifyResponse getInternalModifyResponse()
     {
-        return ( ModifyResponseCodec ) ldapMessage;
+        return ( InternalModifyResponse ) internalMessage;
     }
 
 

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java?rev=984746&r1=984745&r2=984746&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
Thu Aug 12 12:44:17 2010
@@ -75,7 +75,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.extended.ExtendedRequestCodec;
 import org.apache.directory.shared.ldap.codec.intermediate.IntermediateResponseCodec;
 import org.apache.directory.shared.ldap.codec.modify.ModifyRequestCodec;
-import org.apache.directory.shared.ldap.codec.modify.ModifyResponseCodec;
 import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNRequestCodec;
 import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNResponseCodec;
 import org.apache.directory.shared.ldap.codec.search.ExtensibleMatchFilter;
@@ -116,6 +115,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalExtendedResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalLdapResult;
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
+import org.apache.directory.shared.ldap.message.internal.InternalModifyResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalReferral;
 import org.apache.directory.shared.ldap.message.internal.InternalResultResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalUnbindRequest;
@@ -1794,9 +1794,8 @@ public class LdapMessageGrammar extends 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
container;
 
                     // Now, we can allocate the ModifyResponse Object
-                    ModifyResponseCodec modifyResponse = new ModifyResponseCodec();
-                    modifyResponse.setMessageId( ldapMessageContainer.getMessageId() );
-                    ldapMessageContainer.setLdapMessage( modifyResponse );
+                    InternalModifyResponse modifyResponse = new ModifyResponseImpl( ldapMessageContainer.getMessageId()
);
+                    ldapMessageContainer.setInternalMessage( modifyResponse );
 
                     log.debug( "Modify response" );
                 }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapProtocolEncoder.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapProtocolEncoder.java?rev=984746&r1=984745&r2=984746&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapProtocolEncoder.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapProtocolEncoder.java
Thu Aug 12 12:44:17 2010
@@ -36,6 +36,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.CompareResponseImpl;
 import org.apache.directory.shared.ldap.message.DeleteResponseImpl;
 import org.apache.directory.shared.ldap.message.ExtendedResponseImpl;
+import org.apache.directory.shared.ldap.message.ModifyResponseImpl;
 import org.apache.directory.shared.ldap.message.control.Control;
 import org.apache.directory.shared.ldap.message.internal.InternalAddResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalBindResponse;
@@ -44,6 +45,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalExtendedResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalLdapResult;
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
+import org.apache.directory.shared.ldap.message.internal.InternalModifyResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalReferral;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.apache.mina.core.buffer.IoBuffer;
@@ -107,7 +109,7 @@ public class LdapProtocolEncoder extends
 
         if ( ( message instanceof InternalBindResponse ) || ( message instanceof InternalDeleteResponse
)
             || ( message instanceof InternalAddResponse ) || ( message instanceof InternalCompareResponse
)
-            || ( message instanceof InternalExtendedResponse ) )
+            || ( message instanceof InternalExtendedResponse ) || ( message instanceof InternalModifyResponse
) )
         {
             try
             {
@@ -526,6 +528,29 @@ public class LdapProtocolEncoder extends
 
 
     /**
+     * Compute the ModifyResponse length 
+     * 
+     * ModifyResponse : 
+     * <pre>
+     * 0x67 L1 
+     *   | 
+     *   +--> LdapResult 
+     *   
+     * L1 = Length(LdapResult) 
+     * Length(ModifyResponse) = Length(0x67) + Length(L1) + L1
+     * </pre>
+     */
+    private int computeModifyResponseLength( ModifyResponseImpl modifyResponse )
+    {
+        int modifyResponseLength = computeLdapResultLength( modifyResponse.getLdapResult()
);
+
+        modifyResponse.setModifyResponseLength( modifyResponseLength );
+
+        return 1 + TLV.getNbBytes( modifyResponseLength ) + modifyResponseLength;
+    }
+
+
+    /**
      * Encode the AddResponse message to a PDU.
      * 
      * @param buffer The buffer where to put the PDU
@@ -699,6 +724,29 @@ public class LdapProtocolEncoder extends
 
 
     /**
+     * Encode the ModifyResponse message to a PDU.
+     * 
+     * @param buffer The buffer where to put the PDU
+     */
+    private void encodeModifyResponse( ByteBuffer buffer, ModifyResponseImpl modifyResponse
) throws EncoderException
+    {
+        try
+        {
+            // The ModifyResponse Tag
+            buffer.put( LdapConstants.MODIFY_RESPONSE_TAG );
+            buffer.put( TLV.getBytes( modifyResponse.getModifyResponseLength() ) );
+
+            // The LdapResult
+            encodeLdapResult( buffer, modifyResponse.getLdapResult() );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException( I18n.err( I18n.ERR_04005 ) );
+        }
+    }
+
+
+    /**
      * Compute the protocolOp length 
      */
     private int computeProtocolOpLength( InternalMessage message )
@@ -720,6 +768,9 @@ public class LdapProtocolEncoder extends
             case EXTENDED_RESPONSE:
                 return computeExtendedResponseLength( ( ExtendedResponseImpl ) message );
 
+            case MODIFY_RESPONSE:
+                return computeModifyResponseLength( ( ModifyResponseImpl ) message );
+
             default:
                 return 0;
         }
@@ -749,6 +800,10 @@ public class LdapProtocolEncoder extends
             case EXTENDED_RESPONSE:
                 encodeExtendedResponse( bb, ( ExtendedResponseImpl ) message );
                 break;
+
+            case MODIFY_RESPONSE:
+                encodeModifyResponse( bb, ( ModifyResponseImpl ) message );
+                break;
         }
     }
 }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java?rev=984746&r1=984745&r2=984746&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java
Thu Aug 12 12:44:17 2010
@@ -33,7 +33,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.extended.ExtendedRequestCodec;
 import org.apache.directory.shared.ldap.codec.intermediate.IntermediateResponseCodec;
 import org.apache.directory.shared.ldap.codec.modify.ModifyRequestCodec;
-import org.apache.directory.shared.ldap.codec.modify.ModifyResponseCodec;
 import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNRequestCodec;
 import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNResponseCodec;
 import org.apache.directory.shared.ldap.codec.search.AndFilter;
@@ -75,7 +74,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.ModifyDnRequestImpl;
 import org.apache.directory.shared.ldap.message.ModifyDnResponseImpl;
 import org.apache.directory.shared.ldap.message.ModifyRequestImpl;
-import org.apache.directory.shared.ldap.message.ModifyResponseImpl;
 import org.apache.directory.shared.ldap.message.ReferralImpl;
 import org.apache.directory.shared.ldap.message.SearchRequestImpl;
 import org.apache.directory.shared.ldap.message.SearchResponseDoneImpl;
@@ -737,25 +735,6 @@ public class LdapTransformer
 
 
     /**
-     * Transform a Internal ModifyResponse to a Codec ModifyResponse
-     * 
-     * @param internalMessage The incoming Internal ModifyResponse
-     * @return The ModifyResponseCodec instance
-     */
-    private static LdapMessageCodec transformModifyResponse( InternalMessage internalMessage
)
-    {
-        ModifyResponseImpl internalModifyResponse = ( ModifyResponseImpl ) internalMessage;
-
-        ModifyResponseCodec modifyResponse = new ModifyResponseCodec();
-
-        // Transform the ldapResult
-        modifyResponse.setLdapResult( transformLdapResult( ( LdapResultImpl ) internalModifyResponse.getLdapResult()
) );
-
-        return modifyResponse;
-    }
-
-
-    /**
      * Transform a Internal ModifyDNResponse to a Codec ModifyDNResponse
      * 
      * @param internalMessage The incoming Internal ModifyDNResponse
@@ -890,10 +869,6 @@ public class LdapTransformer
                 codecMessage = transformBindRequest( msg );
                 break;
 
-            case MODIFY_RESPONSE:
-                codecMessage = transformModifyResponse( msg );
-                break;
-
             case MODIFYDN_RESPONSE:
                 codecMessage = transformModifyDNResponse( msg );
                 break;

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/DeleteResponseImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/DeleteResponseImpl.java?rev=984746&r1=984745&r2=984746&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/DeleteResponseImpl.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/DeleteResponseImpl.java
Thu Aug 12 12:44:17 2010
@@ -31,7 +31,6 @@ import org.apache.directory.shared.ldap.
  */
 public class DeleteResponseImpl extends InternalAbstractResultResponse implements InternalDeleteResponse
 {
-
     /** The encoded deleteResponse length */
     private int deleteResponseLength;
 

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModifyResponseImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModifyResponseImpl.java?rev=984746&r1=984745&r2=984746&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModifyResponseImpl.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModifyResponseImpl.java
Thu Aug 12 12:44:17 2010
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.shared.ldap.message;
 
+
 import org.apache.directory.shared.ldap.message.internal.InternalAbstractResultResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalModifyResponse;
 
@@ -29,6 +30,8 @@ import org.apache.directory.shared.ldap.
  */
 public class ModifyResponseImpl extends InternalAbstractResultResponse implements InternalModifyResponse
 {
+    /** The encoded modifyResponse length */
+    private int modifyResponseLength;
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -43,8 +46,26 @@ public class ModifyResponseImpl extends 
      * @param id
      *            the sequence id for this response
      */
-    public ModifyResponseImpl(final int id)
+    public ModifyResponseImpl( final int id )
     {
         super( id, TYPE );
     }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setModifyResponseLength( int modifyResponseLength )
+    {
+        this.modifyResponseLength = modifyResponseLength;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getModifyResponseLength()
+    {
+        return modifyResponseLength;
+    }
 }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalModifyResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalModifyResponse.java?rev=984746&r1=984745&r2=984746&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalModifyResponse.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalModifyResponse.java
Thu Aug 12 12:44:17 2010
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.shared.ldap.message.internal;
 
+
 import org.apache.directory.shared.ldap.codec.MessageTypeEnum;
 
 
@@ -31,4 +32,17 @@ public interface InternalModifyResponse 
 {
     /** Modify response message type enumeration value */
     MessageTypeEnum TYPE = MessageTypeEnum.MODIFY_RESPONSE;
+
+
+    /**
+     * Stores the encoded length for the ModifyResponse
+     * @param modifyResponseLength The encoded length
+     */
+    void setModifyResponseLength( int modifyResponseLength );
+
+
+    /**
+     * @return The encoded ModifyResponse's length
+     */
+    int getModifyResponseLength();
 }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyResponseTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyResponseTest.java?rev=984746&r1=984745&r2=984746&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyResponseTest.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modify/ModifyResponseTest.java
Thu Aug 12 12:44:17 2010
@@ -25,7 +25,7 @@ import static org.junit.Assert.assertTru
 import static org.junit.Assert.fail;
 
 import java.nio.ByteBuffer;
-import java.util.List;
+import java.util.Map;
 
 import org.apache.directory.junit.tools.Concurrent;
 import org.apache.directory.junit.tools.ConcurrentJunitRunner;
@@ -34,8 +34,10 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.codec.DecoderException;
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
+import org.apache.directory.shared.ldap.codec.LdapProtocolEncoder;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.message.control.Control;
+import org.apache.directory.shared.ldap.message.internal.InternalModifyResponse;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -50,6 +52,10 @@ import org.junit.runner.RunWith;
 @Concurrent()
 public class ModifyResponseTest
 {
+    /** The encoder instance */
+    LdapProtocolEncoder encoder = new LdapProtocolEncoder();
+
+
     /**
      * Test the decoding of a ModifyResponse
      */
@@ -93,20 +99,21 @@ public class ModifyResponseTest
         }
 
         // Check the decoded ModifyResponse PDU
-        ModifyResponseCodec modifyResponse = ( ( LdapMessageContainer ) ldapMessageContainer
).getModifyResponse();
+        InternalModifyResponse modifyResponse = ( ( LdapMessageContainer ) ldapMessageContainer
)
+            .getInternalModifyResponse();
 
         assertEquals( 1, modifyResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, modifyResponse.getLdapResult().getResultCode()
);
-        assertEquals( "", modifyResponse.getLdapResult().getMatchedDN() );
+        assertEquals( "", modifyResponse.getLdapResult().getMatchedDn().getName() );
         assertEquals( "", modifyResponse.getLdapResult().getErrorMessage() );
 
-        // Check the length
-        assertEquals( 0x0E, modifyResponse.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = modifyResponse.encode();
+            ByteBuffer bb = encoder.encodeMessage( modifyResponse );
+
+            // Check the length
+            assertEquals( 0x0E, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -131,19 +138,27 @@ public class ModifyResponseTest
         ByteBuffer stream = ByteBuffer.allocate( 0x2B );
 
         stream.put( new byte[]
-            { 0x30, 0x29, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x67, 0x07, // CHOICE { ..., modifyResponse ModifyResponse, ...
+            { 0x30,
+                0x29, // LDAPMessage ::=SEQUENCE {
+                0x02, 0x01,
+                0x01, // messageID MessageID
+                0x67,
+                0x07, // CHOICE { ..., modifyResponse ModifyResponse, ...
                 // ModifyResponse ::= [APPLICATION 7] LDAPResult
-                0x0A, 0x01, 0x00, // LDAPResult ::= SEQUENCE {
+                0x0A,
+                0x01,
+                0x00, // LDAPResult ::= SEQUENCE {
                 // resultCode ENUMERATED {
                 // success (0), ...
                 // },
-                0x04, 0x00, // matchedDN LDAPDN,
-                0x04, 0x00, // errorMessage LDAPString,
+                0x04,
+                0x00, // matchedDN LDAPDN,
+                0x04,
+                0x00, // errorMessage LDAPString,
                 // referral [3] Referral OPTIONAL }
                 // }
-                ( byte ) 0xA0, 0x1B, // A control
+                ( byte ) 0xA0,
+                0x1B, // A control
                 0x30, 0x19, 0x04, 0x17, 0x32, 0x2E, 0x31, 0x36, 0x2E, 0x38, 0x34, 0x30, 0x2E,
0x31, 0x2E, 0x31, 0x31,
                 0x33, 0x37, 0x33, 0x30, 0x2E, 0x33, 0x2E, 0x34, 0x2E, 0x32 } );
 
@@ -165,29 +180,30 @@ public class ModifyResponseTest
         }
 
         // Check the decoded ModifyResponse PDU
-        ModifyResponseCodec modifyResponse = ( ( LdapMessageContainer ) ldapMessageContainer
).getModifyResponse();
+        InternalModifyResponse modifyResponse = ( ( LdapMessageContainer ) ldapMessageContainer
)
+            .getInternalModifyResponse();
 
         assertEquals( 1, modifyResponse.getMessageId() );
         assertEquals( ResultCodeEnum.SUCCESS, modifyResponse.getLdapResult().getResultCode()
);
-        assertEquals( "", modifyResponse.getLdapResult().getMatchedDN() );
+        assertEquals( "", modifyResponse.getLdapResult().getMatchedDn().getName() );
         assertEquals( "", modifyResponse.getLdapResult().getErrorMessage() );
 
         // Check the Control
-        List<Control> controls = modifyResponse.getControls();
+        Map<String, Control> controls = modifyResponse.getControls();
 
         assertEquals( 1, controls.size() );
 
-        Control control = modifyResponse.getControls( 0 );
+        Control control = controls.get( "2.16.840.1.113730.3.4.2" );
         assertEquals( "2.16.840.1.113730.3.4.2", control.getOid() );
         assertEquals( "", StringTools.dumpBytes( ( byte[] ) control.getValue() ) );
 
-        // Check the length
-        assertEquals( 0x2B, modifyResponse.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = modifyResponse.encode();
+            ByteBuffer bb = encoder.encodeMessage( modifyResponse );
+
+            // Check the length
+            assertEquals( 0x2B, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 



Mime
View raw message