directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r940243 - /directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java
Date Sun, 02 May 2010 15:05:43 GMT
Author: seelmann
Date: Sun May  2 15:05:43 2010
New Revision: 940243

URL: http://svn.apache.org/viewvc?rev=940243&view=rev
Log:
o fixed a corner case in evaluate(IndexEntry): alias derefencing wasn't checked when the search
base was the context entry
o fixed evaluate(ID): special case for context entry wasn't checked
o merged evaluate methods to avoid duplicate code

Modified:
    directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java

Modified: directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java?rev=940243&r1=940242&r2=940243&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java
(original)
+++ directory/apacheds/trunk/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java
Sun May  2 15:05:43 2010
@@ -112,7 +112,7 @@ public class SubtreeScopeEvaluator<E, ID
 
 
     /**
-     * Asserts whether or not a candidate has one level scope while taking
+     * Asserts whether or not a candidate has sub level scope while taking
      * alias dereferencing into account.
      *
      * @param candidate the entry tested to see if it is in subtree scope
@@ -123,68 +123,12 @@ public class SubtreeScopeEvaluator<E, ID
      */
     public boolean evaluate( IndexEntry<?, E, ID> candidate ) throws Exception
     {
-        /*
-         * This condition catches situations where the candidate is equal to 
-         * the base entry and when the base entry is the context entry.  Note
-         * we do not store a mapping in the subtree index of the context entry
-         * to all it's subordinates since that would be the entire set of 
-         * entries in the db.
-         */
-        if ( baseIsContextEntry || baseId.equals( candidate.getId() ) )
-        {
-            return true;
-        }
-
-        boolean isDescendant = db.getSubLevelIndex().forward( baseId, candidate.getId() );
-
-        /*
-         * The candidate id could be any entry in the db.  If search
-         * dereferencing is not enabled then we return the results of the
-         * descendant test.
-         */
-        if ( !isDereferencing() )
-        {
-            return isDescendant;
-        }
-
-        /*
-         * From here down alias dereferencing is enabled.  We determine if the
-         * candidate id is an alias, if so we reject it since aliases should
-         * not be returned.
-         */
-        if ( null != db.getAliasIndex().reverseLookup( candidate.getId() ) )
-        {
-            return false;
-        }
-
-        /*
-         * The candidate is NOT an alias at this point.  So if it is a
-         * descendant we just return true since it is in normal subtree scope.
-         */
-        if ( isDescendant )
-        {
-            return true;
-        }
-
-        /*
-         * At this point the candidate is not a descendant and it is not an
-         * alias.  We need to check if the candidate is in extended subtree
-         * scope by performing a lookup on the subtree alias index.  This index
-         * stores a tuple mapping the baseId to the ids of objects brought
-         * into subtree scope of the base by an alias:
-         *
-         * ( baseId, aliasedObjId )
-         *
-         * If the candidate id is an object brought into subtree scope then
-         * the lookup returns true accepting the candidate.  Otherwise the
-         * candidate is rejected with a false return because it is not in scope.
-         */
-        return db.getSubAliasIndex().forward( baseId, candidate.getId() );
+        return evaluateId( candidate.getId() );
     }
 
 
     /**
-     * Asserts whether or not a candidate has one level scope while taking
+     * Asserts whether or not a candidate has sub level scope while taking
      * alias dereferencing into account.
      *
      * @param id the id of the entry tested to see if it is in subtree scope
@@ -195,7 +139,14 @@ public class SubtreeScopeEvaluator<E, ID
      */
     public boolean evaluateId( ID id ) throws Exception
     {
-        boolean isDescendant = db.getSubLevelIndex().forward( baseId, id );
+        /*
+         * This condition catches situations where the candidate is equal to 
+         * the base entry and when the base entry is the context entry.  Note
+         * we do not store a mapping in the subtree index of the context entry
+         * to all it's subordinates since that would be the entire set of 
+         * entries in the db.
+         */        
+        boolean isDescendant = baseIsContextEntry || baseId.equals( id ) || db.getSubLevelIndex().forward(
baseId, id );
 
         /*
          * The candidate id could be any entry in the db.  If search
@@ -244,7 +195,7 @@ public class SubtreeScopeEvaluator<E, ID
 
 
     /**
-     * Asserts whether or not a candidate has one level scope while taking
+     * Asserts whether or not a candidate has sub level scope while taking
      * alias dereferencing into account.
      *
      * @param candidate the entry tested to see if it is in subtree scope



Mime
View raw message