directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r918051 - in /directory/clients/ldap/trunk: ldap-client-api/src/main/java/org/apache/directory/ldap/client/api/LdapConnection.java ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java
Date Tue, 02 Mar 2010 14:25:42 GMT
Author: kayyagari
Date: Tue Mar  2 14:25:41 2010
New Revision: 918051

URL: http://svn.apache.org/viewvc?rev=918051&view=rev
Log:
o updated the synchronous search method to use the SearchCursor
o fixed the test case by removing the call to unsupported beforeFirst() operation on SearchCursor
o changed the scope of some static variables

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-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.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=918051&r1=918050&r2=918051&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
Tue Mar  2 14:25:41 2010
@@ -216,9 +216,9 @@
 
     private static final String OPERATION_CANCELLED = "Operation would have been cancelled";
 
-    private static final String TIME_OUT_ERROR = "TimeOut occured";
+    static final String TIME_OUT_ERROR = "TimeOut occured";
 
-    private static final String NO_RESPONSE_ERROR = "The response queue has been emptied,
no response was found.";
+    static final String NO_RESPONSE_ERROR = "The response queue has been emptied, no response
was found.";
 
     private static final String COMPARE_FAILED = "Failed to perform compare operation";
 
@@ -1484,65 +1484,10 @@
     public Cursor<SearchResponse> search( SearchRequest searchRequest ) throws LdapException
     {
         SearchFuture searchFuture = searchAsync( searchRequest );
-        int messageId = searchRequest.getMessageId();
-        
-        // Read the response, waiting for it if not available immediately
-        try
-        {
-            long timeout = getTimeout( searchRequest.getTimeout() );
-            SearchResponse searchResponse = null;
-            List<SearchResponse> searchResponses = new ArrayList<SearchResponse>();
-
-            // We may have more than one response, so loop on the queue
-            do
-            {
-                searchResponse = ( SearchResponse ) searchFuture.get( timeout, TimeUnit.MILLISECONDS
);
-
-                // Check that we didn't get out because of a timeout
-                if ( searchResponse == null )
-                {
-                    // Send an abandon request
-                    abandon( messageId );
-
-                    // We didn't received anything : this is an error
-                    LOG.error( "Search failed : timeout occured" );
-                    
-                    // Remove the future from the map
-                    removeFromFutureMaps( messageId );
-
-                    throw new LdapException( TIME_OUT_ERROR );
-                }
-                
-                if ( !( searchResponse instanceof SearchResultDone ) )
-                {
-                    searchResponses.add( searchResponse );
-                }
-            }
-            while ( !( searchResponse instanceof SearchResultDone ) );
-
-            LOG.debug( "Search successful, {} elements found", searchResponses.size() );
 
-            return new ListCursor<SearchResponse>( searchResponses );
-        }
-        catch ( InterruptedException ie )
-        {
-            LOG.error( OPERATION_CANCELLED, ie );
-            throw new LdapException( OPERATION_CANCELLED, ie );
-        }
-        catch ( Exception e )
-        {
-            LOG.error( NO_RESPONSE_ERROR, e );
-            LdapException ldapException = new LdapException( NO_RESPONSE_ERROR );
-            ldapException.initCause( e );
-
-            // Send an abandon request
-            if ( !searchFuture.isCancelled() )
-            {
-                abandon( messageId );
-            }
-
-            throw ldapException;
-        }
+        long timeout = getTimeout( searchRequest.getTimeout() );
+        
+        return new SearchCursor( searchFuture, timeout, TimeUnit.MILLISECONDS );
     }
 
 

Modified: directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java
URL: http://svn.apache.org/viewvc/directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java?rev=918051&r1=918050&r2=918051&view=diff
==============================================================================
--- directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java
(original)
+++ directory/clients/ldap/trunk/ldap-client-test/src/test/java/org/apache/directory/shared/client/api/operations/ClientAbandonRequestTest.java
Tue Mar  2 14:25:41 2010
@@ -150,7 +150,6 @@
         // Now do a simple synchronous search
         Cursor<SearchResponse> results = connection.search( sr );
         
-        results.beforeFirst();
         int n = -1;
         
         while ( results.next() )



Mime
View raw message