directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r985975 - in /directory: apacheds/branches/apacheds-codec-merge/core-api/src/main/java/org/apache/directory/server/core/ apacheds/branches/apacheds-codec-merge/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations...
Date Mon, 16 Aug 2010 14:50:37 GMT
Author: elecharny
Date: Mon Aug 16 14:50:36 2010
New Revision: 985975

URL: http://svn.apache.org/viewvc?rev=985975&view=rev
Log:
Merged the ModifyDnRequest classes

Removed:
    directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ModifyDnRequest.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/modifyDn/
Modified:
    directory/apacheds/branches/apacheds-codec-merge/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java
    directory/apacheds/branches/apacheds-codec-merge/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java
    directory/apacheds/branches/apacheds-codec-merge/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java
    directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapAsyncConnection.java
    directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
    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/LdapTransformer.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/LdapProtocolEncoder.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModifyDnRequestImpl.java
    directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestTest.java

Modified: directory/apacheds/branches/apacheds-codec-merge/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-codec-merge/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java?rev=985975&r1=985974&r2=985975&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-codec-merge/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java (original)
+++ directory/apacheds/branches/apacheds-codec-merge/core-api/src/main/java/org/apache/directory/server/core/LdapCoreSessionConnection.java Mon Aug 16 14:50:36 2010
@@ -28,7 +28,6 @@ import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.directory.ldap.client.api.LdapConnection;
-import org.apache.directory.ldap.client.api.message.ModifyDnRequest;
 import org.apache.directory.ldap.client.api.message.ModifyRequest;
 import org.apache.directory.ldap.client.api.message.SearchRequest;
 import org.apache.directory.server.core.filtering.EntryFilteringCursor;
@@ -602,23 +601,16 @@ public class LdapCoreSessionConnection i
      *          cause this we call {@link CoreSession#move(InternalModifyDnRequest)} always from this method.
      *          Instead use other specific modifyDn operations like {@link #move(DN, DN)}, {@link #rename(DN, RDN)} etc..
      */
-    public ModifyDnResponse modifyDn( ModifyDnRequest modDnRequest ) throws LdapException
+    public ModifyDnResponse modifyDn( InternalModifyDnRequest modDnRequest ) throws LdapException
     {
         int newId = messageId.incrementAndGet();
 
         ModifyDnResponse resp = new ModifyDnResponseImpl( newId );
         resp.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
 
-        InternalModifyDnRequest iModDnReq = new ModifyDnRequestImpl( newId );
-
         try
         {
-            iModDnReq.setDeleteOldRdn( modDnRequest.isDeleteOldRdn() );
-            iModDnReq.setName( modDnRequest.getEntryDn() );
-            iModDnReq.setNewRdn( modDnRequest.getNewRdn() );
-            iModDnReq.setNewSuperior( modDnRequest.getNewSuperior() );
-
-            session.move( iModDnReq );
+            session.move( modDnRequest );
         }
         catch ( LdapException e )
         {
@@ -628,7 +620,7 @@ public class LdapCoreSessionConnection i
             resp.getLdapResult().setErrorMessage( e.getMessage() );
         }
 
-        addResponseControls( iModDnReq, resp );
+        addResponseControls( modDnRequest, resp );
         return resp;
     }
 

Modified: directory/apacheds/branches/apacheds-codec-merge/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-codec-merge/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java?rev=985975&r1=985974&r2=985975&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-codec-merge/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java (original)
+++ directory/apacheds/branches/apacheds-codec-merge/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientModifyDnRequestTest.java Mon Aug 16 14:50:36 2010
@@ -32,7 +32,6 @@ import java.util.concurrent.TimeoutExcep
 import org.apache.directory.ldap.client.api.LdapAsyncConnection;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
 import org.apache.directory.ldap.client.api.future.ModifyDnFuture;
-import org.apache.directory.ldap.client.api.message.ModifyDnRequest;
 import org.apache.directory.server.annotations.CreateLdapServer;
 import org.apache.directory.server.annotations.CreateTransport;
 import org.apache.directory.server.core.CoreSession;
@@ -40,6 +39,8 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.message.ModifyDnRequestImpl;
+import org.apache.directory.shared.ldap.message.internal.InternalModifyDnRequest;
 import org.apache.directory.shared.ldap.message.internal.ModifyDnResponse;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.name.RDN;
@@ -146,8 +147,8 @@ public class ClientModifyDnRequestTest e
         DN oldDn = new DN( dn );
         DN newDn = new DN( "cn=modifyDnWithString,ou=system" );
 
-        ModifyDnRequest modDnReq = new ModifyDnRequest();
-        modDnReq.setEntryDn( oldDn );
+        InternalModifyDnRequest modDnReq = new ModifyDnRequestImpl();
+        modDnReq.setName( oldDn );
         modDnReq.setNewRdn( new RDN( "cn=modifyDnWithString" ) );
         modDnReq.setDeleteOldRdn( true );
 

Modified: directory/apacheds/branches/apacheds-codec-merge/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-codec-merge/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java?rev=985975&r1=985974&r2=985975&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-codec-merge/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java (original)
+++ directory/apacheds/branches/apacheds-codec-merge/server-tools/src/main/java/org/apache/directory/server/tools/ImportCommand.java Mon Aug 16 14:50:36 2010
@@ -43,7 +43,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.LdapResponseCodec;
 import org.apache.directory.shared.ldap.codec.LdapResultCodec;
 import org.apache.directory.shared.ldap.codec.modify.ModifyRequestCodec;
-import org.apache.directory.shared.ldap.codec.modifyDn.ModifyDNRequestCodec;
 import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Modification;
@@ -57,6 +56,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.BindRequestImpl;
 import org.apache.directory.shared.ldap.message.DeleteRequestImpl;
 import org.apache.directory.shared.ldap.message.LdapProtocolEncoder;
+import org.apache.directory.shared.ldap.message.ModifyDnRequestImpl;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.message.UnbindRequestImpl;
 import org.apache.directory.shared.ldap.message.internal.BindResponse;
@@ -65,6 +65,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalBindRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalDeleteRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
+import org.apache.directory.shared.ldap.message.internal.InternalModifyDnRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalUnbindRequest;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.name.RDN;
@@ -348,7 +349,7 @@ public class ImportCommand extends ToolC
     private int changeModRDNEntry( LdifEntry entry, int messageId ) throws IOException, DecoderException,
         LdapInvalidDnException, EncoderException
     {
-        ModifyDNRequestCodec modifyDNRequest = new ModifyDNRequestCodec();
+        InternalModifyDnRequest modifyDNRequest = new ModifyDnRequestImpl();
 
         String dn = entry.getDn().getName();
 
@@ -357,9 +358,9 @@ public class ImportCommand extends ToolC
             System.out.println( "Modify DN of entry " + dn );
         }
 
-        modifyDNRequest.setEntry( new DN( dn ) );
-        modifyDNRequest.setDeleteOldRDN( entry.isDeleteOldRdn() );
-        modifyDNRequest.setNewRDN( new RDN( entry.getNewRdn() ) );
+        modifyDNRequest.setName( new DN( dn ) );
+        modifyDNRequest.setDeleteOldRdn( entry.isDeleteOldRdn() );
+        modifyDNRequest.setNewRdn( new RDN( entry.getNewRdn() ) );
 
         if ( StringTools.isEmpty( entry.getNewSuperior() ) == false )
         {
@@ -369,7 +370,9 @@ public class ImportCommand extends ToolC
         modifyDNRequest.setMessageId( messageId );
 
         // Encode and send the delete request
-        ByteBuffer bb = modifyDNRequest.encode();
+        LdapProtocolEncoder encoder = new LdapProtocolEncoder();
+
+        ByteBuffer bb = encoder.encodeMessage( modifyDNRequest );
         bb.flip();
 
         sendMessage( bb );

Modified: directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapAsyncConnection.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/LdapAsyncConnection.java?rev=985975&r1=985974&r2=985975&view=diff
==============================================================================
--- directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapAsyncConnection.java (original)
+++ directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapAsyncConnection.java Mon Aug 16 14:50:36 2010
@@ -11,7 +11,6 @@ import org.apache.directory.ldap.client.
 import org.apache.directory.ldap.client.api.future.ModifyDnFuture;
 import org.apache.directory.ldap.client.api.future.ModifyFuture;
 import org.apache.directory.ldap.client.api.future.SearchFuture;
-import org.apache.directory.ldap.client.api.message.ModifyDnRequest;
 import org.apache.directory.ldap.client.api.message.ModifyRequest;
 import org.apache.directory.ldap.client.api.message.SearchRequest;
 import org.apache.directory.shared.ldap.entry.Entry;
@@ -22,6 +21,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalCompareRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalDeleteRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalExtendedRequest;
+import org.apache.directory.shared.ldap.message.internal.InternalModifyDnRequest;
 import org.apache.directory.shared.ldap.name.DN;
 
 
@@ -145,7 +145,7 @@ public interface LdapAsyncConnection ext
      * @return modifyDn operations response, null if non-null listener is provided
      * @throws LdapException
      */
-    ModifyDnFuture modifyDnAsync( ModifyDnRequest modDnRequest ) throws LdapException;
+    ModifyDnFuture modifyDnAsync( InternalModifyDnRequest modDnRequest ) throws LdapException;
 
 
     /**

Modified: directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.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/LdapConnection.java?rev=985975&r1=985974&r2=985975&view=diff
==============================================================================
--- directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java (original)
+++ directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java Mon Aug 16 14:50:36 2010
@@ -4,7 +4,6 @@ package org.apache.directory.ldap.client
 import java.io.IOException;
 import java.util.List;
 
-import org.apache.directory.ldap.client.api.message.ModifyDnRequest;
 import org.apache.directory.ldap.client.api.message.ModifyRequest;
 import org.apache.directory.ldap.client.api.message.SearchRequest;
 import org.apache.directory.shared.asn1.primitives.OID;
@@ -26,6 +25,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalCompareRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalDeleteRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalExtendedRequest;
+import org.apache.directory.shared.ldap.message.internal.InternalModifyDnRequest;
 import org.apache.directory.shared.ldap.message.internal.ModifyDnResponse;
 import org.apache.directory.shared.ldap.message.internal.ModifyResponse;
 import org.apache.directory.shared.ldap.message.internal.Response;
@@ -370,7 +370,7 @@ public interface LdapConnection
      * @return modifyDn operations response, null if non-null listener is provided
      * @throws LdapException
      */
-    public abstract ModifyDnResponse modifyDn( ModifyDnRequest modDnRequest ) throws LdapException;
+    public abstract ModifyDnResponse modifyDn( InternalModifyDnRequest modDnRequest ) throws LdapException;
 
 
     /**

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=985975&r1=985974&r2=985975&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 Mon Aug 16 14:50:36 2010
@@ -51,7 +51,6 @@ import org.apache.directory.ldap.client.
 import org.apache.directory.ldap.client.api.future.ResponseFuture;
 import org.apache.directory.ldap.client.api.future.SearchFuture;
 import org.apache.directory.ldap.client.api.listener.DeleteListener;
-import org.apache.directory.ldap.client.api.message.ModifyDnRequest;
 import org.apache.directory.ldap.client.api.message.ModifyRequest;
 import org.apache.directory.ldap.client.api.message.SearchRequest;
 import org.apache.directory.ldap.client.api.protocol.LdapProtocolCodecFactory;
@@ -64,7 +63,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.MessageEncoderException;
 import org.apache.directory.shared.ldap.codec.controls.ControlImpl;
 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.search.Filter;
 import org.apache.directory.shared.ldap.codec.search.SearchRequestCodec;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
@@ -88,6 +86,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.DeleteRequestImpl;
 import org.apache.directory.shared.ldap.message.ExtendedRequestImpl;
 import org.apache.directory.shared.ldap.message.IntermediateResponseImpl;
+import org.apache.directory.shared.ldap.message.ModifyDnRequestImpl;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.message.UnbindRequestImpl;
 import org.apache.directory.shared.ldap.message.control.Control;
@@ -104,6 +103,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalDeleteRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalExtendedRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
+import org.apache.directory.shared.ldap.message.internal.InternalModifyDnRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalUnbindRequest;
 import org.apache.directory.shared.ldap.message.internal.ModifyDnResponse;
 import org.apache.directory.shared.ldap.message.internal.ModifyResponse;
@@ -1945,8 +1945,8 @@ public class LdapNetworkConnection exten
      */
     public ModifyDnResponse rename( DN entryDn, RDN newRdn, boolean deleteOldRdn ) throws LdapException
     {
-        ModifyDnRequest modDnRequest = new ModifyDnRequest();
-        modDnRequest.setEntryDn( entryDn );
+        InternalModifyDnRequest modDnRequest = new ModifyDnRequestImpl();
+        modDnRequest.setName( entryDn );
         modDnRequest.setNewRdn( newRdn );
         modDnRequest.setDeleteOldRdn( deleteOldRdn );
 
@@ -1976,8 +1976,8 @@ public class LdapNetworkConnection exten
      */
     public ModifyDnResponse move( DN entryDn, DN newSuperiorDn ) throws LdapException
     {
-        ModifyDnRequest modDnRequest = new ModifyDnRequest();
-        modDnRequest.setEntryDn( entryDn );
+        InternalModifyDnRequest modDnRequest = new ModifyDnRequestImpl();
+        modDnRequest.setName( entryDn );
         modDnRequest.setNewSuperior( newSuperiorDn );
 
         //TODO not setting the below value is resulting in error
@@ -2040,8 +2040,8 @@ public class LdapNetworkConnection exten
         }
 
         // Create the request
-        ModifyDnRequest modDnRequest = new ModifyDnRequest();
-        modDnRequest.setEntryDn( entryDn );
+        InternalModifyDnRequest modDnRequest = new ModifyDnRequestImpl();
+        modDnRequest.setName( entryDn );
         modDnRequest.setNewRdn( newDn.getRdn() );
         modDnRequest.setNewSuperior( newDn.getParent() );
         modDnRequest.setDeleteOldRdn( deleteOldRdn );
@@ -2066,7 +2066,7 @@ public class LdapNetworkConnection exten
     /**
      * {@inheritDoc}
      */
-    public ModifyDnResponse modifyDn( ModifyDnRequest modDnRequest ) throws LdapException
+    public ModifyDnResponse modifyDn( InternalModifyDnRequest modDnRequest ) throws LdapException
     {
         ModifyDnFuture modifyDnFuture = modifyDnAsync( modDnRequest );
 
@@ -2074,10 +2074,8 @@ public class LdapNetworkConnection exten
         try
         {
             // Read the response, waiting for it if not available immediately
-            long timeout = getTimeout( modDnRequest.getTimeout() );
-
             // Get the response, blocking
-            ModifyDnResponse modifyDnResponse = modifyDnFuture.get( timeout, TimeUnit.MILLISECONDS );
+            ModifyDnResponse modifyDnResponse = modifyDnFuture.get( timeOut, TimeUnit.MILLISECONDS );
 
             if ( modifyDnResponse == null )
             {
@@ -2132,28 +2130,18 @@ public class LdapNetworkConnection exten
     /**
      * {@inheritDoc}
      */
-    public ModifyDnFuture modifyDnAsync( ModifyDnRequest modDnRequest ) throws LdapException
+    public ModifyDnFuture modifyDnAsync( InternalModifyDnRequest modDnRequest ) throws LdapException
     {
         checkSession();
 
-        ModifyDNRequestCodec modDnCodec = new ModifyDNRequestCodec();
-
         int newId = messageId.incrementAndGet();
         modDnRequest.setMessageId( newId );
-        modDnCodec.setMessageId( newId );
-
-        modDnCodec.setEntry( modDnRequest.getEntryDn() );
-        modDnCodec.setNewRDN( modDnRequest.getNewRdn() );
-        modDnCodec.setDeleteOldRDN( modDnRequest.isDeleteOldRdn() );
-        modDnCodec.setNewSuperior( modDnRequest.getNewSuperior() );
-
-        setControls( modDnRequest.getControls(), modDnCodec );
 
         ModifyDnFuture modifyDnFuture = new ModifyDnFuture( this, newId );
         addToFutureMap( newId, modifyDnFuture );
 
         // Send the request to the server
-        WriteFuture writeFuture = ldapSession.write( modDnCodec );
+        WriteFuture writeFuture = ldapSession.write( modDnRequest );
 
         // Wait for the message to be sent to the server
         if ( !writeFuture.awaitUninterruptibly( getTimeout( 0 ) ) )

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=985975&r1=985974&r2=985975&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 Mon Aug 16 14:50:36 2010
@@ -23,7 +23,6 @@ package org.apache.directory.shared.ldap
 import org.apache.directory.shared.asn1.ber.AbstractContainer;
 import org.apache.directory.shared.ldap.codec.controls.AbstractControl;
 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.search.SearchRequestCodec;
 import org.apache.directory.shared.ldap.message.internal.AddResponse;
 import org.apache.directory.shared.ldap.message.internal.BindResponse;
@@ -38,6 +37,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalDeleteRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalExtendedRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
+import org.apache.directory.shared.ldap.message.internal.InternalModifyDnRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalUnbindRequest;
 import org.apache.directory.shared.ldap.message.internal.ModifyDnResponse;
 import org.apache.directory.shared.ldap.message.internal.ModifyResponse;
@@ -268,9 +268,9 @@ public class LdapMessageContainer extend
     /**
      * @return Returns the ModifyDnRequest stored in the container
      */
-    public ModifyDNRequestCodec getModifyDnRequest()
+    public InternalModifyDnRequest getModifyDnRequest()
     {
-        return ( ModifyDNRequestCodec ) ldapMessage;
+        return ( InternalModifyDnRequest ) 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=985975&r1=985974&r2=985975&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 Mon Aug 16 14:50:36 2010
@@ -73,7 +73,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.controls.ControlEnum;
 import org.apache.directory.shared.ldap.codec.controls.ControlImpl;
 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.search.ExtensibleMatchFilter;
 import org.apache.directory.shared.ldap.codec.search.SearchRequestCodec;
 import org.apache.directory.shared.ldap.codec.search.SubstringFilter;
@@ -92,6 +91,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.ExtendedRequestImpl;
 import org.apache.directory.shared.ldap.message.ExtendedResponseImpl;
 import org.apache.directory.shared.ldap.message.IntermediateResponseImpl;
+import org.apache.directory.shared.ldap.message.ModifyDnRequestImpl;
 import org.apache.directory.shared.ldap.message.ModifyDnResponseImpl;
 import org.apache.directory.shared.ldap.message.ModifyResponseImpl;
 import org.apache.directory.shared.ldap.message.ReferralImpl;
@@ -114,6 +114,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalDeleteRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalExtendedRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
+import org.apache.directory.shared.ldap.message.internal.InternalModifyDnRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalReferral;
 import org.apache.directory.shared.ldap.message.internal.InternalUnbindRequest;
 import org.apache.directory.shared.ldap.message.internal.LdapResult;
@@ -2163,9 +2164,9 @@ public class LdapMessageGrammar extends 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
 
                     // Now, we can allocate the ModifyDNRequest Object
-                    ModifyDNRequestCodec modifyDNRequest = new ModifyDNRequestCodec();
-                    modifyDNRequest.setMessageId( ldapMessageContainer.getMessageId() );
-                    ldapMessageContainer.setLdapMessage( modifyDNRequest );
+                    InternalModifyDnRequest modifyDnRequest = new ModifyDnRequestImpl( ldapMessageContainer
+                        .getMessageId() );
+                    ldapMessageContainer.setInternalMessage( modifyDnRequest );
 
                     log.debug( "ModifyDn request" );
                 }
@@ -2187,7 +2188,7 @@ public class LdapMessageGrammar extends 
                 {
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
 
-                    ModifyDNRequestCodec modifyDNRequest = ldapMessageContainer.getModifyDnRequest();
+                    InternalModifyDnRequest modifyDNRequest = ldapMessageContainer.getModifyDnRequest();
 
                     // Get the Value and store it in the modifyDNRequest
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -2221,7 +2222,7 @@ public class LdapMessageGrammar extends 
                                 DN.EMPTY_DN, ine );
                         }
 
-                        modifyDNRequest.setEntry( entry );
+                        modifyDNRequest.setName( entry );
                     }
 
                     if ( IS_DEBUG )
@@ -2250,7 +2251,7 @@ public class LdapMessageGrammar extends 
                 {
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
 
-                    ModifyDNRequestCodec modifyDNRequest = ldapMessageContainer.getModifyDnRequest();
+                    InternalModifyDnRequest modifyDnRequest = ldapMessageContainer.getModifyDnRequest();
 
                     // Get the Value and store it in the modifyDNRequest
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -2264,9 +2265,9 @@ public class LdapMessageGrammar extends 
                         String msg = I18n.err( I18n.ERR_04090 );
                         log.error( msg );
 
-                        ModifyDnResponseImpl response = new ModifyDnResponseImpl( modifyDNRequest.getMessageId() );
+                        ModifyDnResponseImpl response = new ModifyDnResponseImpl( modifyDnRequest.getMessageId() );
                         throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
-                            modifyDNRequest.getEntry(), null );
+                            modifyDnRequest.getName(), null );
                     }
                     else
                     {
@@ -2284,12 +2285,12 @@ public class LdapMessageGrammar extends 
                                 + ") is invalid";
                             log.error( "{} : {}", msg, ine.getMessage() );
 
-                            ModifyDnResponseImpl response = new ModifyDnResponseImpl( modifyDNRequest.getMessageId() );
+                            ModifyDnResponseImpl response = new ModifyDnResponseImpl( modifyDnRequest.getMessageId() );
                             throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
-                                modifyDNRequest.getEntry(), ine );
+                                modifyDnRequest.getName(), ine );
                         }
 
-                        modifyDNRequest.setNewRDN( newRdn );
+                        modifyDnRequest.setNewRdn( newRdn );
                     }
 
                     if ( IS_DEBUG )
@@ -2315,7 +2316,7 @@ public class LdapMessageGrammar extends 
                 public void action( IAsn1Container container ) throws DecoderException
                 {
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    ModifyDNRequestCodec modifyDNRequest = ldapMessageContainer.getModifyDnRequest();
+                    InternalModifyDnRequest modifyDnRequest = ldapMessageContainer.getModifyDnRequest();
 
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
 
@@ -2329,7 +2330,7 @@ public class LdapMessageGrammar extends 
 
                     try
                     {
-                        modifyDNRequest.setDeleteOldRDN( BooleanDecoder.parse( value ) );
+                        modifyDnRequest.setDeleteOldRdn( BooleanDecoder.parse( value ) );
                     }
                     catch ( BooleanDecoderException bde )
                     {
@@ -2345,7 +2346,7 @@ public class LdapMessageGrammar extends 
 
                     if ( IS_DEBUG )
                     {
-                        if ( modifyDNRequest.isDeleteOldRDN() )
+                        if ( modifyDnRequest.getDeleteOldRdn() )
                         {
                             log.debug( " Old RDN attributes will be deleted" );
                         }
@@ -2372,7 +2373,7 @@ public class LdapMessageGrammar extends 
                 public void action( IAsn1Container container ) throws DecoderException
                 {
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-                    ModifyDNRequestCodec modifyDNRequest = ldapMessageContainer.getModifyDnRequest();
+                    InternalModifyDnRequest modifyDnRequest = ldapMessageContainer.getModifyDnRequest();
 
                     // Get the Value and store it in the modifyDNRequest
                     TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -2384,7 +2385,7 @@ public class LdapMessageGrammar extends 
                     if ( tlv.getLength() == 0 )
                     {
 
-                        if ( modifyDNRequest.isDeleteOldRDN() )
+                        if ( modifyDnRequest.getDeleteOldRdn() )
                         {
                             // This will generate a PROTOCOL_ERROR
                             throw new DecoderException( I18n.err( I18n.ERR_04092 ) );
@@ -2394,7 +2395,7 @@ public class LdapMessageGrammar extends 
                             log.warn( "The new superior is null, so we will change the entry" );
                         }
 
-                        modifyDNRequest.setNewSuperior( newSuperior );
+                        modifyDnRequest.setNewSuperior( newSuperior );
                     }
                     else
                     {
@@ -2411,12 +2412,12 @@ public class LdapMessageGrammar extends 
                                 + StringTools.dumpBytes( dnBytes ) + ") is invalid";
                             log.error( "{} : {}", msg, ine.getMessage() );
 
-                            ModifyDnResponseImpl response = new ModifyDnResponseImpl( modifyDNRequest.getMessageId() );
+                            ModifyDnResponseImpl response = new ModifyDnResponseImpl( modifyDnRequest.getMessageId() );
                             throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_DN_SYNTAX,
-                                modifyDNRequest.getEntry(), ine );
+                                modifyDnRequest.getName(), ine );
                         }
 
-                        modifyDNRequest.setNewSuperior( newSuperior );
+                        modifyDnRequest.setNewSuperior( newSuperior );
                     }
 
                     // We can have an END transition

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=985975&r1=985974&r2=985975&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 Mon Aug 16 14:50:36 2010
@@ -26,7 +26,6 @@ import java.util.List;
 import org.apache.directory.shared.asn1.codec.DecoderException;
 import org.apache.directory.shared.i18n.I18n;
 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.search.AndFilter;
 import org.apache.directory.shared.ldap.codec.search.AttributeValueAssertionFilter;
 import org.apache.directory.shared.ldap.codec.search.ConnectorFilter;
@@ -55,7 +54,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.filter.SimpleNode;
 import org.apache.directory.shared.ldap.filter.SubstringNode;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
-import org.apache.directory.shared.ldap.message.ModifyDnRequestImpl;
 import org.apache.directory.shared.ldap.message.ModifyRequestImpl;
 import org.apache.directory.shared.ldap.message.SearchRequestImpl;
 import org.apache.directory.shared.ldap.message.control.Control;
@@ -80,34 +78,6 @@ public class LdapTransformer
 
 
     /**
-     * Transform a ModifyDNRequest message from a CodecMessage to a
-     * InternalMessage
-     * 
-     * @param modifyDNRequest The message to transform
-     * @param messageId The message Id
-     * @return A Internal ModifyDNRequestImpl
-     */
-    private static InternalMessage transformModifyDNRequest( ModifyDNRequestCodec modifyDNRequest, int messageId )
-    {
-        ModifyDnRequestImpl internalMessage = new ModifyDnRequestImpl( messageId );
-
-        // Codec : DN entry -> Internal : DN m_name
-        internalMessage.setName( modifyDNRequest.getEntry() );
-
-        // Codec : RelativeDN newRDN -> Internal : DN m_newRdn
-        internalMessage.setNewRdn( modifyDNRequest.getNewRDN() );
-
-        // Codec : boolean deleteOldRDN -> Internal : boolean m_deleteOldRdn
-        internalMessage.setDeleteOldRdn( modifyDNRequest.isDeleteOldRDN() );
-
-        // Codec : DN newSuperior -> Internal : DN m_newSuperior
-        internalMessage.setNewSuperior( modifyDNRequest.getNewSuperior() );
-
-        return internalMessage;
-    }
-
-
-    /**
      * Transform a ModifyRequest message from a CodecMessage to a InternalMessage
      * 
      * @param modifyRequest The message to transform
@@ -533,9 +503,6 @@ public class LdapTransformer
                 break;
 
             case MODIFYDN_REQUEST:
-                internalMessage = transformModifyDNRequest( ( ModifyDNRequestCodec ) codecMessage, messageId );
-                break;
-
             case EXTENDED_REQUEST:
             case SEARCH_RESULT_ENTRY:
             case SEARCH_RESULT_DONE:

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/LdapProtocolEncoder.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/LdapProtocolEncoder.java?rev=985975&r1=985974&r2=985975&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/LdapProtocolEncoder.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/LdapProtocolEncoder.java Mon Aug 16 14:50:36 2010
@@ -55,6 +55,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalDeleteRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalExtendedRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
+import org.apache.directory.shared.ldap.message.internal.InternalModifyDnRequest;
 import org.apache.directory.shared.ldap.message.internal.InternalReferral;
 import org.apache.directory.shared.ldap.message.internal.InternalUnbindRequest;
 import org.apache.directory.shared.ldap.message.internal.LdapResult;
@@ -132,7 +133,8 @@ public class LdapProtocolEncoder extends
             || ( message instanceof SearchResultReference ) || ( message instanceof InternalAbandonRequest )
             || ( message instanceof InternalDeleteRequest ) || ( message instanceof InternalUnbindRequest )
             || ( message instanceof InternalBindRequest ) || ( message instanceof InternalAddRequest )
-            || ( message instanceof InternalCompareRequest ) || ( message instanceof InternalExtendedRequest ) )
+            || ( message instanceof InternalCompareRequest ) || ( message instanceof InternalExtendedRequest )
+            || ( message instanceof InternalModifyDnRequest ) )
         {
             try
             {
@@ -906,6 +908,48 @@ public class LdapProtocolEncoder extends
 
 
     /**
+     * Compute the ModifyDNRequest length
+     * 
+     * ModifyDNRequest :
+     * <pre>
+     * 0x6C L1
+     *  |
+     *  +--> 0x04 L2 entry
+     *  +--> 0x04 L3 newRDN
+     *  +--> 0x01 0x01 (true/false) deleteOldRDN (3 bytes)
+     * [+--> 0x80 L4 newSuperior ] 
+     * 
+     * L2 = Length(0x04) + Length(Length(entry)) + Length(entry) 
+     * L3 = Length(0x04) + Length(Length(newRDN)) + Length(newRDN) 
+     * L4 = Length(0x80) + Length(Length(newSuperior)) + Length(newSuperior)
+     * L1 = L2 + L3 + 3 [+ L4] 
+     * 
+     * Length(ModifyDNRequest) = Length(0x6C) + Length(L1) + L1
+     * </pre>
+     * 
+     * @return The PDU's length of a ModifyDN Request
+     */
+    private int computeModifyDnRequestLength( ModifyDnRequestImpl modifyDnResponse )
+    {
+        int newRdnlength = StringTools.getBytesUtf8( modifyDnResponse.getNewRdn().getName() ).length;
+
+        int modifyDNRequestLength = 1 + TLV.getNbBytes( DN.getNbBytes( modifyDnResponse.getName() ) )
+            + DN.getNbBytes( modifyDnResponse.getName() ) + 1 + TLV.getNbBytes( newRdnlength ) + newRdnlength + 1 + 1
+            + 1; // deleteOldRDN
+
+        if ( modifyDnResponse.getNewSuperior() != null )
+        {
+            modifyDNRequestLength += 1 + TLV.getNbBytes( DN.getNbBytes( modifyDnResponse.getNewSuperior() ) )
+                + DN.getNbBytes( modifyDnResponse.getNewSuperior() );
+        }
+
+        modifyDnResponse.setModifyDnRequestLength( modifyDNRequestLength );
+
+        return 1 + TLV.getNbBytes( modifyDNRequestLength ) + modifyDNRequestLength;
+    }
+
+
+    /**
      * Compute the ModifyDNResponse length 
      * 
      * ModifyDNResponse : 
@@ -1743,6 +1787,63 @@ public class LdapProtocolEncoder extends
 
 
     /**
+     * Encode the ModifyDNRequest message to a PDU. 
+     * 
+     * ModifyDNRequest :
+     * <pre>
+     * 0x6C LL
+     *   0x04 LL entry
+     *   0x04 LL newRDN
+     *   0x01 0x01 deleteOldRDN
+     *   [0x80 LL newSuperior]
+     * </pre>
+     * @param buffer The buffer where to put the PDU
+     * @return The PDU.
+     */
+    private void encodeModifyDnRequest( ByteBuffer buffer, ModifyDnRequestImpl modifyDnRequest )
+        throws EncoderException
+    {
+        try
+        {
+            // The ModifyDNRequest Tag
+            buffer.put( LdapConstants.MODIFY_DN_REQUEST_TAG );
+            buffer.put( TLV.getBytes( modifyDnRequest.getModifyDnResponseLength() ) );
+
+            // The entry
+
+            Value.encode( buffer, DN.getBytes( modifyDnRequest.getName() ) );
+
+            // The newRDN
+            Value.encode( buffer, modifyDnRequest.getNewRdn().getName() );
+
+            // The flag deleteOldRdn
+            Value.encode( buffer, modifyDnRequest.getDeleteOldRdn() );
+
+            // The new superior, if any
+            if ( modifyDnRequest.getNewSuperior() != null )
+            {
+                // Encode the reference
+                buffer.put( ( byte ) LdapConstants.MODIFY_DN_REQUEST_NEW_SUPERIOR_TAG );
+
+                int newSuperiorLength = DN.getNbBytes( modifyDnRequest.getNewSuperior() );
+
+                buffer.put( TLV.getBytes( newSuperiorLength ) );
+
+                if ( newSuperiorLength != 0 )
+                {
+                    buffer.put( DN.getBytes( modifyDnRequest.getNewSuperior() ) );
+                }
+            }
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException( I18n.err( I18n.ERR_04005 ) );
+        }
+
+    }
+
+
+    /**
      * Encode the ModifyDnResponse message to a PDU.
      * 
      * @param buffer The buffer where to put the PDU
@@ -1989,6 +2090,9 @@ public class LdapProtocolEncoder extends
             case MODIFY_RESPONSE:
                 return computeModifyResponseLength( ( ModifyResponseImpl ) message );
 
+            case MODIFYDN_REQUEST:
+                return computeModifyDnRequestLength( ( ModifyDnRequestImpl ) message );
+
             case MODIFYDN_RESPONSE:
                 return computeModifyDnResponseLength( ( ModifyDnResponseImpl ) message );
 
@@ -2066,6 +2170,10 @@ public class LdapProtocolEncoder extends
                 encodeModifyResponse( bb, ( ModifyResponseImpl ) message );
                 break;
 
+            case MODIFYDN_REQUEST:
+                encodeModifyDnRequest( bb, ( ModifyDnRequestImpl ) 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/message/ModifyDnRequestImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModifyDnRequestImpl.java?rev=985975&r1=985974&r2=985975&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModifyDnRequestImpl.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/ModifyDnRequestImpl.java Mon Aug 16 14:50:36 2010
@@ -29,7 +29,7 @@ import org.apache.directory.shared.ldap.
 
 
 /**
- * Lockable ModifyDNRequest implementation.
+ * ModifyDNRequest implementation.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
@@ -49,19 +49,31 @@ public class ModifyDnRequestImpl extends
     /** PDU's <b>deleteOldRdn</b> flag */
     private boolean deleteOldRdn = false;
 
+    /** The associated response */
     private ModifyDnResponse response;
 
+    /** The modify DN request length */
+    private int modifyDnRequestLength;
+
 
     // -----------------------------------------------------------------------
     // Constructors
     // -----------------------------------------------------------------------
+    /**
+     * Creates a ModifyDnRequest implementing object used to perform a
+     * dn change on an entry potentially resulting in an entry move.
+     */
+    public ModifyDnRequestImpl()
+    {
+        super( -1, TYPE );
+    }
+
 
     /**
      * Creates a Lockable ModifyDnRequest implementing object used to perform a
      * dn change on an entry potentially resulting in an entry move.
      * 
-     * @param id
-     *            the seq id of this message
+     * @param id the sequence id of this message
      */
     public ModifyDnRequestImpl( final int id )
     {
@@ -76,7 +88,7 @@ public class ModifyDnRequestImpl extends
     /**
      * Gets the flag which determines if the old Rdn attribute is to be removed
      * from the entry when the new Rdn is used in its stead. This property
-     * corresponds to the <b>deleteoldrdn
+     * corresponds to the <b>deleteoldrdn</b>
      * </p>
      * PDU field.
      * 
@@ -91,12 +103,11 @@ public class ModifyDnRequestImpl extends
     /**
      * Sets the flag which determines if the old Rdn attribute is to be removed
      * from the entry when the new Rdn is used in its stead. This property
-     * corresponds to the <b>deleteoldrdn
+     * corresponds to the <b>deleteoldrdn</b>
      * </p>
      * PDU field.
      * 
-     * @param deleteOldRdn
-     *            true if the old rdn is to be deleted, false if it is not
+     * @param deleteOldRdn true if the old rdn is to be deleted, false if it is not
      */
     public void setDeleteOldRdn( boolean deleteOldRdn )
     {
@@ -159,8 +170,7 @@ public class ModifyDnRequestImpl extends
      * Sets the new relative distinguished name for the entry which represents
      * the PDU's <b>newrdn</b> field.
      * 
-     * @param newRdn
-     *            the relative dn with one component
+     * @param newRdn the relative dn with one component
      */
     public void setNewRdn( RDN newRdn )
     {
@@ -189,8 +199,7 @@ public class ModifyDnRequestImpl extends
      * rather than a move operation. Setting this property to a non-null value
      * toggles the move flag obtained via the <code>isMove</code> method.
      * 
-     * @param newSuperior
-     *            the dn of the superior entry the candidate entry for DN
+     * @param newSuperior the dn of the superior entry the candidate entry for DN
      *            modification is moved under.
      */
     public void setNewSuperior( DN newSuperior )
@@ -232,6 +241,25 @@ public class ModifyDnRequestImpl extends
 
 
     /**
+     * @return The encoded ModifyDnRequest's length
+     */
+    /* No Qualifier*/void setModifyDnRequestLength( int modifyDnRequestLength )
+    {
+        this.modifyDnRequestLength = modifyDnRequestLength;
+    }
+
+
+    /**
+     * Stores the encoded length for the ModifyDnRequest
+     * @param modifyDnRequestLength The encoded length
+     */
+    /* No Qualifier*/int getModifyDnResponseLength()
+    {
+        return modifyDnRequestLength;
+    }
+
+
+    /**
      * {@inheritDoc}
      */
     @Override
@@ -262,8 +290,7 @@ public class ModifyDnRequestImpl extends
      * Checks to see of an object equals this ModifyDnRequest stub. The equality
      * presumes all ModifyDnRequest specific properties are the same.
      * 
-     * @param obj
-     *            the object to compare with this stub
+     * @param obj the object to compare with this stub
      * @return true if the obj is equal to this stub, false otherwise
      */
     public boolean equals( Object obj )
@@ -357,6 +384,9 @@ public class ModifyDnRequestImpl extends
             sb.append( "        New superior : '" ).append( newSuperior.toString() ).append( "'\n" );
         }
 
+        // The controls
+        sb.append( super.toString() );
+
         return sb.toString();
     }
 }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestTest.java?rev=985975&r1=985974&r2=985975&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestTest.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/modifyDn/ModifyDNRequestTest.java Mon Aug 16 14:50:36 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;
@@ -35,10 +35,12 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.codec.EncoderException;
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.ResponseCarryingException;
+import org.apache.directory.shared.ldap.message.LdapProtocolEncoder;
 import org.apache.directory.shared.ldap.message.ModifyDnResponseImpl;
 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.InternalMessage;
+import org.apache.directory.shared.ldap.message.internal.InternalModifyDnRequest;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -53,6 +55,10 @@ import org.junit.runner.RunWith;
 @Concurrent()
 public class ModifyDNRequestTest
 {
+    /** The encoder instance */
+    LdapProtocolEncoder encoder = new LdapProtocolEncoder();
+
+
     /**
      * Test the decoding of a full ModifyDNRequest
      */
@@ -65,23 +71,23 @@ public class ModifyDNRequestTest
 
         stream.put( new byte[]
             {
-            0x30, 0x46,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x6C, 0x41,               // CHOICE { ..., modifyDNRequest ModifyDNRequest,
-                                        // ...
-                                        // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
-                                        // entry LDAPDN,
-                0x04, 0x20, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
-                  's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
-                                        // newrdn RelativeLDAPDN,
-                0x04, 0x0F, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 
-                0x01, 0x01, 0x00, // deleteoldrdn BOOLEAN,
-                                        // newSuperior [0] LDAPDN OPTIONAL }
-                ( byte ) 0x80, 0x09, 
-                  'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm' 
-            } );
+                0x30,
+                0x46, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x6C,
+                0x41, // CHOICE { ..., modifyDNRequest ModifyDNRequest,
+                // ...
+                // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
+                // entry LDAPDN,
+                0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+                's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+                // newrdn RelativeLDAPDN,
+                0x04, 0x0F, 'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 0x01, 0x01,
+                0x00, // deleteoldrdn BOOLEAN,
+                // newSuperior [0] LDAPDN OPTIONAL }
+                ( byte ) 0x80, 0x09, 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm' } );
 
         String decodedPdu = StringTools.dumpBytes( stream.array() );
         stream.flip();
@@ -99,21 +105,22 @@ public class ModifyDNRequestTest
             fail( de.getMessage() );
         }
 
-        ModifyDNRequestCodec modifyDNRequest = ( ( LdapMessageContainer ) ldapMessageContainer ).getModifyDnRequest();
-
-        assertEquals( 1, modifyDNRequest.getMessageId() );
-        assertEquals( "cn=testModify,ou=users,ou=system", modifyDNRequest.getEntry().toString() );
-        assertEquals( false, modifyDNRequest.isDeleteOldRDN() );
-        assertEquals( "cn=testDNModify", modifyDNRequest.getNewRDN().toString() );
-        assertEquals( "ou=system", modifyDNRequest.getNewSuperior().toString() );
+        InternalModifyDnRequest modifyDnRequest = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getModifyDnRequest();
 
-        // Check the length
-        assertEquals( 0x48, modifyDNRequest.computeLength() );
+        assertEquals( 1, modifyDnRequest.getMessageId() );
+        assertEquals( "cn=testModify,ou=users,ou=system", modifyDnRequest.getName().toString() );
+        assertEquals( false, modifyDnRequest.getDeleteOldRdn() );
+        assertEquals( "cn=testDNModify", modifyDnRequest.getNewRdn().toString() );
+        assertEquals( "ou=system", modifyDnRequest.getNewSuperior().toString() );
 
         // Check the encoding
         try
         {
-            ByteBuffer bb = modifyDNRequest.encode();
+            ByteBuffer bb = encoder.encodeMessage( modifyDnRequest );
+
+            // Check the length
+            assertEquals( 0x48, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -126,6 +133,7 @@ public class ModifyDNRequestTest
         }
     }
 
+
     /**
      * Test the decoding of a bad DN ModifyDNRequest
      */
@@ -138,23 +146,23 @@ public class ModifyDNRequestTest
 
         stream.put( new byte[]
             {
-            0x30, 0x46,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x6C, 0x41,               // CHOICE { ..., modifyDNRequest ModifyDNRequest,
-                                        // ...
-                                        // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
-                                        // entry LDAPDN,
-                0x04, 0x20, 
-                  'c', 'n', ':', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
-                  's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
-                                        // newrdn RelativeLDAPDN,
-                0x04, 0x0F, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 
-                0x01, 0x01, 0x00, // deleteoldrdn BOOLEAN,
-                                        // newSuperior [0] LDAPDN OPTIONAL }
-                ( byte ) 0x80, 0x09, 
-                  'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm' 
-            } );
+                0x30,
+                0x46, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x6C,
+                0x41, // CHOICE { ..., modifyDNRequest ModifyDNRequest,
+                // ...
+                // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
+                // entry LDAPDN,
+                0x04, 0x20, 'c', 'n', ':', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+                's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+                // newrdn RelativeLDAPDN,
+                0x04, 0x0F, 'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 0x01, 0x01,
+                0x00, // deleteoldrdn BOOLEAN,
+                // newSuperior [0] LDAPDN OPTIONAL }
+                ( byte ) 0x80, 0x09, 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm' } );
 
         stream.flip();
 
@@ -168,15 +176,17 @@ public class ModifyDNRequestTest
         catch ( DecoderException de )
         {
             assertTrue( de instanceof ResponseCarryingException );
-            InternalMessage response = ((ResponseCarryingException)de).getResponse();
+            InternalMessage response = ( ( ResponseCarryingException ) de ).getResponse();
             assertTrue( response instanceof ModifyDnResponseImpl );
-            assertEquals( ResultCodeEnum.INVALID_DN_SYNTAX, ((ModifyDnResponseImpl)response).getLdapResult().getResultCode() );
+            assertEquals( ResultCodeEnum.INVALID_DN_SYNTAX, ( ( ModifyDnResponseImpl ) response ).getLdapResult()
+                .getResultCode() );
             return;
         }
 
         fail( "We should not reach this point" );
     }
 
+
     /**
      * Test the decoding of a bad RDN ModifyDNRequest
      */
@@ -189,23 +199,23 @@ public class ModifyDNRequestTest
 
         stream.put( new byte[]
             {
-            0x30, 0x46,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x6C, 0x41,               // CHOICE { ..., modifyDNRequest ModifyDNRequest,
-                                        // ...
-                                        // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
-                                        // entry LDAPDN,
-                0x04, 0x20, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
-                  's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
-                                        // newrdn RelativeLDAPDN,
-                0x04, 0x0F, 
-                  'c', 'n', ':', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 
-                0x01, 0x01, 0x00,       // deleteoldrdn BOOLEAN,
-                                        // newSuperior [0] LDAPDN OPTIONAL }
-                ( byte ) 0x80, 0x09, 
-                  'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm' 
-            } );
+                0x30,
+                0x46, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x6C,
+                0x41, // CHOICE { ..., modifyDNRequest ModifyDNRequest,
+                // ...
+                // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
+                // entry LDAPDN,
+                0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+                's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+                // newrdn RelativeLDAPDN,
+                0x04, 0x0F, 'c', 'n', ':', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 0x01, 0x01,
+                0x00, // deleteoldrdn BOOLEAN,
+                // newSuperior [0] LDAPDN OPTIONAL }
+                ( byte ) 0x80, 0x09, 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm' } );
 
         stream.flip();
 
@@ -219,15 +229,17 @@ public class ModifyDNRequestTest
         catch ( DecoderException de )
         {
             assertTrue( de instanceof ResponseCarryingException );
-            InternalMessage response = ((ResponseCarryingException)de).getResponse();
+            InternalMessage response = ( ( ResponseCarryingException ) de ).getResponse();
             assertTrue( response instanceof ModifyDnResponseImpl );
-            assertEquals( ResultCodeEnum.INVALID_DN_SYNTAX, ((ModifyDnResponseImpl)response).getLdapResult().getResultCode() );
+            assertEquals( ResultCodeEnum.INVALID_DN_SYNTAX, ( ( ModifyDnResponseImpl ) response ).getLdapResult()
+                .getResultCode() );
             return;
         }
 
         fail( "We should not reach this point" );
     }
 
+
     /**
      * Test the decoding of a bad RDN ModifyDNRequest
      */
@@ -240,23 +252,23 @@ public class ModifyDNRequestTest
 
         stream.put( new byte[]
             {
-            0x30, 0x46,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x6C, 0x41,               // CHOICE { ..., modifyDNRequest ModifyDNRequest,
-                                        // ...
-                                        // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
-                                        // entry LDAPDN,
-                0x04, 0x20, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
-                  's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
-                                        // newrdn RelativeLDAPDN,
-                0x04, 0x0F, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 
-                0x01, 0x01, 0x00,       // deleteoldrdn BOOLEAN,
-                                        // newSuperior [0] LDAPDN OPTIONAL }
-                ( byte ) 0x80, 0x09, 
-                  'o', 'u', ':', 's', 'y', 's', 't', 'e', 'm' 
-            } );
+                0x30,
+                0x46, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x6C,
+                0x41, // CHOICE { ..., modifyDNRequest ModifyDNRequest,
+                // ...
+                // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
+                // entry LDAPDN,
+                0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+                's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+                // newrdn RelativeLDAPDN,
+                0x04, 0x0F, 'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 0x01, 0x01,
+                0x00, // deleteoldrdn BOOLEAN,
+                // newSuperior [0] LDAPDN OPTIONAL }
+                ( byte ) 0x80, 0x09, 'o', 'u', ':', 's', 'y', 's', 't', 'e', 'm' } );
 
         stream.flip();
 
@@ -270,15 +282,17 @@ public class ModifyDNRequestTest
         catch ( DecoderException de )
         {
             assertTrue( de instanceof ResponseCarryingException );
-            InternalMessage response = ((ResponseCarryingException)de).getResponse();
+            InternalMessage response = ( ( ResponseCarryingException ) de ).getResponse();
             assertTrue( response instanceof ModifyDnResponseImpl );
-            assertEquals( ResultCodeEnum.INVALID_DN_SYNTAX, ((ModifyDnResponseImpl)response).getLdapResult().getResultCode() );
+            assertEquals( ResultCodeEnum.INVALID_DN_SYNTAX, ( ( ModifyDnResponseImpl ) response ).getLdapResult()
+                .getResultCode() );
             return;
         }
 
         fail( "We should not reach this point" );
     }
-    
+
+
     /**
      * Test the decoding of a full ModifyDNRequest with controls
      */
@@ -291,26 +305,28 @@ public class ModifyDNRequestTest
 
         stream.put( new byte[]
             {
-            0x30, 0x63,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x6C, 0x41,               // CHOICE { ..., modifyDNRequest ModifyDNRequest,
-                                        // ...
-                                        // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
-                                        // entry LDAPDN,
-                0x04, 0x20, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
-                  's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
-                                        // newrdn RelativeLDAPDN,
-                0x04, 0x0F, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 
-                0x01, 0x01, 0x00,       // deleteoldrdn BOOLEAN,
-                                        // newSuperior [0] LDAPDN OPTIONAL }
-                ( byte ) 0x80, 0x09, 
-                  'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 
-              ( byte ) 0xA0, 0x1B, // A control
+                0x30,
+                0x63, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x6C,
+                0x41, // CHOICE { ..., modifyDNRequest ModifyDNRequest,
+                // ...
+                // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
+                // entry LDAPDN,
+                0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+                's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e',
+                'm',
+                // newrdn RelativeLDAPDN,
+                0x04, 0x0F, 'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 0x01,
+                0x01,
+                0x00, // deleteoldrdn BOOLEAN,
+                // newSuperior [0] LDAPDN OPTIONAL }
+                ( byte ) 0x80, 0x09, 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', ( 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 
-            } );
+                0x33, 0x37, 0x33, 0x30, 0x2E, 0x33, 0x2E, 0x34, 0x2E, 0x32 } );
 
         String decodedPdu = StringTools.dumpBytes( stream.array() );
         stream.flip();
@@ -328,30 +344,31 @@ public class ModifyDNRequestTest
             fail( de.getMessage() );
         }
 
-        ModifyDNRequestCodec modifyDNRequest = ( ( LdapMessageContainer ) ldapMessageContainer ).getModifyDnRequest();
+        InternalModifyDnRequest modifyDnRequest = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getModifyDnRequest();
 
-        assertEquals( 1, modifyDNRequest.getMessageId() );
-        assertEquals( "cn=testModify,ou=users,ou=system", modifyDNRequest.getEntry().toString() );
-        assertEquals( false, modifyDNRequest.isDeleteOldRDN() );
-        assertEquals( "cn=testDNModify", modifyDNRequest.getNewRDN().toString() );
-        assertEquals( "ou=system", modifyDNRequest.getNewSuperior().toString() );
+        assertEquals( 1, modifyDnRequest.getMessageId() );
+        assertEquals( "cn=testModify,ou=users,ou=system", modifyDnRequest.getName().toString() );
+        assertEquals( false, modifyDnRequest.getDeleteOldRdn() );
+        assertEquals( "cn=testDNModify", modifyDnRequest.getNewRdn().toString() );
+        assertEquals( "ou=system", modifyDnRequest.getNewSuperior().toString() );
 
         // Check the Control
-        List<Control> controls = modifyDNRequest.getControls();
+        Map<String, Control> controls = modifyDnRequest.getControls();
 
         assertEquals( 1, controls.size() );
 
-        Control control = modifyDNRequest.getControls( 0 );
+        Control control = modifyDnRequest.getControl( "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( 0x65, modifyDNRequest.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = modifyDNRequest.encode();
+            ByteBuffer bb = encoder.encodeMessage( modifyDnRequest );
+
+            // Check the length
+            assertEquals( 0x65, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -376,21 +393,21 @@ public class ModifyDNRequestTest
         ByteBuffer stream = ByteBuffer.allocate( 0x3D );
 
         stream.put( new byte[]
-            {
-            0x30, 0x3B,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x6C, 0x36,               // CHOICE { ..., modifyDNRequest ModifyDNRequest,
-                                        // ...
-                                        // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
-                                        // entry LDAPDN,
-                0x04, 0x20, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
-                  's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
-                                        // newrdn RelativeLDAPDN,
-                0x04, 0x0F, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 
-                0x01, 0x01, 0x00        // deleteoldrdn BOOLEAN,
-                                        // newSuperior [0] LDAPDN OPTIONAL }
+            { 0x30,
+                0x3B, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x6C,
+                0x36, // CHOICE { ..., modifyDNRequest ModifyDNRequest,
+                // ...
+                // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
+                // entry LDAPDN,
+                0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+                's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
+                // newrdn RelativeLDAPDN,
+                0x04, 0x0F, 'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 0x01, 0x01, 0x00 // deleteoldrdn BOOLEAN,
+            // newSuperior [0] LDAPDN OPTIONAL }
             } );
 
         String decodedPdu = StringTools.dumpBytes( stream.array() );
@@ -409,20 +426,21 @@ public class ModifyDNRequestTest
             fail( de.getMessage() );
         }
 
-        ModifyDNRequestCodec modifyDNRequest = ( ( LdapMessageContainer ) ldapMessageContainer ).getModifyDnRequest();
-
-        assertEquals( 1, modifyDNRequest.getMessageId() );
-        assertEquals( "cn=testModify,ou=users,ou=system", modifyDNRequest.getEntry().toString() );
-        assertEquals( false, modifyDNRequest.isDeleteOldRDN() );
-        assertEquals( "cn=testDNModify", modifyDNRequest.getNewRDN().toString() );
+        InternalModifyDnRequest modifyDnRequest = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getModifyDnRequest();
 
-        // Check the length
-        assertEquals( 0x3D, modifyDNRequest.computeLength() );
+        assertEquals( 1, modifyDnRequest.getMessageId() );
+        assertEquals( "cn=testModify,ou=users,ou=system", modifyDnRequest.getName().toString() );
+        assertEquals( false, modifyDnRequest.getDeleteOldRdn() );
+        assertEquals( "cn=testDNModify", modifyDnRequest.getNewRdn().toString() );
 
         // Check the encoding
         try
         {
-            ByteBuffer bb = modifyDNRequest.encode();
+            ByteBuffer bb = encoder.encodeMessage( modifyDnRequest );
+
+            // Check the length
+            assertEquals( 0x3D, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -448,24 +466,28 @@ public class ModifyDNRequestTest
 
         stream.put( new byte[]
             {
-            0x30, 0x58,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x6C, 0x36,               // CHOICE { ..., modifyDNRequest ModifyDNRequest,
-                                        // ...
-                                        // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
-                                        // entry LDAPDN,
-                0x04, 0x20, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
-                  's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm',
-                                        // newrdn RelativeLDAPDN,
-                0x04, 0x0F, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 
-                0x01, 0x01, 0x00,       // deleteoldrdn BOOLEAN,
-                                        // newSuperior [0] LDAPDN OPTIONAL }
-              ( byte ) 0xA0, 0x1B,      // A control
+                0x30,
+                0x58, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x6C,
+                0x36, // CHOICE { ..., modifyDNRequest ModifyDNRequest,
+                // ...
+                // ModifyDNRequest ::= [APPLICATION 12] SEQUENCE {
+                // entry LDAPDN,
+                0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+                's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e',
+                'm',
+                // newrdn RelativeLDAPDN,
+                0x04, 0x0F, 'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 0x01,
+                0x01,
+                0x00, // deleteoldrdn BOOLEAN,
+                // newSuperior [0] LDAPDN OPTIONAL }
+                ( 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 
-            } );
+                0x33, 0x37, 0x33, 0x30, 0x2E, 0x33, 0x2E, 0x34, 0x2E, 0x32 } );
 
         String decodedPdu = StringTools.dumpBytes( stream.array() );
         stream.flip();
@@ -483,29 +505,32 @@ public class ModifyDNRequestTest
             fail( de.getMessage() );
         }
 
-        ModifyDNRequestCodec modifyDNRequest = ( ( LdapMessageContainer ) ldapMessageContainer ).getModifyDnRequest();
+        InternalModifyDnRequest modifyDnRequest = ( ( LdapMessageContainer ) ldapMessageContainer )
+            .getModifyDnRequest();
 
-        assertEquals( 1, modifyDNRequest.getMessageId() );
-        assertEquals( "cn=testModify,ou=users,ou=system", modifyDNRequest.getEntry().toString() );
-        assertEquals( false, modifyDNRequest.isDeleteOldRDN() );
-        assertEquals( "cn=testDNModify", modifyDNRequest.getNewRDN().toString() );
+        assertEquals( 1, modifyDnRequest.getMessageId() );
+        assertEquals( "cn=testModify,ou=users,ou=system", modifyDnRequest.getName().toString() );
+        assertEquals( false, modifyDnRequest.getDeleteOldRdn() );
+        assertEquals( "cn=testDNModify", modifyDnRequest.getNewRdn().toString() );
 
         // Check the Control
-        List<Control> controls = modifyDNRequest.getControls();
+        Map<String, Control> controls = modifyDnRequest.getControls();
 
         assertEquals( 1, controls.size() );
 
-        Control control = modifyDNRequest.getControls( 0 );
+        assertTrue( modifyDnRequest.hasControl( "2.16.840.1.113730.3.4.2" ) );
+
+        Control control = modifyDnRequest.getControl( "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( 0x5A, modifyDNRequest.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = modifyDNRequest.encode();
+            ByteBuffer bb = encoder.encodeMessage( modifyDnRequest );
+
+            // Check the length
+            assertEquals( 0x5A, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -532,11 +557,10 @@ public class ModifyDNRequestTest
         ByteBuffer stream = ByteBuffer.allocate( 0x07 );
 
         stream.put( new byte[]
-            { 
-            0x30, 0x05,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x6C, 0x00                // CHOICE { ..., modifyDNRequest ModifyDNRequest,
-                                        // ...
+            { 0x30, 0x05, // LDAPMessage ::= SEQUENCE {
+                0x02, 0x01, 0x01, // messageID MessageID
+                0x6C, 0x00 // CHOICE { ..., modifyDNRequest ModifyDNRequest,
+            // ...
             } );
 
         stream.flip();
@@ -568,11 +592,10 @@ public class ModifyDNRequestTest
         ByteBuffer stream = ByteBuffer.allocate( 0x09 );
 
         stream.put( new byte[]
-            { 
-            0x30, 0x07,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x6C, 0x02,               // CHOICE { ..., modifyDNRequest ModifyDNRequest,
-                                        // ...
+            { 0x30, 0x07, // LDAPMessage ::= SEQUENCE {
+                0x02, 0x01, 0x01, // messageID MessageID
+                0x6C, 0x02, // CHOICE { ..., modifyDNRequest ModifyDNRequest,
+                // ...
                 0x04, 0x00 } );
 
         stream.flip();
@@ -604,16 +627,15 @@ public class ModifyDNRequestTest
         ByteBuffer stream = ByteBuffer.allocate( 0x2D );
 
         stream.put( new byte[]
-            { 
-            0x30, 0x2B,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x6C, 0x26,               // CHOICE { ..., modifyDNRequest ModifyDNRequest,
-                            // ...
-                0x04, 0x20, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
-                  's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 
-                0x04, 0x00 
-            } );
+            { 0x30,
+                0x2B, // LDAPMessage ::= SEQUENCE {
+                0x02, 0x01,
+                0x01, // messageID MessageID
+                0x6C,
+                0x26, // CHOICE { ..., modifyDNRequest ModifyDNRequest,
+                // ...
+                0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+                's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 0x04, 0x00 } );
 
         stream.flip();
 
@@ -644,17 +666,18 @@ public class ModifyDNRequestTest
         ByteBuffer stream = ByteBuffer.allocate( 0x3C );
 
         stream.put( new byte[]
-            { 
-            0x30, 0x3A,                 // LDAPMessage ::= SEQUENCE {
-              0x02, 0x01, 0x01,         // messageID MessageID
-              0x6C, 0x35,               // CHOICE { ..., modifyDNRequest ModifyDNRequest,
-                                        // ...
-                0x04, 0x20, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
-                  's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 
-                0x04, 0x0F, 
-                  'c', 'n', '=', 't', 'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 
-                0x01, 0x00              // deleteoldrdn BOOLEAN
+            {
+                0x30,
+                0x3A, // LDAPMessage ::= SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x6C,
+                0x35, // CHOICE { ..., modifyDNRequest ModifyDNRequest,
+                // ...
+                0x04, 0x20, 'c', 'n', '=', 't', 'e', 's', 't', 'M', 'o', 'd', 'i', 'f', 'y', ',', 'o', 'u', '=', 'u',
+                's', 'e', 'r', 's', ',', 'o', 'u', '=', 's', 'y', 's', 't', 'e', 'm', 0x04, 0x0F, 'c', 'n', '=', 't',
+                'e', 's', 't', 'D', 'N', 'M', 'o', 'd', 'i', 'f', 'y', 0x01, 0x00 // deleteoldrdn BOOLEAN
             } );
 
         stream.flip();



Mime
View raw message