directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r984726 [1/2] - in /directory: apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap...
Date Thu, 12 Aug 2010 11:43:55 GMT
Author: elecharny
Date: Thu Aug 12 11:43:54 2010
New Revision: 984726

URL: http://svn.apache.org/viewvc?rev=984726&view=rev
Log:
o Removed the ExtendedResponseCodec class, and fixed the code accordingly
o Renaming some fields in the ExtendedResponse class

Removed:
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/extended/ExtendedResponseCodec.java
Modified:
    directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ExtendedHandler.java
    directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java
    directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StoredProcedureExtendedOperationHandler.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/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/codec/actions/InitReferralsAction.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseAction.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseNameAction.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/ExtendedResponseImpl.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/CancelResponse.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/StoredProcedureRequest.java
    directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalExtendedResponse.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/codec/extended/ExtendedResponseTest.java
    directory/shared/branches/shared-codec-merge/ldap/src/test/java/org/apache/directory/shared/ldap/message/ExtendedResponseImplTest.java

Modified: directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ExtendedHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ExtendedHandler.java?rev=984726&r1=984725&r2=984726&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ExtendedHandler.java (original)
+++ directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ExtendedHandler.java Thu Aug 12 11:43:54 2010
@@ -1,22 +1,22 @@
-    /*
- *  Licensed to the Apache Software Foundation (ASF) under one
- *  or more contributor license agreements.  See the NOTICE file
- *  distributed with this work for additional information
- *  regarding copyright ownership.  The ASF licenses this file
- *  to you under the Apache License, Version 2.0 (the
- *  "License"); you may not use this file except in compliance
- *  with the License.  You may obtain a copy of the License at
- *  
- *    http://www.apache.org/licenses/LICENSE-2.0
- *  
- *  Unless required by applicable law or agreed to in writing,
- *  software distributed under the License is distributed on an
- *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- *  KIND, either express or implied.  See the License for the
- *  specific language governing permissions and limitations
- *  under the License. 
- *  
- */
+/*
+*  Licensed to the Apache Software Foundation (ASF) under one
+*  or more contributor license agreements.  See the NOTICE file
+*  distributed with this work for additional information
+*  regarding copyright ownership.  The ASF licenses this file
+*  to you under the Apache License, Version 2.0 (the
+*  "License"); you may not use this file except in compliance
+*  with the License.  You may obtain a copy of the License at
+*  
+*    http://www.apache.org/licenses/LICENSE-2.0
+*  
+*  Unless required by applicable law or agreed to in writing,
+*  software distributed under the License is distributed on an
+*  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+*  KIND, either express or implied.  See the License for the
+*  specific language governing permissions and limitations
+*  under the License. 
+*  
+*/
 package org.apache.directory.server.ldap.handlers;
 
 
@@ -51,7 +51,7 @@ public class ExtendedHandler extends Lda
             session.getIoSession().write( req.getResultResponse() );
             return;
         }
-        
+
         try
         {
             handler.handleExtendedOperation( session, req );
@@ -60,11 +60,11 @@ public class ExtendedHandler extends Lda
         {
             InternalLdapResult result = req.getResultResponse().getLdapResult();
             result.setResultCode( ResultCodeEnum.OTHER );
-            result.setErrorMessage( ResultCodeEnum.OTHER  
+            result.setErrorMessage( ResultCodeEnum.OTHER
                 + ": Extended operation handler for the specified EXTENSION_OID (" + req.getOid()
                 + ") has failed to process your request:\n" + ExceptionUtils.getStackTrace( e ) );
             InternalExtendedResponse resp = ( InternalExtendedResponse ) req.getResultResponse();
-            resp.setResponse( new byte[0] );
+            resp.setEncodedValue( new byte[0] );
             session.getIoSession().write( req.getResultResponse() );
         }
     }

Modified: directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java?rev=984726&r1=984725&r2=984726&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java (original)
+++ directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StartTlsHandler.java Thu Aug 12 11:43:54 2010
@@ -63,25 +63,24 @@ public class StartTlsHandler implements 
 
     private static final Set<String> EXTENSION_OIDS;
     private static final Logger LOG = LoggerFactory.getLogger( StartTlsHandler.class );
-    
+
     private SSLContext sslContext;
 
-    
     static
     {
         Set<String> set = new HashSet<String>( 3 );
         set.add( EXTENSION_OID );
         EXTENSION_OIDS = Collections.unmodifiableSet( set );
     }
-    
+
 
     public void handleExtendedOperation( LdapSession session, InternalExtendedRequest req ) throws Exception
     {
         LOG.info( "Handling StartTLS request." );
-        
+
         IoFilterChain chain = session.getIoSession().getFilterChain();
         SslFilter sslFilter = ( SslFilter ) chain.get( "sslFilter" );
-        if( sslFilter == null )
+        if ( sslFilter == null )
         {
             sslFilter = new SslFilter( sslContext );
             chain.addFirst( "sslFilter", sslFilter );
@@ -90,19 +89,18 @@ public class StartTlsHandler implements 
         {
             sslFilter.startSsl( session.getIoSession() );
         }
-        
+
         InternalExtendedResponse res = new ExtendedResponseImpl( req.getMessageId() );
         InternalLdapResult result = res.getLdapResult();
         result.setResultCode( ResultCodeEnum.SUCCESS );
-        res.setResponseName( EXTENSION_OID );
-        res.setResponse( new byte[ 0 ] );
+        res.setID( EXTENSION_OID );
+        res.setEncodedValue( new byte[0] );
 
         // Send a response.
         session.getIoSession().setAttribute( SslFilter.DISABLE_ENCRYPTION_ONCE );
         session.getIoSession().write( res );
     }
-    
-    
+
     class ServerX509TrustManager implements X509TrustManager
     {
         public void checkClientTrusted( X509Certificate[] chain, String authType ) throws CertificateException
@@ -110,11 +108,13 @@ public class StartTlsHandler implements 
             LOG.debug( "checkClientTrusted() called" );
         }
 
+
         public void checkServerTrusted( X509Certificate[] chain, String authType ) throws CertificateException
         {
             LOG.debug( "checkServerTrusted() called" );
         }
 
+
         public X509Certificate[] getAcceptedIssuers()
         {
             LOG.debug( "getAcceptedIssuers() called" );
@@ -134,14 +134,16 @@ public class StartTlsHandler implements 
         return EXTENSION_OID;
     }
 
-    
+
     public void setLdapServer( LdapServer ldapServer )
     {
         LOG.debug( "Setting LDAP Service" );
         Provider provider = Security.getProvider( "SUN" );
         LOG.debug( "provider = {}", provider );
         CoreKeyStoreSpi coreKeyStoreSpi = new CoreKeyStoreSpi( ldapServer.getDirectoryService() );
-        KeyStore keyStore = new KeyStore( coreKeyStoreSpi, provider, "JKS" ) {};
+        KeyStore keyStore = new KeyStore( coreKeyStoreSpi, provider, "JKS" )
+        {
+        };
 
         try
         {
@@ -151,7 +153,7 @@ public class StartTlsHandler implements 
         {
             throw new RuntimeException( I18n.err( I18n.ERR_678 ) );
         }
-        
+
         KeyManagerFactory keyManagerFactory = null;
         try
         {
@@ -161,7 +163,7 @@ public class StartTlsHandler implements 
         {
             throw new RuntimeException( I18n.err( I18n.ERR_679 ), e );
         }
-        
+
         try
         {
             keyManagerFactory.init( keyStore, null );
@@ -170,7 +172,7 @@ public class StartTlsHandler implements 
         {
             throw new RuntimeException( I18n.err( I18n.ERR_680 ), e );
         }
-        
+
         try
         {
             sslContext = SSLContext.getInstance( "TLS" );
@@ -179,12 +181,11 @@ public class StartTlsHandler implements 
         {
             throw new RuntimeException( I18n.err( I18n.ERR_681 ), e );
         }
-        
+
         try
         {
-            sslContext.init( keyManagerFactory.getKeyManagers(), 
-                new TrustManager[] { new ServerX509TrustManager() }, 
-                new SecureRandom() );
+            sslContext.init( keyManagerFactory.getKeyManagers(), new TrustManager[]
+                { new ServerX509TrustManager() }, new SecureRandom() );
         }
         catch ( Exception e )
         {

Modified: directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StoredProcedureExtendedOperationHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StoredProcedureExtendedOperationHandler.java?rev=984726&r1=984725&r2=984726&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StoredProcedureExtendedOperationHandler.java (original)
+++ directory/apacheds/branches/apacheds-codec-merge/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/extended/StoredProcedureExtendedOperationHandler.java Thu Aug 12 11:43:54 2010
@@ -60,8 +60,8 @@ public class StoredProcedureExtendedOper
 {
     private StoredProcExecutionManager manager;
     private static final Object[] EMPTY_CLASS_ARRAY = new Object[0];
-    
-    
+
+
     public StoredProcedureExtendedOperationHandler()
     {
         super();
@@ -78,37 +78,38 @@ public class StoredProcedureExtendedOper
     public void handleExtendedOperation( LdapSession session, InternalExtendedRequest req ) throws Exception
     {
         StoredProcedure spBean = decodeBean( req.getPayload() );
-        
+
         String procedure = StringTools.utf8ToString( spBean.getProcedure() );
         ClonedServerEntry spUnit = manager.findStoredProcUnit( session.getCoreSession(), procedure );
         StoredProcEngine engine = manager.getStoredProcEngineInstance( spUnit );
-        
+
         List<Object> valueList = new ArrayList<Object>( spBean.getParameters().size() );
-        
-        for ( StoredProcedureParameter pPojo:spBean.getParameters() )
+
+        for ( StoredProcedureParameter pPojo : spBean.getParameters() )
         {
             byte[] serializedValue = pPojo.getValue();
             Object value = SerializationUtils.deserialize( serializedValue );
-            
+
             if ( value.getClass().equals( LdapContextParameter.class ) )
             {
                 String paramCtx = ( ( LdapContextParameter ) value ).getValue();
                 value = session.getCoreSession().lookup( new DN( paramCtx ) );
             }
-            
+
             valueList.add( value );
         }
-        
+
         Object[] values = valueList.toArray( EMPTY_CLASS_ARRAY );
-        
+
         Object response = engine.invokeProcedure( session.getCoreSession(), procedure, values );
-        
+
         byte[] serializedResponse = SerializationUtils.serialize( ( Serializable ) response );
-        ( ( InternalExtendedResponse )( req.getResultResponse() ) ).setResponse( serializedResponse );
+        ( ( InternalExtendedResponse ) ( req.getResultResponse() ) ).setEncodedValue( serializedResponse );
         session.getIoSession().write( req.getResultResponse() );
-        
+
     }
-    
+
+
     private StoredProcedure decodeBean( byte[] payload )
     {
         Asn1Decoder storedProcedureDecoder = new StoredProcedureDecoder();
@@ -125,19 +126,18 @@ public class StoredProcedureExtendedOper
         }
 
         StoredProcedure spBean = ( ( StoredProcedureContainer ) storedProcedureContainer ).getStoredProcedure();
-        
+
         return spBean;
     }
 
-    
+
     public String getOid()
     {
         return StoredProcedureRequest.EXTENSION_OID;
     }
 
-
     private static final Set<String> EXTENSION_OIDS;
-    
+
     static
     {
         Set<String> s = new HashSet<String>();
@@ -145,8 +145,8 @@ public class StoredProcedureExtendedOper
         s.add( StoredProcedureResponse.EXTENSION_OID );
         EXTENSION_OIDS = Collections.unmodifiableSet( s );
     }
-    
-    
+
+
     public Set<String> getExtensionOids()
     {
         return EXTENSION_OIDS;

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=984726&r1=984725&r2=984726&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 Thu Aug 12 11:43:54 2010
@@ -47,7 +47,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.codec.bind.LdapAuthentication;
 import org.apache.directory.shared.ldap.codec.bind.SimpleAuthentication;
 import org.apache.directory.shared.ldap.codec.del.DelRequestCodec;
-import org.apache.directory.shared.ldap.codec.extended.ExtendedResponseCodec;
 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.unbind.UnBindRequestCodec;
@@ -62,6 +61,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.ldif.LdifReader;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.message.internal.InternalBindResponse;
+import org.apache.directory.shared.ldap.message.internal.InternalExtendedResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.name.RDN;
@@ -181,24 +181,20 @@ public class ImportCommand extends ToolC
                                 System.out.println( "Error : " + resp.getLdapResult().getErrorMessage() );
                             }
                         }
-                    }
-                    else
-                    {
-                        messageResp = ( ( LdapMessageContainer ) ldapMessageContainer ).getLdapMessage();
-
-                        if ( messageResp instanceof ExtendedResponseCodec )
+                        else if ( message instanceof InternalExtendedResponse )
                         {
-                            ExtendedResponseCodec resp = ( ( LdapMessageContainer ) ldapMessageContainer )
-                                .getExtendedResponse();
+                            InternalExtendedResponse response = ( ( LdapMessageContainer ) ldapMessageContainer )
+                                .getInternalExtendedResponse();
 
-                            if ( resp.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS )
+                            if ( response.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS )
                             {
-                                System.out.println( "Error : " + resp.getLdapResult().getErrorMessage() );
+                                System.out.println( "Error : " + response.getLdapResult().getErrorMessage() );
                             }
                         }
                     }
 
                     ( ( LdapMessageContainer ) ldapMessageContainer ).clean();
+
                     break;
                 }
                 else

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=984726&r1=984725&r2=984726&view=diff
==============================================================================
--- directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java (original)
+++ directory/clients/ldap/branches/ldap-client-codec-merge/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java Thu Aug 12 11:43:54 2010
@@ -97,7 +97,6 @@ import org.apache.directory.shared.ldap.
 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.extended.ExtendedRequestCodec;
-import org.apache.directory.shared.ldap.codec.extended.ExtendedResponseCodec;
 import org.apache.directory.shared.ldap.codec.intermediate.IntermediateResponseCodec;
 import org.apache.directory.shared.ldap.codec.modify.ModifyRequestCodec;
 import org.apache.directory.shared.ldap.codec.modify.ModifyResponseCodec;
@@ -129,6 +128,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalBindResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalCompareResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalDeleteResponse;
+import org.apache.directory.shared.ldap.message.internal.InternalExtendedResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalLdapResult;
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
 import org.apache.directory.shared.ldap.name.DN;
@@ -1729,33 +1729,9 @@ public class LdapNetworkConnection exten
 
                     break;
 
-            }
-        }
-        else
-        {
-            LdapMessageCodec response = ( LdapMessageCodec ) message;
-            LOG.debug( "-------> {} Message received <-------", response );
-            int messageId = response.getMessageId();
-
-            // this check is necessary to prevent adding an abandoned operation's
-            // result(s) to corresponding queue
-            ResponseFuture<? extends Response> responseFuture = peekFromFutureMap( messageId );
-
-            if ( responseFuture == null )
-            {
-                LOG.info( "There is no future associated with the messageId {}, ignoring the message", messageId );
-                return;
-            }
-
-            switch ( response.getMessageType() )
-            {
                 case EXTENDED_RESPONSE:
                     // Transform the response
-                    ExtendedResponseCodec extResCodec = ( ExtendedResponseCodec ) response;
-                    extResCodec.setMessageId( messageId );
-                    extResCodec.addControls( response.getControls() );
-
-                    ExtendedResponse extendedResponse = convert( extResCodec );
+                    ExtendedResponse extendedResponse = convert( ( InternalExtendedResponse ) response );
 
                     ExtendedFuture extendedFuture = ( ExtendedFuture ) responseFuture;
 
@@ -1788,6 +1764,26 @@ public class LdapNetworkConnection exten
 
                     break;
 
+            }
+        }
+        else
+        {
+            LdapMessageCodec response = ( LdapMessageCodec ) message;
+            LOG.debug( "-------> {} Message received <-------", response );
+            int messageId = response.getMessageId();
+
+            // this check is necessary to prevent adding an abandoned operation's
+            // result(s) to corresponding queue
+            ResponseFuture<? extends Response> responseFuture = peekFromFutureMap( messageId );
+
+            if ( responseFuture == null )
+            {
+                LOG.info( "There is no future associated with the messageId {}, ignoring the message", messageId );
+                return;
+            }
+
+            switch ( response.getMessageType() )
+            {
                 case INTERMEDIATE_RESPONSE:
                     IntermediateResponseCodec intermediateResponseCodec = ( IntermediateResponseCodec ) response;
                     intermediateResponseCodec.setMessageId( messageId );
@@ -3113,18 +3109,18 @@ public class LdapNetworkConnection exten
 
 
     /**
-     * converts the ExtendedResponseCodec to ExtendedResponse.
+     * converts the InternalExtendedResponse to ExtendedResponse.
      */
-    private ExtendedResponse convert( ExtendedResponseCodec extRespCodec )
+    private ExtendedResponse convert( InternalExtendedResponse internalExtendedResponse )
     {
         ExtendedResponse extResponse = new ExtendedResponse();
 
         OID oid = null;
         try
         {
-            if ( extRespCodec.getResponseName() != null )
+            if ( internalExtendedResponse.getID() != null )
             {
-                oid = new OID( extRespCodec.getResponseName() );
+                oid = new OID( internalExtendedResponse.getID() );
             }
         }
         catch ( DecoderException e )
@@ -3134,11 +3130,11 @@ public class LdapNetworkConnection exten
         }
 
         extResponse.setOid( oid );
-        extResponse.setValue( extRespCodec.getResponse() );
-        extResponse.setMessageId( extRespCodec.getMessageId() );
-        extResponse.setLdapResult( convert( extRespCodec.getLdapResult() ) );
+        extResponse.setValue( internalExtendedResponse.getEncodedValue() );
+        extResponse.setMessageId( internalExtendedResponse.getMessageId() );
+        extResponse.setLdapResult( convert( internalExtendedResponse.getLdapResult() ) );
 
-        addControls( extRespCodec, extResponse );
+        addControls( internalExtendedResponse, extResponse );
 
         return extResponse;
     }

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=984726&r1=984725&r2=984726&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageContainer.java Thu Aug 12 11:43:54 2010
@@ -28,7 +28,6 @@ import org.apache.directory.shared.ldap.
 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.extended.ExtendedRequestCodec;
-import org.apache.directory.shared.ldap.codec.extended.ExtendedResponseCodec;
 import org.apache.directory.shared.ldap.codec.intermediate.IntermediateResponseCodec;
 import org.apache.directory.shared.ldap.codec.modify.ModifyRequestCodec;
 import org.apache.directory.shared.ldap.codec.modify.ModifyResponseCodec;
@@ -48,6 +47,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalCompareResponse;
 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.InternalExtendedResponse;
 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;
@@ -283,9 +283,9 @@ public class LdapMessageContainer extend
     /**
      * @return Returns the ExtendedResponse stored in the container
      */
-    public ExtendedResponseCodec getExtendedResponse()
+    public InternalExtendedResponse getInternalExtendedResponse()
     {
-        return ( ExtendedResponseCodec ) ldapMessage;
+        return ( InternalExtendedResponse ) 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=984726&r1=984725&r2=984726&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapMessageGrammar.java Thu Aug 12 11:43:54 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.extended.ExtendedRequestCodec;
-import org.apache.directory.shared.ldap.codec.extended.ExtendedResponseCodec;
 import org.apache.directory.shared.ldap.codec.intermediate.IntermediateResponseCodec;
 import org.apache.directory.shared.ldap.codec.modify.ModifyRequestCodec;
 import org.apache.directory.shared.ldap.codec.modify.ModifyResponseCodec;
@@ -97,6 +96,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.CompareResponseImpl;
 import org.apache.directory.shared.ldap.message.DeleteRequestImpl;
 import org.apache.directory.shared.ldap.message.DeleteResponseImpl;
+import org.apache.directory.shared.ldap.message.ExtendedResponseImpl;
 import org.apache.directory.shared.ldap.message.ModifyDnResponseImpl;
 import org.apache.directory.shared.ldap.message.ModifyResponseImpl;
 import org.apache.directory.shared.ldap.message.ReferralImpl;
@@ -113,6 +113,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.internal.InternalCompareResponse;
 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.InternalExtendedResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalLdapResult;
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
 import org.apache.directory.shared.ldap.message.internal.InternalReferral;
@@ -2973,9 +2974,9 @@ public class LdapMessageGrammar extends 
                     LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
 
                     // Now, we can allocate the ExtendedResponse Object
-                    ExtendedResponseCodec extendedResponse = new ExtendedResponseCodec();
-                    extendedResponse.setMessageId( ldapMessageContainer.getMessageId() );
-                    ldapMessageContainer.setLdapMessage( extendedResponse );
+                    InternalExtendedResponse extendedResponse = new ExtendedResponseImpl( ldapMessageContainer
+                        .getMessageId() );
+                    ldapMessageContainer.setInternalMessage( extendedResponse );
 
                     log.debug( "Extended 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=984726&r1=984725&r2=984726&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapProtocolEncoder.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapProtocolEncoder.java Thu Aug 12 11:43:54 2010
@@ -35,11 +35,13 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.BindResponseImpl;
 import org.apache.directory.shared.ldap.message.CompareResponseImpl;
 import org.apache.directory.shared.ldap.message.DeleteResponseImpl;
+import org.apache.directory.shared.ldap.message.ExtendedResponseImpl;
 import org.apache.directory.shared.ldap.message.control.Control;
 import org.apache.directory.shared.ldap.message.internal.InternalAddResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalBindResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalCompareResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalDeleteResponse;
+import org.apache.directory.shared.ldap.message.internal.InternalExtendedResponse;
 import org.apache.directory.shared.ldap.message.internal.InternalLdapResult;
 import org.apache.directory.shared.ldap.message.internal.InternalMessage;
 import org.apache.directory.shared.ldap.message.internal.InternalReferral;
@@ -104,7 +106,8 @@ public class LdapProtocolEncoder extends
         ByteBuffer buffer = ByteBuffer.allocate( length );
 
         if ( ( message instanceof InternalBindResponse ) || ( message instanceof InternalDeleteResponse )
-            || ( message instanceof InternalAddResponse ) || ( message instanceof InternalCompareResponse ) )
+            || ( message instanceof InternalAddResponse ) || ( message instanceof InternalCompareResponse )
+            || ( message instanceof InternalExtendedResponse ) )
         {
             try
             {
@@ -373,6 +376,29 @@ public class LdapProtocolEncoder extends
 
 
     /**
+     * Compute the AddResponse length 
+     * 
+     * AddResponse : 
+     * 
+     * 0x69 L1
+     *  |
+     *  +--> LdapResult
+     * 
+     * L1 = Length(LdapResult)
+     * 
+     * Length(AddResponse) = Length(0x69) + Length(L1) + L1
+     */
+    private int computeAddResponseLength( AddResponseImpl addResponse )
+    {
+        int addResponseLength = computeLdapResultLength( addResponse.getLdapResult() );
+
+        addResponse.setAddResponseLength( addResponseLength );
+
+        return 1 + TLV.getNbBytes( addResponseLength ) + addResponseLength;
+    }
+
+
+    /**
      * Compute the BindResponse length 
      * 
      * BindResponse : 
@@ -406,29 +432,6 @@ public class LdapProtocolEncoder extends
 
 
     /**
-     * Compute the AddResponse length 
-     * 
-     * AddResponse : 
-     * 
-     * 0x69 L1
-     *  |
-     *  +--> LdapResult
-     * 
-     * L1 = Length(LdapResult)
-     * 
-     * Length(AddResponse) = Length(0x69) + Length(L1) + L1
-     */
-    private int computeAddResponseLength( AddResponseImpl addResponse )
-    {
-        int addResponseLength = computeLdapResultLength( addResponse.getLdapResult() );
-
-        addResponse.setAddResponseLength( addResponseLength );
-
-        return 1 + TLV.getNbBytes( addResponseLength ) + addResponseLength;
-    }
-
-
-    /**
      * Compute the CompareResponse length 
      * 
      * CompareResponse :
@@ -475,6 +478,54 @@ public class LdapProtocolEncoder extends
 
 
     /**
+     * Compute the ExtendedResponse length
+     * 
+     * ExtendedResponse :
+     * 
+     * 0x78 L1
+     *  |
+     *  +--> LdapResult
+     * [+--> 0x8A L2 name
+     * [+--> 0x8B L3 response]]
+     * 
+     * L1 = Length(LdapResult)
+     *      [ + Length(0x8A) + Length(L2) + L2
+     *       [ + Length(0x8B) + Length(L3) + L3]]
+     * 
+     * Length(ExtendedResponse) = Length(0x78) + Length(L1) + L1
+     * 
+     * @return The ExtendedResponse length
+     */
+    private int computeExtendedResponseLength( InternalExtendedResponse extendedResponse )
+    {
+        int ldapResultLength = computeLdapResultLength( extendedResponse.getLdapResult() );
+
+        int extendedResponseLength = ldapResultLength;
+
+        String id = extendedResponse.getID();
+
+        if ( id != null )
+        {
+            byte[] idBytes = StringTools.getBytesUtf8( id );
+            extendedResponse.setIDBytes( idBytes );
+            int idLength = idBytes.length;
+            extendedResponseLength += 1 + TLV.getNbBytes( idLength ) + idLength;
+        }
+
+        byte[] encodedValue = extendedResponse.getEncodedValue();
+
+        if ( encodedValue != null )
+        {
+            extendedResponseLength += 1 + TLV.getNbBytes( encodedValue.length ) + encodedValue.length;
+        }
+
+        extendedResponse.setExtendedResponseLength( extendedResponseLength );
+
+        return 1 + TLV.getNbBytes( extendedResponseLength ) + extendedResponseLength;
+    }
+
+
+    /**
      * Encode the AddResponse message to a PDU.
      * 
      * @param buffer The buffer where to put the PDU
@@ -590,6 +641,64 @@ public class LdapProtocolEncoder extends
 
 
     /**
+     * Encode the ExtendedResponse message to a PDU. 
+     * ExtendedResponse :
+     * LdapResult.encode()
+     * [0x8A LL response name]
+     * [0x8B LL response]
+     * 
+     * @param buffer The buffer where to put the PDU
+     * @return The PDU.
+     */
+    private void encodeExtendedResponse( ByteBuffer buffer, ExtendedResponseImpl extendedResponse )
+        throws EncoderException
+    {
+        try
+        {
+            // The ExtendedResponse Tag
+            buffer.put( LdapConstants.EXTENDED_RESPONSE_TAG );
+            buffer.put( TLV.getBytes( extendedResponse.getExtendedResponseLength() ) );
+
+            // The LdapResult
+            encodeLdapResult( buffer, extendedResponse.getLdapResult() );
+
+            // The ID, if any
+            byte[] idBytes = extendedResponse.getIDBytes();
+
+            if ( idBytes != null )
+            {
+                buffer.put( ( byte ) LdapConstants.EXTENDED_RESPONSE_RESPONSE_NAME_TAG );
+                buffer.put( TLV.getBytes( idBytes.length ) );
+
+                if ( idBytes.length != 0 )
+                {
+                    buffer.put( idBytes );
+                }
+            }
+
+            // The encodedValue, if any
+            byte[] encodedValue = extendedResponse.getEncodedValue();
+
+            if ( encodedValue != null )
+            {
+                buffer.put( ( byte ) LdapConstants.EXTENDED_RESPONSE_RESPONSE_TAG );
+
+                buffer.put( TLV.getBytes( encodedValue.length ) );
+
+                if ( encodedValue.length != 0 )
+                {
+                    buffer.put( encodedValue );
+                }
+            }
+        }
+        catch ( BufferOverflowException boe )
+        {
+            throw new EncoderException( I18n.err( I18n.ERR_04005 ) );
+        }
+    }
+
+
+    /**
      * Compute the protocolOp length 
      */
     private int computeProtocolOpLength( InternalMessage message )
@@ -608,6 +717,9 @@ public class LdapProtocolEncoder extends
             case DEL_RESPONSE:
                 return computeDeleteResponseLength( ( DeleteResponseImpl ) message );
 
+            case EXTENDED_RESPONSE:
+                return computeExtendedResponseLength( ( ExtendedResponseImpl ) message );
+
             default:
                 return 0;
         }
@@ -633,6 +745,10 @@ public class LdapProtocolEncoder extends
             case DEL_RESPONSE:
                 encodeDeleteResponse( bb, ( DeleteResponseImpl ) message );
                 break;
+
+            case EXTENDED_RESPONSE:
+                encodeExtendedResponse( bb, ( ExtendedResponseImpl ) 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=984726&r1=984725&r2=984726&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/LdapTransformer.java Thu Aug 12 11:43:54 2010
@@ -31,7 +31,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.extended.ExtendedRequestCodec;
-import org.apache.directory.shared.ldap.codec.extended.ExtendedResponseCodec;
 import org.apache.directory.shared.ldap.codec.intermediate.IntermediateResponseCodec;
 import org.apache.directory.shared.ldap.codec.modify.ModifyRequestCodec;
 import org.apache.directory.shared.ldap.codec.modify.ModifyResponseCodec;
@@ -71,7 +70,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.ExtendedRequestImpl;
-import org.apache.directory.shared.ldap.message.ExtendedResponseImpl;
 import org.apache.directory.shared.ldap.message.IntermediateResponseImpl;
 import org.apache.directory.shared.ldap.message.LdapResultImpl;
 import org.apache.directory.shared.ldap.message.ModifyDnRequestImpl;
@@ -706,39 +704,6 @@ public class LdapTransformer
 
 
     /**
-     * Transform a Internal ExtendedResponse to a Codec ExtendedResponse
-     * 
-     * @param internalMessage The incoming Internal ExtendedResponse
-     * @return The ExtendedResponseCodec instance
-     */
-    private static LdapMessageCodec transformExtendedResponse( InternalMessage internalMessage )
-    {
-        ExtendedResponseImpl internalExtendedResponse = ( ExtendedResponseImpl ) internalMessage;
-        ExtendedResponseCodec extendedResponse = new ExtendedResponseCodec();
-
-        // Internal : String oid -> Codec : OID responseName
-        try
-        {
-            extendedResponse.setResponseName( new OID( internalExtendedResponse.getResponseName() ) );
-        }
-        catch ( DecoderException de )
-        {
-            LOG.warn( "The OID " + internalExtendedResponse.getResponseName() + " is invalid : " + de.getMessage() );
-            extendedResponse.setResponseName( null );
-        }
-
-        // Internal : byte [] value -> Codec : Object response
-        extendedResponse.setResponse( internalExtendedResponse.getResponse() );
-
-        // Transform the ldapResult
-        extendedResponse.setLdapResult( transformLdapResult( ( LdapResultImpl ) internalExtendedResponse
-            .getLdapResult() ) );
-
-        return extendedResponse;
-    }
-
-
-    /**
      * Transform a Internal IntermediateResponse to a Codec IntermediateResponse
      * 
      * @param internalMessage The incoming Internal IntermediateResponse
@@ -933,10 +898,6 @@ public class LdapTransformer
                 codecMessage = transformModifyDNResponse( msg );
                 break;
 
-            case EXTENDED_RESPONSE:
-                codecMessage = transformExtendedResponse( msg );
-                break;
-
             case INTERMEDIATE_RESPONSE:
                 codecMessage = transformIntermediateResponse( msg );
                 break;

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitReferralsAction.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitReferralsAction.java?rev=984726&r1=984725&r2=984726&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitReferralsAction.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitReferralsAction.java Thu Aug 12 11:43:54 2010
@@ -28,6 +28,10 @@ import org.apache.directory.shared.i18n.
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
 import org.apache.directory.shared.ldap.codec.LdapResponseCodec;
 import org.apache.directory.shared.ldap.codec.LdapResultCodec;
+import org.apache.directory.shared.ldap.message.ReferralImpl;
+import org.apache.directory.shared.ldap.message.internal.InternalLdapResult;
+import org.apache.directory.shared.ldap.message.internal.InternalReferral;
+import org.apache.directory.shared.ldap.message.internal.InternalResultResponse;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -45,38 +49,51 @@ public class InitReferralsAction extends
     /** Speedup for logs */
     private static final boolean IS_DEBUG = log.isDebugEnabled();
 
+
     public InitReferralsAction()
     {
         super( "Init the referrals list" );
     }
 
+
     /**
      * The initialization action
      */
     public void action( IAsn1Container container ) throws DecoderException
     {
         LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
-        LdapResponseCodec response = ldapMessageContainer.getLdapResponse();
-        LdapResultCodec ldapResult = response.getLdapResult();
-        
+
         TLV tlv = ldapMessageContainer.getCurrentTLV();
 
         // If we hae a Referrals sequence, then it should not be empty
-        // sasl credentials
         if ( tlv.getLength() == 0 )
         {
             String msg = I18n.err( I18n.ERR_04011 );
             log.error( msg );
-         
+
             // This will generate a PROTOCOL_ERROR
             throw new DecoderException( msg );
         }
 
-        if ( IS_DEBUG)
+        if ( ldapMessageContainer.isInternal() )
+        {
+            InternalResultResponse response = ( InternalResultResponse ) ldapMessageContainer.getInternalMessage();
+            InternalLdapResult ldapResult = response.getLdapResult();
+
+            InternalReferral referral = new ReferralImpl();
+            ldapResult.setReferral( referral );
+        }
+        else
+        {
+            LdapResponseCodec response = ldapMessageContainer.getLdapResponse();
+            LdapResultCodec ldapResult = response.getLdapResult();
+
+            ldapResult.initReferrals();
+        }
+
+        if ( IS_DEBUG )
         {
             log.debug( "Initialising a referrals list" );
         }
-        
-        ldapResult.initReferrals();
     }
 }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseAction.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseAction.java?rev=984726&r1=984725&r2=984726&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseAction.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseAction.java Thu Aug 12 11:43:54 2010
@@ -25,7 +25,7 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.tlv.TLV;
 import org.apache.directory.shared.asn1.codec.DecoderException;
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
-import org.apache.directory.shared.ldap.codec.extended.ExtendedResponseCodec;
+import org.apache.directory.shared.ldap.message.internal.InternalExtendedResponse;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -44,11 +44,13 @@ public class ResponseAction extends Gram
     /** Speedup for logs */
     private static final boolean IS_DEBUG = log.isDebugEnabled();
 
+
     public ResponseAction()
     {
         super( "Store response" );
     }
 
+
     /**
      * The initialization action
      */
@@ -58,7 +60,7 @@ public class ResponseAction extends Gram
         LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
 
         // We can allocate the ExtendedResponse Object
-        ExtendedResponseCodec extendedResponse = ldapMessageContainer.getExtendedResponse();
+        InternalExtendedResponse extendedResponse = ldapMessageContainer.getInternalExtendedResponse();
 
         // Get the Value and store it in the ExtendedResponse
         TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -67,11 +69,11 @@ public class ResponseAction extends Gram
         // OID
         if ( tlv.getLength() == 0 )
         {
-            extendedResponse.setResponse( StringTools.EMPTY_BYTES );
+            extendedResponse.setEncodedValue( StringTools.EMPTY_BYTES );
         }
         else
         {
-            extendedResponse.setResponse( tlv.getValue().getData() );
+            extendedResponse.setEncodedValue( tlv.getValue().getData() );
         }
 
         // We can have an END transition
@@ -79,7 +81,7 @@ public class ResponseAction extends Gram
 
         if ( IS_DEBUG )
         {
-            log.debug( "Extended value : {}", extendedResponse.getResponse() );
+            log.debug( "Extended value : {}", extendedResponse.getEncodedValue() );
         }
     }
 }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseNameAction.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseNameAction.java?rev=984726&r1=984725&r2=984726&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseNameAction.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/ResponseNameAction.java Thu Aug 12 11:43:54 2010
@@ -27,7 +27,7 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.primitives.OID;
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
-import org.apache.directory.shared.ldap.codec.extended.ExtendedResponseCodec;
+import org.apache.directory.shared.ldap.message.internal.InternalExtendedResponse;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -46,11 +46,13 @@ public class ResponseNameAction extends 
     /** Speedup for logs */
     private static final boolean IS_DEBUG = log.isDebugEnabled();
 
+
     public ResponseNameAction()
     {
         super( "Store response name" );
     }
 
+
     /**
      * The initialization action
      */
@@ -59,7 +61,7 @@ public class ResponseNameAction extends 
         LdapMessageContainer ldapMessageContainer = ( LdapMessageContainer ) container;
 
         // We can allocate the ExtendedResponse Object
-        ExtendedResponseCodec extendedResponse = ldapMessageContainer.getExtendedResponse();
+        InternalExtendedResponse extendedResponse = ldapMessageContainer.getInternalExtendedResponse();
 
         // Get the Value and store it in the ExtendedResponse
         TLV tlv = ldapMessageContainer.getCurrentTLV();
@@ -74,8 +76,7 @@ public class ResponseNameAction extends 
         }
         else
         {
-            extendedResponse
-                .setResponseName( new OID( StringTools.asciiBytesToString( tlv.getValue().getData() ) ) );
+            extendedResponse.setID( new OID( StringTools.asciiBytesToString( tlv.getValue().getData() ) ).toString() );
         }
 
         // We can have an END transition
@@ -83,7 +84,7 @@ public class ResponseNameAction extends 
 
         if ( IS_DEBUG )
         {
-            log.debug( "OID read : {}", extendedResponse.getResponseName() );
+            log.debug( "OID read : {}", extendedResponse.getID() );
         }
     }
 }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/ExtendedResponseImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/ExtendedResponseImpl.java?rev=984726&r1=984725&r2=984726&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/ExtendedResponseImpl.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/ExtendedResponseImpl.java Thu Aug 12 11:43:54 2010
@@ -27,7 +27,7 @@ import org.apache.directory.shared.ldap.
 
 
 /**
- * Lockable ExtendedResponse implementation
+ * ExtendedResponse implementation
  * 
  * @author <a href="mailto:dev@directory.apache.org"> Apache Directory Project</a>
  */
@@ -38,19 +38,24 @@ public class ExtendedResponseImpl extend
     /** Object identifier for the extended response */
     protected String oid;
 
+    /** The response name as a byte[] */
+    private byte[] oidBytes;
+
     /** Values encoded in the extended response payload */
     protected byte[] value;
 
+    /** The encoded extendedResponse length */
+    private int extendedResponseLength;
+
 
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
 
     /**
-     * Creates a Lockable ExtendedResponse as a reply to an ExtendedRequest.
+     * Creates an ExtendedResponse as a reply to an ExtendedRequest.
      * 
-     * @param id
-     *            the session unique message id
+     * @param id the session unique message id
      */
     public ExtendedResponseImpl( final int id, String oid )
     {
@@ -68,32 +73,13 @@ public class ExtendedResponseImpl extend
     // ------------------------------------------------------------------------
     // ExtendedResponse Interface Method Implementations
     // ------------------------------------------------------------------------
-
-    /**
-     * Gets the reponse OID specific encoded response values.
-     * 
-     * @return the response specific encoded response values.
-     */
-    public byte[] getResponse()
-    {
-        if ( value == null )
-        {
-            return null;
-        }
-
-        final byte[] copy = new byte[value.length];
-        System.arraycopy( value, 0, copy, 0, value.length );
-        return copy;
-    }
-
-
     /**
      * Sets the response OID specific encoded response values.
      * 
      * @param value
      *            the response specific encoded response values.
      */
-    public void setResponse( byte[] value )
+    public void setEncodedValue( byte[] value )
     {
         if ( value != null )
         {
@@ -107,34 +93,37 @@ public class ExtendedResponseImpl extend
     }
 
 
-    public void setOid( String oid )
+    /**
+     * Gets the OID bytes.
+     * 
+     * @return the OID bytes of the extended response type.
+     */
+    public byte[] getIDBytes()
     {
-        this.oid = oid;
+        return oidBytes;
     }
 
 
     /**
-     * Gets the OID uniquely identifying this extended response (a.k.a. its
+     * Sets the OID uniquely identifying this extended response (a.k.a. its
      * name).
      * 
-     * @return the OID of the extended response type.
+     * @param oid the OID of the extended response type.
      */
-    public String getResponseName()
+    public void setID( String oid )
     {
-        return oid;
+        this.oid = oid;
     }
 
 
     /**
-     * Sets the OID uniquely identifying this extended response (a.k.a. its
-     * name).
+     * Sets the OID bytes.
      * 
-     * @param oid
-     *            the OID of the extended response type.
+     * @param oidBytes the OID bytes of the extended response type.
      */
-    public void setResponseName( String oid )
+    public void setIDBytes( byte[] oidBytes )
     {
-        this.oid = oid;
+        this.oidBytes = oidBytes;
     }
 
 
@@ -185,32 +174,32 @@ public class ExtendedResponseImpl extend
 
         InternalExtendedResponse resp = ( InternalExtendedResponse ) obj;
 
-        if ( oid != null && resp.getResponseName() == null )
+        if ( ( oid != null ) && ( resp.getID() == null ) )
         {
             return false;
         }
 
-        if ( oid == null && resp.getResponseName() != null )
+        if ( ( oid == null ) && ( resp.getID() != null ) )
         {
             return false;
         }
 
-        if ( oid != null && resp.getResponseName() != null && !oid.equals( resp.getResponseName() ) )
+        if ( ( oid != null ) && ( resp.getID() != null ) && !oid.equals( resp.getID() ) )
         {
             return false;
         }
 
-        if ( value != null && resp.getResponse() == null )
+        if ( ( value != null ) && ( resp.getEncodedValue() == null ) )
         {
             return false;
         }
 
-        if ( value == null && resp.getResponse() != null )
+        if ( ( value == null ) && ( resp.getEncodedValue() != null ) )
         {
             return false;
         }
 
-        if ( value != null && resp.getResponse() != null && !Arrays.equals( value, resp.getResponse() ) )
+        if ( ( value != null ) && ( resp.getEncodedValue() != null ) && !Arrays.equals( value, resp.getEncodedValue() ) )
         {
             return false;
         }
@@ -219,14 +208,50 @@ public class ExtendedResponseImpl extend
     }
 
 
+    /**
+     * Gets the OID uniquely identifying this extended response (a.k.a. its
+     * name).
+     * 
+     * @return the OID of the extended response type.
+     */
     public String getID()
     {
-        return getResponseName();
+        return oid;
     }
 
 
+    /**
+     * Gets the reponse OID specific encoded response values.
+     * 
+     * @return the response specific encoded response values.
+     */
     public byte[] getEncodedValue()
     {
-        return getResponse();
+        if ( value == null )
+        {
+            return null;
+        }
+
+        final byte[] copy = new byte[value.length];
+        System.arraycopy( value, 0, copy, 0, value.length );
+        return copy;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setExtendedResponseLength( int extendedResponseLength )
+    {
+        this.extendedResponseLength = extendedResponseLength;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getExtendedResponseLength()
+    {
+        return extendedResponseLength;
     }
 }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/CancelResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/CancelResponse.java?rev=984726&r1=984725&r2=984726&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/CancelResponse.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/CancelResponse.java Thu Aug 12 11:43:54 2010
@@ -45,7 +45,7 @@ public class CancelResponse extends Exte
      */
     public CancelResponse( int messageId, ResultCodeEnum rcode )
     {
-        super( messageId, null );
+        super( messageId );
 
         switch ( rcode )
         {
@@ -68,7 +68,7 @@ public class CancelResponse extends Exte
 
     public CancelResponse( int messageId )
     {
-        super( messageId, null );
+        super( messageId );
         super.getLdapResult().setMatchedDn( null );
         super.getLdapResult().setResultCode( ResultCodeEnum.SUCCESS );
     }

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/StoredProcedureRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/StoredProcedureRequest.java?rev=984726&r1=984725&r2=984726&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/StoredProcedureRequest.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/extended/StoredProcedureRequest.java Thu Aug 12 11:43:54 2010
@@ -99,8 +99,8 @@ public class StoredProcedureRequest exte
         throws NamingException
     {
         StoredProcedureResponse resp = ( StoredProcedureResponse ) getResultResponse();
-        resp.setResponse( berValue );
-        resp.setOid( id );
+        resp.setEncodedValue( berValue );
+        resp.setID( id );
         return resp;
     }
 
@@ -135,7 +135,7 @@ public class StoredProcedureRequest exte
         if ( response == null )
         {
             StoredProcedureResponse spr = new StoredProcedureResponse( getMessageId() );
-            spr.setOid( EXTENSION_OID );
+            spr.setID( EXTENSION_OID );
             response = spr;
         }
 

Modified: directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalExtendedResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalExtendedResponse.java?rev=984726&r1=984725&r2=984726&view=diff
==============================================================================
--- directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalExtendedResponse.java (original)
+++ directory/shared/branches/shared-codec-merge/ldap/src/main/java/org/apache/directory/shared/ldap/message/internal/InternalExtendedResponse.java Thu Aug 12 11:43:54 2010
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.shared.ldap.message.internal;
 
+
 import org.apache.directory.shared.ldap.codec.MessageTypeEnum;
 
 
@@ -40,17 +41,32 @@ public interface InternalExtendedRespons
      * 
      * @return the OID of the extended response type.
      */
-    String getResponseName();
+    String getID();
+
+
+    /**
+     * Gets the OID bytes.
+     * 
+     * @return the OID bytes of the extended response type.
+     */
+    byte[] getIDBytes();
 
 
     /**
      * Sets the OID uniquely identifying this extended response (a.k.a. its
      * name).
      * 
-     * @param oid
-     *            the OID of the extended response type.
+     * @param oidv the OID of the extended response type.
      */
-    void setResponseName( String oid );
+    void setID( String oid );
+
+
+    /**
+     * Sets the OID bytes.
+     * 
+     * @param oidBytes the OID bytes of the extended response type.
+     */
+    void setIDBytes( byte[] oidBytes );
 
 
     /**
@@ -58,7 +74,7 @@ public interface InternalExtendedRespons
      * 
      * @return the response specific encoded response values.
      */
-    byte[] getResponse();
+    byte[] getEncodedValue();
 
 
     /**
@@ -67,5 +83,18 @@ public interface InternalExtendedRespons
      * @param value
      *            the response specific encoded response values.
      */
-    void setResponse( byte[] value );
+    void setEncodedValue( byte[] value );
+
+
+    /**
+     * Stores the encoded length for the ExtendedResponse
+     * @param extendedResponseLength The encoded length
+     */
+    void setExtendedResponseLength( int extendedResponseLength );
+
+
+    /**
+     * @return The encoded ExtendedResponse's length
+     */
+    int getExtendedResponseLength();
 }

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=984726&r1=984725&r2=984726&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 Thu Aug 12 11:43:54 2010
@@ -120,7 +120,7 @@ public class DelResponseTest
             ByteBuffer bb = encoder.encodeMessage( delResponse );
 
             // Check the length
-            assertEquals( 0x02D, bb.limit() );
+            assertEquals( 0x2D, bb.limit() );
 
             String encodedPdu = StringTools.dumpBytes( bb.array() );
 



Mime
View raw message