You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2011/01/16 21:03:53 UTC

svn commit: r1059647 - in /directory/apacheds/trunk: core/src/main/java/org/apache/directory/server/core/exception/ xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/ xdbm-partition/src/main/java/org/apache/directory/se...

Author: seelmann
Date: Sun Jan 16 20:03:53 2011
New Revision: 1059647

URL: http://svn.apache.org/viewvc?rev=1059647&view=rev
Log:
Fix for DIRSERVER-1594 (Avoid extra lookup in ExceptionInterceptor.search())

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java?rev=1059647&r1=1059646&r2=1059647&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java Sun Jan 16 20:03:53 2011
@@ -37,7 +37,6 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.interceptor.context.MoveOperationContext;
 import org.apache.directory.server.core.interceptor.context.OperationContext;
 import org.apache.directory.server.core.interceptor.context.RenameOperationContext;
-import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
 import org.apache.directory.server.core.partition.ByPassConstants;
 import org.apache.directory.server.core.partition.Partition;
 import org.apache.directory.server.core.partition.PartitionNexus;
@@ -51,7 +50,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.exception.LdapEntryAlreadyExistsException;
 import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.exception.LdapNoSuchObjectException;
-import org.apache.directory.shared.ldap.exception.LdapOperationException;
 import org.apache.directory.shared.ldap.exception.LdapUnwillingToPerformException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.DN;
@@ -411,36 +409,6 @@ public class ExceptionInterceptor extend
 
 
     /**
-     * Checks to see the entry being searched exists, otherwise throws the appropriate LdapException.
-     */
-    public EntryFilteringCursor search( NextInterceptor nextInterceptor, SearchOperationContext searchContext )
-        throws LdapException
-    {
-        DN base = searchContext.getDn();
-
-        try
-        {
-            EntryFilteringCursor cursor = nextInterceptor.search( searchContext );
-
-            // Check that if the cursor is empty, it's not because the DN is invalid.
-            if ( !cursor.available() && !base.isEmpty() && !subschemSubentryDn.equals( base ) )
-            {
-                // We just check that the entry exists only if we didn't found any entry
-                assertHasEntry( searchContext, "Attempt to search under non-existant entry:", searchContext.getDn() );
-            }
-
-            return cursor;
-        }
-        catch ( Exception ne )
-        {
-            String msg = I18n.err( I18n.ERR_259 );
-            assertHasEntry( searchContext, msg, searchContext.getDn() );
-            throw new LdapOperationException( msg );
-        }
-    }
-
-
-    /**
      * Asserts that an entry is present and as a side effect if it is not, creates a LdapNoSuchObjectException, which is
      * used to set the before exception on the invocation - eventually the exception is thrown.
      *

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java?rev=1059647&r1=1059646&r2=1059647&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java Sun Jan 16 20:03:53 2011
@@ -272,6 +272,11 @@ public abstract class BTreePartition<ID>
 
             return new BaseEntryFilteringCursor( new ServerEntryCursorAdaptor<ID>( this, underlying ), searchContext );
         }
+        catch ( LdapException le )
+        {
+            // TODO: SearchEngine.cursor() should only throw LdapException, then the exception handling here can be removed 
+            throw le;
+        }
         catch ( Exception e )
         {
             throw new LdapOperationErrorException( e.getMessage() );

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java?rev=1059647&r1=1059646&r2=1059647&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java Sun Jan 16 20:03:53 2011
@@ -22,6 +22,7 @@ package org.apache.directory.server.xdbm
 
 import javax.naming.directory.SearchControls;
 
+import org.apache.directory.server.i18n.I18n;
 import org.apache.directory.server.xdbm.EmptyIndexCursor;
 import org.apache.directory.server.xdbm.ForwardIndexEntry;
 import org.apache.directory.server.xdbm.IndexCursor;
@@ -32,6 +33,7 @@ import org.apache.directory.server.xdbm.
 import org.apache.directory.server.xdbm.search.Optimizer;
 import org.apache.directory.server.xdbm.search.SearchEngine;
 import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.exception.LdapNoSuchObjectException;
 import org.apache.directory.shared.ldap.filter.AndNode;
 import org.apache.directory.shared.ldap.filter.BranchNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
@@ -104,8 +106,16 @@ public class DefaultSearchEngine<ID exte
         // Check that we have an entry, otherwise we can immediately get out
         if ( baseId == null )
         {
-            // The entry is not found : ciao !
-            return new EmptyIndexCursor<ID, Entry, ID>();
+            if ( db.getSuffixDn().equals( base ) )
+            {
+                // The context entry is not created yet, return an empty cursor
+                return new EmptyIndexCursor<ID, Entry, ID>();
+            }
+            else
+            {
+                // The search base doesn't exist
+                throw new LdapNoSuchObjectException( I18n.err( I18n.ERR_648, base ) );
+            }
         }
 
         String aliasedBase = db.getAliasIndex().reverseLookup( baseId );