directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r984761 - 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 13:25:05 GMT
Author: elecharny
Date: Thu Aug 12 13:25:05 2010
New Revision: 984761

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

Removed:
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNResponseCodec.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/ModifyDnResponseImpl.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/InternalModifyDnResponse.java
    directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNResponseTest.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=984761&r1=984760&r2=984761&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 13:25:05 2010
@@ -100,7 +100,6 @@ import org.apache.directory.shared.ldap.
 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.modifyDn.ModifyDNRequestCodec;
-import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNResponseCodec;
 import org.apache.directory.shared.ldap.codec.search.Filter;
 import org.apache.directory.shared.ldap.codec.search.SearchRequestCodec;
 import org.apache.directory.shared.ldap.codec.search.SearchResultDoneCodec;
@@ -130,6 +129,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.InternalModifyDnResponse;
 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;
@@ -1798,42 +1798,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 MODIFYDN_RESPONSE:
                     // Transform the response
-                    ModifyDNResponseCodec modDnRespCodec = ( ModifyDNResponseCodec ) response;
-                    modDnRespCodec.setMessageId( messageId );
-                    modDnRespCodec.addControls( response.getControls() );
-
-                    ModifyDnResponse modifyDnResp = convert( modDnRespCodec );
+                    ModifyDnResponse modifyDnResponse = convert( ( InternalModifyDnResponse
) response );
 
                     ModifyDnFuture modifyDnFuture = ( ModifyDnFuture ) responseFuture;
 
@@ -1845,26 +1812,55 @@ public class LdapNetworkConnection exten
 
                     if ( LOG.isDebugEnabled() )
                     {
-                        if ( modifyDnResp.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS
)
+                        if ( modifyDnResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS
)
                         {
                             // Everything is fine, return the response
-                            LOG.debug( "ModifyDN successful : {}", modifyDnResp );
+                            LOG.debug( "ModifyDN successful : {}", modifyDnResponse );
                         }
                         else
                         {
                             // We have had an error
-                            LOG.debug( "ModifyDN failed : {}", modifyDnResp );
+                            LOG.debug( "ModifyDN failed : {}", modifyDnResponse );
                         }
                     }
 
                     // Store the response into the future
-                    modifyDnFuture.set( modifyDnResp );
+                    modifyDnFuture.set( modifyDnResponse );
 
                     // 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 SEARCH_RESULT_DONE:
                     // Store the response into the responseQueue
                     SearchResultDoneCodec searchResultDoneCodec = ( SearchResultDoneCodec
) response;
@@ -2381,21 +2377,6 @@ public class LdapNetworkConnection exten
 
 
     /**
-     * converts the ModifyDnResponseCodec to ModifyResponse.
-     */
-    private ModifyDnResponse convert( ModifyDNResponseCodec modDnRespCodec )
-    {
-        ModifyDnResponse modDnResponse = new ModifyDnResponse();
-
-        modDnResponse.setMessageId( modDnRespCodec.getMessageId() );
-        modDnResponse.setLdapResult( convert( modDnRespCodec.getLdapResult() ) );
-        addControls( modDnRespCodec, modDnResponse );
-
-        return modDnResponse;
-    }
-
-
-    /**
      * {@inheritDoc}
      */
     public DeleteResponse delete( String dn ) throws LdapException
@@ -2893,6 +2874,21 @@ public class LdapNetworkConnection exten
 
 
     /**
+     * converts the InternalModifyDnResponse to ModifyDnResponse object.
+     */
+    private ModifyDnResponse convert( InternalModifyDnResponse internalModifyDnResponse )
+    {
+        ModifyDnResponse response = new ModifyDnResponse();
+
+        response.setMessageId( internalModifyDnResponse.getMessageId() );
+        response.setLdapResult( convert( internalModifyDnResponse.getLdapResult() ) );
+        addControls( internalModifyDnResponse, 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=984761&r1=984760&r2=984761&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 13:25:05 2010
@@ -31,7 +31,6 @@ import org.apache.directory.shared.ldap.
 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.modifyDn.ModifyDNRequestCodec;
-import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNResponseCodec;
 import org.apache.directory.shared.ldap.codec.search.SearchRequestCodec;
 import org.apache.directory.shared.ldap.codec.search.SearchResultDoneCodec;
 import org.apache.directory.shared.ldap.codec.search.SearchResultEntryCodec;
@@ -48,6 +47,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.InternalModifyDnResponse;
 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;
@@ -328,9 +328,9 @@ public class LdapMessageContainer extend
     /**
      * @return Returns the ModifyDnResponse stored in the container
      */
-    public ModifyDNResponseCodec getModifyDnResponse()
+    public InternalModifyDnResponse getInternalModifyDnResponse()
     {
-        return ( ModifyDNResponseCodec ) ldapMessage;
+        return ( InternalModifyDnResponse ) 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=984761&r1=984760&r2=984761&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 13:25:05 2010
@@ -76,7 +76,6 @@ import org.apache.directory.shared.ldap.
 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.modifyDn.ModifyDNRequestCodec;
-import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNResponseCodec;
 import org.apache.directory.shared.ldap.codec.search.ExtensibleMatchFilter;
 import org.apache.directory.shared.ldap.codec.search.SearchRequestCodec;
 import org.apache.directory.shared.ldap.codec.search.SearchResultDoneCodec;
@@ -115,6 +114,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.InternalModifyDnResponse;
 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;
@@ -2456,9 +2456,9 @@ public class LdapMessageGrammar extends 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
container;
 
                     // Now, we can allocate the ModifyDnResponse Object
-                    ModifyDNResponseCodec modifyDnResponse = new ModifyDNResponseCodec();
-                    modifyDnResponse.setMessageId( ldapMessageContainer.getMessageId() );
-                    ldapMessageContainer.setLdapMessage( modifyDnResponse );
+                    InternalModifyDnResponse modifyDnResponse = new ModifyDnResponseImpl(
ldapMessageContainer
+                        .getMessageId() );
+                    ldapMessageContainer.setInternalMessage( modifyDnResponse );
 
                     log.debug( "Modify DN 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=984761&r1=984760&r2=984761&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 13:25:05 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.ModifyDnResponseImpl;
 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;
@@ -45,6 +46,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.InternalModifyDnResponse;
 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;
@@ -109,7 +111,8 @@ public class LdapProtocolEncoder extends
 
         if ( ( message instanceof InternalBindResponse ) || ( message instanceof InternalDeleteResponse
)
             || ( message instanceof InternalAddResponse ) || ( message instanceof InternalCompareResponse
)
-            || ( message instanceof InternalExtendedResponse ) || ( message instanceof InternalModifyResponse
) )
+            || ( message instanceof InternalExtendedResponse ) || ( message instanceof InternalModifyResponse
)
+            || ( message instanceof InternalModifyDnResponse ) )
         {
             try
             {
@@ -551,6 +554,29 @@ public class LdapProtocolEncoder extends
 
 
     /**
+     * Compute the ModifyDNResponse length 
+     * 
+     * ModifyDNResponse : 
+     * <pre>
+     * 0x6D L1 
+     *   | 
+     *   +--> LdapResult 
+     *   
+     * L1 = Length(LdapResult) 
+     * Length(ModifyDNResponse) = Length(0x6D) + Length(L1) + L1
+     * </pre>
+     */
+    private int computeModifyDnResponseLength( ModifyDnResponseImpl modifyDnResponse )
+    {
+        int modifyDnResponseLength = computeLdapResultLength( modifyDnResponse.getLdapResult()
);
+
+        modifyDnResponse.setModifyDnResponseLength( modifyDnResponseLength );
+
+        return 1 + TLV.getNbBytes( modifyDnResponseLength ) + modifyDnResponseLength;
+    }
+
+
+    /**
      * Encode the AddResponse message to a PDU.
      * 
      * @param buffer The buffer where to put the PDU
@@ -747,6 +773,30 @@ public class LdapProtocolEncoder extends
 
 
     /**
+     * Encode the ModifyDnResponse message to a PDU.
+     * 
+     * @param buffer The buffer where to put the PDU
+     */
+    private void encodeModifyDnResponse( ByteBuffer buffer, ModifyDnResponseImpl modifyDnResponse
)
+        throws EncoderException
+    {
+        try
+        {
+            // The ModifyResponse Tag
+            buffer.put( LdapConstants.MODIFY_DN_RESPONSE_TAG );
+            buffer.put( TLV.getBytes( modifyDnResponse.getModifyDnResponseLength() ) );
+
+            // The LdapResult
+            encodeLdapResult( buffer, modifyDnResponse.getLdapResult() );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException( I18n.err( I18n.ERR_04005 ) );
+        }
+    }
+
+
+    /**
      * Compute the protocolOp length 
      */
     private int computeProtocolOpLength( InternalMessage message )
@@ -771,6 +821,9 @@ public class LdapProtocolEncoder extends
             case MODIFY_RESPONSE:
                 return computeModifyResponseLength( ( ModifyResponseImpl ) message );
 
+            case MODIFYDN_RESPONSE:
+                return computeModifyDnResponseLength( ( ModifyDnResponseImpl ) message );
+
             default:
                 return 0;
         }
@@ -804,6 +857,10 @@ public class LdapProtocolEncoder extends
             case MODIFY_RESPONSE:
                 encodeModifyResponse( bb, ( ModifyResponseImpl ) message );
                 break;
+
+            case MODIFYDN_RESPONSE:
+                encodeModifyDnResponse( bb, ( ModifyDnResponseImpl ) 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=984761&r1=984760&r2=984761&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 13:25:05 2010
@@ -34,7 +34,6 @@ import org.apache.directory.shared.ldap.
 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.modifyDn.ModifyDNRequestCodec;
-import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNResponseCodec;
 import org.apache.directory.shared.ldap.codec.search.AndFilter;
 import org.apache.directory.shared.ldap.codec.search.AttributeValueAssertionFilter;
 import org.apache.directory.shared.ldap.codec.search.ConnectorFilter;
@@ -72,7 +71,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.IntermediateResponseImpl;
 import org.apache.directory.shared.ldap.message.LdapResultImpl;
 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.ReferralImpl;
 import org.apache.directory.shared.ldap.message.SearchRequestImpl;
@@ -735,26 +733,6 @@ public class LdapTransformer
 
 
     /**
-     * Transform a Internal ModifyDNResponse to a Codec ModifyDNResponse
-     * 
-     * @param internalMessage The incoming Internal ModifyDNResponse
-     * @return The ModifyDnResponseCodec instance
-     */
-    private static LdapMessageCodec transformModifyDNResponse( InternalMessage internalMessage
)
-    {
-        ModifyDnResponseImpl internalModifyDNResponse = ( ModifyDnResponseImpl ) internalMessage;
-
-        ModifyDNResponseCodec modifyDNResponse = new ModifyDNResponseCodec();
-
-        // Transform the ldapResult
-        modifyDNResponse.setLdapResult( transformLdapResult( ( LdapResultImpl ) internalModifyDNResponse
-            .getLdapResult() ) );
-
-        return modifyDNResponse;
-    }
-
-
-    /**
      * Transform a Internal SearchResponseDone to a Codec SearchResultDone
      * 
      * @param internalMessage The incoming Internal SearchResponseDone
@@ -869,10 +847,6 @@ public class LdapTransformer
                 codecMessage = transformBindRequest( msg );
                 break;
 
-            case MODIFYDN_RESPONSE:
-                codecMessage = transformModifyDNResponse( msg );
-                break;
-
             case INTERMEDIATE_RESPONSE:
                 codecMessage = transformIntermediateResponse( msg );
                 break;

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModifyDnResponseImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModifyDnResponseImpl.java?rev=984761&r1=984760&r2=984761&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModifyDnResponseImpl.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModifyDnResponseImpl.java
Thu Aug 12 13:25:05 2010
@@ -19,17 +19,20 @@
  */
 package org.apache.directory.shared.ldap.message;
 
+
 import org.apache.directory.shared.ldap.message.internal.InternalAbstractResultResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalModifyDnResponse;
 
 
 /**
- * Lockable ModifyDnResponse implementation
+ * ModifyDnResponse implementation
  * 
  * @author <a href="mailto:dev@directory.apache.org"> Apache Directory Project</a>
  */
 public class ModifyDnResponseImpl extends InternalAbstractResultResponse implements InternalModifyDnResponse
 {
+    /** The encoded modifyDnResponse length */
+    private int modifyDnResponseLength;
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -39,13 +42,31 @@ public class ModifyDnResponseImpl extend
 
 
     /**
-     * Creates a Lockable ModifyDnResponse as a reply to an ModifyDnRequest.
+     * Creates a ModifyDnResponse as a reply to an ModifyDnRequest.
      * 
-     * @param id
-     *            the sequence if of this response
+     * @param id the sequence if of this response
      */
-    public ModifyDnResponseImpl(final int id)
+    public ModifyDnResponseImpl( final int id )
     {
         super( id, TYPE );
     }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setModifyDnResponseLength( int modifyDnResponseLength )
+    {
+        this.modifyDnResponseLength = modifyDnResponseLength;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getModifyDnResponseLength()
+    {
+        return modifyDnResponseLength;
+    }
+
 }

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=984761&r1=984760&r2=984761&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 13:25:05 2010
@@ -25,7 +25,7 @@ import org.apache.directory.shared.ldap.
 
 
 /**
- * Lockable ModifyResponse implementation
+ * ModifyResponse implementation
  * 
  */
 public class ModifyResponseImpl extends InternalAbstractResultResponse implements InternalModifyResponse
@@ -41,10 +41,9 @@ public class ModifyResponseImpl extends 
 
 
     /**
-     * Creates a Lockable ModifyResponse as a reply to an ModifyRequest.
+     * Creates a ModifyResponse as a reply to an ModifyRequest.
      * 
-     * @param id
-     *            the sequence id for this response
+     * @param id the sequence id for this response
      */
     public ModifyResponseImpl( final int id )
     {

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalModifyDnResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalModifyDnResponse.java?rev=984761&r1=984760&r2=984761&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalModifyDnResponse.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalModifyDnResponse.java
Thu Aug 12 13:25:05 2010
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.shared.ldap.message.internal;
 
+
 import org.apache.directory.shared.ldap.codec.MessageTypeEnum;
 
 
@@ -32,4 +33,17 @@ public interface InternalModifyDnRespons
 {
     /** Modify DN response message type enumeration value */
     MessageTypeEnum TYPE = MessageTypeEnum.MODIFYDN_RESPONSE;
+
+
+    /**
+     * Stores the encoded length for the ModifyDnResponse
+     * @param modifyDnResponseLength The encoded length
+     */
+    void setModifyDnResponseLength( int modifyDnResponseLength );
+
+
+    /**
+     * @return The encoded ModifyDnResponse's length
+     */
+    int getModifyDnResponseLength();
 }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNResponseTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNResponseTest.java?rev=984761&r1=984760&r2=984761&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNResponseTest.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNResponseTest.java
Thu Aug 12 13:25:05 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.InternalModifyDnResponse;
 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 ModifyDNResponseTest
 {
+    /** The encoder instance */
+    LdapProtocolEncoder encoder = new LdapProtocolEncoder();
+
+
     /**
      * Test the decoding of a ModifyDNResponse
      */
@@ -64,7 +70,7 @@ public class ModifyDNResponseTest
             { 0x30, 0x0C, // LDAPMessage ::=SEQUENCE {
                 0x02, 0x01, 0x01, // messageID MessageID
                 0x6D, 0x07, // CHOICE { ..., modifyDNResponse ModifyDNResponse,
-                            // ...
+                // ...
                 // ModifyDNResponse ::= [APPLICATION 13] LDAPResult
                 0x0A, 0x01, 0x00, // LDAPResult ::= SEQUENCE {
                 // resultCode ENUMERATED {
@@ -94,20 +100,21 @@ public class ModifyDNResponseTest
         }
 
         // Check the decoded ModifyDNResponse PDU
-        ModifyDNResponseCodec modifyDNResponse = ( ( LdapMessageContainer ) ldapMessageContainer
).getModifyDnResponse();
-
-        assertEquals( 1, modifyDNResponse.getMessageId() );
-        assertEquals( ResultCodeEnum.SUCCESS, modifyDNResponse.getLdapResult().getResultCode()
);
-        assertEquals( "", modifyDNResponse.getLdapResult().getMatchedDN() );
-        assertEquals( "", modifyDNResponse.getLdapResult().getErrorMessage() );
+        InternalModifyDnResponse modifyDnResponse = ( ( LdapMessageContainer ) ldapMessageContainer
)
+            .getInternalModifyDnResponse();
 
-        // Check the length
-        assertEquals( 0x0E, modifyDNResponse.computeLength() );
+        assertEquals( 1, modifyDnResponse.getMessageId() );
+        assertEquals( ResultCodeEnum.SUCCESS, modifyDnResponse.getLdapResult().getResultCode()
);
+        assertEquals( "", modifyDnResponse.getLdapResult().getMatchedDn().getName() );
+        assertEquals( "", modifyDnResponse.getLdapResult().getErrorMessage() );
 
         // Check the encoding
         try
         {
-            ByteBuffer bb = modifyDNResponse.encode();
+            ByteBuffer bb = encoder.encodeMessage( modifyDnResponse );
+
+            // Check the length
+            assertEquals( 0x0E, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -132,20 +139,29 @@ public class ModifyDNResponseTest
         ByteBuffer stream = ByteBuffer.allocate( 0x2B );
 
         stream.put( new byte[]
-            { 0x30, 0x29, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x6D, 0x07, // CHOICE { ..., modifyDNResponse ModifyDNResponse,
-                            // ...
+            { 0x30,
+                0x29, // LDAPMessage ::=SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x6D,
+                0x07, // CHOICE { ..., modifyDNResponse ModifyDNResponse,
+                // ...
                 // ModifyDNResponse ::= [APPLICATION 13] 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 } );
 
@@ -167,29 +183,30 @@ public class ModifyDNResponseTest
         }
 
         // Check the decoded ModifyDNResponse PDU
-        ModifyDNResponseCodec modifyDNResponse = ( ( LdapMessageContainer ) ldapMessageContainer
).getModifyDnResponse();
+        InternalModifyDnResponse modifyDnResponse = ( ( LdapMessageContainer ) ldapMessageContainer
)
+            .getInternalModifyDnResponse();
 
-        assertEquals( 1, modifyDNResponse.getMessageId() );
-        assertEquals( ResultCodeEnum.SUCCESS, modifyDNResponse.getLdapResult().getResultCode()
);
-        assertEquals( "", modifyDNResponse.getLdapResult().getMatchedDN() );
-        assertEquals( "", modifyDNResponse.getLdapResult().getErrorMessage() );
+        assertEquals( 1, modifyDnResponse.getMessageId() );
+        assertEquals( ResultCodeEnum.SUCCESS, modifyDnResponse.getLdapResult().getResultCode()
);
+        assertEquals( "", modifyDnResponse.getLdapResult().getMatchedDn().getName() );
+        assertEquals( "", modifyDnResponse.getLdapResult().getErrorMessage() );
 
         // Check the Control
-        List<Control> controls = modifyDNResponse.getControls();
+        Map<String, Control> controls = modifyDnResponse.getControls();
 
         assertEquals( 1, controls.size() );
 
-        Control control = modifyDNResponse.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, modifyDNResponse.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = modifyDNResponse.encode();
+            ByteBuffer bb = encoder.encodeMessage( modifyDnResponse );
+
+            // Check the length
+            assertEquals( 0x2B, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -217,7 +234,7 @@ public class ModifyDNResponseTest
             { 0x30, 0x05, // LDAPMessage ::=SEQUENCE {
                 0x02, 0x01, 0x01, // messageID MessageID
                 0x6D, 0x00 // CHOICE { ..., modifyDNResponse ModifyDNResponse,
-                            // ...
+            // ...
             } );
 
         stream.flip();



Mime
View raw message