directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r758039 [2/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
Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/ModifyOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/ModifyOperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/ModifyOperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/ModifyOperationContext.java Tue Mar 24 21:26:55 2009
@@ -0,0 +1,177 @@
+/*
+ *  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.List;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.server.core.entry.ClonedServerEntry;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.entry.ServerEntryUtils;
+import org.apache.directory.server.core.entry.ServerModification;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.entry.client.ClientModification;
+import org.apache.directory.shared.ldap.message.MessageTypeEnum;
+import org.apache.directory.shared.ldap.message.ModifyRequest;
+import org.apache.directory.shared.ldap.message.control.ManageDsaITControl;
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+
+/**
+ * A Modify context used for Interceptors. It contains all the informations
+ * needed for the modify operation, and used by all the interceptors
+ * 
+ * This context can use either Attributes or ModificationItem, but not both.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ModifyOperationContext extends AbstractChangeOperationContext
+{
+    /** The modification items */
+    private List<Modification> modItems;
+    
+    /** Cloned entry that is modified */
+    private ClonedServerEntry entry;
+
+
+    /**
+     * Creates a new instance of ModifyOperationContext.
+     */
+    public ModifyOperationContext( CoreSession session )
+    {
+        super( session );
+    }
+
+
+    /**
+     * Creates a new instance of ModifyOperationContext.
+     *
+     * @param dn the dn of the entry to be modified
+     * @param modItems the modifications to be performed on the entry
+     */
+    public ModifyOperationContext( CoreSession session, LdapDN dn, List<Modification> modItems )
+    {
+        super( session, dn );
+
+        this.modItems = modItems;
+    }
+
+
+    public ModifyOperationContext( CoreSession session, ModifyRequest modifyRequest ) throws Exception
+    {
+        super( session, modifyRequest.getName() );
+        
+        modItems = ServerEntryUtils.toServerModification( 
+            modifyRequest.getModificationItems().toArray( new ClientModification[0]), 
+            session.getDirectoryService().getRegistries().getAttributeTypeRegistry() );
+        
+        requestControls = modifyRequest.getControls();
+
+        if ( requestControls.containsKey( ManageDsaITControl.CONTROL_OID ) )
+        {
+            ignoreReferral();
+        }
+        else
+        {
+            throwReferral();
+        }
+    }
+
+
+    /**
+     * Set the modified attributes
+     * @param modItems The modified attributes
+     */
+    public void setModItems( List<Modification> modItems )
+    {
+        this.modItems = modItems;
+    }
+
+
+    /**
+     * @return The modifications
+     */
+    public List<Modification> getModItems() 
+    {
+        return modItems;
+    }
+
+
+    public static List<Modification> createModItems( ServerEntry serverEntry, ModificationOperation modOp ) throws NamingException
+    {
+        List<Modification> items = new ArrayList<Modification>( serverEntry.size() );
+        
+        for ( EntryAttribute attribute:serverEntry )
+        {
+            items.add( new ServerModification( modOp, attribute ) );
+        }
+
+        return items;
+    }
+
+
+    /**
+     * @return the operation name
+     */
+    public String getName()
+    {
+        return MessageTypeEnum.MODIFY_REQUEST.name();
+    }
+
+    
+    public void setEntry( ClonedServerEntry entry )
+    {
+        this.entry = entry;
+    }
+    
+    
+    public ClonedServerEntry getEntry()
+    {
+        return entry;
+    }
+
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        StringBuilder sb = new StringBuilder();
+        
+        sb.append("ModifyContext for DN '").append( getDn().getUpName() ).append( "', modifications :\n" );
+        
+        if ( modItems != null )
+        {
+            for ( Modification mod:modItems )
+            {
+                sb.append( mod ).append( '\n' );
+            }
+        }
+        
+        return sb.toString();
+    }
+}

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/MoveAndRenameOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/MoveAndRenameOperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/MoveAndRenameOperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/MoveAndRenameOperationContext.java Tue Mar 24 21:26:55 2009
@@ -0,0 +1,139 @@
+/*
+ *  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.ModifyDnRequest;
+import org.apache.directory.shared.ldap.message.control.ManageDsaITControl;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.name.Rdn;
+
+
+/**
+ * A Move And Rename context used for Interceptors. It contains all the informations
+ * needed for the modify DN operation, and used by all the interceptors
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class MoveAndRenameOperationContext extends RenameOperationContext
+{
+    /** The parent DN */
+    private LdapDN parent;
+
+    /** Cached calculated new DN after move and rename */
+    private LdapDN newDn;
+
+    /**
+     * Creates a new instance of MoveAndRenameOperationContext.
+     */
+    public MoveAndRenameOperationContext( CoreSession session )
+    {
+        super( session );
+    }
+
+
+    /**
+     * Creates a new instance of MoveAndRenameOperationContext.
+     *
+     * @param oldDn the original source entry DN to be moved and renamed
+     * @param parent the new entry superior of the target after the move
+     * @param newRdn the new rdn to use for the target once renamed
+     * @param delOldRdn true if the old rdn value is deleted, false otherwise
+     */
+    public MoveAndRenameOperationContext( CoreSession session, LdapDN oldDn, LdapDN parent, Rdn newRdn, boolean delOldRdn )
+    {
+        super( session, oldDn, newRdn, delOldRdn );
+        this.parent = parent;
+    }
+
+
+    public MoveAndRenameOperationContext( CoreSession session, ModifyDnRequest modifyDnRequest )
+    {
+        // super sets the newRdn and the delOldRdn members and tests
+        super( session, modifyDnRequest );
+        this.parent = modifyDnRequest.getNewSuperior();
+        
+        if ( parent == null )
+        {
+            throw new IllegalStateException( "NewSuperior must not be null: " + modifyDnRequest );
+        }
+        
+        if ( requestControls.containsKey( ManageDsaITControl.CONTROL_OID ) )
+        {
+            ignoreReferral();
+        }
+        else
+        {
+            throwReferral();
+        }
+    }
+
+
+    /**
+     *  @return The parent DN
+     */
+    public LdapDN getParent()
+    {
+        return parent;
+    }
+
+
+    /**
+     * Set the parent DN
+     *
+     * @param parent The parent
+     */
+    public void setParent( LdapDN parent )
+    {
+        this.parent = parent;
+    }
+
+    
+    /**
+     * Gets cached copy of already computed new name or creates it if not 
+     *
+     * @return the normalized new name after move and rename
+     * @throws Exception if the name cannot be normalized
+     */
+    public LdapDN getNewDn() throws Exception
+    {
+        if ( newDn == null )
+        {
+            newDn = new LdapDN( getParent().getUpName() );
+            newDn.add( getNewRdn().getUpName() );
+            newDn.normalize( session.getDirectoryService()
+                .getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
+        }
+        
+        return newDn;
+    }
+    
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "ReplaceContext for old DN '" + getDn().getUpName() + "'" +
+        ", parent '" + parent + "'";
+    }
+}

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/MoveOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/MoveOperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/MoveOperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/MoveOperationContext.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.shared.ldap.message.MessageTypeEnum;
+import org.apache.directory.shared.ldap.message.ModifyDnRequest;
+import org.apache.directory.shared.ldap.message.control.ManageDsaITControl;
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+
+/**
+ * A Move context used for Interceptors. It contains all the informations
+ * needed for the modify DN operation, and used by all the interceptors
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class MoveOperationContext extends AbstractChangeOperationContext
+{
+    /** The parent DN */
+    private LdapDN parent;
+    
+
+    /**
+     * Creates a new instance of MoveOperationContext.
+     */
+    public MoveOperationContext( CoreSession session )
+    {
+        super( session );
+    }
+    
+
+    /**
+     * Creates a new instance of MoveOperationContext.
+     */
+    public MoveOperationContext( CoreSession session, LdapDN oldDn, LdapDN parent )
+    {
+        super( session, oldDn );
+        this.parent = parent;
+    }
+
+    
+    public MoveOperationContext( CoreSession session, ModifyDnRequest modifyDnRequest )
+    {
+        super( session, modifyDnRequest.getName() );
+        this.parent = modifyDnRequest.getNewSuperior();
+        
+        if ( parent == null )
+        {
+            throw new IllegalArgumentException( "The new superior cannot be null for " + modifyDnRequest );
+        }
+        
+        this.requestControls = modifyDnRequest.getControls();
+        
+        if ( modifyDnRequest.getNewRdn() != null )
+        {
+            throw new IllegalArgumentException( modifyDnRequest + " represents a move and rename operation." );
+        }
+        
+        if ( requestControls.containsKey( ManageDsaITControl.CONTROL_OID ) )
+        {
+            ignoreReferral();
+        }
+        else
+        {
+            throwReferral();
+        }
+    }
+
+
+    /**
+     *  @return The parent DN
+     */
+    public LdapDN getParent()
+    {
+        return parent;
+    }
+    
+
+    /**
+     * Set the parent DN
+     *
+     * @param parent The parent
+     */
+    public void setParent( LdapDN parent )
+    {
+        this.parent = parent;
+    }
+
+
+    /**
+     * @return the operation name
+     */
+    public String getName()
+    {
+        return MessageTypeEnum.MOD_DN_REQUEST.name();
+    }
+
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "ReplaceContext for old DN '" + getDn().getUpName() + "'" +
+        ", parent '" + parent + "'";
+    }
+}

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/OperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/OperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/OperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/OperationContext.java Tue Mar 24 21:26:55 2009
@@ -0,0 +1,349 @@
+/*
+ *  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.List;
+
+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.server.core.interceptor.Interceptor;
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+
+/**
+ * This interface represent the context passed as an argument to each interceptor.
+ * It will contain data used by all the operations.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public interface OperationContext
+{
+    /**
+     * Checks to see if this operation is the first operation in a chain of 
+     * operations performed on the DirectoryService.  The first operation in  
+     * a sequence of operations, is not a byproduct of another operation 
+     * unlike operations following in the sequence.  The other operations 
+     * following the first, occur as a side effect to complete this first 
+     * operation.
+     * 
+     * @return true if the operation is the first, false otherwise
+     */
+    boolean isFirstOperation();
+    
+    
+    /**
+     * Gets the first, direct operation issued against the DirectoryService.
+     *
+     * @return the first, direct operation issued 
+     */
+    OperationContext getFirstOperation();
+    
+    
+    /**
+     * Gets the previous, operation issued on the DirectoryService.
+     *
+     * @return the previous, operation issued
+     */
+    OperationContext getPreviousOperation();
+    
+    
+    /**
+     * Gets the next, indirect operation issued on the DirectoryService.
+     *
+     * @return the next, indirect operation issued 
+     */
+    OperationContext getNextOperation();
+    
+    
+    /**
+     * Gets the last, operation issued on the DirectoryService.
+     *
+     * @return the last, operation issued
+     */
+    OperationContext getLastOperation();
+
+
+    /**
+     * Gets the effective principal for this operation which may not be the 
+     * same as the authenticated principal when the session for this context
+     * has an explicit authorization id, or this operation was applied with 
+     * the proxy authorization control.
+     * 
+     * @see CoreSession#getAuthenticatedPrincipal()
+     * @see CoreSession#getEffectivePrincipal()
+     * @return the effective principal for this operation
+     */
+    LdapPrincipal getEffectivePrincipal();
+
+
+    /**
+     * @return The associated DN
+     */
+    LdapDN getDn();
+    
+    
+    /**
+     * Set the context DN
+     *
+     * @param dn The DN to set
+     */
+    void setDn( LdapDN dn );
+
+    
+    /**
+     * Gets the server entry associated with the target DN of this 
+     * OperationContext.  The entry associated with the DN may be altered 
+     * during the course of processing an LDAP operation through the 
+     * InterceptorChain.  This place holder is put here to prevent the need
+     * for repetitive lookups of the target entry.  Furthermore the returned
+     * entry may be altered by any Interceptor in the chain and this is why a
+     * ClonedServerEntry is returned instead of a ServerEntry.  A 
+     * ClonedServerEntry has an immutable reference to the original state of
+     * the target entry.  The original state can be accessed via a call to
+     * {@link ClonedServerEntry#getOriginalEntry()}.  The return value may be 
+     * null in which case any lookup performed to access it may set it to 
+     * prevent the need for subsequent lookups.
+     * 
+     * Also note that during the course of handling some operations such as 
+     * those that rename, move or rename and move the entry, may alter the DN 
+     * of this entry.  Interceptor implementors should not presume the DN or 
+     * the values contained in this entry are currently what is present in the 
+     * DIT.  The original entry contained in the ClonedServerEntry shoudl be 
+     * used as the definitive source of information about the state of the 
+     * entry in the DIT before returning from the Partition subsystem.
+     * 
+     * @return target entry associated with the DN of this OperationContext
+     */
+    ClonedServerEntry getEntry();
+    
+    
+    /**
+     * Sets the server entry associated with the target DN of this 
+     * OperationContext.
+     *
+     * @param entry the entry whose DN is associated with this OperationContext.
+     */
+    void setEntry( ClonedServerEntry entry );
+    
+    
+    /**
+     * Adds a response control to this operation.
+     *
+     * @param responseControl the response control to add to this operation
+     */
+    void addResponseControl( Control responseControl );
+    
+    
+    /** 
+     * Checks to see if a response control is present on this operation.
+     *
+     * @param numericOid the numeric OID of the control also known as it's type OID
+     * @return true if the control is associated with this operation, false otherwise
+     */
+    boolean hasResponseControl( String numericOid );
+    
+    
+    /**
+     * Gets a response control if present for this request.
+     * 
+     * @param numericOid the numeric OID of the control also known as it's type OID
+     * @return the control if present
+     */
+    Control getResponseControl( String numericOid );
+    
+    
+    /**
+     * Gets all the response controls producted during this operation.
+     *
+     * @return an array over all the response controls 
+     */
+    Control[] getResponseControls();
+    
+    
+    /**
+     * Checks if any response controls have been generated for this operation.
+     *
+     * @return true if any response controls have been generated, false otherwise
+     */
+    boolean hasResponseControls();
+    
+    
+    /**
+     * Checks the number of response controls have been generated for this operation.
+     *
+     * @return the number of response controls that have been generated
+     */
+    int getResponseControlCount();
+    
+    
+    /**
+     * Adds a request control to this operation.
+     *
+     * @param requestControl the request control to add to this operation
+     */
+    void addRequestControl( Control requestControl );
+    
+    
+    /** 
+     * Checks to see if a request control is present on this request.
+     *
+     * @param numericOid the numeric OID of the control also known as it's type OID
+     * @return true if the control is associated with this operation, false otherwise
+     */
+    boolean hasRequestControl( String numericOid );
+    
+    
+    /**
+     * Checks if any request controls exists for this operation.
+     *
+     * @return true if any request controls exist, false otherwise
+     */
+    boolean hasRequestControls();
+    
+    
+    /**
+     * Gets a request control if present for this request.
+     * 
+     * @param numericOid the numeric OID of the control also known as it's type OID
+     * @return the control if present
+     */
+    Control getRequestControl( String numericOid );
+
+
+    /**
+     * Adds many request controls to this operation.
+     *
+     * @param requestControls the request controls to add to this operation
+     */
+    void addRequestControls( Control[] requestControls );
+    
+    
+    /**
+     * @return the operation's name
+     */
+    String getName();
+    
+    
+    /**
+     * 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
+     */
+    boolean isBypassed( String interceptorName );
+
+
+    /**
+     * Checks to see if any Interceptors are bypassed by this Invocation.
+     *
+     * @return true if at least one bypass exists
+     */
+    boolean hasBypass();
+    
+    
+    /**
+     * Gets the set of bypassed Interceptors.
+     *
+     * @return the set of bypassed Interceptors
+     */
+    Collection<String> getByPassed();
+    
+    
+    /**
+     * Sets the set of bypassed Interceptors.
+     * 
+     * @param byPassed the set of bypassed Interceptors
+     */
+    void setByPassed( Collection<String> byPassed );
+    
+    
+    /**
+     * Gets the session associated with this operation.
+     *
+     * @return the session associated with this operation
+     */
+    CoreSession getSession();
+    
+    
+    // -----------------------------------------------------------------------
+    // Utility Factory Methods to Create New OperationContexts
+    // -----------------------------------------------------------------------
+    
+    
+    LookupOperationContext newLookupContext( LdapDN dn );
+
+    
+    ClonedServerEntry lookup( LdapDN dn, Collection<String> byPass ) throws Exception;
+    
+    
+    ClonedServerEntry lookup( LookupOperationContext lookupContext ) throws Exception;
+    
+    
+    void modify( LdapDN dn, List<Modification> mods, Collection<String> byPass ) throws Exception;
+    
+    
+    void add( ServerEntry entry, Collection<String> byPass ) throws Exception;
+    
+    
+    void delete( LdapDN dn, Collection<String> byPass ) throws Exception;
+
+
+    /**
+     * Checks to see if an entry exists.
+     *
+     * @param dn the distinguished name of the entry to check
+     * @param byPass collection of {@link Interceptor}'s to bypass for this check
+     * @return true if the entry exists, false if it does not
+     * @throws Exception on failure to perform this operation
+     */
+    boolean hasEntry( LdapDN dn, Collection<String> byPass ) throws Exception;
+    
+    
+    /**
+     * Set the throwReferral flag to true
+     */
+    void throwReferral();
+    
+    
+    /**
+     * @return <code>true</code> if the referrals are thrown
+     */
+    boolean isReferralThrown();
+
+
+    /**
+     * Set the throwReferral flag to false
+     */
+    void ignoreReferral();
+
+
+    /**
+     * @return <code>true</code> if the referrals are ignored
+     */
+    boolean isReferralIgnored();
+}

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

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/RenameOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/RenameOperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/RenameOperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/RenameOperationContext.java Tue Mar 24 21:26:55 2009
@@ -0,0 +1,196 @@
+/*
+ *  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.MessageTypeEnum;
+import org.apache.directory.shared.ldap.message.ModifyDnRequest;
+import org.apache.directory.shared.ldap.message.control.ManageDsaITControl;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.name.Rdn;
+
+
+/**
+ * A RenameService context used for Interceptors. It contains all the informations
+ * needed for the modify DN operation, and used by all the interceptors
+ * 
+ * This is used when the modifyDN is about changing the RDN, not the base DN.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class RenameOperationContext extends AbstractChangeOperationContext
+{
+    /** The new RDN */
+    private Rdn newRdn;
+
+    /** Cached copy of the new DN */
+    private LdapDN newDn;
+
+    /** The flag to remove the old DN Attribute  */
+    private boolean delOldDn;
+
+    /** The entry after being renamed and altered for rdn attributes */ 
+    private ClonedServerEntry alteredEntry;
+    
+
+    /**
+     * Creates a new instance of RenameOperationContext.
+     */
+    public RenameOperationContext( CoreSession session )
+    {
+        super( session );
+    }
+
+
+    /**
+     * Creates a new instance of RenameOperationContext.
+     *
+     * @param oldDn the dn of the entry before the rename
+     * @param newRdn the new RDN to use for the target
+     * @param delOldDn true if we delete the old RDN value
+     */
+    public RenameOperationContext( CoreSession session, LdapDN oldDn, Rdn newRdn, boolean delOldDn )
+    {
+        super( session, oldDn );
+        this.newRdn = newRdn;
+        this.delOldDn = delOldDn;
+    }
+
+
+    public RenameOperationContext( CoreSession session, ModifyDnRequest modifyDnRequest )
+    {
+        super( session, modifyDnRequest.getName() );
+        this.newRdn = modifyDnRequest.getNewRdn();
+        
+        if ( newRdn == null )
+        {
+            throw new IllegalStateException( "newRdn must not be null for a rename: " + modifyDnRequest );
+        }
+        
+        this.delOldDn = modifyDnRequest.getDeleteOldRdn();
+        this.requestControls = modifyDnRequest.getControls();
+        
+        if ( requestControls.containsKey( ManageDsaITControl.CONTROL_OID ) )
+        {
+            ignoreReferral();
+        }
+        else
+        {
+            throwReferral();
+        }
+    }
+
+
+    /**
+     * @return The delete old DN flag
+     */
+    public boolean getDelOldDn() 
+    {
+        return delOldDn;
+    }
+
+
+    /**
+     * Set the flag to delete the old DN
+     * @param delOldDn the flag to set
+     */
+    public void setDelOldDn( boolean delOldDn ) 
+    {
+        this.delOldDn = delOldDn;
+    }
+
+
+    /**
+     * @return The new DN either computed if null or already computed
+     */
+    public LdapDN getNewDn() throws Exception
+    {
+        if ( newDn == null )
+        {
+            newDn = new LdapDN( getDn().getUpName() );
+            newDn.remove( newDn.size() - 1 );
+            newDn.add( newRdn.getUpName() );
+            newDn.normalize( session.getDirectoryService().getRegistries()
+                .getAttributeTypeRegistry().getNormalizerMapping() );
+        }
+        
+        return newDn;
+    }
+
+
+    /**
+     * @return The new RDN
+     */
+    public Rdn getNewRdn()
+    {
+        return newRdn;
+    }
+
+
+    /**
+     * Set the new RDN
+     * @param newRdn The new RDN
+     */
+    public void setNewRdn( Rdn newRdn )
+    {
+        this.newRdn = newRdn;
+    }
+
+
+    /**
+     * @return the operation name
+     */
+    public String getName()
+    {
+        return MessageTypeEnum.MOD_DN_REQUEST.name();
+    }
+    
+    
+    /**
+     * Returns the entry after it has been renamed and potentially changed for 
+     * Rdn alterations.
+     *
+     * @return the new renamed entry
+     */
+    public ClonedServerEntry getAlteredEntry()
+    {
+        return alteredEntry;
+    }
+
+    
+    public void setAlteredEntry( ClonedServerEntry alteredEntry ) 
+    {
+        this.alteredEntry = alteredEntry;
+    }
+    
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "RenameContext for old DN '" + getDn().getUpName() + "'" +
+        ", new RDN '" + newRdn + "'" +
+        ( delOldDn ? ", delete old Dn" : "" ) ; 
+    }
+}

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/SearchOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/SearchOperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/SearchOperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/SearchOperationContext.java Tue Mar 24 21:26:55 2009
@@ -0,0 +1,175 @@
+/*
+ *  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 javax.naming.directory.SearchControls;
+
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.apache.directory.shared.ldap.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.message.MessageTypeEnum;
+import org.apache.directory.shared.ldap.message.SearchRequest;
+import org.apache.directory.shared.ldap.message.control.ManageDsaITControl;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.AttributeTypeOptions;
+
+
+/**
+ * A Search context used for Interceptors. It contains all the informations
+ * needed for the search operation, and used by all the interceptors
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SearchOperationContext extends SearchingOperationContext
+{
+    /** The filter */
+    private ExprNode filter;
+
+
+    /**
+     * Creates a new instance of SearchOperationContext.
+     */
+    public SearchOperationContext( CoreSession session )
+    {
+        super( session );
+    }
+
+
+    /**
+     * Creates a new instance of SearchOperationContext.
+     * @throws Exception 
+     */
+    public SearchOperationContext( CoreSession session, SearchRequest searchRequest ) throws Exception
+    {
+        super( session );
+        
+        this.dn = searchRequest.getBase();
+        this.filter = searchRequest.getFilter();
+        this.abandoned = searchRequest.isAbandoned();
+        this.aliasDerefMode = searchRequest.getDerefAliases();
+        
+        this.requestControls = searchRequest.getControls();
+        this.scope = searchRequest.getScope();
+        this.sizeLimit = searchRequest.getSizeLimit();
+        this.timeLimit = searchRequest.getTimeLimit();
+        this.noAttributes = searchRequest.getTypesOnly();
+        setReturningAttributes( searchRequest.getAttributes() );
+        
+        if ( requestControls.containsKey( ManageDsaITControl.CONTROL_OID ) )
+        {
+            ignoreReferral();
+        }
+        else
+        {
+            throwReferral();
+        }
+    }
+
+
+    /**
+     * Creates a new instance of SearchOperationContext.
+     * 
+     * @param aliasDerefMode the alias dereferencing mode
+     * @param dn the dn of the search base
+     * @param filter the filter AST to use for the search
+     * @param searchControls the search controls
+     */
+    public SearchOperationContext( CoreSession session, LdapDN dn, AliasDerefMode aliasDerefMode, ExprNode filter,
+                                   SearchControls searchControls ) throws Exception
+    {
+        super( session, dn, aliasDerefMode, searchControls );
+        this.filter = filter;
+    }
+
+
+    /**
+     * Creates a new instance of SearchOperationContext.
+     * 
+     * @param session the session this operation is associated with
+     * @param dn the search base
+     * @param scope the search scope
+     * @param filter the filter AST to use for the search
+     * @param aliasDerefMode the alias dereferencing mode
+     * @param returningAttributes the attributes to return
+     */
+    public SearchOperationContext( CoreSession session, LdapDN dn, SearchScope scope,
+        ExprNode filter, AliasDerefMode aliasDerefMode, Set<AttributeTypeOptions> returningAttributes )
+    {
+        super( session, dn, aliasDerefMode, returningAttributes );
+        super.setScope( scope );
+        this.filter = filter;
+    }
+
+
+    /**
+     * Checks whether or not the ManageDsaITControl is present.  If not 
+     * present then the filter is modified to force the return of all referral
+     * entries regardless of whether or not the filter matches the referral
+     * entry.
+     */
+    public boolean hasManageDsaItControl()
+    {
+        return super.hasRequestControl( ManageDsaITControl.CONTROL_OID );
+    }
+    
+    
+    /**
+     * @return The filter
+     */
+    public ExprNode getFilter()
+    {
+        return filter;
+    }
+
+
+    /**
+     * Set the filter into the context.
+     *
+     * @param filter The filter to set
+     */
+    public void setFilter( ExprNode filter )
+    {
+        this.filter = filter;
+    }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "SearchContext for DN '" + getDn().getUpName() + "', filter :'"
+        + filter + "'"; 
+    }
+
+
+    /**
+     * @return the operation name
+     */
+    public String getName()
+    {
+        return MessageTypeEnum.SEARCH_REQUEST.name();
+    }
+}

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/SearchingOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/SearchingOperationContext.java?rev=758039&view=auto
==============================================================================
--- directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/SearchingOperationContext.java (added)
+++ directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/SearchingOperationContext.java Tue Mar 24 21:26:55 2009
@@ -0,0 +1,439 @@
+/*
+ *  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.HashSet;
+import java.util.Set;
+
+import javax.naming.NamingException;
+import javax.naming.directory.NoSuchAttributeException;
+import javax.naming.directory.SearchControls;
+
+import org.apache.directory.server.core.CoreSession;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.filter.SearchScope;
+import org.apache.directory.shared.ldap.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.AttributeTypeOptions;
+import org.apache.directory.shared.ldap.schema.SchemaUtils;
+import org.apache.directory.shared.ldap.util.ArrayUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.apache.directory.shared.ldap.filter.SearchScope.ONELEVEL;
+
+
+/**
+ * A context used for search related operations and used by all 
+ * the Interceptors.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public abstract class SearchingOperationContext extends AbstractOperationContext
+{
+    /** The LoggerFactory used by this Interceptor */
+    private static Logger LOG = LoggerFactory.getLogger( SearchingOperationContext.class );
+    
+    private static String[] EMPTY_STR_ARRAY = new String[0];
+
+    /** A flag describing the way alias should be handled */
+    protected AliasDerefMode aliasDerefMode = AliasDerefMode.DEREF_ALWAYS;
+
+    /** The sizeLimit for this search operation */
+    protected long sizeLimit = 0;
+    
+    /** The timeLimit for this search operation */
+    protected int timeLimit = 0;
+    
+    /** The scope for this search : default to One Level */
+    protected SearchScope scope = ONELEVEL;
+
+    /** A flag set if the returned attributes set contains '+' */
+    protected boolean allOperationalAttributes = false;
+    
+    /** A flag set if the returned attributes set contains '*' */
+    protected boolean allUserAttributes = false;
+    
+    /** A flag set if the returned attributes set contains '1.1' */
+    protected boolean noAttributes = false;
+    
+    /** A set containing the returning attributeTypesOptions */
+    protected Set<AttributeTypeOptions> returningAttributes; 
+    
+    /** A flag if the search operation is abandoned */
+    protected boolean abandoned = false;
+    
+    
+    /**
+     * Creates a new instance of ListOperationContext.
+     */
+    public SearchingOperationContext( CoreSession session )
+    {
+        super( session );
+    }
+
+
+    /**
+     * Creates a new instance of ListOperationContext.
+     *
+     * @param dn The DN to get the suffix from
+     */
+    public SearchingOperationContext( 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 SearchingOperationContext( CoreSession session, LdapDN dn, AliasDerefMode aliasDerefMode )
+    {
+        super( session, dn );
+        this.aliasDerefMode = aliasDerefMode;
+    }
+
+    
+    protected void setReturningAttributes( Collection<String> attributesIds ) 
+        throws Exception
+    {
+        setReturningAttributes( attributesIds.toArray( EMPTY_STR_ARRAY ) );
+    }
+    
+    
+    protected void setReturningAttributes( String[] attributesIds ) throws Exception
+    {
+        if ( attributesIds != null && attributesIds.length != 0 )
+        {
+            returningAttributes = new HashSet<AttributeTypeOptions>();
+            
+            for ( String returnAttribute : attributesIds )
+            {
+                if ( returnAttribute.equals( SchemaConstants.NO_ATTRIBUTE ) )
+                {
+                    noAttributes = true;
+                    continue;
+                }
+                
+                if ( returnAttribute.equals( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES ) )
+                {
+                    allOperationalAttributes = true;
+                    continue;
+                }
+                
+                if ( returnAttribute.equals( SchemaConstants.ALL_USER_ATTRIBUTES ) )
+                {
+                    allUserAttributes = true;
+                    continue;
+                }
+                
+                try
+                {
+                    String id = SchemaUtils.stripOptions( returnAttribute );
+                    Set<String> options = SchemaUtils.getOptions( returnAttribute );
+                    
+                    AttributeType attributeType = session.getDirectoryService()
+                        .getRegistries().getAttributeTypeRegistry().lookup( id );
+                    AttributeTypeOptions attrOptions = new AttributeTypeOptions( attributeType, options );
+                    
+                    returningAttributes.add( attrOptions );
+                }
+                catch ( NoSuchAttributeException nsae )
+                {
+                    LOG.warn( "Requested attribute {} does not exist in the schema, it will be ignored", returnAttribute );
+                    // Unknown attributes should be silently ignored, as RFC 2251 states
+                }
+            }
+        }
+    }
+    
+    
+    /**
+     * Creates a new instance of ListOperationContext.
+     *
+     * @param dn The DN to get the suffix from
+     * @param aliasDerefMode the alias dereferencing mode to use
+     * @throws NamingException 
+     */
+    public SearchingOperationContext( CoreSession session, LdapDN dn, AliasDerefMode aliasDerefMode, 
+        SearchControls searchControls ) throws Exception
+    {
+        super( session, dn );
+        this.aliasDerefMode = aliasDerefMode;
+        this.scope = SearchScope.getSearchScope( searchControls );
+        this.timeLimit = searchControls.getTimeLimit();
+        this.sizeLimit = searchControls.getCountLimit();
+        
+        if ( searchControls.getReturningAttributes() != null )
+        {
+            setReturningAttributes( searchControls.getReturningAttributes() );
+        }
+    }
+
+    
+    /**
+     * Creates a new instance of a SearchingOperationContext using one level 
+     * scope, with attributes to return.
+     *
+     * @param dn The DN to get the suffix from
+     * @param aliasDerefMode the alias dereferencing mode to use
+     * @throws NamingException 
+     */
+    public SearchingOperationContext( CoreSession session, LdapDN dn, AliasDerefMode aliasDerefMode,
+        Set<AttributeTypeOptions> returningAttributes )
+    {
+        super( session, dn );
+        this.aliasDerefMode = aliasDerefMode;
+        this.returningAttributes = returningAttributes;
+    }
+
+
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "ListOperationContext with DN '" + getDn().getUpName() + "'";
+    }
+
+    
+    public AliasDerefMode getAliasDerefMode()
+    {
+        return aliasDerefMode;
+    }
+
+
+    /**
+     * @param sizeLimit the sizeLimit to set
+     */
+    public void setSizeLimit( long sizeLimit )
+    {
+        this.sizeLimit = sizeLimit;
+    }
+
+
+    /**
+     * @return the sizeLimit
+     */
+    public long getSizeLimit()
+    {
+        return sizeLimit;
+    }
+
+
+    /**
+     * @param timeLimit the timeLimit to set
+     */
+    public void setTimeLimit( int timeLimit )
+    {
+        this.timeLimit = timeLimit;
+    }
+
+
+    /**
+     * @return the timeLimit
+     */
+    public int getTimeLimit()
+    {
+        return timeLimit;
+    }
+
+
+    /**
+     * @param scope the scope to set
+     */
+    public void setScope( SearchScope scope )
+    {
+        this.scope = scope;
+    }
+
+
+    /**
+     * @return the scope
+     */
+    public SearchScope getScope()
+    {
+        return scope;
+    }
+
+
+    /**
+     * @param allOperationalAttributes the allOperationalAttributes to set
+     */
+    public void setAllOperationalAttributes( boolean allOperationalAttribute )
+    {
+        this.allOperationalAttributes = allOperationalAttribute;
+    }
+
+
+    /**
+     * @return the allOperationalAttributes
+     */
+    public boolean isAllOperationalAttributes()
+    {
+        return allOperationalAttributes;
+    }
+
+
+    /**
+     * @param allUserAttributes the allUserAttributes to set
+     */
+    public void setAllUserAttributes( boolean allUserAttributes )
+    {
+        this.allUserAttributes = allUserAttributes;
+    }
+
+
+    /**
+     * @return the allUserAttributes
+     */
+    public boolean isAllUserAttributes()
+    {
+        return allUserAttributes;
+    }
+
+
+    /**
+     * @param noAttributes the noAttributes to set
+     */
+    public void setNoAttributes( boolean noAttributes )
+    {
+        this.noAttributes = noAttributes;
+    }
+
+
+    /**
+     * @return the noAttributes
+     */
+    public boolean isNoAttributes()
+    {
+        return noAttributes;
+    }
+
+
+    /**
+     * @param returningAttributes the returningAttributes to set
+     */
+    public void setReturningAttributes( Set<AttributeTypeOptions> returningAttributes )
+    {
+        this.returningAttributes = returningAttributes;
+    }
+
+
+    /**
+     * @return the returningAttributes
+     */
+    public Set<AttributeTypeOptions> getReturningAttributes()
+    {
+        return returningAttributes;
+    }
+
+    
+    /**
+     * Creates a new SearchControls object populated with the parameters 
+     * contained in this SearchOperationContext in normalized form.
+     *
+     * @return a new SearchControls object
+     */
+    public SearchControls getSearchControls()
+    {
+        return getSearchControls( false );
+    }
+    
+    
+    /**
+     * Creates a new SearchControls object populated with the parameters 
+     * contained in this SearchOperationContext.
+     *
+     * @param denormalized true if attribute values are <b>not</b> normalized
+     * @return a new SearchControls object
+     */
+    public SearchControls getSearchControls( boolean denormalized )
+    {
+        SearchControls controls = new SearchControls();
+        controls.setCountLimit( sizeLimit );
+        controls.setSearchScope( scope.getJndiScope() );
+        controls.setTimeLimit( timeLimit );
+
+        Set<String> allReturningAttributes = new HashSet<String>();
+        
+        if ( noAttributes )
+        {
+            allReturningAttributes.add( SchemaConstants.NO_ATTRIBUTE );
+        }
+        
+        if ( allUserAttributes )
+        {
+            allReturningAttributes.add( SchemaConstants.ALL_USER_ATTRIBUTES );
+        }
+        
+        if ( allOperationalAttributes )
+        {
+            allReturningAttributes.add( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES );
+        }
+        
+        if ( returningAttributes != null )
+        {
+            for ( AttributeTypeOptions at : returningAttributes )
+            {
+                if ( denormalized )
+                {
+                    allReturningAttributes.add( at.getAttributeType().getName() );
+                }
+                else
+                {
+                    allReturningAttributes.add( at.getAttributeType().getOid() );
+                }
+            }
+        }
+        
+        if ( allReturningAttributes.size() > 0 )
+        {
+            controls.setReturningAttributes( allReturningAttributes.toArray( ArrayUtils.EMPTY_STRING_ARRAY ) );
+        }
+        
+        return controls;
+    }
+
+
+    /**
+     * @param abandoned the abandoned to set
+     */
+    public void setAbandoned( boolean abandoned )
+    {
+        this.abandoned = abandoned;
+    }
+
+
+    /**
+     * @return the abandoned
+     */
+    public boolean isAbandoned()
+    {
+        return abandoned;
+    }
+}

Added: directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/UnbindOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/ldif-partition/core-interceptor/src/main/java/org/apache/directory/server/core/interceptor/context/UnbindOperationContext.java?rev=758039&view=auto
==============================================================================
--- 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/UnbindOperationContext.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.message.MessageTypeEnum;
+import org.apache.directory.shared.ldap.message.UnbindRequest;
+
+
+/**
+ * A Unbind context used for Interceptors. It contains all the informations
+ * needed for the unbind operation, and used by all the interceptors
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class UnbindOperationContext extends AbstractOperationContext
+{
+    /**
+     * Creates a new instance of UnbindOperationContext.
+     */
+    public UnbindOperationContext( CoreSession session )
+    {
+        super( session, session.getEffectivePrincipal().getJndiName() );
+    }
+    
+
+    public UnbindOperationContext( CoreSession session, UnbindRequest unbindRequest )
+    {
+        super( session, session.getEffectivePrincipal().getJndiName() );
+        this.setRequestControls( unbindRequest.getControls() );
+    }
+
+    
+    /**
+     * @return the operation name
+     */
+    public String getName()
+    {
+        return MessageTypeEnum.UNBIND_REQUEST.name();
+    }
+
+    
+    /**
+     * @see Object#toString()
+     */
+    public String toString()
+    {
+        return "UnbindContext for DN '" + getDn().getUpName() + "'";
+    }
+}



Mime
View raw message