Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 66F226A07 for ; Thu, 16 Jun 2011 10:48:39 +0000 (UTC) Received: (qmail 92589 invoked by uid 500); 16 Jun 2011 10:48:39 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 92531 invoked by uid 500); 16 Jun 2011 10:48:39 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 92524 invoked by uid 99); 16 Jun 2011 10:48:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Jun 2011 10:48:38 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Jun 2011 10:48:37 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 74C3523889BB; Thu, 16 Jun 2011 10:48:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1136367 - /directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java Date: Thu, 16 Jun 2011 10:48:17 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110616104817.74C3523889BB@eris.apache.org> Author: elecharny Date: Thu Jun 16 10:48:17 2011 New Revision: 1136367 URL: http://svn.apache.org/viewvc?rev=1136367&view=rev Log: Reverted the change made yesterday (http://svn.apache.org/viewvc?rev=1136242&view=rev) Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java?rev=1136367&r1=1136366&r2=1136367&view=diff ============================================================================== --- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java (original) +++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java Thu Jun 16 10:48:17 2011 @@ -24,8 +24,6 @@ import static java.lang.Math.min; import static org.apache.directory.server.ldap.LdapServer.NO_SIZE_LIMIT; import static org.apache.directory.server.ldap.LdapServer.NO_TIME_LIMIT; -import java.util.ArrayList; -import java.util.List; import java.util.concurrent.TimeUnit; import org.apache.commons.lang.exception.ExceptionUtils; @@ -360,11 +358,10 @@ public class SearchHandler extends LdapR } - private List readResults( LdapSession session, SearchRequest req, LdapResult ldapResult, + private void readResults( LdapSession session, SearchRequest req, LdapResult ldapResult, EntryFilteringCursor cursor, long sizeLimit ) throws Exception { long count = 0; - List aliasList = new ArrayList(); while ( ( count < sizeLimit ) && cursor.next() ) { @@ -383,14 +380,7 @@ public class SearchHandler extends LdapR break; } - Entry entry = cursor.get(); - - // Here, we have to check if the candidate is an alias or not - if ( entry.contains( OBJECT_CLASS_AT, SchemaConstants.ALIAS_OC ) ) - { - aliasList.add( entry.getDn() ); - } - + ClonedServerEntry entry = cursor.get(); session.getIoSession().write( generateResponse( session, req, entry ) ); LOG.debug( "Sending {}", entry.getDn() ); count++; @@ -408,8 +398,6 @@ public class SearchHandler extends LdapR // Special case if the user has requested more elements than the request size limit ldapResult.setResultCode( ResultCodeEnum.SIZE_LIMIT_EXCEEDED ); } - - return aliasList; } @@ -780,65 +768,44 @@ public class SearchHandler extends LdapR } // A normal search - // We have to process all the found aliases - List searchDnList = new ArrayList(); - searchDnList.add( req.getBase() ); - - int currentSearch = 0; - - while ( currentSearch < searchDnList.size() ) + // Check that we have a cursor or not. + // No cursor : do a search. + EntryFilteringCursor cursor = session.getCoreSession().search( req ); + + // Position the cursor at the beginning + cursor.beforeFirst(); + + /* + * Iterate through all search results building and sending back responses + * for each search result returned. + */ + try { - if ( req.getBase() == null ) - { - req.setBase( searchDnList.get( currentSearch ) ); - } - - EntryFilteringCursor cursor = session.getCoreSession().search( req ); + // Get the size limits + // Don't bother setting size limits for administrators that don't ask for it + long serverLimit = getServerSizeLimit( session, req ); + + long requestLimit = req.getSizeLimit() == 0L ? Long.MAX_VALUE : req.getSizeLimit(); + + req.addAbandonListener( new SearchAbandonListener( ldapServer, cursor ) ); + setTimeLimitsOnCursor( req, session, cursor ); + LOG.debug( "using <{},{}> for size limit", requestLimit, serverLimit ); + long sizeLimit = min( requestLimit, serverLimit ); - // Position the cursor at the beginning - cursor.beforeFirst(); - - /* - * Iterate through all search results building and sending back responses - * for each search result returned. - */ - try + readResults( session, req, ldapResult, cursor, sizeLimit ); + } + finally + { + if ( cursor != null ) { - // Get the size limits - // Don't bother setting size limits for administrators that don't ask for it - long serverLimit = getServerSizeLimit( session, req ); - - long requestLimit = req.getSizeLimit() == 0L ? Long.MAX_VALUE : req.getSizeLimit(); - - req.addAbandonListener( new SearchAbandonListener( ldapServer, cursor ) ); - setTimeLimitsOnCursor( req, session, cursor ); - LOG.debug( "using <{},{}> for size limit", requestLimit, serverLimit ); - long sizeLimit = min( requestLimit, serverLimit ); - - List aliasList = readResults( session, req, ldapResult, cursor, sizeLimit ); - - currentSearch++; - - if ( aliasList.size() != 0 ) + try { - searchDnList.addAll( aliasList ); + cursor.close(); } - } - finally - { - if ( cursor != null ) + catch ( Exception e ) { - try - { - cursor.close(); - } - catch ( Exception e ) - { - LOG.error( I18n.err( I18n.ERR_168 ), e ); - } + LOG.error( I18n.err( I18n.ERR_168 ), e ); } - - req.setBase( null ); } } @@ -1204,6 +1171,7 @@ public class SearchHandler extends LdapR // if the entry is null we still have to check for a referral ancestor // also the referrals need to be adjusted based on the ancestor's ref // values to yield the correct path to the entry in the target DSAs + else { // The entry is null : it has a parent referral.