org.apache.directory.server.core.interceptor.context
Class AbstractOperationContext

java.lang.Object
  extended by org.apache.directory.server.core.interceptor.context.AbstractOperationContext
All Implemented Interfaces:
OperationContext
Direct Known Subclasses:
AbstractChangeOperationContext, CompareOperationContext, EmptyOperationContext, EntryOperationContext, GetMatchedNameOperationContext, GetRootDSEOperationContext, GetSuffixOperationContext, ListSuffixOperationContext, LookupOperationContext, RemoveContextPartitionOperationContext, SearchingOperationContext, UnbindOperationContext

public abstract class AbstractOperationContext
extends java.lang.Object
implements OperationContext

This abstract class stores common context elements, like the DN, which is used in all the contexts.

Version:
$Rev$, $Date$
Author:
Apache Directory Project

Field Summary
protected  LdapPrincipal authorizedPrincipal
           
protected  java.util.Collection<java.lang.String> byPassed
          the Interceptors bypassed by this operation
protected  org.apache.directory.shared.ldap.name.LdapDN dn
          The DN associated with the context
protected static javax.naming.ldap.Control[] EMPTY_CONTROLS
           
protected  ClonedServerEntry entry
          The entry associated with the target entry of this OperationContext
protected  OperationContext next
           
protected  OperationContext previous
           
protected  java.util.Map<java.lang.String,javax.naming.ldap.Control> requestControls
          The associated request's controls
protected  java.util.Map<java.lang.String,javax.naming.ldap.Control> responseControls
          The associated response's controls
protected  CoreSession session
           
 
Constructor Summary
AbstractOperationContext(CoreSession session)
          Creates a new instance of AbstractOperationContext.
AbstractOperationContext(CoreSession session, org.apache.directory.shared.ldap.name.LdapDN dn)
          Creates a new instance of AbstractOperationContext.
 
Method Summary
 void add(ServerEntry entry, java.util.Collection<java.lang.String> byPassed)
           
 void addRequestControl(javax.naming.ldap.Control requestControl)
          Adds a request control to this operation.
 void addRequestControls(javax.naming.ldap.Control[] requestControls)
          Adds many request controls to this operation.
 void addResponseControl(javax.naming.ldap.Control responseControl)
          Adds a response control to this operation.
 void delete(org.apache.directory.shared.ldap.name.LdapDN dn, java.util.Collection<java.lang.String> byPassed)
           
 java.util.Collection<java.lang.String> getByPassed()
          Gets the set of bypassed Interceptors.
 org.apache.directory.shared.ldap.name.LdapDN getDn()
           
 LdapPrincipal getEffectivePrincipal()
          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.
 ClonedServerEntry getEntry()
          Gets the server entry associated with the target DN of this OperationContext.
 OperationContext getFirstOperation()
          Gets the first, direct operation issued against the DirectoryService.
 OperationContext getLastOperation()
          Gets the last, operation issued on the DirectoryService.
abstract  java.lang.String getName()
           
 OperationContext getNextOperation()
          Gets the next, indirect operation issued on the DirectoryService.
 OperationContext getPreviousOperation()
          Gets the previous, operation issued on the DirectoryService.
 javax.naming.ldap.Control getRequestControl(java.lang.String numericOid)
          Gets a request control if present for this request.
 javax.naming.ldap.Control getResponseControl(java.lang.String numericOid)
          Gets a response control if present for this request.
 int getResponseControlCount()
          Checks the number of response controls have been generated for this operation.
 javax.naming.ldap.Control[] getResponseControls()
          Gets all the response controls producted during this operation.
 CoreSession getSession()
          Gets the session associated with this operation.
 boolean hasBypass()
          Checks to see if any Interceptors are bypassed by this operation.
 boolean hasEntry(org.apache.directory.shared.ldap.name.LdapDN dn, java.util.Collection<java.lang.String> byPassed)
          Checks to see if an entry exists.
 boolean hasRequestControl(java.lang.String numericOid)
          Checks to see if a request control is present on this request.
 boolean hasRequestControls()
          Checks if any request controls exists for this operation.
 boolean hasResponseControl(java.lang.String numericOid)
          Checks to see if a response control is present on this operation.
 boolean hasResponseControls()
          Checks if any response controls have been generated for this operation.
 boolean isBypassed(java.lang.String interceptorName)
          Checks to see if an Interceptor is bypassed for this operation.
 boolean isFirstOperation()
          Checks to see if this operation is the first operation in a chain of operations performed on the DirectoryService.
 ClonedServerEntry lookup(org.apache.directory.shared.ldap.name.LdapDN dn, java.util.Collection<java.lang.String> byPassed)
           
 ClonedServerEntry lookup(LookupOperationContext opContext)
           
 void modify(org.apache.directory.shared.ldap.name.LdapDN dn, java.util.List<org.apache.directory.shared.ldap.entry.Modification> mods, java.util.Collection<java.lang.String> byPassed)
           
 LookupOperationContext newLookupContext(org.apache.directory.shared.ldap.name.LdapDN dn)
           
protected  void setAuthorizedPrincipal(LdapPrincipal authorizedPrincipal)
           
 void setByPassed(java.util.Collection<java.lang.String> byPassed)
          Sets the set of bypassed Interceptors.
 void setDn(org.apache.directory.shared.ldap.name.LdapDN dn)
          Set the context DN
 void setEntry(ClonedServerEntry entry)
          Sets the server entry associated with the target DN of this OperationContext.
protected  void setNextOperation(OperationContext next)
           
protected  void setPreviousOperation(OperationContext previous)
           
 void setRequestControls(java.util.Map<java.lang.String,javax.naming.ldap.Control> requestControls)
           
protected  void setSession(CoreSession session)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_CONTROLS

protected static final javax.naming.ldap.Control[] EMPTY_CONTROLS

dn

protected org.apache.directory.shared.ldap.name.LdapDN dn
The DN associated with the context


entry

protected ClonedServerEntry entry
The entry associated with the target entry of this OperationContext


requestControls

protected java.util.Map<java.lang.String,javax.naming.ldap.Control> requestControls
The associated request's controls


responseControls

protected java.util.Map<java.lang.String,javax.naming.ldap.Control> responseControls
The associated response's controls


byPassed

protected java.util.Collection<java.lang.String> byPassed
the Interceptors bypassed by this operation


authorizedPrincipal

protected LdapPrincipal authorizedPrincipal

session

protected CoreSession session

next

protected OperationContext next

previous

protected OperationContext previous
Constructor Detail

AbstractOperationContext

public AbstractOperationContext(CoreSession session)
Creates a new instance of AbstractOperationContext.


AbstractOperationContext

public AbstractOperationContext(CoreSession session,
                                org.apache.directory.shared.ldap.name.LdapDN dn)
Creates a new instance of AbstractOperationContext.

Parameters:
dn - The associated DN
Method Detail

getSession

public CoreSession getSession()
Description copied from interface: OperationContext
Gets the session associated with this operation.

Specified by:
getSession in interface OperationContext
Returns:
the session associated with this operation

setSession

protected void setSession(CoreSession session)

setAuthorizedPrincipal

protected void setAuthorizedPrincipal(LdapPrincipal authorizedPrincipal)

getDn

public org.apache.directory.shared.ldap.name.LdapDN getDn()
Specified by:
getDn in interface OperationContext
Returns:
The associated DN

setDn

public void setDn(org.apache.directory.shared.ldap.name.LdapDN dn)
Set the context DN

Specified by:
setDn in interface OperationContext
Parameters:
dn - The DN to set

addRequestControl

public void addRequestControl(javax.naming.ldap.Control requestControl)
Description copied from interface: OperationContext
Adds a request control to this operation.

Specified by:
addRequestControl in interface OperationContext
Parameters:
requestControl - the request control to add to this operation

getRequestControl

public javax.naming.ldap.Control getRequestControl(java.lang.String numericOid)
Description copied from interface: OperationContext
Gets a request control if present for this request.

Specified by:
getRequestControl in interface OperationContext
Parameters:
numericOid - the numeric OID of the control also known as it's type OID
Returns:
the control if present

hasRequestControl

public boolean hasRequestControl(java.lang.String numericOid)
Description copied from interface: OperationContext
Checks to see if a request control is present on this request.

Specified by:
hasRequestControl in interface OperationContext
Parameters:
numericOid - the numeric OID of the control also known as it's type OID
Returns:
true if the control is associated with this operation, false otherwise

hasRequestControls

public boolean hasRequestControls()
Description copied from interface: OperationContext
Checks if any request controls exists for this operation.

Specified by:
hasRequestControls in interface OperationContext
Returns:
true if any request controls exist, false otherwise

addResponseControl

public void addResponseControl(javax.naming.ldap.Control responseControl)
Description copied from interface: OperationContext
Adds a response control to this operation.

Specified by:
addResponseControl in interface OperationContext
Parameters:
responseControl - the response control to add to this operation

getResponseControl

public javax.naming.ldap.Control getResponseControl(java.lang.String numericOid)
Description copied from interface: OperationContext
Gets a response control if present for this request.

Specified by:
getResponseControl in interface OperationContext
Parameters:
numericOid - the numeric OID of the control also known as it's type OID
Returns:
the control if present

hasResponseControl

public boolean hasResponseControl(java.lang.String numericOid)
Description copied from interface: OperationContext
Checks to see if a response control is present on this operation.

Specified by:
hasResponseControl in interface OperationContext
Parameters:
numericOid - the numeric OID of the control also known as it's type OID
Returns:
true if the control is associated with this operation, false otherwise

getResponseControls

public javax.naming.ldap.Control[] getResponseControls()
Description copied from interface: OperationContext
Gets all the response controls producted during this operation.

Specified by:
getResponseControls in interface OperationContext
Returns:
an array over all the response controls

hasResponseControls

public boolean hasResponseControls()
Description copied from interface: OperationContext
Checks if any response controls have been generated for this operation.

Specified by:
hasResponseControls in interface OperationContext
Returns:
true if any response controls have been generated, false otherwise

getResponseControlCount

public int getResponseControlCount()
Description copied from interface: OperationContext
Checks the number of response controls have been generated for this operation.

Specified by:
getResponseControlCount in interface OperationContext
Returns:
the number of response controls that have been generated

addRequestControls

public void addRequestControls(javax.naming.ldap.Control[] requestControls)
Description copied from interface: OperationContext
Adds many request controls to this operation.

Specified by:
addRequestControls in interface OperationContext
Parameters:
requestControls - the request controls to add to this operation

setRequestControls

public void setRequestControls(java.util.Map<java.lang.String,javax.naming.ldap.Control> requestControls)

getName

public abstract java.lang.String getName()
Specified by:
getName in interface OperationContext
Returns:
the operation name

getByPassed

public java.util.Collection<java.lang.String> getByPassed()
Gets the set of bypassed Interceptors.

Specified by:
getByPassed in interface OperationContext
Returns:
the set of bypassed Interceptors

setByPassed

public void setByPassed(java.util.Collection<java.lang.String> byPassed)
Sets the set of bypassed Interceptors.

Specified by:
setByPassed in interface OperationContext
Parameters:
byPassed - the set of bypassed Interceptors

isBypassed

public boolean isBypassed(java.lang.String interceptorName)
Checks to see if an Interceptor is bypassed for this operation.

Specified by:
isBypassed in interface OperationContext
Parameters:
interceptorName - the interceptorName of the Interceptor to check for bypass
Returns:
true if the Interceptor should be bypassed, false otherwise

hasBypass

public boolean hasBypass()
Checks to see if any Interceptors are bypassed by this operation.

Specified by:
hasBypass in interface OperationContext
Returns:
true if at least one bypass exists

hasEntry

public boolean hasEntry(org.apache.directory.shared.ldap.name.LdapDN dn,
                        java.util.Collection<java.lang.String> byPassed)
                 throws java.lang.Exception
Description copied from interface: OperationContext
Checks to see if an entry exists.

Specified by:
hasEntry in interface OperationContext
Parameters:
dn - the distinguished name of the entry to check
byPassed - collection of Interceptor's to bypass for this check
Returns:
true if the entry exists, false if it does not
Throws:
java.lang.Exception - on failure to perform this operation

add

public void add(ServerEntry entry,
                java.util.Collection<java.lang.String> byPassed)
         throws java.lang.Exception
Specified by:
add in interface OperationContext
Throws:
java.lang.Exception

delete

public void delete(org.apache.directory.shared.ldap.name.LdapDN dn,
                   java.util.Collection<java.lang.String> byPassed)
            throws java.lang.Exception
Specified by:
delete in interface OperationContext
Throws:
java.lang.Exception

modify

public void modify(org.apache.directory.shared.ldap.name.LdapDN dn,
                   java.util.List<org.apache.directory.shared.ldap.entry.Modification> mods,
                   java.util.Collection<java.lang.String> byPassed)
            throws java.lang.Exception
Specified by:
modify in interface OperationContext
Throws:
java.lang.Exception

newLookupContext

public LookupOperationContext newLookupContext(org.apache.directory.shared.ldap.name.LdapDN dn)
Specified by:
newLookupContext in interface OperationContext

lookup

public ClonedServerEntry lookup(LookupOperationContext opContext)
                         throws java.lang.Exception
Specified by:
lookup in interface OperationContext
Throws:
java.lang.Exception

lookup

public ClonedServerEntry lookup(org.apache.directory.shared.ldap.name.LdapDN dn,
                                java.util.Collection<java.lang.String> byPassed)
                         throws java.lang.Exception
Specified by:
lookup in interface OperationContext
Throws:
java.lang.Exception

getEffectivePrincipal

public LdapPrincipal getEffectivePrincipal()
Description copied from interface: OperationContext
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.

Specified by:
getEffectivePrincipal in interface OperationContext
Returns:
the effective principal for this operation
See Also:
CoreSession.getAuthenticatedPrincipal(), CoreSession.getEffectivePrincipal()

isFirstOperation

public boolean isFirstOperation()
Description copied from 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.

Specified by:
isFirstOperation in interface OperationContext
Returns:
true if the operation is the first, false otherwise

getFirstOperation

public OperationContext getFirstOperation()
Description copied from interface: OperationContext
Gets the first, direct operation issued against the DirectoryService.

Specified by:
getFirstOperation in interface OperationContext
Returns:
the first, direct operation issued

getLastOperation

public OperationContext getLastOperation()
Description copied from interface: OperationContext
Gets the last, operation issued on the DirectoryService.

Specified by:
getLastOperation in interface OperationContext
Returns:
the last, operation issued

getNextOperation

public OperationContext getNextOperation()
Description copied from interface: OperationContext
Gets the next, indirect operation issued on the DirectoryService.

Specified by:
getNextOperation in interface OperationContext
Returns:
the next, indirect operation issued

setNextOperation

protected void setNextOperation(OperationContext next)

getPreviousOperation

public OperationContext getPreviousOperation()
Description copied from interface: OperationContext
Gets the previous, operation issued on the DirectoryService.

Specified by:
getPreviousOperation in interface OperationContext
Returns:
the previous, operation issued

setPreviousOperation

protected void setPreviousOperation(OperationContext previous)

setEntry

public void setEntry(ClonedServerEntry entry)
Description copied from interface: OperationContext
Sets the server entry associated with the target DN of this OperationContext.

Specified by:
setEntry in interface OperationContext
Parameters:
entry - the entry to set

getEntry

public ClonedServerEntry getEntry()
Description copied from interface: OperationContext
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 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.

Specified by:
getEntry in interface OperationContext
Returns:
the entry


Copyright © 2003-2009 Apache Software Foundation. All Rights Reserved.