You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2010/02/22 18:59:05 UTC
svn commit: r914993 - in
/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api:
./ message/
Author: kayyagari
Date: Mon Feb 22 17:59:05 2010
New Revision: 914993
URL: http://svn.apache.org/viewvc?rev=914993&view=rev
Log:
o converted the IntermediateResponse class to an interface
o added specific IntermediateResponse implementations for search and extended operations (this will help in making the
API return operation specific type values rather than generic Response objects)
o updated the LdapConnection to handle the IntermediateResponse messages
Added:
directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ExtendedIntermediateResponse.java
directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/SearchIntermediateResponse.java
Modified:
directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/IntermediateResponse.java
Modified: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java?rev=914993&r1=914992&r2=914993&view=diff
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java (original)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java Mon Feb 22 17:59:05 2010
@@ -32,6 +32,7 @@
import java.util.Set;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
@@ -61,6 +62,7 @@
import org.apache.directory.ldap.client.api.message.CompareResponse;
import org.apache.directory.ldap.client.api.message.DeleteRequest;
import org.apache.directory.ldap.client.api.message.DeleteResponse;
+import org.apache.directory.ldap.client.api.message.ExtendedIntermediateResponse;
import org.apache.directory.ldap.client.api.message.ExtendedRequest;
import org.apache.directory.ldap.client.api.message.ExtendedResponse;
import org.apache.directory.ldap.client.api.message.IntermediateResponse;
@@ -71,6 +73,7 @@
import org.apache.directory.ldap.client.api.message.ModifyResponse;
import org.apache.directory.ldap.client.api.message.Referral;
import org.apache.directory.ldap.client.api.message.Response;
+import org.apache.directory.ldap.client.api.message.SearchIntermediateResponse;
import org.apache.directory.ldap.client.api.message.SearchRequest;
import org.apache.directory.ldap.client.api.message.SearchResponse;
import org.apache.directory.ldap.client.api.message.SearchResultDone;
@@ -357,17 +360,30 @@
/**
- * Convert a IntermediateResponseCodec to a IntermediateResponse message
+ * Convert a IntermediateResponseCodec to a IntermediateResponse message based on the ResponseFuture's type
*/
- private IntermediateResponse convert( IntermediateResponseCodec intermediateResponseCodec )
+ private void setIResponse( IntermediateResponseCodec intermediateResponseCodec, ResponseFuture responseFuture ) throws Exception
{
- IntermediateResponse intermediateResponse = new IntermediateResponse();
+ IntermediateResponse intermediateResponse = null;
- intermediateResponse.setMessageId( intermediateResponseCodec.getMessageId() );
+ if( responseFuture instanceof SearchFuture )
+ {
+ intermediateResponse = new SearchIntermediateResponse();
+ }
+ else if( responseFuture instanceof ExtendedFuture )
+ {
+ intermediateResponse = new ExtendedIntermediateResponse();
+ }
+ else
+ {
+ // currently we only support IR for search and extended operations
+ throw new UnsupportedOperationException( "Unknown ResponseFuture type " + responseFuture.getClass().getName() );
+ }
+
intermediateResponse.setResponseName( intermediateResponseCodec.getResponseName() );
intermediateResponse.setResponseValue( intermediateResponseCodec.getResponseValue() );
- return intermediateResponse;
+ responseFuture.set( intermediateResponse );
}
@@ -1804,19 +1820,13 @@
break;
- //FIXME the way we handle the intermediate responses is broken
case INTERMEDIATE_RESPONSE:
- // Store the response into the responseQueue
IntermediateResponseCodec intermediateResponseCodec = (IntermediateResponseCodec)response;
intermediateResponseCodec.setMessageId( messageId );
intermediateResponseCodec.addControl( response.getCurrentControl() );
- IntermediateResponse intrmResp = convert( intermediateResponseCodec );
+ setIResponse( intermediateResponseCodec, responseFuture );
- // Store the response into the responseQueue
- BlockingQueue<IntermediateResponse> intermediateResponseQueue = (BlockingQueue<IntermediateResponse>)respQueueMap.remove( messageId );
- intermediateResponseQueue.add( intrmResp );
-
break;
case MODIFY_RESPONSE:
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ExtendedIntermediateResponse.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ExtendedIntermediateResponse.java?rev=914993&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ExtendedIntermediateResponse.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/ExtendedIntermediateResponse.java Mon Feb 22 17:59:05 2010
@@ -0,0 +1,75 @@
+/*
+ * 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.ldap.client.api.message;
+
+
+/**
+ * IntermediateResponse received during the extended operation
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ExtendedIntermediateResponse extends ExtendedResponse implements IntermediateResponse
+{
+
+ /** The Response OID */
+ private String responseName;
+
+ /** The response value */
+ private byte[] responseValue;
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getResponseName()
+ {
+ return responseName;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public byte[] getResponseValue()
+ {
+ return responseValue;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setResponseName( String responseName )
+ {
+ this.responseName = responseName;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setResponseValue( byte[] responseValue )
+ {
+ this.responseValue = responseValue;
+ }
+
+}
Modified: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/IntermediateResponse.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/IntermediateResponse.java?rev=914993&r1=914992&r2=914993&view=diff
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/IntermediateResponse.java (original)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/IntermediateResponse.java Mon Feb 22 17:59:05 2010
@@ -25,63 +25,37 @@
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
-public class IntermediateResponse extends AbstractMessage implements Response
+public interface IntermediateResponse
{
- /** The Response OID */
- private String responseName;
- /** The response value */
- private byte[] responseValue;
-
- /**
- * Creates a new instance of IntermediateResponseImpl.
- */
- public IntermediateResponse()
- {
- super();
- }
-
-
/**
* Get the original response OID.
*
* @return The response OID
*/
- public String getResponseName()
- {
- return responseName;
- }
-
-
+ public String getResponseName();
+
+
/**
* Sets the original response OID
*
* @param responseName The response OID
*/
- public void setResponseName( String responseName )
- {
- this.responseName = responseName;
- }
-
-
+ public void setResponseName( String responseName );
+
+
/**
* Get the associated response value
*
* @return The response value
*/
- public byte[] getResponseValue()
- {
- return responseValue;
- }
+ public byte[] getResponseValue();
+
-
/**
* Sets the response's value
*
* @param responseValue The associated response's value
*/
- public void setResponseValue( byte[] responseValue )
- {
- this.responseValue = responseValue;
- }
+ public void setResponseValue( byte[] responseValue );
}
Added: directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/SearchIntermediateResponse.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/SearchIntermediateResponse.java?rev=914993&view=auto
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/SearchIntermediateResponse.java (added)
+++ directory/clients/ldap/trunk/ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/message/SearchIntermediateResponse.java Mon Feb 22 17:59:05 2010
@@ -0,0 +1,76 @@
+/*
+ * 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.ldap.client.api.message;
+
+
+/**
+ *
+ * IntermediateResponse received during the search operation
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SearchIntermediateResponse extends AbstractMessage implements IntermediateResponse, SearchResponse
+{
+
+ /** The Response OID */
+ private String responseName;
+
+ /** The response value */
+ private byte[] responseValue;
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getResponseName()
+ {
+ return responseName;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public byte[] getResponseValue()
+ {
+ return responseValue;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setResponseName( String responseName )
+ {
+ this.responseName = responseName;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setResponseValue( byte[] responseValue )
+ {
+ this.responseValue = responseValue;
+ }
+
+}