directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r659774 - in /directory: apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/event/ apacheds/branches/bigbang/core/src/main...
Date Sat, 24 May 2008 08:45:25 GMT
Author: akarasulu
Date: Sat May 24 01:45:24 2008
New Revision: 659774

URL: http://svn.apache.org/viewvc?rev=659774&view=rev
Log:
fixing several bugs withsearch such as applying controls and with subtree scope processing - also added new enumerated type for SearchScope and added more (better) paramters into SearchingOperationContexts instead of using SearchControls

Added:
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SearchScope.java
Modified:
    directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ClonedServerEntry.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/event/ScopeEvaluator.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/filtering/EntryFilteringCursor.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/SearchOperationContext.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/SearchingOperationContext.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/NamingEnumerationAdapter.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java
    directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java
    directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java
    directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
    directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java
    directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeEvaluator.java
    directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java
    directory/apacheds/branches/bigbang/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java
    directory/apacheds/branches/bigbang/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java

Modified: directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ClonedServerEntry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ClonedServerEntry.java?rev=659774&r1=659773&r2=659774&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ClonedServerEntry.java (original)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ClonedServerEntry.java Sat May 24 01:45:24 2008
@@ -19,6 +19,8 @@
  */
 package org.apache.directory.server.core.entry;
 
+
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
@@ -392,4 +394,282 @@
     {
         return ( ServerEntry ) clonedEntry.clone();
     }
+    
+    
+    public String toString()
+    {
+        return clonedEntry.toString();
+    }
+    
+    
+    class EmptyEntry implements ServerEntry
+    {
+        LdapDN dn;
+        
+        EmptyEntry( LdapDN dn )
+        {
+            this.dn = dn;
+        }
+        
+        public void add( AttributeType attributeType, byte[]... values ) throws NamingException
+        {
+        }
+
+        public void add( AttributeType attributeType, String... values ) throws NamingException
+        {
+        }
+
+        public void add( AttributeType attributeType, Value<?>... values ) throws NamingException
+        {
+        }
+
+        public void add( String upId, AttributeType attributeType, byte[]... values ) throws NamingException
+        {
+        }
+
+        public void add( String upId, AttributeType attributeType, String... values ) throws NamingException
+        {
+        }
+
+        public void add( String upId, AttributeType attributeType, Value<?>... values ) throws NamingException
+        {
+        }
+
+        public boolean contains( AttributeType attributeType, byte[]... values )
+        {
+            return false;
+        }
+
+        public boolean contains( AttributeType attributeType, String... values )
+        {
+            return false;
+        }
+
+        public boolean contains( AttributeType attributeType, Value<?>... values )
+        {
+            return false;
+        }
+
+        public boolean containsAttribute( AttributeType attributeType )
+        {
+            return false;
+        }
+
+        public EntryAttribute get( AttributeType attributeType )
+        {
+            return null;
+        }
+
+        public Set<AttributeType> getAttributeTypes()
+        {
+            return null;
+        }
+
+        public boolean hasObjectClass( EntryAttribute objectClass )
+        {
+            return false;
+        }
+
+        public boolean isValid()
+        {
+            return false;
+        }
+
+        public boolean isValid( String objectClass )
+        {
+            return false;
+        }
+
+        public boolean isValid( EntryAttribute objectClass )
+        {
+            return false;
+        }
+
+        public EntryAttribute put( AttributeType attributeType, byte[]... values ) throws NamingException
+        {
+            return null;
+        }
+
+        public EntryAttribute put( AttributeType attributeType, String... values ) throws NamingException
+        {
+            return null;
+        }
+
+        public EntryAttribute put( AttributeType attributeType, Value<?>... values ) throws NamingException
+        {
+            return null;
+        }
+
+        public EntryAttribute put( String upId, AttributeType attributeType, byte[]... values ) throws NamingException
+        {
+            return null;
+        }
+
+        public EntryAttribute put( String upId, AttributeType attributeType, String... values ) throws NamingException
+        {
+            return null;
+        }
+
+        public EntryAttribute put( String upId, AttributeType attributeType, Value<?>... values )
+            throws NamingException
+        {
+            return null;
+        }
+
+        public boolean remove( AttributeType attributeType, byte[]... values ) throws NamingException
+        {
+            return false;
+        }
+
+        public boolean remove( AttributeType attributeType, String... values ) throws NamingException
+        {
+            return false;
+        }
+
+        public boolean remove( AttributeType attributeType, Value<?>... values ) throws NamingException
+        {
+            return false;
+        }
+
+        public List<EntryAttribute> remove( EntryAttribute... attributes ) throws NamingException
+        {
+            return Collections.emptyList();
+        }
+
+        public List<EntryAttribute> removeAttributes( AttributeType... attributes )
+        {
+            return Collections.emptyList();
+        }
+
+        public List<EntryAttribute> set( AttributeType... attributeTypes )
+        {
+            return Collections.emptyList();
+        }
+
+        public void add( EntryAttribute... attributes ) throws NamingException
+        {
+        }
+
+        public void add( String upId, String... values ) throws NamingException
+        {
+        }
+
+        public void add( String upId, byte[]... values ) throws NamingException
+        {
+        }
+
+        public void add( String upId, Value<?>... values ) throws NamingException
+        {
+        }
+
+        public void clear()
+        {
+        }
+
+        public boolean contains( EntryAttribute... attributes ) throws NamingException
+        {
+            return false;
+        }
+
+        public boolean contains( String upId, byte[]... values )
+        {
+            return false;
+        }
+
+        public boolean contains( String upId, String... values )
+        {
+            return false;
+        }
+
+        public boolean contains( String upId, Value<?>... values )
+        {
+            return false;
+        }
+
+        public boolean containsAttribute( String... attributes )
+        {
+            return false;
+        }
+
+        public EntryAttribute get( String alias )
+        {
+            return null;
+        }
+
+        public LdapDN getDn()
+        {
+            return null;
+        }
+
+        public boolean hasObjectClass( String objectClass )
+        {
+            return false;
+        }
+
+        @SuppressWarnings("unchecked")
+        public Iterator<EntryAttribute> iterator()
+        {
+            return ( ( List <EntryAttribute> ) Collections.EMPTY_LIST ).iterator();
+        }
+
+        public List<EntryAttribute> put( EntryAttribute... attributes ) throws NamingException
+        {
+            return Collections.emptyList();
+        }
+
+        public EntryAttribute put( String upId, byte[]... values )
+        {
+            return null;
+        }
+
+        public EntryAttribute put( String upId, String... values )
+        {
+            return null;
+        }
+
+        public EntryAttribute put( String upId, Value<?>... values )
+        {
+            return null;
+        }
+
+        public boolean remove( String upId, byte[]... values ) throws NamingException
+        {
+            return false;
+        }
+
+        public boolean remove( String upId, String... values ) throws NamingException
+        {
+            return false;
+        }
+
+        public boolean remove( String upId, Value<?>... values ) throws NamingException
+        {
+            return false;
+        }
+
+        public List<EntryAttribute> removeAttributes( String... attributes )
+        {
+            return Collections.emptyList();
+        }
+
+        public List<EntryAttribute> set( String... upIds )
+        {
+            return Collections.emptyList();
+        }
+
+        public void setDn( LdapDN dn )
+        {
+            this.dn = dn;
+        }
+
+        public int size()
+        {
+            return 0;
+        }
+    
+        public ServerEntry clone()
+        {
+            return new EmptyEntry( dn );
+        }
+    }
 }

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java?rev=659774&r1=659773&r2=659774&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java Sat May 24 01:45:24 2008
@@ -56,6 +56,7 @@
 import org.apache.directory.shared.ldap.filter.LeafNode;
 import org.apache.directory.shared.ldap.filter.NotNode;
 import org.apache.directory.shared.ldap.filter.ScopeNode;
+import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.name.NameComponentNormalizer;
@@ -165,7 +166,7 @@
         }
 
         ScopeNode scope = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES, normalizedBaseDn.toNormName(),
-            searchControls.getSearchScope() );
+            SearchScope.getSearchScope( searchControls ) );
 
         if ( filter != null )
         {

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/event/ScopeEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/event/ScopeEvaluator.java?rev=659774&r1=659773&r2=659774&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/event/ScopeEvaluator.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/event/ScopeEvaluator.java Sat May 24 01:45:24 2008
@@ -51,10 +51,10 @@
 
         switch ( snode.getScope() )
         {
-            case ( SearchControls.OBJECT_SCOPE  ):
+            case OBJECT:
                 return dn.equals( snode.getBaseDn() );
             
-            case ( SearchControls.ONELEVEL_SCOPE  ):
+            case ONELEVEL:
                 if ( dn.endsWith( snode.getBaseDn() ) )
                 {
                     LdapDN candidateDn = new LdapDN( dn );
@@ -62,7 +62,7 @@
                     return ( scopeDn.size() + 1 ) == candidateDn.size();
                 }
             
-            case ( SearchControls.SUBTREE_SCOPE  ):
+            case SUBTREE:
                 return dn.endsWith( snode.getBaseDn() );
             
             default:

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/filtering/EntryFilteringCursor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/filtering/EntryFilteringCursor.java?rev=659774&r1=659773&r2=659774&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/filtering/EntryFilteringCursor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/filtering/EntryFilteringCursor.java Sat May 24 01:45:24 2008
@@ -32,6 +32,8 @@
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.interceptor.context.SearchingOperationContext;
 import org.apache.directory.shared.ldap.exception.OperationAbandonedException;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.UsageEnum;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -62,9 +64,6 @@
     
     /** the first accepted search result that is pre fetched */
     private ClonedServerEntry prefetched;
-    
-    /** whether or not this search has been abandoned */
-    private boolean abandoned = false;
 
     
     // ------------------------------------------------------------------------
@@ -122,7 +121,7 @@
         this.filters = new ArrayList<EntryFilter>();
         this.filters.addAll( filters );
     }
-
+    
     
     // ------------------------------------------------------------------------
     // Class Specific Methods
@@ -136,7 +135,7 @@
      */
     public boolean isAbandoned()
     {
-        return abandoned;
+        return getOperationContext().isAbandoned();
     }
     
     
@@ -147,7 +146,7 @@
      */
     public void setAbandoned( boolean abandoned )
     {
-        this.abandoned = abandoned;
+        getOperationContext().setAbandoned( abandoned );
         
         if ( abandoned )
         {
@@ -269,7 +268,7 @@
      */
     public boolean first() throws Exception
     {
-        if ( abandoned )
+        if ( getOperationContext().isAbandoned() )
         {
             log.info( "Cursor has been abandoned." );
             close();
@@ -318,7 +317,7 @@
      */
     public boolean last() throws Exception
     {
-        if ( abandoned )
+        if ( getOperationContext().isAbandoned() )
         {
             log.info( "Cursor has been abandoned." );
             close();
@@ -328,14 +327,73 @@
         afterLast();
         return previous();
     }
+    
+    
+    private void filterContents( ClonedServerEntry entry ) throws Exception
+    {
+        boolean returnAll = getOperationContext().getReturningAttributes() == null ||
+            ( getOperationContext().isAllOperationalAttributes() && getOperationContext().isAllUserAttributes() );
+        
+        if ( returnAll )
+        {
+            return;
+        }
+        
+        if ( getOperationContext().isAllUserAttributes() )
+        {
+            for ( AttributeType at : entry.getOriginalEntry().getAttributeTypes() )
+            {
+                boolean isNotRequested = ! getOperationContext().getReturningAttributes().contains( at );
+                boolean isNotUserAttribute = at.getUsage() != UsageEnum.USER_APPLICATIONS;
+                
+                if (  isNotRequested && isNotUserAttribute )
+                {
+                    entry.removeAttributes( at );
+                }
+            }
+            
+            return;
+        }
+        
+        if ( getOperationContext().isAllOperationalAttributes() )
+        {
+            for ( AttributeType at : entry.getOriginalEntry().getAttributeTypes() )
+            {
+                boolean isNotRequested = ! getOperationContext().getReturningAttributes().contains( at );
+                boolean isUserAttribute = at.getUsage() == UsageEnum.USER_APPLICATIONS;
+                
+                if ( isNotRequested && isUserAttribute )
+                {
+                    entry.removeAttributes( at );
+                }
+            }
+            
+            return;
+        }
 
+        if ( getOperationContext().isNoAttributes() )
+        {
+            for ( AttributeType at : entry.getOriginalEntry().getAttributeTypes() )
+            {
+                boolean isNotRequested = ! getOperationContext().getReturningAttributes().contains( at );
 
+                if ( isNotRequested )
+                {
+                    entry.removeAttributes( at );
+                }
+            }
+            
+            return;
+        }
+    }
+    
+    
     /* 
      * @see Cursor#next()
      */
     public boolean next() throws Exception
     {
-        if ( abandoned )
+        if ( getOperationContext().isAbandoned() )
         {
             log.info( "Cursor has been abandoned." );
             close();
@@ -368,14 +426,16 @@
             if ( filters.isEmpty() )
             {
                 prefetched = tempResult;
+                filterContents( prefetched );
                 return true;
             }
             
             if ( filters.size() == 1 )
             {
-                if ( filters.get( 0 ).accept( operationContext, tempResult ) )
+                if ( filters.get( 0 ).accept( getOperationContext(), tempResult ) )
                 {
                     prefetched = tempResult;
+                    filterContents( prefetched );
                     return true;
                 }
             }
@@ -385,7 +445,7 @@
             for ( EntryFilter filter : filters )
             {
                 // if a filter rejects then short and continue with outer loop
-                if ( ! ( accepted &= filter.accept( operationContext, tempResult ) ) )
+                if ( ! ( accepted &= filter.accept( getOperationContext(), tempResult ) ) )
                 {
                     continue outer;
                 }
@@ -394,8 +454,8 @@
             /*
              * Here the entry has been accepted by all filters.
              */
-            
             prefetched = tempResult;
+            filterContents( prefetched );
             return true;
         }
         
@@ -409,7 +469,7 @@
      */
     public boolean previous() throws Exception
     {
-        if ( abandoned )
+        if ( getOperationContext().isAbandoned() )
         {
             log.info( "Cursor has been abandoned." );
             close();
@@ -433,14 +493,16 @@
             if ( filters.isEmpty() )
             {
                 prefetched = tempResult;
+                filterContents( prefetched );
                 return true;
             }
             
             if ( filters.size() == 1 )
             {
-                if ( filters.get( 0 ).accept( operationContext, tempResult ) )
+                if ( filters.get( 0 ).accept( getOperationContext(), tempResult ) )
                 {
                     prefetched = tempResult;
+                    filterContents( prefetched );
                     return true;
                 }
             }
@@ -450,7 +512,7 @@
             for ( EntryFilter filter : filters )
             {
                 // if a filter rejects then short and continue with outer loop
-                if ( ! ( accepted &= filter.accept( operationContext, tempResult ) ) )
+                if ( ! ( accepted &= filter.accept( getOperationContext(), tempResult ) ) )
                 {
                     continue outer;
                 }
@@ -459,8 +521,8 @@
             /*
              * Here the entry has been accepted by all filters.
              */
-            
             prefetched = tempResult;
+            filterContents( prefetched );
             return true;
         }
         

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/SearchOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/SearchOperationContext.java?rev=659774&r1=659773&r2=659774&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/SearchOperationContext.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/SearchOperationContext.java Sat May 24 01:45:24 2008
@@ -20,14 +20,16 @@
 package org.apache.directory.server.core.interceptor.context;
 
 
+import javax.naming.NamingException;
+import javax.naming.directory.SearchControls;
+
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.message.MessageTypeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 
-import javax.naming.directory.SearchControls;
-
 
 /**
  * A Search context used for Interceptors. It contains all the informations
@@ -57,9 +59,10 @@
      * @param dn the dn of the search base
      * @param filter the filter AST to use for the search
      * @param searchControls the search controls
+     * @throws NamingException 
      */
     public SearchOperationContext( Registries registries, LdapDN dn, AliasDerefMode aliasDerefMode, ExprNode filter,
-                                   SearchControls searchControls )
+                                   SearchControls searchControls ) throws NamingException
     {
         super( registries, dn, aliasDerefMode, searchControls );
         this.filter = filter;

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/SearchingOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/SearchingOperationContext.java?rev=659774&r1=659773&r2=659774&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/SearchingOperationContext.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/SearchingOperationContext.java Sat May 24 01:45:24 2008
@@ -20,11 +20,21 @@
 package org.apache.directory.server.core.interceptor.context;
 
 
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.naming.NamingException;
 import javax.naming.directory.SearchControls;
 
 import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.util.ArrayUtils;
+
+import static org.apache.directory.shared.ldap.filter.SearchScope.ONELEVEL;
 
 
 /**
@@ -38,9 +48,22 @@
 {
     private AliasDerefMode aliasDerefMode = AliasDerefMode.DEREF_ALWAYS;
 
-    /** The controls */
-    protected SearchControls searchControls = new SearchControls();
+    private long sizeLimit = 0;
+    
+    private int timeLimit = 0;
+    
+    private SearchScope scope = ONELEVEL;
 
+    private boolean allOperationalAttributes = false;
+    
+    private boolean allUserAttributes = false;
+    
+    private boolean noAttributes = false;
+    
+    private Set<AttributeType> returningAttributes; 
+    
+    private boolean abandoned = false;
+    
     
     /**
      * Creates a new instance of ListOperationContext.
@@ -80,16 +103,48 @@
      *
      * @param dn The DN to get the suffix from
      * @param aliasDerefMode the alias dereferencing mode to use
+     * @throws NamingException 
      */
     public SearchingOperationContext( Registries registries, LdapDN dn, AliasDerefMode aliasDerefMode, 
-        SearchControls searchControls )
+        SearchControls searchControls ) throws NamingException
     {
         super( registries, dn );
         this.aliasDerefMode = aliasDerefMode;
-        this.searchControls = searchControls;
+        this.scope = SearchScope.getSearchScope( searchControls );
+        this.timeLimit = searchControls.getTimeLimit();
+        this.sizeLimit = searchControls.getCountLimit();
+        
+        if ( searchControls.getReturningAttributes() != null )
+        {
+            returningAttributes = new HashSet<AttributeType>();
+            for ( String returnAttribute : searchControls.getReturningAttributes() )
+            {
+                if ( returnAttribute.equals( SchemaConstants.NO_ATTRIBUTE ) )
+                {
+                    noAttributes = true;
+                    continue;
+                }
+                
+                if ( returnAttribute.equals( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES ) )
+                {
+                    allOperationalAttributes = true;
+                    continue;
+                }
+                
+                if ( returnAttribute.equals( SchemaConstants.ALL_USER_ATTRIBUTES ) )
+                {
+                    allUserAttributes = true;
+                    continue;
+                }
+                
+                returningAttributes.add( registries.getAttributeTypeRegistry().lookup( returnAttribute ) );
+            }
+        }
     }
 
     
+    
+    
     /**
      * @see Object#toString()
      */
@@ -98,29 +153,216 @@
         return "ListOperationContext with DN '" + getDn().getUpName() + "'";
     }
 
+    
+    public AliasDerefMode getAliasDerefMode()
+    {
+        return aliasDerefMode;
+    }
+
 
     /**
-     *  @return The search controls
+     * @param sizeLimit the sizeLimit to set
      */
-    public SearchControls getSearchControls()
+    public void setSizeLimit( long sizeLimit )
     {
-        return searchControls;
+        this.sizeLimit = sizeLimit;
     }
 
 
     /**
-     * Set the search controls
-     *
-     * @param searchControls The search controls
+     * @return the sizeLimit
+     */
+    public long getSizeLimit()
+    {
+        return sizeLimit;
+    }
+
+
+    /**
+     * @param timeLimit the timeLimit to set
+     */
+    public void setTimeLimit( int timeLimit )
+    {
+        this.timeLimit = timeLimit;
+    }
+
+
+    /**
+     * @return the timeLimit
+     */
+    public int getTimeLimit()
+    {
+        return timeLimit;
+    }
+
+
+    /**
+     * @param scope the scope to set
+     */
+    public void setScope( SearchScope scope )
+    {
+        this.scope = scope;
+    }
+
+
+    /**
+     * @return the scope
+     */
+    public SearchScope getScope()
+    {
+        return scope;
+    }
+
+
+    /**
+     * @param allOperationalAttributes the allOperationalAttributes to set
+     */
+    public void setAllOperationalAttributes( boolean allOperationalAttribute )
+    {
+        this.allOperationalAttributes = allOperationalAttribute;
+    }
+
+
+    /**
+     * @return the allOperationalAttributes
+     */
+    public boolean isAllOperationalAttributes()
+    {
+        return allOperationalAttributes;
+    }
+
+
+    /**
+     * @param allUserAttributes the allUserAttributes to set
+     */
+    public void setAllUserAttributes( boolean allUserAttributes )
+    {
+        this.allUserAttributes = allUserAttributes;
+    }
+
+
+    /**
+     * @return the allUserAttributes
+     */
+    public boolean isAllUserAttributes()
+    {
+        return allUserAttributes;
+    }
+
+
+    /**
+     * @param noAttributes the noAttributes to set
+     */
+    public void setNoAttributes( boolean noAttributes )
+    {
+        this.noAttributes = noAttributes;
+    }
+
+
+    /**
+     * @return the noAttributes
+     */
+    public boolean isNoAttributes()
+    {
+        return noAttributes;
+    }
+
+
+    /**
+     * @param returningAttributes the returningAttributes to set
+     */
+    public void setReturningAttributes( Set<AttributeType> returningAttributes )
+    {
+        this.returningAttributes = returningAttributes;
+    }
+
+
+    /**
+     * @return the returningAttributes
      */
-    public void setSearchControls( SearchControls searchControls )
+    public Set<AttributeType> getReturningAttributes()
     {
-        this.searchControls = searchControls;
+        return returningAttributes;
     }
 
     
-    public AliasDerefMode getAliasDerefMode()
+    /**
+     * Creates a new SearchControls object populated with the parameters 
+     * contained in this SearchOperationContext in normalized form.
+     *
+     * @return a new SearchControls object
+     */
+    public SearchControls getSearchControls()
     {
-        return aliasDerefMode;
+        return getSearchControls( false );
+    }
+    
+    
+    /**
+     * Creates a new SearchControls object populated with the parameters 
+     * contained in this SearchOperationContext.
+     *
+     * @param denormalized true if attribute values are <b>not</b> normalized
+     * @return a new SearchControls object
+     */
+    public SearchControls getSearchControls( boolean denormalized )
+    {
+        SearchControls controls = new SearchControls();
+        controls.setCountLimit( sizeLimit );
+        controls.setSearchScope( scope.getJndiScope() );
+        controls.setTimeLimit( timeLimit );
+
+        Set<String> allReturningAttributes = new HashSet<String>();
+        
+        if ( noAttributes )
+        {
+            allReturningAttributes.add( SchemaConstants.NO_ATTRIBUTE );
+        }
+        
+        if ( allUserAttributes )
+        {
+            allReturningAttributes.add( SchemaConstants.ALL_USER_ATTRIBUTES );
+        }
+        
+        if ( allOperationalAttributes )
+        {
+            allReturningAttributes.add( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES );
+        }
+        
+        if ( returningAttributes != null )
+        {
+            for ( AttributeType at : returningAttributes )
+            {
+                if ( denormalized )
+                {
+                    allReturningAttributes.add( at.getName() );
+                }
+                else
+                {
+                    allReturningAttributes.add( at.getOid() );
+                }
+            }
+        }
+        
+        controls.setReturningAttributes( allReturningAttributes.toArray( ArrayUtils.EMPTY_STRING_ARRAY ) );
+        return controls;
+    }
+
+
+    /**
+     * @param abandoned the abandoned to set
+     */
+    public void setAbandoned( boolean abandoned )
+    {
+        this.abandoned = abandoned;
+    }
+
+
+    /**
+     * @return the abandoned
+     */
+    public boolean isAbandoned()
+    {
+        return abandoned;
     }
 }

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/NamingEnumerationAdapter.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/NamingEnumerationAdapter.java?rev=659774&r1=659773&r2=659774&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/NamingEnumerationAdapter.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/NamingEnumerationAdapter.java Sat May 24 01:45:24 2008
@@ -118,7 +118,6 @@
         
         SearchResult result = new SearchResult( entry.getDn().getUpName(), null, ServerEntryUtils.toAttributesImpl( entry ) );
         result.setRelative( false );
-        
         return result;
     }
 
@@ -137,26 +136,13 @@
      */
     public SearchResult nextElement()
     {
-        ClonedServerEntry entry = null;
-        
         try
         {
-            entry = cursor.get();
-            if ( available = cursor.next() )
-            {
-                cursor.close();
-            }
+            return next();
         }
-        catch ( Exception e )
+        catch ( NamingException e )
         {
-            NoSuchElementException nsee = new NoSuchElementException( e.getMessage() );
-            nsee.initCause( e );
-            throw nsee;
+            throw new NoSuchElementException( e.getMessage() );
         }
-        
-        SearchResult result = new SearchResult( entry.getDn().getUpName(), null, ServerEntryUtils.toAttributesImpl( entry ) );
-        result.setRelative( false );
-        
-        return result;
     }
 }

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java?rev=659774&r1=659773&r2=659774&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexusProxy.java Sat May 24 01:45:24 2008
@@ -510,42 +510,41 @@
         EntryFilteringCursor cursor = search( opContext, null );
         final SearchControls searchCtls = opContext.getSearchControls();
 
-            if ( searchCtls.getTimeLimit() + searchCtls.getCountLimit() > 0 )
+        if ( searchCtls.getTimeLimit() + searchCtls.getCountLimit() > 0 )
+        {
+            // this will be the last filter added so other filters before it must
+            // have passed/approved of the entry to be returned back to the client
+            // so the candidate we have is going to be returned for sure
+            cursor.addEntryFilter( new EntryFilter()
             {
-                // this will be the last filter added so other filters before it must
-                // have passed/approved of the entry to be returned back to the client
-                // so the candidate we have is going to be returned for sure
-                cursor.addEntryFilter( new EntryFilter()
-                {
-                    final long startTime = System.currentTimeMillis();
-                    int count = 1; // with prefetch we've missed one which is ok since 1 is the minimum
-
+                final long startTime = System.currentTimeMillis();
+                int count = 0; // with prefetch we've missed one which is ok since 1 is the minimum
 
-                    public boolean accept( SearchingOperationContext operation, ClonedServerEntry entry )
-                            throws Exception
+                public boolean accept( SearchingOperationContext operation, ClonedServerEntry entry )
+                        throws Exception
+                {
+                    if ( searchCtls.getTimeLimit() > 0 )
                     {
-                        if ( searchCtls.getTimeLimit() > 0 )
+                        long runtime = System.currentTimeMillis() - startTime;
+                        if ( runtime > searchCtls.getTimeLimit() )
                         {
-                            long runtime = System.currentTimeMillis() - startTime;
-                            if ( runtime > searchCtls.getTimeLimit() )
-                            {
-                                throw new LdapTimeLimitExceededException();
-                            }
+                            throw new LdapTimeLimitExceededException();
                         }
+                    }
 
-                        if ( searchCtls.getCountLimit() > 0 )
+                    if ( searchCtls.getCountLimit() > 0 )
+                    {
+                        if ( count > searchCtls.getCountLimit() )
                         {
-                            if ( count > searchCtls.getCountLimit() )
-                            {
-                                throw new LdapSizeLimitExceededException();
-                            }
+                            throw new LdapSizeLimitExceededException();
                         }
-
-                        count++;
-                        return true;
                     }
-                } );
-            }
+
+                    count++;
+                    return true;
+                }
+            } );
+        }
 
         return cursor;
     }

Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java?rev=659774&r1=659773&r2=659774&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/CursorBuilder.java Sat May 24 01:45:24 2008
@@ -23,8 +23,6 @@
 import java.util.List;
 import java.util.ArrayList;
 
-import javax.naming.directory.SearchControls;
-
 import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.xdbm.search.Evaluator;
@@ -78,7 +76,7 @@
             case PRESENCE:
                 return new PresenceCursor( db, ( PresenceEvaluator ) evaluatorBuilder.build( node ) );
             case SCOPE:
-                if ( ( ( ScopeNode ) node ).getScope() == SearchControls.ONELEVEL_SCOPE )
+                if ( ( ( ScopeNode ) node ).getScope() == SearchScope.ONELEVEL )
                 {
                     return new OneLevelScopeCursor( db, ( OneLevelScopeEvaluator ) evaluatorBuilder.build( node ) );
                 }

Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java?rev=659774&r1=659773&r2=659774&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultOptimizer.java Sat May 24 01:45:24 2008
@@ -22,8 +22,6 @@
 
 import java.util.List;
 
-import javax.naming.directory.SearchControls;
-
 import org.apache.directory.shared.ldap.filter.AndNode;
 import org.apache.directory.shared.ldap.filter.ApproximateNode;
 import org.apache.directory.shared.ldap.filter.AssertionNode;
@@ -341,14 +339,14 @@
     {
         switch ( node.getScope() )
         {
-            case ( SearchControls.OBJECT_SCOPE  ):
+            case OBJECT:
                 return 1L;
             
-            case ( SearchControls.ONELEVEL_SCOPE  ):
+            case ONELEVEL:
                 Long id = db.getEntryId( node.getBaseDn() );
                 return db.getChildCount( id );
                 
-            case ( SearchControls.SUBTREE_SCOPE  ):
+            case SUBTREE:
                 return db.count();
             
             default:

Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java?rev=659774&r1=659773&r2=659774&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/DefaultSearchEngine.java Sat May 24 01:45:24 2008
@@ -26,6 +26,7 @@
 import org.apache.directory.shared.ldap.filter.BranchNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.filter.ScopeNode;
+import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.server.xdbm.*;
@@ -124,7 +125,8 @@
         
         // Add the scope node using the effective base to the filter
         BranchNode root = new AndNode();
-        ExprNode node = new ScopeNode( aliasDerefMode, effectiveBase.toString(), searchCtls.getSearchScope() );
+        ExprNode node = new ScopeNode( aliasDerefMode, effectiveBase.toString(), 
+            SearchScope.getSearchScope( searchCtls ) );
         root.getChildren().add( node );
         root.getChildren().add( filter );
 

Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java?rev=659774&r1=659773&r2=659774&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EvaluatorBuilder.java Sat May 24 01:45:24 2008
@@ -20,8 +20,6 @@
 package org.apache.directory.server.xdbm.search.impl;
 
 
-import javax.naming.directory.SearchControls;
-
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.server.xdbm.search.Evaluator;
@@ -77,7 +75,7 @@
             case PRESENCE:
                 return new PresenceEvaluator( ( PresenceNode ) node, db, registries );
             case SCOPE:
-                if ( ( ( ScopeNode ) node ).getScope() == SearchControls.ONELEVEL_SCOPE )
+                if ( ( ( ScopeNode ) node ).getScope() == SearchScope.ONELEVEL )
                 {
                     return new OneLevelScopeEvaluator<ServerEntry>( db, ( ScopeNode ) node );
                 }

Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeEvaluator.java?rev=659774&r1=659773&r2=659774&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeEvaluator.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeEvaluator.java Sat May 24 01:45:24 2008
@@ -20,9 +20,8 @@
 package org.apache.directory.server.xdbm.search.impl;
 
 
-import javax.naming.directory.SearchControls;
-
 import org.apache.directory.shared.ldap.filter.ScopeNode;
+import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.server.xdbm.search.Evaluator;
@@ -60,7 +59,7 @@
     {
         this.node = node;
 
-        if ( node.getScope() != SearchControls.ONELEVEL_SCOPE )
+        if ( node.getScope() != SearchScope.ONELEVEL )
         {
             throw new IllegalStateException( "ScopeNode is not of onelevel scope." );
         }

Modified: directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java?rev=659774&r1=659773&r2=659774&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeEvaluator.java Sat May 24 01:45:24 2008
@@ -21,12 +21,11 @@
 
 
 import org.apache.directory.shared.ldap.filter.ScopeNode;
+import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.server.xdbm.search.Evaluator;
 
-import javax.naming.directory.SearchControls;
-
 
 /**
  * Evaluates ScopeNode assertions with subtree scope on candidates using an
@@ -74,7 +73,7 @@
         this.db = db;
         this.node = node;
 
-        if ( node.getScope() != SearchControls.SUBTREE_SCOPE )
+        if ( node.getScope() != SearchScope.SUBTREE )
         {
             throw new IllegalStateException( "ScopeNode is not of subtree scope." );
         }

Modified: directory/apacheds/branches/bigbang/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java?rev=659774&r1=659773&r2=659774&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java Sat May 24 01:45:24 2008
@@ -36,6 +36,7 @@
 import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.filter.ScopeNode;
+import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.commons.io.FileUtils;
@@ -47,7 +48,6 @@
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertEquals;
 
-import javax.naming.directory.SearchControls;
 import java.io.File;
 import java.util.Set;
 import java.util.HashSet;
@@ -138,7 +138,7 @@
     {
         ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES,
             SchemaConstants.OU_AT_OID + "=sales," +
-            SchemaConstants.O_AT_OID  + "=good times co.", SearchControls.ONELEVEL_SCOPE );
+            SchemaConstants.O_AT_OID  + "=good times co.", SearchScope.ONELEVEL );
         OneLevelScopeEvaluator<ServerEntry> evaluator = new OneLevelScopeEvaluator<ServerEntry>( store, node );
         OneLevelScopeCursor cursor = new OneLevelScopeCursor( store, evaluator );
 
@@ -285,7 +285,7 @@
     {
         ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES,
             SchemaConstants.OU_AT_OID + "=engineering," +
-            SchemaConstants.O_AT_OID  + "=good times co.", SearchControls.ONELEVEL_SCOPE );
+            SchemaConstants.O_AT_OID  + "=good times co.", SearchScope.ONELEVEL );
         OneLevelScopeEvaluator<ServerEntry> evaluator = new OneLevelScopeEvaluator<ServerEntry>( store, node );
         OneLevelScopeCursor cursor = new OneLevelScopeCursor( store, evaluator );
 
@@ -432,7 +432,7 @@
     {
         ScopeNode node = new ScopeNode( AliasDerefMode.DEREF_IN_SEARCHING,
             SchemaConstants.OU_AT_OID + "=board of directors," +
-            SchemaConstants.O_AT_OID  + "=good times co.", SearchControls.ONELEVEL_SCOPE );
+            SchemaConstants.O_AT_OID  + "=good times co.", SearchScope.ONELEVEL );
         OneLevelScopeEvaluator<ServerEntry> evaluator = new OneLevelScopeEvaluator<ServerEntry>( store, node );
         OneLevelScopeCursor cursor = new OneLevelScopeCursor( store, evaluator );
 
@@ -558,7 +558,7 @@
         ScopeNode node = new ScopeNode( AliasDerefMode.DEREF_IN_SEARCHING,
             SchemaConstants.OU_AT_OID + "=apache," +
             SchemaConstants.OU_AT_OID + "=board of directors," +
-            SchemaConstants.O_AT_OID  + "=good times co.", SearchControls.ONELEVEL_SCOPE );
+            SchemaConstants.O_AT_OID  + "=good times co.", SearchScope.ONELEVEL );
         OneLevelScopeEvaluator<ServerEntry> evaluator = new OneLevelScopeEvaluator<ServerEntry>( store, node );
         OneLevelScopeCursor cursor = new OneLevelScopeCursor( store, evaluator );
 
@@ -674,7 +674,7 @@
 
         ScopeNode node = new ScopeNode( AliasDerefMode.DEREF_IN_SEARCHING,
             SchemaConstants.OU_AT_OID + "=board of directors," +
-            SchemaConstants.O_AT_OID  + "=good times co.", SearchControls.ONELEVEL_SCOPE );
+            SchemaConstants.O_AT_OID  + "=good times co.", SearchScope.ONELEVEL );
         OneLevelScopeEvaluator<ServerEntry> evaluator = new OneLevelScopeEvaluator<ServerEntry>( store, node );
         OneLevelScopeCursor cursor = new OneLevelScopeCursor( store, evaluator );
 
@@ -905,7 +905,7 @@
     {
         ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES,
             SchemaConstants.OU_AT_OID + "=sales," +
-            SchemaConstants.O_AT_OID  + "=good times co.", SearchControls.ONELEVEL_SCOPE );
+            SchemaConstants.O_AT_OID  + "=good times co.", SearchScope.ONELEVEL );
         OneLevelScopeEvaluator<ServerEntry> evaluator = new OneLevelScopeEvaluator<ServerEntry>( store, node );
 
         ForwardIndexEntry<Long,ServerEntry> indexEntry = new ForwardIndexEntry<Long,ServerEntry>();
@@ -919,7 +919,7 @@
     {
         ScopeNode node = new ScopeNode( AliasDerefMode.DEREF_ALWAYS,
             SchemaConstants.OU_AT_OID + "=engineering," +
-            SchemaConstants.O_AT_OID  + "=good times co.", SearchControls.ONELEVEL_SCOPE );
+            SchemaConstants.O_AT_OID  + "=good times co.", SearchScope.ONELEVEL );
         OneLevelScopeEvaluator<ServerEntry> evaluator = new OneLevelScopeEvaluator<ServerEntry>( store, node );
         assertEquals( node, evaluator.getExpression() );
 
@@ -951,7 +951,7 @@
     {
         ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES,
             SchemaConstants.OU_AT_OID + "=sales," +
-            SchemaConstants.O_AT_OID  + "=good times co.", SearchControls.ONELEVEL_SCOPE );
+            SchemaConstants.O_AT_OID  + "=good times co.", SearchScope.ONELEVEL );
         OneLevelScopeEvaluator<ServerEntry> evaluator = new OneLevelScopeEvaluator<ServerEntry>( store, node );
         OneLevelScopeCursor cursor = new OneLevelScopeCursor( store, evaluator );
         cursor.get();
@@ -963,7 +963,7 @@
     {
         ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES,
             SchemaConstants.OU_AT_OID + "=sales," +
-            SchemaConstants.O_AT_OID  + "=good times co.", SearchControls.ONELEVEL_SCOPE );
+            SchemaConstants.O_AT_OID  + "=good times co.", SearchScope.ONELEVEL );
         OneLevelScopeEvaluator<ServerEntry> evaluator = new OneLevelScopeEvaluator<ServerEntry>( store, node );
         OneLevelScopeCursor cursor = new OneLevelScopeCursor( store, evaluator );
 
@@ -979,7 +979,7 @@
     {
         ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES,
             SchemaConstants.OU_AT_OID + "=sales," +
-            SchemaConstants.O_AT_OID  + "=good times co.", SearchControls.ONELEVEL_SCOPE );
+            SchemaConstants.O_AT_OID  + "=good times co.", SearchScope.ONELEVEL );
         OneLevelScopeEvaluator<ServerEntry> evaluator = new OneLevelScopeEvaluator<ServerEntry>( store, node );
         OneLevelScopeCursor cursor = new OneLevelScopeCursor( store, evaluator );
 
@@ -995,7 +995,7 @@
     {
         ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES,
             SchemaConstants.OU_AT_OID + "=sales," +
-            SchemaConstants.O_AT_OID  + "=good times co.", SearchControls.SUBTREE_SCOPE );
+            SchemaConstants.O_AT_OID  + "=good times co.", SearchScope.ONELEVEL );
         new OneLevelScopeEvaluator<ServerEntry>( store, node );
     }
 }
\ No newline at end of file

Modified: directory/apacheds/branches/bigbang/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java?rev=659774&r1=659773&r2=659774&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java (original)
+++ directory/apacheds/branches/bigbang/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java Sat May 24 01:45:24 2008
@@ -36,6 +36,7 @@
 import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.filter.ScopeNode;
+import org.apache.directory.shared.ldap.filter.SearchScope;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.commons.io.FileUtils;
@@ -48,7 +49,6 @@
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 
-import javax.naming.directory.SearchControls;
 import java.io.File;
 import java.util.Set;
 import java.util.HashSet;
@@ -139,7 +139,7 @@
     {
         ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES,
             SchemaConstants.OU_AT_OID + "=sales," +
-            SchemaConstants.O_AT_OID  + "=good times co.", SearchControls.SUBTREE_SCOPE );
+            SchemaConstants.O_AT_OID  + "=good times co.", SearchScope.SUBTREE);
         SubtreeScopeEvaluator<ServerEntry> evaluator = new SubtreeScopeEvaluator<ServerEntry>( store, node );
         SubtreeScopeCursor cursor = new SubtreeScopeCursor( store, evaluator );
 
@@ -264,7 +264,7 @@
     {
         ScopeNode node = new ScopeNode( AliasDerefMode.DEREF_IN_SEARCHING,
             SchemaConstants.OU_AT_OID + "=board of directors," +
-            SchemaConstants.O_AT_OID  + "=good times co.", SearchControls.SUBTREE_SCOPE );
+            SchemaConstants.O_AT_OID  + "=good times co.", SearchScope.SUBTREE );
         SubtreeScopeEvaluator<ServerEntry> evaluator = new SubtreeScopeEvaluator<ServerEntry>( store, node );
         SubtreeScopeCursor cursor = new SubtreeScopeCursor( store, evaluator );
 
@@ -414,7 +414,7 @@
         ScopeNode node = new ScopeNode( AliasDerefMode.DEREF_IN_SEARCHING,
             SchemaConstants.OU_AT_OID + "=apache," +
             SchemaConstants.OU_AT_OID + "=board of directors," +
-            SchemaConstants.O_AT_OID  + "=good times co.", SearchControls.SUBTREE_SCOPE );
+            SchemaConstants.O_AT_OID  + "=good times co.", SearchScope.SUBTREE );
         SubtreeScopeEvaluator<ServerEntry> evaluator = new SubtreeScopeEvaluator<ServerEntry>( store, node );
         SubtreeScopeCursor cursor = new SubtreeScopeCursor( store, evaluator );
 
@@ -530,7 +530,7 @@
 
         ScopeNode node = new ScopeNode( AliasDerefMode.DEREF_IN_SEARCHING,
             SchemaConstants.OU_AT_OID + "=board of directors," +
-            SchemaConstants.O_AT_OID  + "=good times co.", SearchControls.SUBTREE_SCOPE );
+            SchemaConstants.O_AT_OID  + "=good times co.", SearchScope.SUBTREE );
         SubtreeScopeEvaluator<ServerEntry> evaluator = new SubtreeScopeEvaluator<ServerEntry>( store, node );
         SubtreeScopeCursor cursor = new SubtreeScopeCursor( store, evaluator );
 
@@ -755,7 +755,7 @@
     {
         ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES,
             SchemaConstants.OU_AT_OID + "=sales," +
-            SchemaConstants.O_AT_OID  + "=good times co.", SearchControls.SUBTREE_SCOPE );
+            SchemaConstants.O_AT_OID  + "=good times co.", SearchScope.SUBTREE );
         SubtreeScopeEvaluator<ServerEntry> evaluator = new SubtreeScopeEvaluator<ServerEntry>( store, node );
 
         ForwardIndexEntry<Long,ServerEntry> indexEntry = new ForwardIndexEntry<Long,ServerEntry>();
@@ -769,7 +769,7 @@
     {
         ScopeNode node = new ScopeNode( AliasDerefMode.DEREF_ALWAYS,
             SchemaConstants.OU_AT_OID + "=engineering," +
-            SchemaConstants.O_AT_OID  + "=good times co.", SearchControls.SUBTREE_SCOPE );
+            SchemaConstants.O_AT_OID  + "=good times co.", SearchScope.SUBTREE );
         SubtreeScopeEvaluator<ServerEntry> evaluator = new SubtreeScopeEvaluator<ServerEntry>( store, node );
         assertEquals( node, evaluator.getExpression() );
 
@@ -796,7 +796,7 @@
     {
         ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES,
             SchemaConstants.OU_AT_OID + "=sales," +
-            SchemaConstants.O_AT_OID  + "=good times co.", SearchControls.SUBTREE_SCOPE );
+            SchemaConstants.O_AT_OID  + "=good times co.", SearchScope.SUBTREE );
         SubtreeScopeEvaluator<ServerEntry> evaluator = new SubtreeScopeEvaluator<ServerEntry>( store, node );
         SubtreeScopeCursor cursor = new SubtreeScopeCursor( store, evaluator );
         cursor.get();
@@ -808,7 +808,7 @@
     {
         ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES,
             SchemaConstants.OU_AT_OID + "=sales," +
-            SchemaConstants.O_AT_OID  + "=good times co.", SearchControls.SUBTREE_SCOPE );
+            SchemaConstants.O_AT_OID  + "=good times co.", SearchScope.SUBTREE );
         SubtreeScopeEvaluator<ServerEntry> evaluator = new SubtreeScopeEvaluator<ServerEntry>( store, node );
         SubtreeScopeCursor cursor = new SubtreeScopeCursor( store, evaluator );
 
@@ -824,7 +824,7 @@
     {
         ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES,
             SchemaConstants.OU_AT_OID + "=sales," +
-            SchemaConstants.O_AT_OID  + "=good times co.", SearchControls.SUBTREE_SCOPE );
+            SchemaConstants.O_AT_OID  + "=good times co.", SearchScope.SUBTREE );
         SubtreeScopeEvaluator<ServerEntry> evaluator = new SubtreeScopeEvaluator<ServerEntry>( store, node );
         SubtreeScopeCursor cursor = new SubtreeScopeCursor( store, evaluator );
 
@@ -840,7 +840,7 @@
     {
         ScopeNode node = new ScopeNode( AliasDerefMode.NEVER_DEREF_ALIASES,
             SchemaConstants.OU_AT_OID + "=sales," +
-            SchemaConstants.O_AT_OID  + "=good times co.", SearchControls.ONELEVEL_SCOPE );
+            SchemaConstants.O_AT_OID  + "=good times co.", SearchScope.ONELEVEL );
         SubtreeScopeEvaluator<ServerEntry> evaluator = new SubtreeScopeEvaluator<ServerEntry>( store, node );
         assertNull( evaluator );
     }

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java?rev=659774&r1=659773&r2=659774&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ScopeNode.java Sat May 24 01:45:24 2008
@@ -20,8 +20,6 @@
 package org.apache.directory.shared.ldap.filter;
 
 
-import javax.naming.directory.SearchControls;
-
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
 
 
@@ -35,7 +33,7 @@
 public class ScopeNode extends AbstractExprNode
 {
     /** the scope of this node */
-    private final int scope;
+    private final SearchScope scope;
 
     /** the search base */
     private final String baseDn;
@@ -51,7 +49,7 @@
      * @param baseDn the search base
      * @param scope the search scope
      */
-    public ScopeNode( AliasDerefMode aliasDerefAliases, String baseDn, int scope )
+    public ScopeNode( AliasDerefMode aliasDerefAliases, String baseDn, SearchScope scope )
     {
         super( AssertionType.SCOPE );
         this.scope = scope;
@@ -72,14 +70,11 @@
 
 
     /**
-     * Gets the scope constant for this node.
+     * Gets the search scope.
      * 
-     * @return the scope constant
-     * @see javax.naming.directory.SearchControls#OBJECT_SCOPE
-     * @see javax.naming.directory.SearchControls#ONELEVEL_SCOPE
-     * @see javax.naming.directory.SearchControls#SUBTREE_SCOPE
+     * @return the search scope 
      */
-    public int getScope()
+    public SearchScope getScope()
     {
         return scope;
     }
@@ -143,7 +138,7 @@
         h = h*17 + super.hashCode();
         h = h*17 + ( aliasDerefAliases != null ? aliasDerefAliases.hashCode() : 0 );
         h = h*17 + ( baseDn != null ? baseDn.hashCode() : 0 );
-        h = h*17 + scope;
+        h = h*17 + scope.getJndiScope();
         
         return h;
     }
@@ -160,17 +155,17 @@
 
         switch ( scope )
         {
-            case ( SearchControls.OBJECT_SCOPE  ):
+            case OBJECT:
                 buf.append( "OBJECT_SCOPE" );
 
                 break;
 
-            case ( SearchControls.ONELEVEL_SCOPE  ):
+            case ONELEVEL:
                 buf.append( "ONE_LEVEL_SCOPE" );
 
                 break;
 
-            case ( SearchControls.SUBTREE_SCOPE  ):
+            case SUBTREE:
                 buf.append( "SUBTREE_SCOPE (Estimated)" );
 
                 break;

Added: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SearchScope.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SearchScope.java?rev=659774&view=auto
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SearchScope.java (added)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SearchScope.java Sat May 24 01:45:24 2008
@@ -0,0 +1,100 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+package org.apache.directory.shared.ldap.filter;
+
+import javax.naming.directory.SearchControls;
+
+/**
+ * A search scope enumerated type.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public enum SearchScope
+{
+    OBJECT( SearchControls.OBJECT_SCOPE ), 
+    ONELEVEL( SearchControls.ONELEVEL_SCOPE ), 
+    SUBTREE( SearchControls.SUBTREE_SCOPE );
+    
+    /** 
+     * The corresponding JNDI scope constant value as defined in 
+     * SearchControls.
+     * 
+     * @see javax.naming.directory.SearchControls#OBJECT_SCOPE
+     * @see javax.naming.directory.SearchControls#ONELEVEL_SCOPE
+     * @see javax.naming.directory.SearchControls#SUBTREE_SCOPE
+     */ 
+    private final int jndiScope;
+    
+
+    /**
+     * Creates a new instance of SearchScope based on the respective 
+     * SearchControls scope constant.
+     *
+     * @param jndiScope the JNDI scope constant
+     */
+    private SearchScope( int jndiScope )
+    {
+        this.jndiScope = jndiScope;
+    }
+
+
+    /**
+     * Gets the corresponding JNDI scope constant value as defined in 
+     * SearchControls.
+     * 
+     * @return the jndiScope
+     * @see javax.naming.directory.SearchControls#OBJECT_SCOPE
+     * @see javax.naming.directory.SearchControls#ONELEVEL_SCOPE
+     * @see javax.naming.directory.SearchControls#SUBTREE_SCOPE
+     */
+    public int getJndiScope()
+    {
+        return jndiScope;
+    }
+    
+    
+    /**
+     * Gets the SearchScope enumerated type for the corresponding 
+     * SearchControls scope setting.
+     *
+     * @param searchControls the search controls to get SearchScope for
+     * @return the SearchScope enumerated type for the SearchControls
+     */
+    public static SearchScope getSearchScope( SearchControls searchControls )
+    {
+        SearchScope scope = OBJECT;
+        
+        switch( searchControls.getSearchScope() )
+        {
+            case( SearchControls.OBJECT_SCOPE ): 
+                scope = OBJECT;
+                break;
+            case( SearchControls.ONELEVEL_SCOPE ):
+                scope = ONELEVEL;
+                break;
+            case( SearchControls.SUBTREE_SCOPE ):
+                scope = SUBTREE;
+                break;
+        }
+        
+        return scope;
+    }
+}

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java?rev=659774&r1=659773&r2=659774&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java Sat May 24 01:45:24 2008
@@ -160,7 +160,7 @@
             return false;
         }
 
-        SimpleNode otherNode = ( SimpleNode ) other;
+        SimpleNode<?> otherNode = ( SimpleNode<?> ) other;
 
         if ( value == null )
         {



Mime
View raw message