directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r984552 - 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 Wed, 11 Aug 2010 19:37:47 GMT
Author: elecharny
Date: Wed Aug 11 19:37:46 2010
New Revision: 984552

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

Removed:
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/del/DelResponseCodec.java
Modified:
    directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapProtocolEncoder.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/DeleteResponseImpl.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/LdapResultImpl.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalDeleteResponse.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalLdapResult.java
    directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/del/DelResponseTest.java
    directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/message/LdapResultImplTest.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=984552&r1=984551&r2=984552&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
Wed Aug 11 19:37:46 2010
@@ -98,7 +98,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.compare.CompareResponseCodec;
 import org.apache.directory.shared.ldap.codec.controls.ControlImpl;
 import org.apache.directory.shared.ldap.codec.del.DelRequestCodec;
-import org.apache.directory.shared.ldap.codec.del.DelResponseCodec;
 import org.apache.directory.shared.ldap.codec.extended.ExtendedRequestCodec;
 import org.apache.directory.shared.ldap.codec.extended.ExtendedResponseCodec;
 import org.apache.directory.shared.ldap.codec.intermediate.IntermediateResponseCodec;
@@ -129,6 +128,7 @@ import org.apache.directory.shared.ldap.
 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.InternalBindResponse;
+import org.apache.directory.shared.ldap.message.internal.InternalDeleteResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalLdapResult;
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
 import org.apache.directory.shared.ldap.name.DN;
@@ -1624,6 +1624,41 @@ public class LdapNetworkConnection exten
                     removeFromFutureMaps( messageId );
 
                     break;
+
+                case DEL_RESPONSE:
+                    // Transform the response
+                    DeleteResponse deleteResponse = convert( ( InternalDeleteResponse ) response
);
+
+                    DeleteFuture deleteFuture = ( DeleteFuture ) responseFuture;
+
+                    if ( deleteFuture == null )
+                    {
+                        LOG.error( "DeleteFuture is null" );
+                        throw new LdapException( "DeleteFuture is null" );
+                    }
+
+                    if ( LOG.isDebugEnabled() )
+                    {
+                        if ( deleteResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS
)
+                        {
+                            // Everything is fine, return the response
+                            LOG.debug( "Delete successful : {}", deleteResponse );
+                        }
+                        else
+                        {
+                            // We have had an error
+                            LOG.debug( "Delete failed : {}", deleteResponse );
+                        }
+                    }
+
+                    // Store the response into the future
+                    deleteFuture.set( deleteResponse );
+
+                    // Remove the future from the map
+                    removeFromFutureMaps( messageId );
+
+                    break;
+
             }
         }
         else
@@ -1722,44 +1757,6 @@ public class LdapNetworkConnection exten
 
                     break;
 
-                case DEL_RESPONSE:
-                    // Transform the response
-                    DelResponseCodec delRespCodec = ( DelResponseCodec ) response;
-                    delRespCodec.addControls( response.getControls() );
-                    delRespCodec.setMessageId( messageId );
-
-                    DeleteResponse deleteResponse = convert( delRespCodec );
-
-                    DeleteFuture deleteFuture = ( DeleteFuture ) responseFuture;
-
-                    if ( deleteFuture == null )
-                    {
-                        LOG.error( "DeleteFuture is null" );
-                        throw new LdapException( "DeleteFuture is null" );
-                    }
-
-                    if ( LOG.isDebugEnabled() )
-                    {
-                        if ( deleteResponse.getLdapResult().getResultCode() == ResultCodeEnum.SUCCESS
)
-                        {
-                            // Everything is fine, return the response
-                            LOG.debug( "Delete successful : {}", deleteResponse );
-                        }
-                        else
-                        {
-                            // We have had an error
-                            LOG.debug( "Delete failed : {}", deleteResponse );
-                        }
-                    }
-
-                    // Store the response into the future
-                    deleteFuture.set( deleteResponse );
-
-                    // Remove the future from the map
-                    removeFromFutureMaps( messageId );
-
-                    break;
-
                 case EXTENDED_RESPONSE:
                     // Transform the response
                     ExtendedResponseCodec extResCodec = ( ExtendedResponseCodec ) response;
@@ -2897,15 +2894,15 @@ public class LdapNetworkConnection exten
 
 
     /**
-     * converts the DeleteResponseCodec to DeleteResponse object.
+     * converts the InternalDeleteResponse to DeleteResponse object.
      */
-    private DeleteResponse convert( DelResponseCodec delRespCodec )
+    private DeleteResponse convert( InternalDeleteResponse internalDeleteResponse )
     {
         DeleteResponse response = new DeleteResponse();
 
-        response.setMessageId( delRespCodec.getMessageId() );
-        response.setLdapResult( convert( delRespCodec.getLdapResult() ) );
-        addControls( delRespCodec, response );
+        response.setMessageId( internalDeleteResponse.getMessageId() );
+        response.setLdapResult( convert( internalDeleteResponse.getLdapResult() ) );
+        addControls( internalDeleteResponse, response );
 
         return response;
     }

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=984552&r1=984551&r2=984552&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
Wed Aug 11 19:37:46 2010
@@ -29,7 +29,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.compare.CompareResponseCodec;
 import org.apache.directory.shared.ldap.codec.controls.AbstractControl;
 import org.apache.directory.shared.ldap.codec.del.DelRequestCodec;
-import org.apache.directory.shared.ldap.codec.del.DelResponseCodec;
 import org.apache.directory.shared.ldap.codec.extended.ExtendedRequestCodec;
 import org.apache.directory.shared.ldap.codec.extended.ExtendedResponseCodec;
 import org.apache.directory.shared.ldap.codec.intermediate.IntermediateResponseCodec;
@@ -48,6 +47,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalBindResponse;
 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.InternalDeleteResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
 import org.apache.directory.shared.ldap.message.internal.InternalUnbindRequest;
 import org.apache.directory.shared.ldap.message.spi.BinaryAttributeDetector;
@@ -265,9 +265,9 @@ public class LdapMessageContainer extend
     /**
      * @return Returns the DelResponse stored in the container
      */
-    public DelResponseCodec getDelResponse()
+    public InternalDeleteResponse getInternalDelResponse()
     {
-        return ( DelResponseCodec ) ldapMessage;
+        return ( InternalDeleteResponse ) 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=984552&r1=984551&r2=984552&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
Wed Aug 11 19:37:46 2010
@@ -74,7 +74,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.compare.CompareResponseCodec;
 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.del.DelResponseCodec;
 import org.apache.directory.shared.ldap.codec.extended.ExtendedRequestCodec;
 import org.apache.directory.shared.ldap.codec.extended.ExtendedResponseCodec;
 import org.apache.directory.shared.ldap.codec.intermediate.IntermediateResponseCodec;
@@ -112,6 +111,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalBindResponse;
 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.InternalDeleteResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
 import org.apache.directory.shared.ldap.message.internal.InternalUnbindRequest;
 import org.apache.directory.shared.ldap.name.DN;
@@ -2095,9 +2095,8 @@ public class LdapMessageGrammar extends 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer )
container;
 
                     // Now, we can allocate the DelResponse Object
-                    DelResponseCodec delResponse = new DelResponseCodec();
-                    delResponse.setMessageId( ldapMessageContainer.getMessageId() );
-                    ldapMessageContainer.setLdapMessage( delResponse );
+                    InternalDeleteResponse delResponse = new DeleteResponseImpl( ldapMessageContainer.getMessageId()
);
+                    ldapMessageContainer.setInternalMessage( delResponse );
 
                     log.debug( "Del 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=984552&r1=984551&r2=984552&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
Wed Aug 11 19:37:46 2010
@@ -32,8 +32,10 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.codec.controls.CodecControl;
 import org.apache.directory.shared.ldap.message.BindResponseImpl;
+import org.apache.directory.shared.ldap.message.DeleteResponseImpl;
 import org.apache.directory.shared.ldap.message.control.Control;
 import org.apache.directory.shared.ldap.message.internal.InternalBindResponse;
+import org.apache.directory.shared.ldap.message.internal.InternalDeleteResponse;
 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.InternalReferral;
@@ -97,7 +99,7 @@ public class LdapProtocolEncoder extends
         int length = computeMessageLength( message );
         ByteBuffer buffer = ByteBuffer.allocate( length );
 
-        if ( message instanceof InternalBindResponse )
+        if ( ( message instanceof InternalBindResponse ) || ( message instanceof InternalDeleteResponse
) )
         {
             try
             {
@@ -270,6 +272,7 @@ public class LdapProtocolEncoder extends
             byte[] matchedDNBytes = StringTools.getBytesUtf8( StringTools
                 .trimLeft( ldapResult.getMatchedDn().getName() ) );
             ldapResultLength += 1 + TLV.getNbBytes( matchedDNBytes.length ) + matchedDNBytes.length;
+            ldapResult.setMatchedDnBytes( matchedDNBytes );
         }
 
         // The errorMessage length
@@ -295,6 +298,8 @@ public class LdapProtocolEncoder extends
                     referral.addLdapUrlBytes( ldapUrlBytes );
                 }
 
+                ldapResult.setReferralsLength( referralsLength );
+
                 // The referrals
                 ldapResultLength += 1 + TLV.getNbBytes( referralsLength ) + referralsLength;
             }
@@ -340,20 +345,20 @@ public class LdapProtocolEncoder extends
 
         if ( referral != null )
         {
-            Collection<String> ldapUrls = referral.getLdapUrls();
+            Collection<byte[]> ldapUrlsBytes = referral.getLdapUrlsBytes();
 
-            if ( ( ldapUrls != null ) && ( ldapUrls.size() != 0 ) )
+            if ( ( ldapUrlsBytes != null ) && ( ldapUrlsBytes.size() != 0 ) )
             {
                 // Encode the referrals sequence
                 // The referrals length MUST have been computed before !
                 buffer.put( ( byte ) LdapConstants.LDAP_RESULT_REFERRAL_SEQUENCE_TAG );
-                //buffer.put( TLV.getBytes( referralsLength ) );
+                buffer.put( TLV.getBytes( ldapResult.getReferralsLength() ) );
 
                 // Each referral
-                for ( String ldapUrl : ldapUrls )
+                for ( byte[] ldapUrlBytes : ldapUrlsBytes )
                 {
                     // Encode the current referral
-                    //Value.encode( buffer, referral.getBytesReference() );
+                    Value.encode( buffer, ldapUrlBytes );
                 }
             }
         }
@@ -396,6 +401,29 @@ public class LdapProtocolEncoder extends
 
 
     /**
+     * Compute the DelResponse length 
+     * 
+     * DelResponse :
+     * 
+     * 0x6B L1
+     *  |
+     *  +--> LdapResult
+     * 
+     * L1 = Length(LdapResult)
+     * 
+     * Length(DelResponse) = Length(0x6B) + Length(L1) + L1
+     */
+    private int computeDeleteResponseLength( DeleteResponseImpl deleteResponse )
+    {
+        int deleteResponseLength = computeLdapResultLength( deleteResponse.getLdapResult()
);
+
+        deleteResponse.setDeleteResponseLength( deleteResponseLength );
+
+        return 1 + TLV.getNbBytes( deleteResponseLength ) + deleteResponseLength;
+    }
+
+
+    /**
      * Encode the BindResponse message to a PDU.
      * 
      * BindResponse :
@@ -441,6 +469,29 @@ public class LdapProtocolEncoder extends
 
 
     /**
+     * Encode the DelResponse message to a PDU.
+     * 
+     * @param buffer The buffer where to put the PDU
+     */
+    private void encodeDeleteResponse( ByteBuffer buffer, DeleteResponseImpl deleteResponse
) throws EncoderException
+    {
+        try
+        {
+            // The BindResponse Tag
+            buffer.put( LdapConstants.DEL_RESPONSE_TAG );
+            buffer.put( TLV.getBytes( deleteResponse.getDeleteResponseLength() ) );
+
+            // The LdapResult
+            encodeLdapResult( buffer, deleteResponse.getLdapResult() );
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException( I18n.err( I18n.ERR_04005 ) );
+        }
+    }
+
+
+    /**
      * Compute the BindRequest length 
      * 
      * BindRequest : 
@@ -464,6 +515,9 @@ public class LdapProtocolEncoder extends
             case BIND_RESPONSE:
                 return computeBindResponseLength( ( BindResponseImpl ) message );
 
+            case DEL_RESPONSE:
+                return computeDeleteResponseLength( ( DeleteResponseImpl ) message );
+
             default:
                 return 0;
         }
@@ -476,6 +530,11 @@ public class LdapProtocolEncoder extends
         {
             case BIND_RESPONSE:
                 encodeBindResponse( bb, ( BindResponseImpl ) message );
+                break;
+
+            case DEL_RESPONSE:
+                encodeDeleteResponse( bb, ( DeleteResponseImpl ) 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=984552&r1=984551&r2=984552&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
Wed Aug 11 19:37:46 2010
@@ -32,7 +32,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.bind.SaslCredentials;
 import org.apache.directory.shared.ldap.codec.bind.SimpleAuthentication;
 import org.apache.directory.shared.ldap.codec.compare.CompareResponseCodec;
-import org.apache.directory.shared.ldap.codec.del.DelResponseCodec;
 import org.apache.directory.shared.ldap.codec.extended.ExtendedRequestCodec;
 import org.apache.directory.shared.ldap.codec.extended.ExtendedResponseCodec;
 import org.apache.directory.shared.ldap.codec.intermediate.IntermediateResponseCodec;
@@ -75,7 +74,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.message.BindRequestImpl;
 import org.apache.directory.shared.ldap.message.CompareResponseImpl;
-import org.apache.directory.shared.ldap.message.DeleteResponseImpl;
 import org.apache.directory.shared.ldap.message.ExtendedRequestImpl;
 import org.apache.directory.shared.ldap.message.ExtendedResponseImpl;
 import org.apache.directory.shared.ldap.message.IntermediateResponseImpl;
@@ -751,25 +749,6 @@ public class LdapTransformer
 
 
     /**
-     * Transform a Internal DelResponse to a Codec DelResponse
-     * 
-     * @param internalMessage The incoming Internal DelResponse
-     * @return The DelResponseCodec instance
-     */
-    private static LdapMessageCodec transformDelResponse( InternalMessage internalMessage
)
-    {
-        DeleteResponseImpl internalDelResponse = ( DeleteResponseImpl ) internalMessage;
-
-        DelResponseCodec delResponse = new DelResponseCodec();
-
-        // Transform the ldapResult
-        delResponse.setLdapResult( transformLdapResult( ( LdapResultImpl ) internalDelResponse.getLdapResult()
) );
-
-        return delResponse;
-    }
-
-
-    /**
      * Transform a Internal ExtendedResponse to a Codec ExtendedResponse
      * 
      * @param internalMessage The incoming Internal ExtendedResponse
@@ -997,10 +976,6 @@ public class LdapTransformer
                 codecMessage = transformCompareResponse( msg );
                 break;
 
-            case DEL_RESPONSE:
-                codecMessage = transformDelResponse( msg );
-                break;
-
             case MODIFY_RESPONSE:
                 codecMessage = transformModifyResponse( msg );
                 break;

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/DeleteResponseImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/DeleteResponseImpl.java?rev=984552&r1=984551&r2=984552&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/DeleteResponseImpl.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/DeleteResponseImpl.java
Wed Aug 11 19:37:46 2010
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.shared.ldap.message;
 
+
 import org.apache.directory.shared.ldap.message.internal.InternalAbstractResultResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalDeleteResponse;
 
@@ -31,6 +32,9 @@ import org.apache.directory.shared.ldap.
 public class DeleteResponseImpl extends InternalAbstractResultResponse implements InternalDeleteResponse
 {
 
+    /** The encoded deleteResponse length */
+    private int deleteResponseLength;
+
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
@@ -44,8 +48,26 @@ public class DeleteResponseImpl extends 
      * @param id
      *            the session unique message id
      */
-    public DeleteResponseImpl(final int id)
+    public DeleteResponseImpl( final int id )
     {
         super( id, TYPE );
     }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setDeleteResponseLength( int deleteResponseLength )
+    {
+        this.deleteResponseLength = deleteResponseLength;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getDeleteResponseLength()
+    {
+        return deleteResponseLength;
+    }
 }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/LdapResultImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/LdapResultImpl.java?rev=984552&r1=984551&r2=984552&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/LdapResultImpl.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/LdapResultImpl.java
Wed Aug 11 19:37:46 2010
@@ -53,10 +53,30 @@ public class LdapResultImpl implements I
     /** Resultant operation error code - defaults to SUCCESS */
     private ResultCodeEnum resultCode = ResultCodeEnum.SUCCESS;
 
+    /** The length of all the referrals */
+    private int referralsLength;
+
 
     // ------------------------------------------------------------------------
     // LdapResult Interface Method Implementations
     // ------------------------------------------------------------------------
+    /**
+     * {@inheritDoc}
+     */
+    public int getReferralsLength()
+    {
+        return referralsLength;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setReferralsLength( int referralsLength )
+    {
+        this.referralsLength = referralsLength;
+    }
+
 
     /**
      * Gets the descriptive error message associated with the error code. May be

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalDeleteResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalDeleteResponse.java?rev=984552&r1=984551&r2=984552&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalDeleteResponse.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalDeleteResponse.java
Wed Aug 11 19:37:46 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 InternalDeleteResponse 
 {
     /** Delete response message type enumeration value */
     MessageTypeEnum TYPE = MessageTypeEnum.DEL_RESPONSE;
+
+
+    /**
+     * Stores the encoded length for the DeleteResponse
+     * @param deleteResponseLength The encoded length
+     */
+    void setDeleteResponseLength( int deleteResponseLength );
+
+
+    /**
+     * @return The encoded DeleteResponse's length
+     */
+    int getDeleteResponseLength();
 }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalLdapResult.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalLdapResult.java?rev=984552&r1=984551&r2=984552&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalLdapResult.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalLdapResult.java
Wed Aug 11 19:37:46 2010
@@ -161,4 +161,17 @@ public interface InternalLdapResult
      *            optional referral on REFERRAL errors.
      */
     void setReferral( InternalReferral referral );
+
+
+    /**
+     * @return The total length of the Referral's URL
+     */
+    int getReferralsLength();
+
+
+    /**
+     * Set the length of all the referral' URL
+     * @param referralsLength The total length of the Referral
+     */
+    void setReferralsLength( int referralsLength );
 }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/del/DelResponseTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/del/DelResponseTest.java?rev=984552&r1=984551&r2=984552&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/del/DelResponseTest.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/codec/del/DelResponseTest.java
Wed Aug 11 19:37:46 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.InternalDeleteResponse;
 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 DelResponseTest
 {
+    /** The encoder instance */
+    LdapProtocolEncoder encoder = new LdapProtocolEncoder();
+
+
     /**
      * Test the decoding of a DelResponse
      */
@@ -61,18 +67,24 @@ public class DelResponseTest
         ByteBuffer stream = ByteBuffer.allocate( 0x2D );
 
         stream.put( new byte[]
-            { 0x30, 0x2B, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x6B, 0x26, // CHOICE { ..., delResponse DelResponse, ...
+            { 0x30,
+                0x2B, // LDAPMessage ::=SEQUENCE {
+                0x02, 0x01,
+                0x01, // messageID MessageID
+                0x6B,
+                0x26, // CHOICE { ..., delResponse DelResponse, ...
                 // DelResponse ::= [APPLICATION 11] LDAPResult
-                0x0A, 0x01, 0x21, // LDAPResult ::= SEQUENCE {
+                0x0A,
+                0x01,
+                0x21, // LDAPResult ::= SEQUENCE {
                 // resultCode ENUMERATED {
                 // success (0), ...
                 // },
-                0x04, 0x1F, // matchedDN LDAPDN,
+                0x04,
+                0x1F, // matchedDN LDAPDN,
                 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd',
'c', '=', 'e', 'x', 'a',
                 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x04, 0x00 // errorMessage
-                                                                                    // LDAPString,
+            // LDAPString,
             // referral [3] Referral OPTIONAL }
             // }
             } );
@@ -95,20 +107,20 @@ public class DelResponseTest
         }
 
         // Check the decoded DelResponse PDU
-        DelResponseCodec delResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getDelResponse();
+        InternalDeleteResponse delResponse = ( ( LdapMessageContainer ) ldapMessageContainer
).getInternalDelResponse();
 
         assertEquals( 1, delResponse.getMessageId() );
         assertEquals( ResultCodeEnum.ALIAS_PROBLEM, delResponse.getLdapResult().getResultCode()
);
-        assertEquals( "uid=akarasulu,dc=example,dc=com", delResponse.getLdapResult().getMatchedDN()
);
+        assertEquals( "uid=akarasulu,dc=example,dc=com", delResponse.getLdapResult().getMatchedDn().getName()
);
         assertEquals( "", delResponse.getLdapResult().getErrorMessage() );
 
-        // Check the length
-        assertEquals( 0x2D, delResponse.computeLength() );
-
         // Check the encoding
         try
         {
-            ByteBuffer bb = delResponse.encode();
+            ByteBuffer bb = encoder.encodeMessage( delResponse );
+
+            // Check the length
+            assertEquals( 0x02D, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 
@@ -169,21 +181,33 @@ public class DelResponseTest
         ByteBuffer stream = ByteBuffer.allocate( 0x4A );
 
         stream.put( new byte[]
-            { 0x30, 0x48, // LDAPMessage ::=SEQUENCE {
-                0x02, 0x01, 0x01, // messageID MessageID
-                0x6B, 0x26, // CHOICE { ..., delResponse DelResponse, ...
+            {
+                0x30,
+                0x48, // LDAPMessage ::=SEQUENCE {
+                0x02,
+                0x01,
+                0x01, // messageID MessageID
+                0x6B,
+                0x26, // CHOICE { ..., delResponse DelResponse, ...
                 // DelResponse ::= [APPLICATION 11] LDAPResult
-                0x0A, 0x01, 0x21, // LDAPResult ::= SEQUENCE {
+                0x0A,
+                0x01,
+                0x21, // LDAPResult ::= SEQUENCE {
                 // resultCode ENUMERATED {
                 // success (0), ...
                 // },
-                0x04, 0x1F, // matchedDN LDAPDN,
+                0x04,
+                0x1F, // matchedDN LDAPDN,
                 'u', 'i', 'd', '=', 'a', 'k', 'a', 'r', 'a', 's', 'u', 'l', 'u', ',', 'd',
'c', '=', 'e', 'x', 'a',
-                'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm', 0x04, 0x00, // errorMessage
-                                                                                    // LDAPString,
+                'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o',
+                'm',
+                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
 
@@ -207,29 +231,29 @@ public class DelResponseTest
         }
 
         // Check the decoded DelResponse PDU
-        DelResponseCodec delResponse = ( ( LdapMessageContainer ) ldapMessageContainer ).getDelResponse();
+        InternalDeleteResponse delResponse = ( ( LdapMessageContainer ) ldapMessageContainer
).getInternalDelResponse();
 
         assertEquals( 1, delResponse.getMessageId() );
         assertEquals( ResultCodeEnum.ALIAS_PROBLEM, delResponse.getLdapResult().getResultCode()
);
-        assertEquals( "uid=akarasulu,dc=example,dc=com", delResponse.getLdapResult().getMatchedDN()
);
+        assertEquals( "uid=akarasulu,dc=example,dc=com", delResponse.getLdapResult().getMatchedDn().getName()
);
         assertEquals( "", delResponse.getLdapResult().getErrorMessage() );
 
-        // Check the length
-        assertEquals( 0x4A, delResponse.computeLength() );
-
         // Check the Control
-        List<Control> controls = delResponse.getControls();
+        Map<String, Control> controls = delResponse.getControls();
 
         assertEquals( 1, controls.size() );
 
-        Control control = delResponse.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 encoding
         try
         {
-            ByteBuffer bb = delResponse.encode();
+            ByteBuffer bb = encoder.encodeMessage( delResponse );
+
+            // Check the length
+            assertEquals( 0x4A, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 

Modified: directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/message/LdapResultImplTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/message/LdapResultImplTest.java?rev=984552&r1=984551&r2=984552&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/message/LdapResultImplTest.java
(original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/message/LdapResultImplTest.java
Wed Aug 11 19:37:46 2010
@@ -163,6 +163,17 @@ public class LdapResultImplTest
             public void setErrorMessageBytes( byte[] errorMessageBytes )
             {
             }
+
+
+            public int getReferralsLength()
+            {
+                return 0;
+            }
+
+
+            public void setReferralsLength( int referralsLength )
+            {
+            }
         };
 
         assertTrue( "r0 equals should see other impl r1 as equal", r0.equals( r1 ) );



Mime
View raw message