From commits-return-34323-apmail-directory-commits-archive=directory.apache.org@directory.apache.org Wed Aug 22 09:31:50 2012 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 97089D98F for ; Wed, 22 Aug 2012 09:31:50 +0000 (UTC) Received: (qmail 40441 invoked by uid 500); 22 Aug 2012 09:31:49 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 40409 invoked by uid 500); 22 Aug 2012 09:31:49 -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 40384 invoked by uid 99); 22 Aug 2012 09:31:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Aug 2012 09:31:48 +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; Wed, 22 Aug 2012 09:31:47 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 0644923888E4 for ; Wed, 22 Aug 2012 09:31:04 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1375957 - /directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java Date: Wed, 22 Aug 2012 09:31:03 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120822093104.0644923888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elecharny Date: Wed Aug 22 09:31:03 2012 New Revision: 1375957 URL: http://svn.apache.org/viewvc?rev=1375957&view=rev Log: Handle a search on BASE_OBJECT using a lookup instead of a cursor 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=1375957&r1=1375956&r2=1375957&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 Wed Aug 22 09:31:03 2012 @@ -232,16 +232,14 @@ public class SearchHandler extends LdapR /** - * Handles search requests on the RootDSE. + * Handles a simple lookup, or a RootDSE lookup. * * @param session the LdapSession for which this search is conducted * @param req the search request on the RootDSE * @throws Exception if failures are encountered while searching */ - private void handleRootDseSearch( LdapSession session, SearchRequest req ) throws Exception + private void handleLookup( LdapSession session, SearchRequest req ) throws Exception { - EntryFilteringCursor cursor = null; - try { Map controlMap = req.getControls(); @@ -260,30 +258,18 @@ public class SearchHandler extends LdapR } } - Entry rootDse = session.getCoreSession().lookup( + Entry entry = session.getCoreSession().lookup( req.getBase(), controls, req.getAttributes().toArray( new String[]{} ) ); - session.getIoSession().write( generateResponse( session, req, rootDse ) ); + session.getIoSession().write( generateResponse( session, req, entry ) ); // write the SearchResultDone message session.getIoSession().write( req.getResultResponse() ); } finally { - // Close the cursor now. - if ( cursor != null ) - { - try - { - cursor.close(); - } - catch ( Exception e ) - { - LOG.error( I18n.err( I18n.ERR_168 ), e ); - } - } } } @@ -1017,6 +1003,20 @@ public class SearchHandler extends LdapR } } +/* + if ( isBaseScope && isObjectClassFilter ) + { + // This is a lookup + handleLookup( session, req ); + + return true; + } + else + { + // a standard search + return false; + } +*/ boolean isBaseIsRoot = req.getBase().isEmpty(); if ( isBaseScope && isObjectClassFilter ) @@ -1024,7 +1024,7 @@ public class SearchHandler extends LdapR if ( isBaseIsRoot ) { // This is a rootDse lookup - handleRootDseSearch( session, req ); + handleLookup( session, req ); return true; } @@ -1081,38 +1081,6 @@ public class SearchHandler extends LdapR return; } - // =============================================================== - // Handle lookups deifferently - // =============================================================== - // First check that we aren't doing a lookup (ie scope is BASE, and the filter is (ObjectClass=*) ) - boolean isLookup = false; - - if ( req.getScope() == SearchScope.OBJECT ) - { - if ( req.getFilter() instanceof PresenceNode ) - { - ExprNode filter = req.getFilter(); - - if ( filter.isSchemaAware() ) - { - AttributeType attributeType = ( ( PresenceNode ) req.getFilter() ).getAttributeType(); - isLookup = attributeType.equals( OBJECT_CLASS_AT ); - } - else - { - String attribute = ( ( PresenceNode ) req.getFilter() ).getAttribute(); - isLookup = attribute.equalsIgnoreCase( SchemaConstants.OBJECT_CLASS_AT ) - || attribute.equals( SchemaConstants.OBJECT_CLASS_AT_OID ); - } - } - } - - if ( isLookup ) - { - - } - - // modify the filter to affect continuation support modifyFilter( session, req ); @@ -1373,46 +1341,6 @@ public class SearchHandler extends LdapR /** - * 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 - */ - private boolean isRootDseSearch( SearchRequest req ) - { - boolean isBaseIsRoot = req.getBase().isEmpty(); - boolean isBaseScope = req.getScope() == SearchScope.OBJECT; - boolean isRootDseFilter = false; - - if ( req.getFilter() instanceof PresenceNode ) - { - ExprNode filter = req.getFilter(); - - if ( filter.isSchemaAware() ) - { - AttributeType attributeType = ( ( PresenceNode ) req.getFilter() ).getAttributeType(); - isRootDseFilter = attributeType.equals( OBJECT_CLASS_AT ); - } - else - { - String attribute = ( ( PresenceNode ) req.getFilter() ).getAttribute(); - isRootDseFilter = attribute.equalsIgnoreCase( SchemaConstants.OBJECT_CLASS_AT ) - || attribute.equals( SchemaConstants.OBJECT_CLASS_AT_OID ); - } - } - - return isBaseIsRoot && isBaseScope && isRootDseFilter; - } - - - /** *

* Determines if a search request is a subSchemaSubEntry search. *