directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r806950 - /directory/shared/trunk/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/LdapConnection.java
Date Sun, 23 Aug 2009 10:29:42 GMT
Author: kayyagari
Date: Sun Aug 23 10:29:42 2009
New Revision: 806950

URL: http://svn.apache.org/viewvc?rev=806950&view=rev
Log:
added a method to convert ControlCodecs to Controls and set in the corresponding clientside
AbstractMessage

Modified:
    directory/shared/trunk/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/LdapConnection.java

Modified: directory/shared/trunk/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/LdapConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/LdapConnection.java?rev=806950&r1=806949&r2=806950&view=diff
==============================================================================
--- directory/shared/trunk/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/LdapConnection.java
(original)
+++ directory/shared/trunk/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/LdapConnection.java
Sun Aug 23 10:29:42 2009
@@ -57,6 +57,7 @@
 import org.apache.directory.shared.ldap.client.api.listeners.OperationResponseListener;
 import org.apache.directory.shared.ldap.client.api.listeners.SearchListener;
 import org.apache.directory.shared.ldap.client.api.messages.AbandonRequest;
+import org.apache.directory.shared.ldap.client.api.messages.AbstractMessage;
 import org.apache.directory.shared.ldap.client.api.messages.AddRequest;
 import org.apache.directory.shared.ldap.client.api.messages.AddResponse;
 import org.apache.directory.shared.ldap.client.api.messages.BindRequest;
@@ -297,6 +298,45 @@
     
     
     /**
+     * converts the ControlCodec(s) present in LdapMessageCodec to BasicControl(s) 
+     * and adds them to the corresponding client side message.
+     *
+     * @param codec the codec in which the <i>ControlCodec</i>s are present 
+     * @param message the message to which the <i>Control</i>s needs to be added
+     */
+    private void copyControlsFromCodecToMessage( LdapMessageCodec codec, AbstractMessage
message )
+    {
+        if( codec == null || message == null )
+        {
+            return;
+        }
+        
+        List<ControlCodec> ctrlCodecList = codec.getControls();
+
+        if( ctrlCodecList != null )
+        {
+            for( ControlCodec ctrlCodec : ctrlCodecList )
+            {
+                if( ctrlCodec == null )
+                {
+                    continue;
+                }
+                
+                Control control = new BasicControl( ctrlCodec.getControlType(), ctrlCodec.getCriticality(),
ctrlCodec.getEncodedValue() );
+                try
+                {
+                    message.add( control );
+                }
+                catch( Exception e )
+                {
+                    LOG.error( "Failed to add the control associated with SearchResultEntryCodec",
e );
+                }
+            }
+        }
+    }
+    
+    
+    /**
      * Get the smallest timeout from the client timeout and the connection
      * timeout.
      */
@@ -327,7 +367,8 @@
         bindResponse.setMessageId( bindResponseCodec.getMessageId() );
         bindResponse.setServerSaslCreds( bindResponseCodec.getServerSaslCreds() );
         bindResponse.setLdapResult( convert( bindResponseCodec.getLdapResult() ) );
-
+        copyControlsFromCodecToMessage( bindResponseCodec, bindResponse );
+        
         return bindResponse;
     }
 
@@ -342,6 +383,7 @@
         intermediateResponse.setMessageId( intermediateResponseCodec.getMessageId() );
         intermediateResponse.setResponseName( intermediateResponseCodec.getResponseName()
);
         intermediateResponse.setResponseValue( intermediateResponseCodec.getResponseValue()
);
+        copyControlsFromCodecToMessage( intermediateResponseCodec, intermediateResponse );
 
         return intermediateResponse;
     }
@@ -384,7 +426,8 @@
         
         searchResultEntry.setMessageId( searchEntryResultCodec.getMessageId() );
         searchResultEntry.setEntry( searchEntryResultCodec.getEntry() );
-        
+        copyControlsFromCodecToMessage( searchEntryResultCodec, searchResultEntry );
+
         return searchResultEntry;
     }
 
@@ -398,6 +441,7 @@
         
         searchResultDone.setMessageId( searchResultDoneCodec.getMessageId() );
         searchResultDone.setLdapResult( convert( searchResultDoneCodec.getLdapResult() )
);
+        copyControlsFromCodecToMessage( searchResultDoneCodec, searchResultDone );
         
         return searchResultDone;
     }
@@ -424,7 +468,8 @@
         }
         
         searchResultReference.setReferral( referral );
-
+        copyControlsFromCodecToMessage( searchEntryReferenceCodec, searchResultReference
);
+        
         return searchResultReference;
     }
 
@@ -771,6 +816,7 @@
         
         addResponse.setMessageId( addRespCodec.getMessageId() );
         addResponse.setLdapResult( convert( addRespCodec.getLdapResult() ) );
+        copyControlsFromCodecToMessage( addRespCodec, addResponse );
         
         return addResponse;
     }
@@ -1824,7 +1870,8 @@
         
         modResponse.setMessageId( modRespCodec.getMessageId() );
         modResponse.setLdapResult( convert( modRespCodec.getLdapResult() ) );
-
+        copyControlsFromCodecToMessage( modRespCodec, modResponse );
+        
         return modResponse;
     }
 
@@ -2008,6 +2055,7 @@
         
         modDnResponse.setMessageId( modDnRespCodec.getMessageId() );
         modDnResponse.setLdapResult( convert( modDnRespCodec.getLdapResult() ) );
+        copyControlsFromCodecToMessage( modDnRespCodec, modDnResponse );
         
         return modDnResponse;
     }
@@ -2521,6 +2569,7 @@
         
         compareResponse.setMessageId( compareRespCodec.getMessageId() );
         compareResponse.setLdapResult( convert( compareRespCodec.getLdapResult() ) );
+        copyControlsFromCodecToMessage( compareRespCodec, compareResponse );
         
         return compareResponse;
     }
@@ -2535,6 +2584,7 @@
         
         response.setMessageId( delRespCodec.getMessageId() );
         response.setLdapResult( convert( delRespCodec.getLdapResult() ) );
+        copyControlsFromCodecToMessage( delRespCodec, response );
         
         return response;
     }
@@ -2695,6 +2745,7 @@
         extResponse.setValue( extRespCodec.getResponse() );
         extResponse.setMessageId( extRespCodec.getMessageId() );
         extResponse.setLdapResult( convert( extRespCodec.getLdapResult() ) );
+        copyControlsFromCodecToMessage( extRespCodec, extResponse );
         
         return extResponse;
     }



Mime
View raw message