directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r758039 [1/2] - /directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/
Date Tue, 24 Mar 2009 21:26:57 GMT
Author: akarasulu
Date: Tue Mar 24 21:26:55 2009
New Revision: 758039

URL: http://svn.apache.org/viewvc?rev=758039&view=rev
Log:
 

Added:
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractChangeOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/AddContextPartitionOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/AddOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/BindOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/ChangeOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/CompareOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/DeleteOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/EmptyOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/EntryOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/GetMatchedNameOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/GetRootDSEOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/GetSuffixOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/ListOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/ListSuffixOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/LookupOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/ModifyOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/MoveAndRenameOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/MoveOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/OperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/RemoveContextPartitionOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/RenameOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/SearchOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/SearchingOperationContext.java
    directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/UnbindOperationContext.java

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractChangeOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractChangeOperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractChangeOperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractChangeOperationContext.java Tue Mar 24 21:26:55 2009
@@ -0,0 +1,86 @@
+/*
+ *   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.interceptor.context;
+
+
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.changelog.ChangeLogEvent;
+import org.apache.directory.server.core.CoreSession.LogChange;
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+
+/**
+ * An abstract base class used by all change inducing operations.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class AbstractChangeOperationContext extends AbstractOperationContext implements ChangeOperationContext
+{
+    private ChangeLogEvent changeLogEvent;
+    
+    /** The flag used to tell the server to store the change sinto the changeLog */
+    protected LogChange logChange;
+
+    
+    public AbstractChangeOperationContext( CoreSession session )
+    {
+        super( session );
+    }
+
+    
+    public AbstractChangeOperationContext( CoreSession session, LdapDN dn )
+    {
+        super( session, dn );
+    }
+
+    
+    /**
+     * @see org.apache.directory.server.core.interceptor.context.ChangeOperationContext#getChangeLogEvent()
+     */
+    public ChangeLogEvent getChangeLogEvent()
+    {
+        return changeLogEvent;
+    }
+    
+    
+    public void setChangeLogEvent( ChangeLogEvent changeLogEvent )
+    {
+        this.changeLogEvent = changeLogEvent;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void setLogChange( LogChange logChange )
+    {
+        this.logChange = logChange;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isLogChange()
+    {
+        return logChange != logChange.FALSE;
+    }
+}

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractOperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractOperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractOperationContext.java Tue Mar 24 21:26:55 2009
@@ -0,0 +1,469 @@
+/*
+ *  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.interceptor.context;
+
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.ldap.Control;
+
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.authn.LdapPrincipal;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+
+/**
+ * This abstract class stores common context elements, like the DN, which is used
+ * in all the contexts.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class AbstractOperationContext implements OperationContext
+{
+    protected static final Control[] EMPTY_CONTROLS = new Control[0];
+
+    /** The DN associated with the context */
+    protected LdapDN dn;
+    
+    /** The entry associated with the target entry of this OperationContext */
+    protected ClonedServerEntry entry;
+    
+    /** The associated request's controls */
+    protected Map<String, Control> requestControls = new HashMap<String, Control>(4);
+
+    /** The associated response's controls */
+    protected Map<String, Control> responseControls = new HashMap<String, Control>(4);
+
+    /** the Interceptors bypassed by this operation */
+    protected Collection<String> byPassed;
+    
+    protected LdapPrincipal authorizedPrincipal;
+    
+    /** The core session */
+    protected CoreSession session;
+    
+    protected OperationContext next;
+    
+    protected OperationContext previous;
+
+    /** A flag used to tell if we should consider referrals as standard entries */
+    protected boolean throwReferral;
+    
+    
+    /**
+     * Creates a new instance of AbstractOperationContext.
+     */
+    public AbstractOperationContext( CoreSession session )
+    {
+        this.session = session;
+    }
+    
+    
+    /**
+     * Creates a new instance of AbstractOperationContext.
+     *
+     * @param dn The associated DN
+     */
+    public AbstractOperationContext( CoreSession session, LdapDN dn )
+    {
+        this.dn = dn;
+        this.session = session;
+        
+        // The flag is set to ignore, so that the revert operation can act on 
+        // the entries, even if they are referrals.
+        ignoreReferral();
+    }
+
+
+    public CoreSession getSession()
+    {
+        return session;
+    }
+    
+    
+    protected void setSession( CoreSession session )
+    {
+        this.session = session;
+    }
+    
+    
+    protected void setAuthorizedPrincipal( LdapPrincipal authorizedPrincipal )
+    {
+        this.authorizedPrincipal = authorizedPrincipal;
+    }
+
+
+    /**
+     * @return The associated DN
+     */
+    public LdapDN getDn()
+    {
+        return dn;
+    }
+
+    
+    /**
+     * Set the context DN
+     *
+     * @param dn The DN to set
+     */
+    public void setDn( LdapDN dn )
+    {
+        this.dn = dn;
+    }
+
+    
+    public void addRequestControl( Control requestControl )
+    {
+        requestControls.put( requestControl.getID(), requestControl );
+    }
+
+    
+    public Control getRequestControl( String numericOid )
+    {
+        return requestControls.get( numericOid );
+    }
+
+    
+    public boolean hasRequestControl( String numericOid )
+    {
+        return requestControls.containsKey( numericOid );
+    }
+
+    
+    public boolean hasRequestControls()
+    {
+        return ! requestControls.isEmpty();
+    }
+
+
+    public void addResponseControl( Control responseControl )
+    {
+        responseControls.put( responseControl.getID(), responseControl );
+    }
+
+
+    public Control getResponseControl( String numericOid )
+    {
+        return responseControls.get( numericOid );
+    }
+
+
+    public boolean hasResponseControl( String numericOid )
+    {
+        return responseControls.containsKey( numericOid );
+    }
+
+
+    public Control[] getResponseControls()
+    {
+        if ( responseControls.isEmpty() )
+        {
+            return EMPTY_CONTROLS;
+        }
+        
+        return responseControls.values().toArray( EMPTY_CONTROLS );
+    }
+
+
+    public boolean hasResponseControls()
+    {
+        return ! responseControls.isEmpty();
+    }
+
+
+    public int getResponseControlCount()
+    {
+        return responseControls.size();
+    }
+
+
+    public void addRequestControls( Control[] requestControls )
+    {
+        for ( Control c : requestControls )
+        {
+            this.requestControls.put( c.getID(), c );
+        }
+    }
+
+    
+    public void setRequestControls( Map<String, Control> requestControls )
+    {
+        this.requestControls = requestControls;
+    }
+
+    
+    /**
+     * @return the operation name
+     */
+    public abstract String getName();
+
+
+    /**
+     * Gets the set of bypassed Interceptors.
+     *
+     * @return the set of bypassed Interceptors
+     */
+    public Collection<String> getByPassed()
+    {
+        if ( byPassed == null )
+        {
+            return Collections.emptyList();
+        }
+        
+        return Collections.unmodifiableCollection( byPassed );
+    }
+    
+    
+    /**
+     * Sets the set of bypassed Interceptors.
+     * 
+     * @param byPassed the set of bypassed Interceptors
+     */
+    public void setByPassed( Collection<String> byPassed )
+    {
+        this.byPassed = byPassed;
+    }
+
+    
+    /**
+     * Checks to see if an Interceptor is bypassed for this operation.
+     *
+     * @param interceptorName the interceptorName of the Interceptor to check for bypass
+     * @return true if the Interceptor should be bypassed, false otherwise
+     */
+    public boolean isBypassed( String interceptorName )
+    {
+        return byPassed != null && byPassed.contains( interceptorName );
+    }
+
+
+    /**
+     * Checks to see if any Interceptors are bypassed by this operation.
+     *
+     * @return true if at least one bypass exists
+     */
+    public boolean hasBypass()
+    {
+        return byPassed != null && !byPassed.isEmpty();
+    }
+
+    
+    private void setup( AbstractOperationContext opContext )
+    {
+        opContext.setPreviousOperation( this );
+        next = opContext;
+        opContext.setByPassed( byPassed );
+        opContext.setAuthorizedPrincipal( authorizedPrincipal );
+    }
+    
+    
+    public boolean hasEntry( LdapDN dn, Collection<String> byPassed ) throws Exception
+    {
+        EntryOperationContext opContext = new EntryOperationContext( session, dn );
+        setup( opContext );
+        opContext.setByPassed( byPassed );
+        return session.getDirectoryService().getOperationManager().hasEntry( opContext );
+    }
+    
+    
+    public void add( ServerEntry entry, Collection<String> byPassed ) throws Exception
+    {
+        AddOperationContext opContext = new AddOperationContext( session, entry );
+        setup( opContext );
+        opContext.setByPassed( byPassed );
+        session.getDirectoryService().getOperationManager().add( opContext );
+    }
+    
+    
+    public void delete( LdapDN dn, Collection<String> byPassed ) throws Exception
+    {
+        DeleteOperationContext opContext = new DeleteOperationContext( session, dn );
+        setup( opContext );
+        opContext.setByPassed( byPassed );
+        session.getDirectoryService().getOperationManager().delete( opContext );
+    }
+    
+    
+    public void modify( LdapDN dn, List<Modification> mods, Collection<String> byPassed ) throws Exception
+    {
+        ModifyOperationContext opContext = new ModifyOperationContext( session, dn, mods );
+        setup( opContext );
+        opContext.setByPassed( byPassed );
+        session.getDirectoryService().getOperationManager().modify( opContext );
+    }
+    
+    
+    // TODO - need synchronization here and where we update links
+    public LookupOperationContext newLookupContext( LdapDN dn )
+    {
+        LookupOperationContext opContext = new LookupOperationContext( session, dn );
+        setup( opContext );
+        return opContext;
+    }
+
+
+    public ClonedServerEntry lookup( LookupOperationContext opContext ) throws Exception
+    {
+        if ( opContext != next )
+        {
+            throw new IllegalStateException( "Cannot execute indirect lookup if it is not the next operation." );
+        }
+        return session.getDirectoryService().getOperationManager().lookup( opContext );
+    }
+
+
+    public ClonedServerEntry lookup( LdapDN dn, Collection<String> byPassed ) throws Exception
+    {
+        LookupOperationContext opContext = newLookupContext( dn );
+        opContext.setByPassed( byPassed );
+        return session.getDirectoryService().getOperationManager().lookup( opContext );
+    }
+    
+
+    public LdapPrincipal getEffectivePrincipal()
+    {
+        if ( authorizedPrincipal != null )
+        {
+            return authorizedPrincipal;
+        }
+        
+        return session.getEffectivePrincipal();
+    }
+    
+    
+    // -----------------------------------------------------------------------
+    // OperationContext Linked List Methods
+    // -----------------------------------------------------------------------
+    
+    
+    public boolean isFirstOperation()
+    {
+        return previous == null;
+    }
+    
+    
+    public OperationContext getFirstOperation()
+    {
+        if ( previous == null )
+        {
+            return this;
+        }
+        
+        return previous.getFirstOperation();
+    }
+    
+    
+    public OperationContext getLastOperation()
+    {
+        if ( next == null )
+        {
+            return this;
+        }
+        
+        return next.getLastOperation();
+    }
+    
+    
+    public OperationContext getNextOperation()
+    {
+        return next;
+    }
+    
+    
+    protected void setNextOperation( OperationContext next )
+    {
+        this.next = next;
+    }
+    
+    
+    public OperationContext getPreviousOperation()
+    {
+        return previous;
+    }
+    
+    
+    protected void setPreviousOperation( OperationContext previous )
+    {
+        this.previous = previous;
+    }
+
+
+    /**
+     * @param entry the entry to set
+     */
+    public void setEntry( ClonedServerEntry entry )
+    {
+        this.entry = entry;
+    }
+
+
+    /**
+     * @return the entry
+     */
+    public ClonedServerEntry getEntry()
+    {
+        return entry;
+    }
+    
+    
+    /**
+     * Set the throwReferral flag to true
+     */
+    public void throwReferral()
+    {
+        throwReferral = true;
+    }
+    
+    
+    /**
+     * @return <code>true</code> if the referrals are thrown
+     */
+    public boolean isReferralThrown()
+    {
+        return throwReferral;
+    }
+
+
+    /**
+     * Set the throwReferral flag to false
+     */
+    public void ignoreReferral()
+    {
+        throwReferral = false;
+    }
+
+
+    /**
+     * @return <code>true</code> if the referrals are ignored
+     */
+    public boolean isReferralIgnored()
+    {
+        return !throwReferral;
+    }
+}

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/AddContextPartitionOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/AddContextPartitionOperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/AddContextPartitionOperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/AddContextPartitionOperationContext.java Tue Mar 24 21:26:55 2009
@@ -0,0 +1,90 @@
+/*
+ *  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.interceptor.context;
+
+
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.partition.Partition;
+
+
+/**
+ * A AddContextPartition context used for Interceptors. It contains all the informations
+ * needed for the addContextPartition operation, and used by all the interceptors.  If 
+ * it does not have a partition set for it, then it will load and instantiate it 
+ * automatically using the information in the partition configuration.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AddContextPartitionOperationContext extends EmptyOperationContext
+{
+    /** the instantiated partition class */
+    private Partition partition;
+       
+    
+    /**
+     * Creates a new instance of AddContextPartitionOperationContext.
+     *
+     * @param partition The partition to add
+     */
+    public AddContextPartitionOperationContext( CoreSession session, Partition partition )
+    {
+        super( session );
+        this.partition = partition;
+    }
+    
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "AddContextPartitionOperationContext for partition context '" + partition.getId() + "'";
+    }
+
+    
+    /**
+     * @return The partition
+     */
+    public Partition getPartition()
+    {
+        return partition;
+    }
+
+    
+    /**
+     * Set the partition.
+     * 
+     * @param partition the partition
+     */
+    public void setPartitionConfiguration( Partition partition )
+    {
+        this.partition = partition;
+    }
+    
+    
+    /**
+     * @return the operation name
+     */
+    public String getName()
+    {
+        return "AddContextPartition";
+    }
+}

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/AddOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/AddOperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/AddOperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/AddOperationContext.java Tue Mar 24 21:26:55 2009
@@ -0,0 +1,127 @@
+/*
+ *  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.interceptor.context;
+
+
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.shared.ldap.message.AddRequest;
+import org.apache.directory.shared.ldap.message.MessageTypeEnum;
+import org.apache.directory.shared.ldap.message.control.ManageDsaITControl;
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+
+/**
+ * A Add context used for Interceptors. It contains all the informations
+ * needed for the add operation, and used by all the interceptors
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AddOperationContext extends AbstractChangeOperationContext
+{
+    /**
+     * Creates a new instance of AddOperationContext.
+     * 
+     * @param session the current Session 
+     */
+    public AddOperationContext( CoreSession session )
+    {
+        super( session );
+    }
+
+
+    /**
+     * Creates a new instance of AddOperationContext.
+     * 
+     * @param session the current Session 
+     * @param dn the name of the entry being added
+     */
+    public AddOperationContext( CoreSession session, LdapDN dn )
+    {
+        super( session, dn );
+    }
+
+
+    /**
+     * Creates a new instance of AddOperationContext.
+     * 
+     * @param session the current Session 
+     * @param entry the entry being added
+     */
+    public AddOperationContext( CoreSession session, ServerEntry entry )
+    {
+        super( session, entry.getDn() );
+        this.entry = new ClonedServerEntry( entry );
+    }
+
+
+    /**
+     * Creates a new instance of ModifyOperationContext.
+     *
+     * @param session the current Session 
+     * @param dn the name of the entry being added
+     * @param entry the entry being added
+     */
+    public AddOperationContext( CoreSession session, LdapDN dn, ServerEntry entry )
+    {
+        super( session, dn );
+        this.entry = new ClonedServerEntry( entry );
+    }
+
+
+    public AddOperationContext( CoreSession session, AddRequest addRequest ) throws Exception
+    {
+        super( session );
+        entry = new ClonedServerEntry( 
+            new DefaultServerEntry( session.getDirectoryService().getRegistries(), addRequest.getEntry() ) );
+        dn = addRequest.getEntry().getDn();
+        requestControls = addRequest.getControls();
+        
+        if ( requestControls.containsKey( ManageDsaITControl.CONTROL_OID ) )
+        {
+            ignoreReferral();
+        }
+        else
+        {
+            throwReferral();
+        }
+    }
+
+
+    /**
+     * @return the operation name
+     */
+    public String getName()
+    {
+        return MessageTypeEnum.ADD_REQUEST.name();
+    }
+
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "AddContext for DN '" + getDn().getUpName() + "'" + ", added entry: " + entry;
+    }
+}

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/BindOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/BindOperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/BindOperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/BindOperationContext.java Tue Mar 24 21:26:55 2009
@@ -0,0 +1,555 @@
+/*
+ *  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.interceptor.context;
+ 
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.ldap.Control;
+
+import org.apache.commons.lang.NotImplementedException;
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.ReferralHandlingMode;
+import org.apache.directory.server.core.authn.LdapPrincipal;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.message.MessageTypeEnum;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+
+/**
+ * A Bind context used for Interceptors. It contains all the informations
+ * needed for the bind operation, and used by all the interceptors
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BindOperationContext implements OperationContext
+{
+    /** The password */
+    private byte[] credentials;
+
+    /** The SASL mechanism */
+    private String saslMechanism;
+    
+    /** The SASL identifier */
+    private String saslAuthId;
+    
+    private static final Control[] EMPTY_CONTROLS = new Control[0];
+
+    /** The DN associated with the context */
+    private LdapDN dn;
+    
+    /** The associated request's controls */
+    private Map<String, Control> requestControls = new HashMap<String, Control>(4);
+
+    /** The associated response's controls */
+    private Map<String, Control> responseControls = new HashMap<String, Control>(4);
+
+    /** A flag to tell that this is a collateral operation */
+    private boolean collateralOperation;
+    
+    /** the Interceptors bypassed by this operation */
+    private Collection<String> bypassed;
+    
+    private CoreSession session;
+    
+    private LdapPrincipal authorizedPrincipal;
+    
+    private OperationContext next;
+    
+    private OperationContext previous;
+
+    private ReferralHandlingMode referralHandlingMode;
+
+    private ClonedServerEntry entry;
+
+    
+    /**
+     * Creates a new instance of BindOperationContext.
+     */
+    public BindOperationContext( CoreSession session )
+    {
+        this.session = session;
+    }
+
+    
+    /**
+     * @return The authentication level. One of :
+     * <li>ANONYMOUS</li>
+     * <li>SIMPLE</li>
+     * <li>STRONG (sasl)</li>
+     * <li>INVALID</li>
+     */
+    public AuthenticationLevel getAuthenticationLevel()
+    {
+        if ( ( saslMechanism == null ) )
+        {
+            if ( dn.isEmpty() )
+            {
+                if ( StringTools.isEmpty( credentials ) )
+                {
+                    // Dn and Credentials are empty, this is an anonymous authent
+                    return AuthenticationLevel.NONE;
+                }
+                else
+                {
+                    // If we have a password but no DN, this is invalid 
+                    return AuthenticationLevel.INVALID;
+                }
+            }
+            else if ( StringTools.isEmpty( credentials ) )
+            {
+                return AuthenticationLevel.UNAUTHENT;
+            }
+            else
+            {
+                return AuthenticationLevel.SIMPLE;
+            }
+        }
+        else
+        {
+            return AuthenticationLevel.STRONG;
+        }
+    }
+    
+    
+    /**
+     * @return the SASL mechanisms
+     */
+    public String getSaslMechanism()
+    {
+        return saslMechanism;
+    }
+
+    
+    public void setSaslMechanism( String saslMechanism )
+    {
+        this.saslMechanism = saslMechanism;
+    }
+
+    
+    /**
+     * @return The principal password
+     */
+    public byte[] getCredentials()
+    {
+        return credentials;
+    }
+
+    
+    public void setCredentials( byte[] credentials )
+    {
+        this.credentials = credentials;
+    }
+
+    
+    /**
+     * @return The SASL authentication ID
+     */
+    public String getSaslAuthId()
+    {
+        return saslAuthId;
+    }
+
+
+    public void setSaslAuthId( String saslAuthId )
+    {
+        this.saslAuthId = saslAuthId;
+    }
+    
+    
+    public boolean isSaslBind()
+    {
+        return saslMechanism != null;
+    }
+    
+    
+    /**
+     * @return the operation name
+     */
+    public String getName()
+    {
+        return MessageTypeEnum.BIND_REQUEST.name();
+    }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "BindContext for DN '" + getDn().getUpName() + "', credentials <" +
+            ( credentials != null ? StringTools.dumpBytes( credentials ) : "" ) + ">" +
+            ( saslMechanism != null ? ", saslMechanism : <" + saslMechanism + ">" : "" ) +
+            ( saslAuthId != null ? ", saslAuthId <" + saslAuthId + ">" : "" );
+    }
+
+
+    public CoreSession getSession()
+    {
+        return session;
+    }
+    
+    
+    public void setSession( CoreSession session )
+    {
+        this.session = session;
+    }
+
+
+    /**
+     * Tells if the current operation is considered a side effect of the
+     * current context
+     */
+    public boolean isCollateralOperation()
+    {
+        return collateralOperation;
+    }
+
+
+    public void setCollateralOperation( boolean collateralOperation )
+    {
+        this.collateralOperation = collateralOperation;
+    }
+
+
+    /**
+     * @return The associated DN
+     */
+    public LdapDN getDn()
+    {
+        return dn;
+    }
+
+    
+    /**
+     * Set the context DN
+     *
+     * @param dn The DN to set
+     */
+    public void setDn( LdapDN dn )
+    {
+        this.dn = dn;
+    }
+
+    
+    public void addRequestControl( Control requestControl )
+    {
+        requestControls.put( requestControl.getID(), requestControl );
+    }
+
+    
+    public Control getRequestControl( String numericOid )
+    {
+        return requestControls.get( numericOid );
+    }
+
+    
+    public boolean hasRequestControl( String numericOid )
+    {
+        return requestControls.containsKey( numericOid );
+    }
+
+    
+    public boolean hasRequestControls()
+    {
+        return ! requestControls.isEmpty();
+    }
+
+
+    public void addResponseControl( Control responseControl )
+    {
+        responseControls.put( responseControl.getID(), responseControl );
+    }
+
+
+    public Control getResponseControl( String numericOid )
+    {
+        return responseControls.get( numericOid );
+    }
+
+
+    public boolean hasResponseControl( String numericOid )
+    {
+        return responseControls.containsKey( numericOid );
+    }
+
+
+    public Control[] getResponseControls()
+    {
+        if ( responseControls.isEmpty() )
+        {
+            return EMPTY_CONTROLS;
+        }
+        
+        return responseControls.values().toArray( EMPTY_CONTROLS );
+    }
+
+
+    public boolean hasResponseControls()
+    {
+        return ! responseControls.isEmpty();
+    }
+
+
+    public int getResponseControlCount()
+    {
+        return responseControls.size();
+    }
+
+
+    public void addRequestControls( Control[] requestControls )
+    {
+        for ( Control c : requestControls )
+        {
+            this.requestControls.put( c.getID(), c );
+        }
+    }
+
+
+    /**
+     * Gets the set of bypassed Interceptors.
+     *
+     * @return the set of bypassed Interceptors
+     */
+    public Collection<String> getByPassed()
+    {
+        if ( bypassed == null )
+        {
+            return Collections.emptyList();
+        }
+        
+        return Collections.unmodifiableCollection( bypassed );
+    }
+    
+    
+    /**
+     * Sets the set of bypassed Interceptors.
+     * 
+     * @param byPassed the set of bypassed Interceptors
+     */
+    public void setByPassed( Collection<String> byPassed )
+    {
+        this.bypassed = byPassed;
+    }
+
+    
+    /**
+     * Checks to see if an Interceptor is bypassed for this operation.
+     *
+     * @param interceptorName the interceptorName of the Interceptor to check for bypass
+     * @return true if the Interceptor should be bypassed, false otherwise
+     */
+    public boolean isBypassed( String interceptorName )
+    {
+        return bypassed != null && bypassed.contains( interceptorName );
+    }
+
+
+    /**
+     * Checks to see if any Interceptors are bypassed by this operation.
+     *
+     * @return true if at least one bypass exists
+     */
+    public boolean hasBypass()
+    {
+        return bypassed != null && !bypassed.isEmpty();
+    }
+    
+    
+    public LookupOperationContext newLookupContext( LdapDN dn )
+    {
+        return new LookupOperationContext( session, dn );
+    }
+
+
+    public ClonedServerEntry lookup( LookupOperationContext opContext ) throws Exception
+    {
+        return session.getDirectoryService().getOperationManager().lookup( opContext );
+    }
+
+
+    public ClonedServerEntry lookup( LdapDN dn, Collection<String> byPassed ) throws Exception
+    {
+        LookupOperationContext opContext = newLookupContext( dn );
+        opContext.setByPassed( byPassed );
+        return session.getDirectoryService().getOperationManager().lookup( opContext );
+    }
+
+
+    public LdapPrincipal getEffectivePrincipal()
+    {
+        if ( authorizedPrincipal != null )
+        {
+            return authorizedPrincipal;
+        }
+        
+        return session.getEffectivePrincipal();
+    }
+    
+    
+    // -----------------------------------------------------------------------
+    // OperationContext Linked List Methods
+    // -----------------------------------------------------------------------
+    
+    
+    public boolean isFirstOperation()
+    {
+        return previous == null;
+    }
+    
+    
+    public OperationContext getFirstOperation()
+    {
+        if ( previous == null )
+        {
+            return this;
+        }
+        
+        return previous.getFirstOperation();
+    }
+    
+    
+    public OperationContext getLastOperation()
+    {
+        if ( next == null )
+        {
+            return this;
+        }
+        
+        return next.getLastOperation();
+    }
+    
+    
+    public OperationContext getNextOperation()
+    {
+        return next;
+    }
+    
+    
+    public OperationContext getPreviousOperation()
+    {
+        return previous;
+    }
+
+
+    public void add( ServerEntry entry, Collection<String> bypass ) throws Exception
+    {
+        throw new NotImplementedException();
+    }
+
+
+    public void delete( LdapDN dn, Collection<String> bypass ) throws Exception
+    {
+        throw new NotImplementedException();
+    }
+
+
+    public void modify( LdapDN dn, List<Modification> mods, Collection<String> bypass ) throws Exception
+    {
+        throw new NotImplementedException();
+    }
+
+
+    private void setup( AbstractOperationContext opContext )
+    {
+        opContext.setPreviousOperation( this );
+        next = opContext;
+        opContext.setByPassed( opContext.getByPassed() );
+        opContext.setAuthorizedPrincipal( authorizedPrincipal );
+    }
+    
+    
+    public boolean hasEntry( LdapDN dn, Collection<String> byPassed ) throws Exception
+    {
+        EntryOperationContext opContext = new EntryOperationContext( session, dn );
+        setup( opContext );
+        opContext.setByPassed( byPassed );
+        return session.getDirectoryService().getOperationManager().hasEntry( opContext );
+    }
+
+
+    public ReferralHandlingMode getReferralHandlingMode()
+    {
+        return referralHandlingMode;
+    }
+
+
+    public void setReferralHandlingMode( ReferralHandlingMode referralHandlingMode )
+    {
+        this.referralHandlingMode = referralHandlingMode;
+    }
+
+
+    public ClonedServerEntry getEntry()
+    {
+        return entry;
+    }
+
+
+    public void setEntry( ClonedServerEntry entry )
+    {
+        this.entry = entry;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void throwReferral()
+    {
+        throw new NotImplementedException( " The throwReferral method is not implemented for a Bind operation" );
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isReferralThrown()
+    {
+        throw new NotImplementedException( " The isReferralThrown method is not implemented for a Bind operation" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void ignoreReferral()
+    {
+        throw new NotImplementedException( " The ignoreReferral method is not implemented for a Bind operation" );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isReferralIgnored()
+    {
+        throw new NotImplementedException( " The isReferralIgnored method is not implemented for a Bind operation" );
+    }
+}

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/ChangeOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/ChangeOperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/ChangeOperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/ChangeOperationContext.java Tue Mar 24 21:26:55 2009
@@ -0,0 +1,58 @@
+/*
+ *  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.interceptor.context;
+
+
+import org.apache.directory.server.core.changelog.ChangeLogEvent;
+import org.apache.directory.server.core.CoreSession.LogChange;
+
+
+/**
+ * Operations (write based) causing changes extend this interface. 
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface ChangeOperationContext extends OperationContext
+{
+    /**
+     * Gets the ChangeLogEvent associated with this operation after the 
+     * operation has been executed.  Returns null if the ChangeLogService has 
+     * not been enabled. 
+     *
+     * @return the ChangeLogEvent associated with this operation, or null
+     */
+    ChangeLogEvent getChangeLogEvent();
+    
+    
+    /**
+     * Set the flag which tells the server to log the changes into
+     * the changeLog file
+     * 
+     * @param log The flag
+     */
+    void setLogChange( LogChange log );
+
+    
+    /**
+     * @return True if the changes are logged into the changeLog
+     */
+    boolean isLogChange();
+}

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/CompareOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/CompareOperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/CompareOperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/CompareOperationContext.java Tue Mar 24 21:26:55 2009
@@ -0,0 +1,190 @@
+/*
+ *  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.interceptor.context;
+
+
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
+import org.apache.directory.shared.ldap.message.CompareRequest;
+import org.apache.directory.shared.ldap.message.MessageTypeEnum;
+import org.apache.directory.shared.ldap.message.control.ManageDsaITControl;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+
+/**
+ * A Compare context used for Interceptors. It contains all the informations
+ * needed for the compare operation, and used by all the interceptors
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class CompareOperationContext extends AbstractOperationContext
+{
+    /** The entry OID */
+    private String oid;
+
+    /** The value to be compared */
+    private Value<?> value;
+    
+    
+    /**
+     * 
+     * Creates a new instance of CompareOperationContext.
+     *
+     */
+    public CompareOperationContext( CoreSession session )
+    {
+        super( session );
+    }
+
+    
+    /**
+     * 
+     * Creates a new instance of CompareOperationContext.
+     *
+     */
+    public CompareOperationContext( CoreSession session, LdapDN dn )
+    {
+        super( session, dn );
+    }
+
+    
+    /**
+     * 
+     * Creates a new instance of LookupOperationContext.
+     *
+     */
+    public CompareOperationContext( CoreSession session, String oid )
+    {
+        super( session );
+        this.oid = oid;
+    }
+
+    
+    /**
+     * 
+     * Creates a new instance of LookupOperationContext.
+     *
+     */
+    public CompareOperationContext( CoreSession session, LdapDN dn, String oid )
+    {
+        super( session, dn );
+        this.oid = oid;
+    }
+
+    
+    /**
+     * 
+     * Creates a new instance of LookupOperationContext.
+     *
+     */
+    public CompareOperationContext( CoreSession session, LdapDN dn, String oid, Value<?> value )
+    {
+        super( session, dn );
+        this.oid = oid;
+        this.value = value;
+    }
+
+    
+    public CompareOperationContext( CoreSession session, CompareRequest compareRequest )
+    {
+        super( session, compareRequest.getName() );
+        this.oid = compareRequest.getAttributeId();
+        this.value = compareRequest.getAssertionValue();
+        this.requestControls = compareRequest.getControls();
+        
+        if ( requestControls.containsKey( ManageDsaITControl.CONTROL_OID ) )
+        {
+            ignoreReferral();
+        }
+        else
+        {
+            throwReferral();
+        }
+    }
+
+
+    /**
+     * @return The compared OID
+     */
+    public String getOid() 
+    {
+        return oid;
+    }
+
+    
+    /**
+     * Set the compared OID
+     * @param oid The compared OID
+     */
+    public void setOid( String  oid ) 
+    {
+        this.oid = oid;
+    }
+
+    
+    /**
+     * @return The value to compare
+     */
+    public Object getValue() 
+    {
+        return value;
+    }
+
+    
+    /**
+     * Set the value to compare
+     * @param value The value to compare
+     */
+    public void setValue( Value<?> value ) 
+    {
+        this.value = value;
+    }
+
+
+    /**
+     * @return the operation name
+     */
+    public String getName()
+    {
+        return MessageTypeEnum.COMPARE_REQUEST.name();
+    }
+
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "CompareContext for DN '" + getDn().getUpName() + "'" + 
+            ( ( oid != null ) ? ", oid : <" + oid + ">" : "" ) +
+            ( ( value != null ) ? ", value :'" +
+                    ( ( value instanceof ClientStringValue ) ?
+                            ((ClientStringValue)value).get() :
+                            ( ( value instanceof ClientBinaryValue ) ?
+                                    StringTools.dumpBytes( ((ClientBinaryValue)value).getReference() ) : 
+                                        "unknown value type" ) )
+                        + "'"
+                    : "" );
+    }
+}

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/DeleteOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/DeleteOperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/DeleteOperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/DeleteOperationContext.java Tue Mar 24 21:26:55 2009
@@ -0,0 +1,120 @@
+/*
+ *  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.interceptor.context;
+
+
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
+import org.apache.directory.shared.ldap.message.DeleteRequest;
+import org.apache.directory.shared.ldap.message.MessageTypeEnum;
+import org.apache.directory.shared.ldap.message.control.ManageDsaITControl;
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+
+/**
+ * A Delete context used for Interceptors. It contains all the informations
+ * needed for the delete operation, and used by all the interceptors
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class DeleteOperationContext extends AbstractChangeOperationContext
+{
+    /**
+     * An optimization added to prevent redundant lookups of the deleted 
+     * entry.
+     */
+    private ClonedServerEntry entry;
+    
+    
+    /**
+     * Creates a new instance of DeleteOperationContext.
+     */
+    public DeleteOperationContext( CoreSession session )
+    {
+        super( session );
+    }
+    
+
+    /**
+     * Creates a new instance of DeleteOperationContext.
+     *
+     * @param deleteDn The entry DN to delete
+     */
+    public DeleteOperationContext( CoreSession session, LdapDN deleteDn )
+    {
+        super( session, deleteDn );
+    }
+
+
+    public DeleteOperationContext( CoreSession session, DeleteRequest deleteRequest )
+    {
+        super( session, deleteRequest.getName() );
+        requestControls = deleteRequest.getControls();
+        
+        if ( requestControls.containsKey( ManageDsaITControl.CONTROL_OID ) )
+        {
+            ignoreReferral();
+        }
+        else
+        {
+            throwReferral();
+        }
+    }
+    
+    
+    /**
+     * @return the operation name
+     */
+    public String getName()
+    {
+        return MessageTypeEnum.DEL_REQUEST.name();
+    }
+
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "DeleteContext for DN '" + getDn().getUpName() + "'";
+    }
+
+
+    /**
+     * @param entry the entry to set
+     */
+    public void setEntry( ClonedServerEntry entry )
+    {
+        this.entry = entry;
+    }
+
+
+    /**
+     * Gets the deleted entry if cached.  Must be called before deleting the 
+     * entry when the entry member is null or this call will fail.  
+     * 
+     * @return the entry
+     */
+    public ClonedServerEntry getEntry()
+    {
+        return entry;
+    }
+}

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/EmptyOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/EmptyOperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/EmptyOperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/EmptyOperationContext.java Tue Mar 24 21:26:55 2009
@@ -0,0 +1,69 @@
+/*
+ *  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.interceptor.context;
+
+
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+
+/**
+ * An EmptySuffix context used for Interceptors. It contains no data, and mask
+ * the DN in AbstractOperationContext
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class EmptyOperationContext extends AbstractOperationContext
+{
+    /**
+     * Creates a new instance of EmptyOperationContext.
+     */
+    public EmptyOperationContext( CoreSession session )
+    {
+        super( session, LdapDN.EMPTY_LDAPDN );
+    }
+    
+
+    /**
+     * Set the context DN
+     *
+     * @param dn The DN to set
+     */
+    public void setDn( LdapDN dn )
+    {
+        if ( dn.equals( LdapDN.EMPTY_LDAPDN ) )
+        {
+            return;
+        }
+        
+        throw new UnsupportedOperationException( 
+            "Cannot set the empty operation context to anything other than the EmptyDN" );
+    }
+
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "EmptyOperationContext";
+    }
+}

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/EntryOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/EntryOperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/EntryOperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/EntryOperationContext.java Tue Mar 24 21:26:55 2009
@@ -0,0 +1,72 @@
+/*
+ *  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.interceptor.context;
+
+
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.shared.ldap.message.MessageTypeEnum;
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+
+/**
+ * A Entry context used for Interceptors. It contains all the informations
+ * needed for the hasEntry operation, and used by all the interceptors
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class EntryOperationContext extends AbstractOperationContext
+{
+    /**
+     * Creates a new instance of EntryOperationContext.
+     */
+    public EntryOperationContext( CoreSession session )
+    {
+        super( session );
+    }
+    
+    /**
+     * Creates a new instance of EntryOperationContext.
+     *
+     * @param entryDn The Entry DN to unbind
+     */
+    public EntryOperationContext( CoreSession session, LdapDN entryDn )
+    {
+        super( session, entryDn );
+    }
+    
+
+    /**
+     * @return the operation name
+     */
+    public String getName()
+    {
+        return MessageTypeEnum.ADD_REQUEST.name();
+    }
+
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "EntryContext for DN '" + getDn().getUpName() + "'";
+    }
+}

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/GetMatchedNameOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/GetMatchedNameOperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/GetMatchedNameOperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/GetMatchedNameOperationContext.java Tue Mar 24 21:26:55 2009
@@ -0,0 +1,71 @@
+/*
+ *  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.interceptor.context;
+
+
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+
+/**
+ * A GetMatchedName context used for Interceptors. It contains all the informations
+ * needed for the getMatchedName operation, and used by all the interceptors
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class GetMatchedNameOperationContext extends AbstractOperationContext
+{
+    /**
+     * Creates a new instance of GetMatchedNameOperationContext.
+     */
+    public GetMatchedNameOperationContext( CoreSession session )
+    {
+        super( session );
+    }
+    
+    /**
+     * Creates a new instance of GetMatchedNameOperationContext.
+     *
+     * @param dn The DN to match
+     */
+    public GetMatchedNameOperationContext( CoreSession session, LdapDN dn )
+    {
+        super( session, dn );
+    }
+    
+
+    /**
+     * @return the operation name
+     */
+    public String getName()
+    {
+        return "MatchedName";
+    }
+
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "GetMatchedNameContext with DN '" + getDn().getUpName() + "'";
+    }
+}

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/GetRootDSEOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/GetRootDSEOperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/GetRootDSEOperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/GetRootDSEOperationContext.java Tue Mar 24 21:26:55 2009
@@ -0,0 +1,70 @@
+/*
+ *  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.interceptor.context;
+
+
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+
+/**
+ * A GetRootDSE context used for Interceptors. It contains all the informations
+ * needed for the getRootDSE operation, and used by all the interceptors
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class GetRootDSEOperationContext extends AbstractOperationContext
+{
+    /**
+     * Creates a new instance of GetRootDSEOperationContext.
+     */
+    public GetRootDSEOperationContext( CoreSession session )
+    {
+        super( session );
+    }
+    
+    /**
+     * Creates a new instance of GetRootDSEOperationContext.
+     *
+     * @param dn The entry DN used to get the rootDSE
+     */
+    public GetRootDSEOperationContext( CoreSession session, LdapDN dn )
+    {
+        super( session, dn );
+    }
+    
+    /**
+     * @return the operation name
+     */
+    public String getName()
+    {
+        return "GetRootDSE";
+    }
+
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "GetRootDSEContext with DN '" + getDn().getUpName() + "'";
+    }
+}

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/GetSuffixOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/GetSuffixOperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/GetSuffixOperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/GetSuffixOperationContext.java Tue Mar 24 21:26:55 2009
@@ -0,0 +1,71 @@
+/*
+ *  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.interceptor.context;
+
+
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+
+/**
+ * A GetSuffix context used for Interceptors. It contains all the informations
+ * needed for the GetSuffix operation, and used by all the interceptors
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class GetSuffixOperationContext extends AbstractOperationContext
+{
+    /**
+     * Creates a new instance of GetSuffixOperationContext.
+     */
+    public GetSuffixOperationContext( CoreSession session )
+    {
+        super( session );
+    }
+    
+    /**
+     * Creates a new instance of GetSuffixOperationContext.
+     *
+     * @param dn The DN to get the suffix from
+     */
+    public GetSuffixOperationContext( CoreSession session, LdapDN dn )
+    {
+        super( session, dn );
+    }
+    
+
+    /**
+     * @return the operation name
+     */
+    public String getName()
+    {
+        return "GetSuffix";
+    }
+
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "GetSuffixOperationContext with DN '" + getDn().getUpName() + "'";
+    }
+}

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/ListOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/ListOperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/ListOperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/ListOperationContext.java Tue Mar 24 21:26:55 2009
@@ -0,0 +1,103 @@
+/*
+ *  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.interceptor.context;
+
+
+import java.util.Set;
+
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.AttributeTypeOptions;
+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
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ListOperationContext extends SearchingOperationContext
+{
+    /**
+     * Creates a new instance of ListOperationContext.
+     */
+    public ListOperationContext( CoreSession session )
+    {
+        super( session );
+    }
+
+
+    /**
+     * Creates a new instance of ListOperationContext.
+     *
+     * @param dn The DN to get the suffix from
+     */
+    public ListOperationContext( CoreSession session, LdapDN dn )
+    {
+        super( session, dn );
+    }
+
+
+    /**
+     * Creates a new instance of ListOperationContext.
+     *
+     * @param dn The DN to get the suffix from
+     * @param aliasDerefMode the alias dereferencing mode to use
+     */
+    public ListOperationContext( CoreSession session, LdapDN dn, AliasDerefMode aliasDerefMode )
+    {
+        super( session, dn, aliasDerefMode );
+    }
+
+    
+    /**
+     * Creates a new instance of ListOperationContext with attributes to return.
+     *
+     * @param session the session associated with this {@link OperationContext}
+     * @param dn the base DN 
+     * @param aliasDerefMode the alias dereferencing mode to use
+     * @param returningAttributes the attributes to return
+     */
+    public ListOperationContext( CoreSession session, LdapDN dn, AliasDerefMode aliasDerefMode,
+        Set<AttributeTypeOptions> returningAttributes )
+    {
+        super( session, dn, aliasDerefMode, returningAttributes );
+    }
+
+
+    /**
+     * @return the operation name
+     */
+    public String getName()
+    {
+        return "List";
+    }
+
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "List with DN '" + getDn().getUpName() + "'";
+    }
+}

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/ListSuffixOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/ListSuffixOperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/ListSuffixOperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/ListSuffixOperationContext.java Tue Mar 24 21:26:55 2009
@@ -0,0 +1,72 @@
+/*
+ *  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.interceptor.context;
+
+
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+
+/**
+ * A ListSuffix context used for Interceptors. It contains all the informations
+ * needed for the ListSuffix operation, and used by all the interceptors
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ListSuffixOperationContext extends AbstractOperationContext
+{
+    /**
+     * Creates a new instance of ListSuffixOperationContext.
+     */
+    public ListSuffixOperationContext( CoreSession session )
+    {
+        super( session );
+    }
+    
+    /**
+     * Creates a new instance of ListSuffixOperationContext.
+     *
+     * @param dn The DN to get the suffix from
+     */
+    public ListSuffixOperationContext( CoreSession session, Registries registries, LdapDN dn )
+    {
+        super( session, dn );
+    }
+    
+
+    /**
+     * @return the operation name
+     */
+    public String getName()
+    {
+        return "ListSuffix";
+    }
+
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "ListSuffixOperationContext with DN '" + getDn().getUpName() + "'";
+    }
+}

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/LookupOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/LookupOperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/LookupOperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/LookupOperationContext.java Tue Mar 24 21:26:55 2009
@@ -0,0 +1,217 @@
+/*
+ *  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.interceptor.context;
+ 
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+
+/**
+ * A context for tracking lookup operations. Lookup operations will return a
+ * cloned server entry.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class LookupOperationContext extends AbstractOperationContext
+{
+    private static final String[] EMPTY = new String[] {};
+    
+    /** The list of attributes id to return */
+    private List<String> attrsId = new ArrayList<String>();
+    
+    private Boolean allOperational;
+    
+    private Boolean allUser;
+    
+    
+    /**
+     * 
+     * Creates a new instance of LookupOperationContext.
+     *
+     */
+    public LookupOperationContext( CoreSession session )
+    {
+        super( session );
+    }
+    
+
+    /**
+     * 
+     * Creates a new instance of LookupOperationContext.
+     *
+     */
+    public LookupOperationContext( CoreSession session, LdapDN dn )
+    {
+        super( session, dn );
+    }
+    
+
+    /**
+     * 
+     * Creates a new instance of LookupOperationContext.
+     *
+     */
+    public LookupOperationContext( CoreSession session, String attrsId[] )
+    {
+        super( session );
+        setAttrsId( attrsId );
+    }
+
+    
+    /**
+     * 
+     * Creates a new instance of LookupOperationContext.
+     *
+     */
+    public LookupOperationContext( CoreSession session, LdapDN dn, String attrsId[] )
+    {
+        super( session, dn );
+        setAttrsId( attrsId );
+    }
+
+    
+    /**
+     * @return Get the attribute ids as a String array
+     */
+    public String[] getAttrsIdArray()
+    {
+        if ( attrsId == null || attrsId.size() == 0 )
+        {
+            return EMPTY;
+        }
+        else
+        {
+            String[] attrs = new String[ attrsId.size()];
+            return attrsId.toArray( attrs );
+        }
+    }
+
+    
+    /**
+     * Set the attribute Ids
+     *
+     * @param attrsId The String array containing all the attribute IDs
+     */
+    public void setAttrsId( String[] attrsId )
+    {
+        if ( attrsId != null && attrsId.length > 0 )
+        {
+            this.attrsId = new ArrayList<String>( Arrays.asList( attrsId ) );
+            
+            // filter out the '+' and '*' and set boolean parameters 
+            for ( String id : this.attrsId )
+            {
+                if ( id.equals( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES ) )
+                {
+                    allOperational = true;
+                }
+                else if ( id.equals( SchemaConstants.ALL_USER_ATTRIBUTES ) )
+                {
+                    allUser = true;
+                }
+            }
+
+            if ( allOperational != null && allOperational )
+            {
+                this.attrsId.remove( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES );
+            }
+            
+            if ( allUser != null && allUser )
+            {
+                this.attrsId.remove( SchemaConstants.ALL_USER_ATTRIBUTES );
+            }
+        }
+    }
+
+
+    /**
+     * Add an attribute ID to the current list, creating the list if necessary
+     *
+     * @param attrId the Id to add
+     */
+    public void addAttrsId( String attrId )
+    {
+        if ( attrId.equals( SchemaConstants.ALL_USER_ATTRIBUTES ) )
+        {
+            allUser = true;
+            return;
+        }
+        
+        if ( attrId.equals( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES ) )
+        {
+            allOperational = true;
+            return;
+        }
+        
+        if ( attrsId == null )
+        {
+            attrsId = new ArrayList<String>(); 
+        }
+        
+        attrsId.add( attrId );
+    }
+
+    
+    /**
+     * @return The attribute IDs list
+     */
+    public List<String> getAttrsId()
+    {
+        return attrsId;
+    }
+
+    
+    public Boolean getAllUser()
+    {
+        return allUser;
+    }
+    
+
+    public Boolean getAllOperational()
+    {
+        return allOperational;
+    }
+    
+
+    /**
+     * @return the operation name
+     */
+    public String getName()
+    {
+        return "Lookup";
+    }
+
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "LookupContext for DN '" + getDn().getUpName() + "'" + ( ( attrsId != null ) ? ", attributes : <" + StringTools.listToString( attrsId ) + ">" : "" );
+    }
+}



Mime
View raw message