directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r539015 - /directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionService.java
Date Thu, 17 May 2007 17:01:30 GMT
Author: elecharny
Date: Thu May 17 10:01:29 2007
New Revision: 539015

URL: http://svn.apache.org/viewvc?view=rev&rev=539015
Log:
Remove the call to assertHasEntry() from the search() method : it cost 
a lot of time just to be sure that the entry exists before searching for it.
If the entry does not exist, we trap the exception, check that it's really
the reason for the failure, and return the correct error message.

Note that we should even avoid to call this method...

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionService.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionService.java?view=diff&rev=539015&r1=539014&r2=539015
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionService.java
Thu May 17 10:01:29 2007
@@ -428,22 +428,29 @@
      */
     public NamingEnumeration<SearchResult> search( NextInterceptor nextInterceptor,
OperationContext opContext ) throws NamingException
     {
-        String msg = "Attempt to search under non-existant entry: ";
         LdapDN base = opContext.getDn();
 
-        if ( base.size() == 0 )
+        try
         {
-            return nextInterceptor.search( opContext );
-        }
+	        NamingEnumeration<SearchResult> result =  nextInterceptor.search( opContext
);
+	        
+	        if ( result.hasMoreElements() == false )
+	        {
+	            if ( !base.isEmpty() && !( subschemSubentryDn.toNormName() ).equalsIgnoreCase(
base.toNormName() ) )
+	            {
+	                // We just check that the entry exists only if we didn't found any entry
+	                assertHasEntry( nextInterceptor, "Attempt to search under non-existant entry:"
, base );
+	            }
+	        }
 
-        if ( ( subschemSubentryDn.toNormName() ).equalsIgnoreCase( base.toNormName() ) )
+	        return result;
+        }
+        catch ( NamingException ne )
         {
-            return nextInterceptor.search( opContext );
+            String msg = "Attempt to search under non-existant entry: ";
+            assertHasEntry( nextInterceptor, msg, base );
+            throw ne;
         }
-
-        assertHasEntry( nextInterceptor, msg, base );
-
-        return nextInterceptor.search( opContext );
     }
 
 



Mime
View raw message