directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r771496 - /directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/LdapConnection.java
Date Mon, 04 May 2009 23:28:01 GMT
Author: elecharny
Date: Mon May  4 23:28:00 2009
New Revision: 771496

URL: http://svn.apache.org/viewvc?rev=771496&view=rev
Log:
Fixed many problems for the synchronous search

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

Modified: directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/LdapConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/LdapConnection.java?rev=771496&r1=771495&r2=771496&view=diff
==============================================================================
--- directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/LdapConnection.java
(original)
+++ directory/shared/branches/shared-replication/client-api/src/main/java/org/apache/directory/shared/ldap/client/api/LdapConnection.java
Mon May  4 23:28:00 2009
@@ -95,6 +95,7 @@
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.filter.FilterParser;
 import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.apache.directory.shared.ldap.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.util.LdapURL;
@@ -1185,12 +1186,12 @@
                     // Store the result into the list, after conversion
                 {
                     // It's an entry
-                    searchResponses.add( convert( (SearchResultEntryCodec)response ) );
+                    searchResponses.add( (SearchResultEntry)response );
                 }
                 else if ( response instanceof SearchResultReference )
                 {
                     // It's a reference
-                    searchResponses.add( convert( (SearchResultReferenceCodec)response )
);
+                    searchResponses.add( (SearchResultReference)response );
                 }
 
                 // get the next response
@@ -1221,7 +1222,18 @@
 
         LOG.debug( "Search successful, {} elements found", searchResponses.size() );
         
-        return new ListCursor<SearchResponse>( searchResponses );
+        ListCursor<SearchResponse> cursor = new ListCursor<SearchResponse>( searchResponses
);
+        
+        try
+        {
+            cursor.first();
+        }
+        catch ( Exception e )
+        {
+            // TODO: handle exception
+        }
+        
+        return cursor;
     }
 
     
@@ -1260,8 +1272,15 @@
         // Set the scope
         request.setScope( searchRequest.getScope() );
         
-        // Set the typesOnly flag
-        request.setDerefAliases( searchRequest.getDerefAliases().getValue() );
+        // Set the derefAlias flag
+        if ( searchRequest.getDerefAliases() != null )
+        {
+            request.setDerefAliases( searchRequest.getDerefAliases().getValue() );
+        }
+        else
+        {
+            request.setDerefAliases( AliasDerefMode.NEVER_DEREF_ALIASES.getValue() );
+        }
         
         // Set the timeLimit
         request.setTimeLimit( searchRequest.getTimeLimit() );
@@ -1294,7 +1313,7 @@
         // Set the attributes
         Set<String> attributes = searchRequest.getAttributes();
         
-        if ( attributes != null )
+        if ( ( attributes != null ) && ( attributes.size() != 0 ) )
         {
             for ( String attribute:attributes )
             {
@@ -1447,7 +1466,6 @@
                 // Store the response into the responseQueue
                 IntermediateResponseCodec intermediateResponseCodec = 
                     response.getIntermediateResponse();
-                intermediateResponseCodec.addControl( response.getCurrentControl() );
                 
                 if ( intermediateResponseListener != null )
                 {
@@ -1476,7 +1494,6 @@
                 // Store the response into the responseQueue
                 SearchResultDoneCodec searchResultDoneCodec = 
                     response.getSearchResultDone();
-                searchResultDoneCodec.addControl( response.getCurrentControl() );
                 
                 if ( searchListener != null )
                 {
@@ -1493,7 +1510,6 @@
                 // Store the response into the responseQueue
                 SearchResultEntryCodec searchResultEntryCodec = 
                     response.getSearchResultEntry();
-                searchResultEntryCodec.addControl( response.getCurrentControl() );
                 
                 if ( searchListener != null )
                 {
@@ -1501,7 +1517,8 @@
                 }
                 else
                 {
-                    searchResponseQueue.add( convert( searchResultEntryCodec ) );
+                    SearchResultEntry entry = convert( searchResultEntryCodec );
+                    searchResponseQueue.add( entry );
                 }
                 
                 break;
@@ -1510,7 +1527,6 @@
                 // Store the response into the responseQueue
                 SearchResultReferenceCodec searchResultReferenceCodec = 
                     response.getSearchResultReference();
-                searchResultReferenceCodec.addControl( response.getCurrentControl() );
 
                 if ( searchListener != null )
                 {



Mime
View raw message