From commits-return-17989-apmail-directory-commits-archive=directory.apache.org@directory.apache.org Thu May 01 14:25:59 2008 Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 73508 invoked from network); 1 May 2008 14:25:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 May 2008 14:25:59 -0000 Received: (qmail 64546 invoked by uid 500); 1 May 2008 14:26:01 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 64488 invoked by uid 500); 1 May 2008 14:26:00 -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 64477 invoked by uid 99); 1 May 2008 14:26:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 May 2008 07:26:00 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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, 01 May 2008 14:25:24 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6CA362388A00; Thu, 1 May 2008 07:25:38 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r652530 - /directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultSearchHandler.java Date: Thu, 01 May 2008 14:25:38 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080501142538.6CA362388A00@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elecharny Date: Thu May 1 07:25:38 2008 New Revision: 652530 URL: http://svn.apache.org/viewvc?rev=652530&view=rev Log: o Fixed some potential error when searching for RootDSE with (2.5.4.0=*) instead of (ObjectClass=*) o Fixed some Javadoc and added some more o Extracted the PersistentSearch code from the main handler to create a specific method, for clarity Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultSearchHandler.java Modified: directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultSearchHandler.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultSearchHandler.java?rev=652530&r1=652529&r2=652530&view=diff ============================================================================== --- directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultSearchHandler.java (original) +++ directory/apacheds/branches/bigbang/protocol-ldap/src/main/java/org/apache/directory/server/ldap/support/DefaultSearchHandler.java Thu May 1 07:25:38 2008 @@ -21,7 +21,6 @@ import org.apache.directory.server.constants.ServerDNConstants; -import org.apache.directory.server.core.entry.ServerSearchResult; import org.apache.directory.server.core.jndi.ServerLdapContext; import org.apache.directory.server.ldap.LdapServer; import org.apache.directory.shared.ldap.constants.JndiPropertyConstants; @@ -30,7 +29,6 @@ import org.apache.directory.shared.ldap.exception.OperationAbandonedException; import org.apache.directory.shared.ldap.filter.PresenceNode; import org.apache.directory.shared.ldap.message.AbandonListener; -import org.apache.directory.shared.ldap.message.AliasDerefMode; import org.apache.directory.shared.ldap.message.LdapResult; import org.apache.directory.shared.ldap.message.ManageDsaITControl; import org.apache.directory.shared.ldap.message.PersistentSearchControl; @@ -126,6 +124,13 @@ /** * Determines if a search request is on the RootDSE of the server. + * + * It is a RootDSE search if : + * - the base DN is empty + * - and the scope is BASE OBJECT + * - and the filter is (ObjectClass = *) + * + * (RFC 4511, 5.1, par. 1 & 2) * * @param req the request issued * @return true if the search is on the RootDSE false otherwise @@ -138,12 +143,75 @@ if ( req.getFilter() instanceof PresenceNode ) { - isRootDSEFilter = ( ( PresenceNode ) req.getFilter() ).getAttribute().equalsIgnoreCase( SchemaConstants.OBJECT_CLASS_AT ); + String attribute = ( ( PresenceNode ) req.getFilter() ).getAttribute(); + isRootDSEFilter = attribute.equalsIgnoreCase( SchemaConstants.OBJECT_CLASS_AT ) || + attribute.equals( SchemaConstants.OBJECT_CLASS_AT_OID ); } return isBaseIsRoot && isBaseScope && isRootDSEFilter; } + + private void handlePersistentSearch( IoSession session, SearchRequest req, ServerLdapContext ctx, + SearchControls controls, PersistentSearchControl psearchControl, + NamingEnumeration list ) throws NamingException + { + // there are no limits for psearch processing + controls.setCountLimit( 0 ); + controls.setTimeLimit( 0 ); + + if ( !psearchControl.isChangesOnly() ) + { + list = ctx.search( req.getBase(), req.getFilter(), + controls ); + + if ( list instanceof AbandonListener ) + { + req.addAbandonListener( ( AbandonListener ) list ); + } + + if ( list.hasMore() ) + { + Iterator it = new SearchResponseIterator( req, ctx, list, controls.getSearchScope(), + session, getSessionRegistry() ); + + while ( it.hasNext() ) + { + Response resp = it.next(); + + if ( resp instanceof SearchResponseDone ) + { + // ok if normal search beforehand failed somehow quickly abandon psearch + ResultCodeEnum rcode = ( ( SearchResponseDone ) resp ).getLdapResult().getResultCode(); + + if ( rcode != ResultCodeEnum.SUCCESS ) + { + session.write( resp ); + return; + } + // if search was fine then we returned all entries so now + // instead of returning the DONE response we break from the + // loop and user the notification listener to send back + // notificationss to the client in never ending search + else + { + break; + } + } + else + { + session.write( resp ); + } + } + } + } + + // now we process entries for ever as they change + PersistentSearchListener handler = new PersistentSearchListener( getSessionRegistry(), + ctx, session, req ); + ctx.addNamingListener( req.getBase(), req.getFilter().toString(), controls, handler ); + return; + } /** * Main message handing method for search requests. @@ -230,7 +298,7 @@ } // =============================================================== - // Handle annonymous binds + // Handle anonymous binds // =============================================================== boolean allowAnonymousBinds = ldapServer.isAllowAnonymousAccess(); @@ -280,60 +348,7 @@ if ( psearchControl != null ) { - // there are no limits for psearch processing - controls.setCountLimit( 0 ); - controls.setTimeLimit( 0 ); - - if ( !psearchControl.isChangesOnly() ) - { - list = ctx.search( req.getBase(), req.getFilter(), - controls ); - - if ( list instanceof AbandonListener ) - { - req.addAbandonListener( ( AbandonListener ) list ); - } - - if ( list.hasMore() ) - { - Iterator it = new SearchResponseIterator( req, ctx, list, controls.getSearchScope(), - session, getSessionRegistry() ); - - while ( it.hasNext() ) - { - Response resp = it.next(); - - if ( resp instanceof SearchResponseDone ) - { - // ok if normal search beforehand failed somehow quickly abandon psearch - ResultCodeEnum rcode = ( ( SearchResponseDone ) resp ).getLdapResult().getResultCode(); - - if ( rcode != ResultCodeEnum.SUCCESS ) - { - session.write( resp ); - return; - } - // if search was fine then we returned all entries so now - // instead of returning the DONE response we break from the - // loop and user the notification listener to send back - // notificationss to the client in never ending search - else - { - break; - } - } - else - { - session.write( resp ); - } - } - } - } - - // now we process entries for ever as they change - PersistentSearchListener handler = new PersistentSearchListener( getSessionRegistry(), - ctx, session, req ); - ctx.addNamingListener( req.getBase(), req.getFilter().toString(), controls, handler ); + handlePersistentSearch( session, req, ctx, controls, psearchControl, list ); return; }