directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r659229 [1/2] - in /directory/apacheds/branches/bigbang: core-entry/src/main/java/org/apache/directory/server/core/entry/ core/src/main/java/org/apache/directory/server/core/authn/ core/src/main/java/org/apache/directory/server/core/authz/ ...
Date Thu, 22 May 2008 20:00:40 GMT
Author: akarasulu
Date: Thu May 22 13:00:38 2008
New Revision: 659229

URL: http://svn.apache.org/viewvc?rev=659229&view=rev
Log:
removing SearchResultFilter and SearchResultFilterEnumeration and replacing with EntryFilter and EntryFilteringCursor

Added:
    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/filtering/
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/filtering/EntryFilter.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/filtering/EntryFilteringCursor.java
Removed:
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/enumeration/SearchResultEnumeration.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/enumeration/SearchResultFilter.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/enumeration/SearchResultFilteringEnumeration.java
Modified:
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationInterceptor.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authz/GroupCache.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authz/TupleCache.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/BaseInterceptor.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/Interceptor.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/NextInterceptor.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/ListOperationContext.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/jndi/ServerContext.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/Partition.java
    directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/PartitionNexus.java

Added: 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=659229&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ClonedServerEntry.java (added)
+++ directory/apacheds/branches/bigbang/core-entry/src/main/java/org/apache/directory/server/core/entry/ClonedServerEntry.java Thu May 22 13:00:38 2008
@@ -0,0 +1,395 @@
+/*
+ *   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.server.core.entry;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+
+
+/**
+ * A ServerEntry refers to the original entry before being modified by 
+ * EntryFilters or operations.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ClonedServerEntry implements ServerEntry
+{
+    /** The original entry as returned by the backend */
+    private final ServerEntry originalEntry;
+    
+    /** The copied entry */
+    private final ServerEntry clonedEntry;
+
+    
+    /**
+     * Creates a new instance of ClonedServerEntry.
+     * 
+     * The original entry is cloned in order to protect its content.
+     *
+     * @param originalEntry The original entry
+     */
+    public ClonedServerEntry( ServerEntry originalEntry )
+    {
+        this.originalEntry = originalEntry;
+        this.clonedEntry = ( ServerEntry ) originalEntry.clone();
+    }
+    
+    
+    /**
+     * @return the originalEntry
+     */
+    public ServerEntry getOriginalEntry()
+    {
+        return originalEntry;
+    }
+
+
+    public void add( AttributeType attributeType, byte[]... values ) throws NamingException
+    {
+        clonedEntry.add( attributeType, values );
+    }
+
+
+    public void add( AttributeType attributeType, String... values ) throws NamingException
+    {
+        clonedEntry.add( attributeType, values );
+    }
+
+
+    public void add( AttributeType attributeType, Value<?>... values ) throws NamingException
+    {
+        clonedEntry.add( attributeType, values );
+    }
+
+
+    public void add( String upId, AttributeType attributeType, byte[]... values ) throws NamingException
+    {
+        clonedEntry.add( attributeType, values );
+    }
+
+
+    public void add( String upId, AttributeType attributeType, String... values ) throws NamingException
+    {
+        clonedEntry.add( attributeType, values );
+    }
+
+
+    public void add( String upId, AttributeType attributeType, Value<?>... values ) throws NamingException
+    {
+        clonedEntry.add( attributeType, values );
+    }
+
+
+    public boolean contains( AttributeType attributeType, byte[]... values )
+    {
+        return clonedEntry.contains( attributeType, values );
+    }
+
+
+    public boolean contains( AttributeType attributeType, String... values )
+    {
+        return clonedEntry.contains( attributeType, values );
+    }
+
+
+    public boolean contains( AttributeType attributeType, Value<?>... values )
+    {
+        return clonedEntry.contains( attributeType, values );
+    }
+
+
+    public boolean containsAttribute( AttributeType attributeType )
+    {
+        return clonedEntry.containsAttribute( attributeType );
+    }
+
+
+    public EntryAttribute get( AttributeType attributeType )
+    {
+        return clonedEntry.get( attributeType );
+    }
+
+
+    public Set<AttributeType> getAttributeTypes()
+    {
+        return clonedEntry.getAttributeTypes();
+    }
+
+
+    public boolean hasObjectClass( EntryAttribute objectClass )
+    {
+        return clonedEntry.hasObjectClass( objectClass );
+    }
+
+
+    public boolean isValid()
+    {
+        return clonedEntry.isValid();
+    }
+
+
+    public boolean isValid( String objectClass )
+    {
+        return clonedEntry.isValid( objectClass );
+    }
+
+
+    public boolean isValid( EntryAttribute objectClass )
+    {
+        return clonedEntry.isValid( objectClass );
+    }
+
+
+    public EntryAttribute put( AttributeType attributeType, byte[]... values ) throws NamingException
+    {
+        return clonedEntry.put( attributeType, values );
+    }
+
+
+    public EntryAttribute put( AttributeType attributeType, String... values ) throws NamingException
+    {
+        return clonedEntry.put( attributeType, values );
+    }
+
+
+    public EntryAttribute put( AttributeType attributeType, Value<?>... values ) throws NamingException
+    {
+        return clonedEntry.put( attributeType, values );
+    }
+
+
+    public EntryAttribute put( String upId, AttributeType attributeType, byte[]... values ) throws NamingException
+    {
+        return clonedEntry.put( attributeType, values );
+    }
+
+
+    public EntryAttribute put( String upId, AttributeType attributeType, String... values ) throws NamingException
+    {
+        return clonedEntry.put( upId, attributeType, values );
+    }
+
+
+    public EntryAttribute put( String upId, AttributeType attributeType, Value<?>... values ) throws NamingException
+    {
+        return clonedEntry.put( upId, attributeType, values );
+    }
+
+
+    public boolean remove( AttributeType attributeType, byte[]... values ) throws NamingException
+    {
+        return clonedEntry.remove( attributeType, values );
+    }
+
+
+    public boolean remove( AttributeType attributeType, String... values ) throws NamingException
+    {
+        return clonedEntry.remove( attributeType, values );
+    }
+
+
+    public boolean remove( AttributeType attributeType, Value<?>... values ) throws NamingException
+    {
+        return clonedEntry.remove( attributeType, values );
+    }
+
+
+    public List<EntryAttribute> remove( EntryAttribute... attributes ) throws NamingException
+    {
+        return clonedEntry.remove( attributes );
+    }
+
+
+    public List<EntryAttribute> removeAttributes( AttributeType... attributes )
+    {
+        return clonedEntry.removeAttributes( attributes );
+    }
+
+
+    public List<EntryAttribute> set( AttributeType... attributeTypes )
+    {
+        return clonedEntry.set( attributeTypes );
+    }
+
+
+    public void add( EntryAttribute... attributes ) throws NamingException
+    {
+        clonedEntry.add( attributes );
+    }
+
+
+    public void add( String upId, String... values ) throws NamingException
+    {
+        clonedEntry.add( upId, values );
+    }
+
+
+    public void add( String upId, byte[]... values ) throws NamingException
+    {
+        clonedEntry.add( upId, values );
+    }
+
+
+    public void add( String upId, Value<?>... values ) throws NamingException
+    {
+        clonedEntry.add( upId, values );
+    }
+
+
+    public void clear()
+    {
+        clonedEntry.clear();
+    }
+
+
+    public boolean contains( EntryAttribute... attributes ) throws NamingException
+    {
+        return clonedEntry.contains( attributes );
+    }
+
+
+    public boolean contains( String upId, byte[]... values )
+    {
+        return clonedEntry.contains( upId, values );
+    }
+
+
+    public boolean contains( String upId, String... values )
+    {
+        return clonedEntry.contains( upId, values );
+    }
+
+
+    public boolean contains( String upId, Value<?>... values )
+    {
+        return clonedEntry.contains( upId, values );
+    }
+
+
+    public boolean containsAttribute( String... attributes )
+    {
+        return clonedEntry.containsAttribute( attributes );
+    }
+
+
+    public EntryAttribute get( String alias )
+    {
+        return clonedEntry.get( alias );
+    }
+
+
+    public LdapDN getDn()
+    {
+        return clonedEntry.getDn();
+    }
+
+
+    public boolean hasObjectClass( String objectClass )
+    {
+        return clonedEntry.hasObjectClass( objectClass );
+    }
+
+
+    public Iterator<EntryAttribute> iterator()
+    {
+        return clonedEntry.iterator();
+    }
+
+
+    public List<EntryAttribute> put( EntryAttribute... attributes ) throws NamingException
+    {
+        return clonedEntry.put( attributes );
+    }
+
+
+    public EntryAttribute put( String upId, byte[]... values )
+    {
+        return clonedEntry.put( upId, values );
+    }
+
+
+    public EntryAttribute put( String upId, String... values )
+    {
+        return clonedEntry.put( upId, values );
+    }
+
+
+    public EntryAttribute put( String upId, Value<?>... values )
+    {
+        return clonedEntry.put( upId, values );
+    }
+
+
+    public boolean remove( String upId, byte[]... values ) throws NamingException
+    {
+        return clonedEntry.remove( upId, values );
+    }
+
+
+    public boolean remove( String upId, String... values ) throws NamingException
+    {
+        return clonedEntry.remove( upId, values );
+    }
+
+
+    public boolean remove( String upId, Value<?>... values ) throws NamingException
+    {
+        return clonedEntry.remove( upId, values );
+    }
+
+
+    public List<EntryAttribute> removeAttributes( String... attributes )
+    {
+        return clonedEntry.removeAttributes( attributes );
+    }
+
+
+    public List<EntryAttribute> set( String... upIds )
+    {
+        return clonedEntry.set( upIds );
+    }
+
+
+    public void setDn( LdapDN dn )
+    {
+        clonedEntry.setDn( dn );
+    }
+
+
+    public int size()
+    {
+        return clonedEntry.size();
+    }
+
+
+    public ServerEntry clone()
+    {
+        return ( ServerEntry ) clonedEntry.clone();
+    }
+}

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java?rev=659229&r1=659228&r2=659229&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java Thu May 22 13:00:38 2008
@@ -30,8 +30,8 @@
 import java.util.Set;
 
 import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.cursor.Cursor;
-import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
+import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.interceptor.BaseInterceptor;
 import org.apache.directory.server.core.interceptor.Interceptor;
 import org.apache.directory.server.core.interceptor.NextInterceptor;
@@ -228,7 +228,7 @@
     }
 
 
-    public ServerEntry getRootDSE( NextInterceptor next, GetRootDSEOperationContext opContext ) throws Exception
+    public ClonedServerEntry getRootDSE( NextInterceptor next, GetRootDSEOperationContext opContext ) throws Exception
     {
         if ( IS_DEBUG )
         {
@@ -264,7 +264,7 @@
     }
 
 
-    public Cursor<ServerEntry> list( NextInterceptor next, ListOperationContext opContext ) throws Exception
+    public EntryFilteringCursor list( NextInterceptor next, ListOperationContext opContext ) throws Exception
     {
         if ( IS_DEBUG )
         {
@@ -288,7 +288,7 @@
     }
 
 
-    public ServerEntry lookup( NextInterceptor next, LookupOperationContext opContext ) throws Exception
+    public ClonedServerEntry lookup( NextInterceptor next, LookupOperationContext opContext ) throws Exception
     {
         if ( IS_DEBUG )
         {
@@ -382,7 +382,7 @@
     }
 
 
-    public Cursor<ServerEntry> search( NextInterceptor next, SearchOperationContext opContext ) throws Exception
+    public EntryFilteringCursor search( NextInterceptor next, SearchOperationContext opContext ) throws Exception
     {
         if ( IS_DEBUG )
         {

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java?rev=659229&r1=659228&r2=659229&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java Thu May 22 13:00:38 2008
@@ -20,17 +20,16 @@
 package org.apache.directory.server.core.authz;
 
 
-import org.apache.commons.lang.NotImplementedException;
 import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.authn.LdapPrincipal;
 import org.apache.directory.server.core.authz.support.ACDFEngine;
-import org.apache.directory.server.core.cursor.Cursor;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.core.entry.ServerAttribute;
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.entry.ServerEntryUtils;
-import org.apache.directory.server.core.entry.ServerSearchResult;
-import org.apache.directory.server.core.enumeration.SearchResultFilter;
+import org.apache.directory.server.core.filtering.EntryFilter;
+import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.interceptor.BaseInterceptor;
 import org.apache.directory.server.core.interceptor.InterceptorChain;
 import org.apache.directory.server.core.interceptor.NextInterceptor;
@@ -46,6 +45,7 @@
 import org.apache.directory.server.core.interceptor.context.MoveOperationContext;
 import org.apache.directory.server.core.interceptor.context.RenameOperationContext;
 import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
+import org.apache.directory.server.core.interceptor.context.SearchingOperationContext;
 import org.apache.directory.server.core.invocation.Invocation;
 import org.apache.directory.server.core.invocation.InvocationStack;
 import org.apache.directory.server.core.jndi.ServerContext;
@@ -759,7 +759,7 @@
     }
 
 
-    public ServerEntry lookup( NextInterceptor next, LookupOperationContext lookupContext ) throws Exception
+    public ClonedServerEntry lookup( NextInterceptor next, LookupOperationContext lookupContext ) throws Exception
     {
         Invocation invocation = InvocationStack.getInstance().peek();
         LdapPrincipal principal = ( ( ServerContext ) invocation.getCaller() ).getPrincipal();
@@ -995,32 +995,31 @@
     }
 
     
-    public Cursor<ServerEntry> list( NextInterceptor next, ListOperationContext opContext ) throws Exception
+    public EntryFilteringCursor list( NextInterceptor next, ListOperationContext opContext ) throws Exception
     {
         Invocation invocation = InvocationStack.getInstance().peek();
         ServerLdapContext ctx = ( ServerLdapContext ) invocation.getCaller();
         LdapPrincipal user = ctx.getPrincipal();
-        Cursor<ServerEntry> e = next.list( opContext );
+        EntryFilteringCursor cursor = next.list( opContext );
         
         if ( isPrincipalAnAdministrator( user.getJndiName() ) || !enabled )
         {
-            return e;
+            return cursor;
         }
         
         AuthorizationFilter authzFilter = new AuthorizationFilter();
-//        return new SearchResultFilteringEnumeration( e, DEFAULT_SEARCH_CONTROLS, invocation, authzFilter, "List authorization Filter" );
-        // TODO NotImplementedException
-        throw new NotImplementedException();
+        cursor.addEntryFilter( authzFilter );
+        return cursor;
     }
 
 
-    public Cursor<ServerEntry> search( NextInterceptor next, SearchOperationContext opContext ) throws Exception
+    public EntryFilteringCursor search( NextInterceptor next, SearchOperationContext opContext ) throws Exception
     {
         Invocation invocation = InvocationStack.getInstance().peek();
         ServerLdapContext ctx = ( ServerLdapContext ) invocation.getCaller();
         LdapPrincipal user = ctx.getPrincipal();
         LdapDN principalDn = user.getJndiName();
-        Cursor<ServerEntry> e = next.search( opContext );
+        EntryFilteringCursor cursor = next.search( opContext );
 
         boolean isSubschemaSubentryLookup = subschemaSubentryDn.equals( opContext.getDn().getNormName() );
         SearchControls searchCtls = opContext.getSearchControls();
@@ -1028,13 +1027,11 @@
 
         if ( isPrincipalAnAdministrator( principalDn ) || !enabled || isRootDSELookup || isSubschemaSubentryLookup )
         {
-            return e;
+            return cursor;
         }
         
-        AuthorizationFilter authzFilter = new AuthorizationFilter();
-//        return new SearchResultFilteringEnumeration( e, searchCtls, invocation, authzFilter, "Search authorization Filter" );
-        // TODO NotImplementedException
-        throw new NotImplementedException();
+        cursor.addEntryFilter( new AuthorizationFilter() );
+        return cursor;
     }
 
     
@@ -1129,15 +1126,14 @@
     }
 
 
-    private boolean filter( Invocation invocation, LdapDN normName, ServerSearchResult result ) throws Exception
+    private boolean filter( LdapDN normName, ClonedServerEntry clonedEntry ) throws Exception
     {
-        ServerEntry resultEntry = result.getServerEntry();
-
         /*
          * First call hasPermission() for entry level "Browse" and "ReturnDN" perm
          * tests.  If we hasPermission() returns false we immediately short the
          * process and return false.
          */
+        Invocation invocation = InvocationStack.getInstance().peek();
         ServerEntry entry = invocation.getProxy().lookup( 
                 new LookupOperationContext( registries, normName ), PartitionNexusProxy.LOOKUP_BYPASS );
         
@@ -1160,7 +1156,7 @@
                         null, 
                         SEARCH_ENTRY_PERMS, 
                         tuples, 
-                        entry, 
+                        clonedEntry.getOriginalEntry(), 
                         null ) )
         {
             return false;
@@ -1175,11 +1171,11 @@
          */
         List<AttributeType> attributeToRemove = new ArrayList<AttributeType>();
         
-        for ( AttributeType attributeType:resultEntry.getAttributeTypes() )
+        for ( AttributeType attributeType:clonedEntry.getAttributeTypes() )
         {
             // if attribute type scope access is not allowed then remove the attribute and continue
             String id = attributeType.getName();
-            EntryAttribute attr = resultEntry.get( attributeType );
+            EntryAttribute attr = clonedEntry.get( attributeType );
         
             if ( !engine.hasPermission( 
                         registries, 
@@ -1236,10 +1232,9 @@
         
         for ( AttributeType attributeType:attributeToRemove )
         {
-            resultEntry.removeAttributes( attributeType );
+            clonedEntry.removeAttributes( attributeType );
         }
 
-        result.setServerEntry( resultEntry );
         return true;
     }
 
@@ -1247,13 +1242,13 @@
     /**
      * WARNING: create one of these filters fresh every time for each new search.
      */
-    class AuthorizationFilter implements SearchResultFilter
+    class AuthorizationFilter implements EntryFilter
     {
-        public boolean accept( Invocation invocation, ServerSearchResult result, SearchControls controls ) 
+        public boolean accept( SearchingOperationContext operationContext, ClonedServerEntry entry ) 
             throws Exception
         {
-            LdapDN normName = result.getDn().normalize( atRegistry.getNormalizerMapping() );
-            return filter( invocation, normName, result );
+            LdapDN normName = entry.getDn().normalize( atRegistry.getNormalizerMapping() );
+            return filter( normName, entry );
         }
     }
 }

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationInterceptor.java?rev=659229&r1=659228&r2=659229&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationInterceptor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authz/DefaultAuthorizationInterceptor.java Thu May 22 13:00:38 2008
@@ -20,12 +20,12 @@
 package org.apache.directory.server.core.authz;
 
 
-import org.apache.commons.lang.NotImplementedException;
 import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.cursor.Cursor;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.entry.ServerSearchResult;
+import org.apache.directory.server.core.filtering.EntryFilter;
+import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.interceptor.BaseInterceptor;
 import org.apache.directory.server.core.interceptor.Interceptor;
 import org.apache.directory.server.core.interceptor.NextInterceptor;
@@ -37,6 +37,7 @@
 import org.apache.directory.server.core.interceptor.context.MoveOperationContext;
 import org.apache.directory.server.core.interceptor.context.RenameOperationContext;
 import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
+import org.apache.directory.server.core.interceptor.context.SearchingOperationContext;
 import org.apache.directory.server.core.invocation.Invocation;
 import org.apache.directory.server.core.invocation.InvocationStack;
 import org.apache.directory.server.core.jndi.ServerContext;
@@ -422,9 +423,9 @@
     }
 
 
-    public ServerEntry lookup( NextInterceptor nextInterceptor, LookupOperationContext opContext ) throws Exception
+    public ClonedServerEntry lookup( NextInterceptor nextInterceptor, LookupOperationContext opContext ) throws Exception
     {
-        ServerEntry serverEntry = nextInterceptor.lookup( opContext );
+        ClonedServerEntry serverEntry = nextInterceptor.lookup( opContext );
         
         if ( !enabled || ( serverEntry == null ) )
         {
@@ -494,57 +495,48 @@
     }
 
 
-    public Cursor<ServerEntry> search( NextInterceptor nextInterceptor, SearchOperationContext opContext ) throws Exception
+    public EntryFilteringCursor search( NextInterceptor nextInterceptor, SearchOperationContext opContext ) throws Exception
     {
-        Cursor<ServerEntry> e = nextInterceptor.search( opContext );
+        EntryFilteringCursor cursor = nextInterceptor.search( opContext );
 
         if ( !enabled )
         {
-            return e;
+            return cursor;
         }
 
-        Invocation invocation = InvocationStack.getInstance().peek();
-
-//        return new SearchResultFilteringEnumeration( e, opContext.getSearchControls(), invocation, 
-//            new SearchResultFilter()
-//        {
-//            public boolean accept( Invocation invocation, ServerSearchResult result, SearchControls controls )
-//                throws Exception
-//            {
-//                return DefaultAuthorizationInterceptor.this.isSearchable( invocation, result );
-//            }
-//        }, "Search Default Authorization filter" );
-        // TODO not implemented
-        throw new NotImplementedException();
+        cursor.addEntryFilter( new EntryFilter() {
+            public boolean accept( SearchingOperationContext operation, ClonedServerEntry result ) throws Exception
+            {
+                Invocation invocation = InvocationStack.getInstance().peek();
+                return DefaultAuthorizationInterceptor.this.isSearchable( invocation, result );
+            }
+        } );
+        return cursor;
     }
 
 
-    public Cursor<ServerEntry> list( NextInterceptor nextInterceptor, ListOperationContext opContext ) throws Exception
+    public EntryFilteringCursor list( NextInterceptor nextInterceptor, ListOperationContext opContext ) throws Exception
     {
-        Cursor<ServerEntry> result = nextInterceptor.list( opContext );
+        EntryFilteringCursor cursor = nextInterceptor.list( opContext );
         
         if ( !enabled )
         {
-            return result;
+            return cursor;
         }
 
-        Invocation invocation = InvocationStack.getInstance().peek();
-        
-//        return new SearchResultFilteringEnumeration( result, null, invocation, new SearchResultFilter()
-//        {
-//            public boolean accept( Invocation invocation, ServerSearchResult result, SearchControls controls )
-//                throws Exception
-//            {
-//                return DefaultAuthorizationInterceptor.this.isSearchable( invocation, result );
-//            }
-//        }, "List Default Authorization filter" );
-        
-        // TODO not implemented
-        throw new NotImplementedException();
+        cursor.addEntryFilter( new EntryFilter()
+        {
+            public boolean accept( SearchingOperationContext operation, ClonedServerEntry entry ) throws Exception
+            {
+                Invocation invocation = InvocationStack.getInstance().peek();
+                return DefaultAuthorizationInterceptor.this.isSearchable( invocation, entry );
+            }
+        } );
+        return cursor;
     }
 
 
-    private boolean isSearchable( Invocation invocation, ServerSearchResult result ) throws Exception
+    private boolean isSearchable( Invocation invocation, ClonedServerEntry result ) throws Exception
     {
         LdapDN principalDn = ( ( ServerContext ) invocation.getCaller() ).getPrincipal().getJndiName();
         LdapDN dn = result.getDn();

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authz/GroupCache.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authz/GroupCache.java?rev=659229&r1=659228&r2=659229&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authz/GroupCache.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authz/GroupCache.java Thu May 22 13:00:38 2008
@@ -29,9 +29,9 @@
 
 import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.cursor.Cursor;
 import org.apache.directory.server.core.entry.ServerAttribute;
 import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
 import org.apache.directory.server.core.partition.PartitionNexus;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
@@ -142,7 +142,7 @@
             LdapDN baseDn = new LdapDN( suffix );
             SearchControls ctls = new SearchControls();
             ctls.setSearchScope( SearchControls.SUBTREE_SCOPE );
-            Cursor<ServerEntry> results = nexus.search( new SearchOperationContext( registries,
+            EntryFilteringCursor results = nexus.search( new SearchOperationContext( registries,
                 baseDn, AliasDerefMode.DEREF_ALWAYS, filter, ctls ) );
 
             while ( results.next() )

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authz/TupleCache.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authz/TupleCache.java?rev=659229&r1=659228&r2=659229&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authz/TupleCache.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/authz/TupleCache.java Thu May 22 13:00:38 2008
@@ -21,9 +21,9 @@
 
 
 import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.cursor.Cursor;
 import org.apache.directory.server.core.entry.ServerAttribute;
 import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
 import org.apache.directory.server.core.partition.PartitionNexus;
 import org.apache.directory.server.schema.ConcreteNameComponentNormalizer;
@@ -134,7 +134,7 @@
                 SchemaConstants.ACCESS_CONTROL_SUBENTRY_OC ) );
             SearchControls ctls = new SearchControls();
             ctls.setSearchScope( SearchControls.SUBTREE_SCOPE );
-            Cursor<ServerEntry> results = nexus.search( new SearchOperationContext( registries,
+            EntryFilteringCursor results = nexus.search( new SearchOperationContext( registries,
                 baseDn, AliasDerefMode.NEVER_DEREF_ALIASES, filter, ctls ) );
 
             while ( results.next() )

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java?rev=659229&r1=659228&r2=659229&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java Thu May 22 13:00:38 2008
@@ -20,13 +20,12 @@
 package org.apache.directory.server.core.collective;
 
 
-import org.apache.commons.lang.NotImplementedException;
 import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.cursor.Cursor;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.core.entry.DefaultServerAttribute;
 import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.entry.ServerSearchResult;
-import org.apache.directory.server.core.enumeration.SearchResultFilter;
+import org.apache.directory.server.core.filtering.EntryFilter;
+import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.interceptor.BaseInterceptor;
 import org.apache.directory.server.core.interceptor.NextInterceptor;
 import org.apache.directory.server.core.interceptor.context.AddOperationContext;
@@ -34,8 +33,7 @@
 import org.apache.directory.server.core.interceptor.context.LookupOperationContext;
 import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
 import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
-import org.apache.directory.server.core.invocation.Invocation;
-import org.apache.directory.server.core.invocation.InvocationStack;
+import org.apache.directory.server.core.interceptor.context.SearchingOperationContext;
 import org.apache.directory.server.core.partition.PartitionNexus;
 import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.server.schema.registries.Registries;
@@ -45,8 +43,6 @@
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 
-import javax.naming.NamingException;
-import javax.naming.directory.SearchControls;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -79,22 +75,20 @@
     /**
      * the search result filter to use for collective attribute injection
      */
-    private final SearchResultFilter SEARCH_FILTER = new SearchResultFilter()
+    private final EntryFilter SEARCH_FILTER = new EntryFilter()
     {
-        public boolean accept( Invocation invocation, ServerSearchResult result, SearchControls controls )
+        public boolean accept( SearchingOperationContext operation, ClonedServerEntry result )
             throws Exception
         {
-            LdapDN name = ((ServerSearchResult)result).getDn();
+            LdapDN name = result.getDn();
             
             if ( name.isNormalized() == false )
             {
             	name = LdapDN.normalize( name, atRegistry.getNormalizerMapping() );
             }
             
-            ServerEntry entry = result.getServerEntry();
-            String[] retAttrs = controls.getReturningAttributes();
-            addCollectiveAttributes( name, entry, retAttrs );
-            result.setServerEntry( entry );
+            String[] retAttrs = operation.getSearchControls().getReturningAttributes();
+            addCollectiveAttributes( name, result, retAttrs );
             return true;
         }
     };
@@ -285,7 +279,7 @@
     }
     
     
-    private Set<AttributeType> getAllSuperTypes( AttributeType id ) throws NamingException
+    private Set<AttributeType> getAllSuperTypes( AttributeType id ) throws Exception
     {
         Set<AttributeType> allSuperTypes = new HashSet<AttributeType>();
         AttributeType superType = id;
@@ -307,9 +301,12 @@
     // ------------------------------------------------------------------------
     // Interceptor Method Overrides
     // ------------------------------------------------------------------------
-    public ServerEntry lookup( NextInterceptor nextInterceptor, LookupOperationContext opContext ) throws Exception
+
+    
+    public ClonedServerEntry lookup( NextInterceptor nextInterceptor, LookupOperationContext opContext ) 
+        throws Exception
     {
-        ServerEntry result = nextInterceptor.lookup( opContext );
+        ClonedServerEntry result = nextInterceptor.lookup( opContext );
         
         if ( result == null )
         {
@@ -329,34 +326,27 @@
     }
 
 
-    public Cursor<ServerEntry> list( NextInterceptor nextInterceptor, ListOperationContext opContext ) throws Exception
+    public EntryFilteringCursor list( NextInterceptor nextInterceptor, ListOperationContext opContext ) throws Exception
     {
-        Cursor<ServerEntry> result = nextInterceptor.list( opContext );
-        Invocation invocation = InvocationStack.getInstance().peek();
-        
-//        return new SearchResultFilteringEnumeration( result, new SearchControls(), invocation, SEARCH_FILTER, "List collective Filter" );
-        
-        // TODO not implemented
-        throw new NotImplementedException();
+        EntryFilteringCursor cursor = nextInterceptor.list( opContext );
+        cursor.addEntryFilter( SEARCH_FILTER );
+        return cursor;
     }
 
 
-    public Cursor<ServerEntry> search( NextInterceptor nextInterceptor, SearchOperationContext opContext ) throws Exception
+    public EntryFilteringCursor search( NextInterceptor nextInterceptor, SearchOperationContext opContext ) throws Exception
     {
-        Cursor<ServerEntry> result = nextInterceptor.search( opContext );
-        Invocation invocation = InvocationStack.getInstance().peek();
-        
-//        return new SearchResultFilteringEnumeration( 
-//            result, opContext.getSearchControls(), invocation, SEARCH_FILTER, "Search collective Filter" );
-        
-        // TODO not implemented
-        throw new NotImplementedException();
+        EntryFilteringCursor cursor = nextInterceptor.search( opContext );
+        cursor.addEntryFilter( SEARCH_FILTER );
+        return cursor;
     }
+
     
     // ------------------------------------------------------------------------
     // Partial Schema Checking
     // ------------------------------------------------------------------------
     
+    
     public void add( NextInterceptor next, AddOperationContext opContext ) throws Exception
     {
         collectiveAttributesSchemaChecker.checkAdd( opContext.getDn(), opContext.getEntry() );

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java?rev=659229&r1=659228&r2=659229&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java Thu May 22 13:00:38 2008
@@ -22,10 +22,11 @@
 
 import org.apache.commons.collections.map.LRUMap;
 import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.cursor.Cursor;
 import org.apache.directory.server.core.cursor.EmptyCursor;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.core.entry.ServerAttribute;
 import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.interceptor.BaseInterceptor;
 import org.apache.directory.server.core.interceptor.NextInterceptor;
 import org.apache.directory.server.core.interceptor.context.AddOperationContext;
@@ -232,7 +233,7 @@
 
         // check if entry to delete has children (only leaves can be deleted)
         boolean hasChildren = false;
-        Cursor<ServerEntry> list = nextInterceptor.list( new ListOperationContext( registries, name ) );
+        EntryFilteringCursor list = nextInterceptor.list( new ListOperationContext( registries, name ) );
         
         if ( list.next() )
         {
@@ -263,12 +264,12 @@
     /**
      * Checks to see the base being searched exists, otherwise throws the appropriate LdapException.
      */
-    public Cursor<ServerEntry> list( NextInterceptor nextInterceptor, ListOperationContext opContext ) throws Exception
+    public EntryFilteringCursor list( NextInterceptor nextInterceptor, ListOperationContext opContext ) throws Exception
     {
         if ( opContext.getDn().getNormName().equals( subschemSubentryDn.getNormName() ) )
         {
             // there is nothing under the schema subentry
-            return new EmptyCursor<ServerEntry>();
+            return new EntryFilteringCursor( new EmptyCursor<ServerEntry>(), opContext );
         }
         
         // check if entry to search exists
@@ -282,7 +283,7 @@
     /**
      * Checks to see the base being searched exists, otherwise throws the appropriate LdapException.
      */
-    public ServerEntry lookup( NextInterceptor nextInterceptor, LookupOperationContext opContext ) throws Exception
+    public ClonedServerEntry lookup( NextInterceptor nextInterceptor, LookupOperationContext opContext ) throws Exception
     {
         if ( opContext.getDn().getNormName().equals( subschemSubentryDn.getNormName() ) )
         {
@@ -516,15 +517,15 @@
     /**
      * Checks to see the entry being searched exists, otherwise throws the appropriate LdapException.
      */
-    public Cursor<ServerEntry> search( NextInterceptor nextInterceptor, SearchOperationContext opContext ) throws Exception
+    public EntryFilteringCursor search( NextInterceptor nextInterceptor, SearchOperationContext opContext ) throws Exception
     {
         LdapDN base = opContext.getDn();
 
         try
         {
-            Cursor<ServerEntry> result =  nextInterceptor.search( opContext );
+            EntryFilteringCursor cursor =  nextInterceptor.search( opContext );
 	        
-	        if ( ! result.next() )
+	        if ( ! cursor.next() )
 	        {
 	            if ( !base.isEmpty() && !( subschemSubentryDn.toNormName() ).equalsIgnoreCase( base.toNormName() ) )
 	            {
@@ -533,7 +534,7 @@
 	            }
 	        }
 
-	        return result;
+	        return cursor;
         }
         catch ( Exception ne )
         {

Added: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/filtering/EntryFilter.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/filtering/EntryFilter.java?rev=659229&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/filtering/EntryFilter.java (added)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/filtering/EntryFilter.java Thu May 22 13:00:38 2008
@@ -0,0 +1,52 @@
+/*
+ *  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.server.core.filtering;
+
+
+import org.apache.directory.server.core.entry.ClonedServerEntry;
+import org.apache.directory.server.core.interceptor.context.SearchingOperationContext;
+
+
+/**
+ * An entry filter is used to modify search results while they are being 
+ * returned from Cursors over ServerEntry objects.  These filters are used in
+ * conjunction with a {@link FilteringCursor}.  Multiple filters can be 
+ * applied one after the other and hence they are stack-able and applied in
+ * order.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public interface EntryFilter
+{
+    /**
+     * Filters the contents of search entries on the way out the door to 
+     * client callers.  These filters can and do produce side-effects on the 
+     * entry results if need be.  These entries, their attributes and values
+     * should be cloned when alterations are made to avoid altering cached
+     * entries.
+     *
+     * @param result the result to accept or reject possibly modifying it
+     * @param controls search controls associated with the invocation
+     * @return true if the entry is to be returned, false if it is rejected
+     * @throws Exception if there are failures during evaluation
+     */
+    boolean accept( SearchingOperationContext operation, ClonedServerEntry result ) throws Exception;
+}

Added: 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=659229&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/filtering/EntryFilteringCursor.java (added)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/filtering/EntryFilteringCursor.java Thu May 22 13:00:38 2008
@@ -0,0 +1,470 @@
+/*
+ *   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.server.core.filtering;
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.directory.server.core.cursor.Cursor;
+import org.apache.directory.server.core.cursor.CursorIterator;
+import org.apache.directory.server.core.cursor.InvalidCursorPositionException;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
+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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * A Cursor which uses a list of filters to selectively return entries and/or
+ * modify the contents of entries.  Uses lazy pre-fetching on positioning 
+ * operations which means adding filters after creation will not miss candidate
+ * entries.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class EntryFilteringCursor implements Cursor<ClonedServerEntry>
+{
+    /** the logger used by this class */
+    private static final Logger log = LoggerFactory.getLogger( EntryFilteringCursor.class );
+
+    /** the underlying wrapped search results Cursor */
+    private final Cursor<ServerEntry> wrapped;
+    
+    /** the parameters associated with the search operation */
+    private final SearchingOperationContext operationContext;
+    
+    /** the list of filters to be applied */
+    private final List<EntryFilter> filters;
+    
+    /** the first accepted search result that is pre fetched */
+    private ClonedServerEntry prefetched;
+    
+    /** whether or not this search has been abandoned */
+    private boolean abandoned = false;
+
+    
+    // ------------------------------------------------------------------------
+    // C O N S T R U C T O R S
+    // ------------------------------------------------------------------------
+
+    
+    /**
+     * Creates a new entry filtering Cursor over an existing Cursor using a 
+     * single filter initially: more can be added later after creation.
+     * 
+     * @param wrapped the underlying wrapped Cursor whose entries are filtered
+     * @param searchControls the controls of search that created this Cursor
+     * @param invocation the search operation invocation creating this Cursor
+     * @param filter a single filter to be used
+     */
+    public EntryFilteringCursor( Cursor<ServerEntry> wrapped, 
+        SearchingOperationContext operationContext, EntryFilter filter )
+    {
+        this( wrapped, operationContext, Collections.singletonList( filter ) );
+    }
+
+    
+    /**
+     * Creates a new entry filtering Cursor over an existing Cursor using a 
+     * no filter initially: more can be added later after creation.
+     * 
+     * @param wrapped the underlying wrapped Cursor whose entries are filtered
+     * @param searchControls the controls of search that created this Cursor
+     * @param invocation the search operation invocation creating this Cursor
+     * @param filter a single filter to be used
+     */
+    public EntryFilteringCursor( Cursor<ServerEntry> wrapped, SearchingOperationContext operationContext )
+    {
+        this.wrapped = wrapped;
+        this.operationContext = operationContext;
+        this.filters = new ArrayList<EntryFilter>();
+    }
+
+    
+    /**
+     * Creates a new entry filtering Cursor over an existing Cursor using a 
+     * list of filters initially: more can be added later after creation.
+     * 
+     * @param wrapped the underlying wrapped Cursor whose entries are filtered
+     * @param operationContext the operation context that created this Cursor
+     * @param invocation the search operation invocation creating this Cursor
+     * @param filters a list of filters to be used
+     */
+    public EntryFilteringCursor( Cursor<ServerEntry> wrapped, 
+        SearchingOperationContext operationContext, List<EntryFilter> filters )
+    {
+        this.wrapped = wrapped;
+        this.operationContext = operationContext;
+        this.filters = new ArrayList<EntryFilter>();
+        this.filters.addAll( filters );
+    }
+
+    
+    // ------------------------------------------------------------------------
+    // Class Specific Methods
+    // ------------------------------------------------------------------------
+
+    
+    /**
+     * Gets whether or not this EntryFilteringCursor has been abandoned.
+     *
+     * @return true if abandoned, false if not
+     */
+    public boolean isAbandoned()
+    {
+        return abandoned;
+    }
+    
+    
+    /**
+     * Sets whether this EntryFilteringCursor has been abandoned.
+     *
+     * @param abandoned true if abandoned, false if not
+     */
+    public void setAbandoned( boolean abandoned )
+    {
+        this.abandoned = abandoned;
+        
+        if ( abandoned )
+        {
+            log.info( "Cursor has been abandoned." );
+        }
+    }
+    
+    
+    /**
+     * Adds an entry filter to this EntryFilteringCursor at the very end of 
+     * the filter list.  EntryFilters are applied in the order of addition.
+     * 
+     * @param filter a filter to apply to the entries
+     * @return the result of {@link List#add(Object)}
+     */
+    public boolean addEntryFilter( EntryFilter filter )
+    {
+        return filters.add( filter );
+    }
+    
+    
+    /**
+     * Removes an entry filter to this EntryFilteringCursor at the very end of 
+     * the filter list.  
+     * 
+     * @param filter a filter to remove from the filter list
+     * @return the result of {@link List#remove(Object)}
+     */
+    public boolean removeEntryFilter( EntryFilter filter )
+    {
+        return filters.remove( filter );
+    }
+    
+    
+    /**
+     * Gets an unmodifiable list of EntryFilters applied.
+     *
+     * @return an unmodifiable list of EntryFilters applied
+     */
+    public List<EntryFilter> getEntryFilters()
+    {
+        return Collections.unmodifiableList( filters );
+    }
+    
+    
+    /**
+     * @return the operationContext
+     */
+    public SearchingOperationContext getOperationContext()
+    {
+        return operationContext;
+    }
+
+    
+    // ------------------------------------------------------------------------
+    // Cursor Interface Methods
+    // ------------------------------------------------------------------------
+
+    
+    /* 
+     * @see Cursor#after(Object)
+     */
+    public void after( ClonedServerEntry element ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    /* 
+     * @see Cursor#afterLast()
+     */
+    public void afterLast() throws Exception
+    {
+        wrapped.afterLast();
+        prefetched = null;
+    }
+
+
+    /* 
+     * @see Cursor#available()
+     */
+    public boolean available()
+    {
+        return prefetched != null;
+    }
+
+
+    /* 
+     * @see Cursor#before(java.lang.Object)
+     */
+    public void before( ClonedServerEntry element ) throws Exception
+    {
+        throw new UnsupportedOperationException();
+    }
+
+
+    /* 
+     * @see Cursor#beforeFirst()
+     */
+    public void beforeFirst() throws Exception
+    {
+        wrapped.beforeFirst();
+        prefetched = null;
+    }
+
+
+    /* 
+     * @see Cursor#close()
+     */
+    public void close() throws Exception
+    {
+        wrapped.close();
+        prefetched = null;
+    }
+
+
+    /* 
+     * @see Cursor#first()
+     */
+    public boolean first() throws Exception
+    {
+        if ( abandoned )
+        {
+            log.info( "Cursor has been abandoned." );
+            close();
+            throw new OperationAbandonedException();
+        }
+        
+        beforeFirst();
+        return next();
+    }
+
+
+    /* 
+     * @see Cursor#get()
+     */
+    public ClonedServerEntry get() throws Exception
+    {
+        if ( available() )
+        {
+            return prefetched;
+        }
+        
+        throw new InvalidCursorPositionException();
+    }
+
+
+    /* 
+     * @see Cursor#isClosed()
+     */
+    public boolean isClosed() throws Exception
+    {
+        return wrapped.isClosed();
+    }
+
+
+    /* 
+     * @see Cursor#isElementReused()
+     */
+    public boolean isElementReused()
+    {
+        return true;
+    }
+
+
+    /* 
+     * @see Cursor#last()
+     */
+    public boolean last() throws Exception
+    {
+        if ( abandoned )
+        {
+            log.info( "Cursor has been abandoned." );
+            close();
+            throw new OperationAbandonedException();
+        }
+
+        afterLast();
+        return previous();
+    }
+
+
+    /* 
+     * @see Cursor#next()
+     */
+    public boolean next() throws Exception
+    {
+        if ( abandoned )
+        {
+            log.info( "Cursor has been abandoned." );
+            close();
+            throw new OperationAbandonedException();
+        }
+        
+        ClonedServerEntry tempResult = null;
+        outer: while ( wrapped.next() )
+        {
+            boolean accepted = true;
+            tempResult = new ClonedServerEntry( wrapped.get() );
+            
+            /*
+             * O P T I M I Z A T I O N
+             * -----------------------
+             * 
+             * Don't want to waste cycles on enabling a loop for processing 
+             * filters if we have zero or one filter.
+             */
+            
+            if ( filters.isEmpty() )
+            {
+                prefetched = tempResult;
+                return true;
+            }
+            
+            if ( filters.size() == 1 )
+            {
+                if ( filters.get( 0 ).accept( operationContext, tempResult ) )
+                {
+                    prefetched = tempResult;
+                    return true;
+                }
+            }
+            
+            /* E N D   O P T I M I Z A T I O N */
+            
+            for ( EntryFilter filter : filters )
+            {
+                // if a filter rejects then short and continue with outer loop
+                if ( ! ( accepted &= filter.accept( operationContext, tempResult ) ) )
+                {
+                    continue outer;
+                }
+            }
+            
+            /*
+             * Here the entry has been accepted by all filters.
+             */
+            
+            prefetched = tempResult;
+            return true;
+        }
+        
+        prefetched = null;
+        return false;
+    }
+
+
+    /* 
+     * @see Cursor#previous()
+     */
+    public boolean previous() throws Exception
+    {
+        if ( abandoned )
+        {
+            log.info( "Cursor has been abandoned." );
+            close();
+            throw new OperationAbandonedException();
+        }
+        
+        ClonedServerEntry tempResult = null;
+        outer: while ( wrapped.previous() )
+        {
+            boolean accepted = true;
+            tempResult = new ClonedServerEntry( wrapped.get() );
+            
+            /*
+             * O P T I M I Z A T I O N
+             * -----------------------
+             * 
+             * Don't want to waste cycles on enabling a loop for processing 
+             * filters if we have zero or one filter.
+             */
+            
+            if ( filters.isEmpty() )
+            {
+                prefetched = tempResult;
+                return true;
+            }
+            
+            if ( filters.size() == 1 )
+            {
+                if ( filters.get( 0 ).accept( operationContext, tempResult ) )
+                {
+                    prefetched = tempResult;
+                    return true;
+                }
+            }
+            
+            /* E N D   O P T I M I Z A T I O N */
+            
+            for ( EntryFilter filter : filters )
+            {
+                // if a filter rejects then short and continue with outer loop
+                if ( ! ( accepted &= filter.accept( operationContext, tempResult ) ) )
+                {
+                    continue outer;
+                }
+            }
+            
+            /*
+             * Here the entry has been accepted by all filters.
+             */
+            
+            prefetched = tempResult;
+            return true;
+        }
+        
+        prefetched = null;
+        return false;
+    }
+
+
+    /* 
+     * @see Iterable#iterator()
+     */
+    public Iterator<ClonedServerEntry> iterator()
+    {
+        return new CursorIterator<ClonedServerEntry>( this );
+    }
+}

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/BaseInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/BaseInterceptor.java?rev=659229&r1=659228&r2=659229&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/BaseInterceptor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/BaseInterceptor.java Thu May 22 13:00:38 2008
@@ -22,8 +22,8 @@
 
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.authn.LdapPrincipal;
-import org.apache.directory.server.core.cursor.Cursor;
-import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
+import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.interceptor.context.AddContextPartitionOperationContext;
 import org.apache.directory.server.core.interceptor.context.AddOperationContext;
 import org.apache.directory.server.core.interceptor.context.BindOperationContext;
@@ -142,7 +142,7 @@
     }
 
 
-    public ServerEntry getRootDSE( NextInterceptor next, GetRootDSEOperationContext opContext ) throws Exception
+    public ClonedServerEntry getRootDSE( NextInterceptor next, GetRootDSEOperationContext opContext ) throws Exception
     {
         return next.getRootDSE( opContext );
     }
@@ -160,7 +160,7 @@
     }
 
 
-    public Cursor<ServerEntry> list( NextInterceptor next, ListOperationContext opContext ) throws Exception
+    public EntryFilteringCursor list( NextInterceptor next, ListOperationContext opContext ) throws Exception
     {
         return next.list( opContext );
     }
@@ -173,7 +173,7 @@
     }
 
 
-    public ServerEntry lookup( NextInterceptor next, LookupOperationContext opContext ) throws Exception
+    public ClonedServerEntry lookup( NextInterceptor next, LookupOperationContext opContext ) throws Exception
     {
         return next.lookup( opContext );
     }
@@ -204,7 +204,7 @@
     }
 
 
-    public Cursor<ServerEntry> search( NextInterceptor next, SearchOperationContext opContext ) throws Exception
+    public EntryFilteringCursor search( NextInterceptor next, SearchOperationContext opContext ) throws Exception
     {
         return next.search( opContext );
     }

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/Interceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/Interceptor.java?rev=659229&r1=659228&r2=659229&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/Interceptor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/Interceptor.java Thu May 22 13:00:38 2008
@@ -21,8 +21,8 @@
 
 
 import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.cursor.Cursor;
-import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
+import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.interceptor.context.AddContextPartitionOperationContext;
 import org.apache.directory.server.core.interceptor.context.AddOperationContext;
 import org.apache.directory.server.core.interceptor.context.BindOperationContext;
@@ -138,7 +138,7 @@
     /**
      * Filters {@link PartitionNexus#getRootDSE( GetRootDSEOperationContext )} call.
      */
-    ServerEntry getRootDSE( NextInterceptor next, GetRootDSEOperationContext  opContext ) throws Exception;
+    ClonedServerEntry getRootDSE( NextInterceptor next, GetRootDSEOperationContext  opContext ) throws Exception;
 
 
     /**
@@ -198,19 +198,19 @@
     /**
      * Filters {@link Partition#list( ListOperationContext )} call.
      */
-    Cursor<ServerEntry> list( NextInterceptor next, ListOperationContext opContext ) throws Exception;
+    EntryFilteringCursor list( NextInterceptor next, ListOperationContext opContext ) throws Exception;
 
 
     /**
      * Filters {@link Partition#search( SearchOperationContext )} call.
      */
-    Cursor<ServerEntry> search( NextInterceptor next, SearchOperationContext opContext ) throws Exception;
+    EntryFilteringCursor search( NextInterceptor next, SearchOperationContext opContext ) throws Exception;
 
 
     /**
      * Filters {@link Partition#lookup( LookupOperationContext )} call.
      */
-    ServerEntry lookup( NextInterceptor next, LookupOperationContext opContext ) throws Exception;
+    ClonedServerEntry lookup( NextInterceptor next, LookupOperationContext opContext ) throws Exception;
 
 
     /**

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java?rev=659229&r1=659228&r2=659229&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java Thu May 22 13:00:38 2008
@@ -27,8 +27,8 @@
 import java.util.Map;
 
 import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.cursor.Cursor;
-import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
+import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.interceptor.context.AddContextPartitionOperationContext;
 import org.apache.directory.server.core.interceptor.context.AddOperationContext;
 import org.apache.directory.server.core.interceptor.context.BindOperationContext;
@@ -100,7 +100,7 @@
         }
 
 
-        public ServerEntry getRootDSE( NextInterceptor next, GetRootDSEOperationContext opContext ) throws Exception
+        public ClonedServerEntry getRootDSE( NextInterceptor next, GetRootDSEOperationContext opContext ) throws Exception
         {
             return nexus.getRootDSE( opContext );
         }
@@ -142,21 +142,21 @@
         }
 
 
-        public Cursor<ServerEntry> list( NextInterceptor next, ListOperationContext opContext ) throws Exception
+        public EntryFilteringCursor list( NextInterceptor next, ListOperationContext opContext ) throws Exception
         {
             return nexus.list( opContext );
         }
 
 
-        public Cursor<ServerEntry>  search( NextInterceptor next, SearchOperationContext opContext ) throws Exception
+        public EntryFilteringCursor search( NextInterceptor next, SearchOperationContext opContext ) throws Exception
         {
             return nexus.search( opContext );
         }
 
 
-        public ServerEntry lookup( NextInterceptor next, LookupOperationContext opContext ) throws Exception
+        public ClonedServerEntry lookup( NextInterceptor next, LookupOperationContext opContext ) throws Exception
         {
-            return ( ServerEntry ) nexus.lookup( opContext ).clone();
+            return nexus.lookup( opContext );
         }
 
 
@@ -534,7 +534,7 @@
     }
 
 
-    public ServerEntry getRootDSE( GetRootDSEOperationContext opContext ) throws Exception
+    public ClonedServerEntry getRootDSE( GetRootDSEOperationContext opContext ) throws Exception
     {
         Entry entry = getStartingEntry();
         Interceptor head = entry.interceptor;
@@ -793,7 +793,7 @@
     }
 
 
-    public Cursor<ServerEntry> list( ListOperationContext opContext ) throws Exception
+    public EntryFilteringCursor list( ListOperationContext opContext ) throws Exception
     {
         Entry entry = getStartingEntry();
         Interceptor head = entry.interceptor;
@@ -815,7 +815,7 @@
     }
 
 
-    public Cursor<ServerEntry> search( SearchOperationContext opContext )
+    public EntryFilteringCursor search( SearchOperationContext opContext )
         throws Exception
     {
         Entry entry = getStartingEntry();
@@ -838,7 +838,7 @@
     }
 
 
-    public ServerEntry lookup( LookupOperationContext opContext ) throws Exception
+    public ClonedServerEntry lookup( LookupOperationContext opContext ) throws Exception
     {
         Entry entry = getStartingEntry();
         Interceptor head = entry.interceptor;
@@ -1039,7 +1039,7 @@
                 }
 
 
-                public ServerEntry getRootDSE( GetRootDSEOperationContext opContext ) throws Exception
+                public ClonedServerEntry getRootDSE( GetRootDSEOperationContext opContext ) throws Exception
                 {
                     Entry next = getNextEntry();
                     Interceptor interceptor = next.interceptor;
@@ -1183,7 +1183,7 @@
                 }
 
                 
-                public Cursor<ServerEntry> list( ListOperationContext opContext ) throws Exception
+                public EntryFilteringCursor list( ListOperationContext opContext ) throws Exception
                 {
                     Entry next = getNextEntry();
                     Interceptor interceptor = next.interceptor;
@@ -1204,7 +1204,7 @@
                 }
 
 
-                public Cursor<ServerEntry> search( SearchOperationContext opContext )
+                public EntryFilteringCursor search( SearchOperationContext opContext )
                     throws Exception
                 {
                     Entry next = getNextEntry();
@@ -1226,7 +1226,7 @@
                 }
 
 
-                public ServerEntry lookup( LookupOperationContext opContext ) throws Exception
+                public ClonedServerEntry lookup( LookupOperationContext opContext ) throws Exception
                 {
                     Entry next = getNextEntry();
                     Interceptor interceptor = next.interceptor;

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/NextInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/NextInterceptor.java?rev=659229&r1=659228&r2=659229&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/NextInterceptor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/NextInterceptor.java Thu May 22 13:00:38 2008
@@ -22,8 +22,8 @@
 
 import java.util.Iterator;
 
-import org.apache.directory.server.core.cursor.Cursor;
-import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
+import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.interceptor.context.AddContextPartitionOperationContext;
 import org.apache.directory.server.core.interceptor.context.AddOperationContext;
 import org.apache.directory.server.core.interceptor.context.BindOperationContext;
@@ -66,7 +66,7 @@
     /**
      * Calls the next interceptor's {@link Interceptor#getRootDSE( NextInterceptor, GetRootDSEOperationContext )}.
      */
-    ServerEntry getRootDSE( GetRootDSEOperationContext opContext ) throws Exception;
+    ClonedServerEntry getRootDSE( GetRootDSEOperationContext opContext ) throws Exception;
 
 
     /**
@@ -119,19 +119,19 @@
     /**
      * Calls the next interceptor's {@link Interceptor#list( NextInterceptor, ListOperationContext )}.
      */
-    Cursor<ServerEntry> list( ListOperationContext opContext ) throws Exception;
+    EntryFilteringCursor list( ListOperationContext opContext ) throws Exception;
 
 
     /**
      * Calls the next interceptor's {@link Interceptor#search( NextInterceptor, SearchOperationContext opContext )}.
      */
-    Cursor<ServerEntry> search( SearchOperationContext opContext ) throws Exception;
+    EntryFilteringCursor search( SearchOperationContext opContext ) throws Exception;
 
 
     /**
      * Calls the next interceptor's {@link Interceptor#lookup( NextInterceptor, LookupOperationContext )}.
      */
-    ServerEntry lookup( LookupOperationContext opContext ) throws Exception;
+    ClonedServerEntry lookup( LookupOperationContext opContext ) throws Exception;
 
 
     /**

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/ListOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/ListOperationContext.java?rev=659229&r1=659228&r2=659229&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/ListOperationContext.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/interceptor/context/ListOperationContext.java Thu May 22 13:00:38 2008
@@ -19,10 +19,12 @@
  */
 package org.apache.directory.server.core.interceptor.context;
 
+
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
 
+
 /**
  * A ListContext context used for Interceptors. It contains all the informations
  * needed for the List operation, and used by all the interceptors
@@ -30,11 +32,8 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class ListOperationContext extends AbstractOperationContext
+public class ListOperationContext extends SearchingOperationContext
 {
-    private AliasDerefMode aliasDerefMode = AliasDerefMode.DEREF_ALWAYS;
-
-
     /**
      * Creates a new instance of ListOperationContext.
      */
@@ -63,8 +62,7 @@
      */
     public ListOperationContext( Registries registries, LdapDN dn, AliasDerefMode aliasDerefMode )
     {
-        super( registries, dn );
-        this.aliasDerefMode = aliasDerefMode;
+        super( registries, dn, aliasDerefMode );
     }
 
     
@@ -75,10 +73,4 @@
     {
         return "ListOperationContext with DN '" + getDn().getUpName() + "'";
     }
-
-
-    public AliasDerefMode getAliasDerefMode()
-    {
-        return aliasDerefMode;
-    }
 }

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=659229&r1=659228&r2=659229&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 Thu May 22 13:00:38 2008
@@ -35,16 +35,10 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class SearchOperationContext extends AbstractOperationContext
+public class SearchOperationContext extends SearchingOperationContext
 {
     /** The filter */
     private ExprNode filter;
-    
-    /** The controls */
-    private SearchControls searchControls;
-
-    /** The mode of alias handling */
-    private AliasDerefMode aliasDerefMode;
 
 
     /**
@@ -66,10 +60,8 @@
     public SearchOperationContext( Registries registries, LdapDN dn, AliasDerefMode aliasDerefMode, ExprNode filter,
                                    SearchControls searchControls )
     {
-        super( registries, dn );
+        super( registries, dn, aliasDerefMode, searchControls );
         this.filter = filter;
-        this.aliasDerefMode = aliasDerefMode;
-        this.searchControls = searchControls;
     }
 
 
@@ -94,26 +86,6 @@
 
 
     /**
-     *  @return The search controls
-     */
-    public SearchControls getSearchControls()
-    {
-        return searchControls;
-    }
-
-
-    /**
-     * Set the search controls
-     *
-     * @param searchControls The search controls
-     */
-    public void setSearchControls( SearchControls searchControls )
-    {
-        this.searchControls = searchControls;
-    }
-
-
-    /**
      * @see Object#toString()
      */
     public String toString()
@@ -121,23 +93,4 @@
         return "SearchContext for DN '" + getDn().getUpName() + "', filter :'"
         + filter + "'"; 
     }
-
-
-    /**
-     *  @return The alias handling mode
-     */
-    public AliasDerefMode getAliasDerefMode()
-    {
-        return aliasDerefMode;
-    }
-
-
-    /**
-     * Set the alias handling mode
-     *  @param aliasDerefMode The alias handling mode
-     */
-    public void setAliasDerefMode( AliasDerefMode aliasDerefMode )
-    {
-        this.aliasDerefMode = aliasDerefMode;
-    }
 }

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java?rev=659229&r1=659228&r2=659229&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java Thu May 22 13:00:38 2008
@@ -24,11 +24,11 @@
 import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.authn.AuthenticationInterceptor;
 import org.apache.directory.server.core.authn.LdapPrincipal;
-import org.apache.directory.server.core.cursor.Cursor;
 import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.entry.ServerEntryUtils;
+import org.apache.directory.server.core.filtering.EntryFilteringCursor;
 import org.apache.directory.server.core.interceptor.context.AddOperationContext;
 import org.apache.directory.server.core.interceptor.context.BindOperationContext;
 import org.apache.directory.server.core.interceptor.context.DeleteOperationContext;
@@ -253,7 +253,7 @@
      * @param searchControls
      * @return NamingEnumeration
      */
-    protected Cursor<ServerEntry> doSearchOperation( LdapDN dn, AliasDerefMode aliasDerefMode,
+    protected EntryFilteringCursor doSearchOperation( LdapDN dn, AliasDerefMode aliasDerefMode,
         ExprNode filter, SearchControls searchControls ) throws Exception
     {
         // setup the op context and populate with request controls
@@ -262,7 +262,7 @@
         opCtx.addRequestControls( requestControls );
 
         // execute search operation
-        Cursor<ServerEntry> results = nexusProxy.search( opCtx );
+        EntryFilteringCursor results = nexusProxy.search( opCtx );
 
         // clear the request controls and set the response controls 
         requestControls = EMPTY_CONTROLS;
@@ -275,14 +275,14 @@
     /**
      * Used to encapsulate [de]marshalling of controls before and after list operations.
      */
-    protected Cursor<ServerEntry> doListOperation( LdapDN target ) throws Exception
+    protected EntryFilteringCursor doListOperation( LdapDN target ) throws Exception
     {
         // setup the op context and populate with request controls
         ListOperationContext opCtx = new ListOperationContext( registries, target );
         opCtx.addRequestControls( requestControls );
 
         // execute list operation
-        Cursor<ServerEntry> results = nexusProxy.list( opCtx );
+        EntryFilteringCursor results = nexusProxy.list( opCtx );
 
         // clear the request controls and set the response controls 
         requestControls = EMPTY_CONTROLS;
@@ -1170,6 +1170,7 @@
         ctls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
         AliasDerefMode aliasDerefMode = AliasDerefMode.getEnum( getEnvironment() );
 //        return doSearchOperation( base, aliasDerefMode, filter, ctls );
+        
         // TODO not implemented
         throw new NotImplementedException();
     }

Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java?rev=659229&r1=659228&r2=659229&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/partition/AbstractPartition.java Thu May 22 13:00:38 2008
@@ -21,7 +21,7 @@
 
 
 import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.core.interceptor.context.EntryOperationContext;
 import org.apache.directory.server.core.interceptor.context.LookupOperationContext;
 
@@ -166,7 +166,7 @@
      * with null <tt>attributeIds</tt> by default.  Please override
      * this method if there is more effective way for your implementation.
      */
-    public ServerEntry lookup( LookupOperationContext lookupContext ) throws NamingException
+    public ClonedServerEntry lookup( LookupOperationContext lookupContext ) throws NamingException
     {
         return null;
     }



Mime
View raw message