org.opends.server.core
Class AddOperationBasis

java.lang.Object
  extended by org.opends.server.types.AbstractOperation
      extended by org.opends.server.core.AddOperationBasis
All Implemented Interfaces:
java.lang.Runnable, AddOperation, Operation, PluginOperation, PostResponseAddOperation, PostResponseOperation, PreParseAddOperation, PreParseOperation

public class AddOperationBasis
extends AbstractOperation
implements PreParseAddOperation, AddOperation, java.lang.Runnable, PostResponseAddOperation

This class defines an operation that may be used to add a new entry to the Directory Server.


Field Summary
 
Fields inherited from class org.opends.server.types.AbstractOperation
clientConnection, messageID, NO_RESPONSE_CONTROLS, operationID, useNanoTime
 
Fields inherited from interface org.opends.server.types.Operation
LOCALBACKENDOPERATIONS
 
Constructor Summary
AddOperationBasis(ClientConnection clientConnection, long operationID, int messageID, java.util.List<Control> requestControls, ByteString rawEntryDN, java.util.List<RawAttribute> rawAttributes)
          Creates a new add operation with the provided information.
AddOperationBasis(ClientConnection clientConnection, long operationID, int messageID, java.util.List<Control> requestControls, DN entryDN, java.util.Map<ObjectClass,java.lang.String> objectClasses, java.util.Map<AttributeType,java.util.List<Attribute>> userAttributes, java.util.Map<AttributeType,java.util.List<Attribute>> operationalAttributes)
          Creates a new add operation with the provided information.
 
Method Summary
 void addObjectClass(ObjectClass objectClass, java.lang.String name)
          Adds the provided objectclass to the entry to add.
 void addRawAttribute(RawAttribute rawAttribute)
          Adds the provided attribute to the set of raw attributes for this add operation.
 void addResponseControl(Control control)
          Adds the provided control to the set of controls to include in the response to the client.
 CancelResult cancel(CancelRequest cancelRequest)
          Attempts to cancel this operation before processing has completed.
 void disconnectClient(DisconnectReason disconnectReason, boolean sendNotification, Message message)
          Terminates the client connection being used to process this operation.
 CancelRequest getCancelRequest()
          Retrieves the cancel request that has been issued for this operation, if there is one.
 long getChangeNumber()
          Retrieves the change number that has been assigned to this operation.
 DN getEntryDN()
          Retrieves the DN of the entry to add.
 Entry getEntryToAdd()
          Retrieves the entry to be added to the server. This method always returns null.
 java.util.Map<ObjectClass,java.lang.String> getObjectClasses()
          Retrieves the set of processed objectclasses for the entry to add.
 java.util.Map<AttributeType,java.util.List<Attribute>> getOperationalAttributes()
          Retrieves the set of processed operational attributes for the entry to add.
 OperationType getOperationType()
          Retrieves the operation type for this operation.
 DN getProxiedAuthorizationDN()
          Retrieves the proxied authorization DN for this operation if proxied authorization has been requested.
 java.util.List<RawAttribute> getRawAttributes()
          Retrieves the set of attributes in their raw, unparsed form as read from the client request.
 ByteString getRawEntryDN()
          Retrieves the DN of the entry to add in a raw, unparsed form as it was included in the request.
 java.lang.String[][] getRequestLogElements()
          Retrieves a standard set of elements that should be logged in requests for this type of operation.
 java.util.ArrayList<Control> getResponseControls()
          Retrieves the set of controls to include in the response to the client.
 java.lang.String[][] getResponseLogElements()
          Retrieves a standard set of elements that should be logged in responses for this type of operation.
 java.util.Map<AttributeType,java.util.List<Attribute>> getUserAttributes()
          Retrieves the set of processed user attributes for the entry to add.
 void removeAttribute(AttributeType attributeType)
          Removes the specified attribute from the entry to add.
 void removeObjectClass(ObjectClass objectClass)
          Removes the provided objectclass from the entry to add.
 void removeResponseControl(Control control)
          Removes the provided control from the set of controls to include in the response to the client.
 void run()
          Performs the work of actually processing this operation.
 void setAttribute(AttributeType attributeType, java.util.List<Attribute> attributeList)
          Sets the specified attribute in the entry to add, overwriting any existing attribute of the specified type if necessary.
 boolean setCancelRequest(CancelRequest cancelRequest)
          Sets the cancel request for this operation, if applicable.
 void setChangeNumber(long changeNumber)
          Specifies the change number that has been assigned to this operation by the synchronization mechanism.
 void setProxiedAuthorizationDN(DN proxiedAuthorizationDN)
          Set the proxied authorization DN for this operation if proxied authorization has been requested.
 void setRawAttributes(java.util.List<RawAttribute> rawAttributes)
          Replaces the set of raw attributes for this add operation.
 void setRawEntryDN(ByteString rawEntryDN)
          Specifies the raw entry DN for the entry to add.
 void toString(java.lang.StringBuilder buffer)
          Appends a string representation of this operation to the provided buffer.
 
Methods inherited from class org.opends.server.types.AbstractOperation
addRequestControl, appendAdditionalLogMessage, appendErrorMessage, dontSynchronize, getAdditionalLogMessage, getAttachment, getAttachments, getAuthorizationDN, getAuthorizationEntry, getCancelResult, getClientConnection, getCommonLogElements, getConnectionID, getErrorMessage, getMatchedDN, getMessageID, getOperationID, getProcessingNanoTime, getProcessingStartTime, getProcessingStopTime, getProcessingTime, getReferralURLs, getRequestControls, getResultCode, indicateCancelled, isInternalOperation, isSynchronizationOperation, operationCompleted, removeAttachment, removeRequestControl, setAdditionalLogMessage, setAttachment, setAttachments, setAuthorizationEntry, setCancelResult, setDontSynchronize, setErrorMessage, setInternalOperation, setMatchedDN, setProcessingStartTime, setProcessingStopTime, setReferralURLs, setResponseData, setResultCode, setSynchronizationOperation, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opends.server.types.operation.PreParseOperation
addRequestControl, appendAdditionalLogMessage, appendErrorMessage, getAdditionalLogMessage, getErrorMessage, getMatchedDN, getReferralURLs, getResultCode, removeRequestControl, setAdditionalLogMessage, setErrorMessage, setMatchedDN, setReferralURLs, setResponseData, setResultCode
 
Methods inherited from interface org.opends.server.types.operation.PluginOperation
getAttachment, getAttachments, getClientConnection, getConnectionID, getMessageID, getOperationID, getProcessingStartTime, getRequestControls, isInternalOperation, isSynchronizationOperation, removeAttachment, setAttachment, toString
 
Methods inherited from interface org.opends.server.types.Operation
addRequestControl, appendAdditionalLogMessage, appendErrorMessage, dontSynchronize, getAdditionalLogMessage, getAttachment, getAttachments, getAuthorizationDN, getAuthorizationEntry, getCancelResult, getClientConnection, getCommonLogElements, getConnectionID, getErrorMessage, getMatchedDN, getMessageID, getOperationID, getProcessingNanoTime, getProcessingStartTime, getProcessingStopTime, getProcessingTime, getReferralURLs, getRequestControls, getResultCode, indicateCancelled, isInternalOperation, isSynchronizationOperation, operationCompleted, removeAttachment, removeRequestControl, setAdditionalLogMessage, setAttachment, setAttachments, setAuthorizationEntry, setCancelResult, setDontSynchronize, setErrorMessage, setInternalOperation, setMatchedDN, setProcessingStartTime, setProcessingStopTime, setReferralURLs, setResponseData, setResultCode, setSynchronizationOperation, toString
 
Methods inherited from interface org.opends.server.types.operation.PostResponseOperation
getAdditionalLogMessage, getAuthorizationDN, getErrorMessage, getMatchedDN, getProcessingStopTime, getProcessingTime, getReferralURLs, getResultCode
 
Methods inherited from interface org.opends.server.types.operation.PluginOperation
getAttachment, getAttachments, getClientConnection, getConnectionID, getMessageID, getOperationID, getProcessingStartTime, getRequestControls, isInternalOperation, isSynchronizationOperation, removeAttachment, setAttachment, toString
 

Constructor Detail

AddOperationBasis

public AddOperationBasis(ClientConnection clientConnection,
                         long operationID,
                         int messageID,
                         java.util.List<Control> requestControls,
                         ByteString rawEntryDN,
                         java.util.List<RawAttribute> rawAttributes)
Creates a new add operation with the provided information.

Parameters:
clientConnection - The client connection with which this operation is associated.
operationID - The operation ID for this operation.
messageID - The message ID of the request with which this operation is associated.
requestControls - The set of controls included in the request.
rawEntryDN - The raw DN of the entry to add from the client request. This may or may not be a valid DN.
rawAttributes - The raw set of attributes from the client request (including the objectclass attribute). This may contain invalid attributes.

AddOperationBasis

public AddOperationBasis(ClientConnection clientConnection,
                         long operationID,
                         int messageID,
                         java.util.List<Control> requestControls,
                         DN entryDN,
                         java.util.Map<ObjectClass,java.lang.String> objectClasses,
                         java.util.Map<AttributeType,java.util.List<Attribute>> userAttributes,
                         java.util.Map<AttributeType,java.util.List<Attribute>> operationalAttributes)
Creates a new add operation with the provided information.

Parameters:
clientConnection - The client connection with which this operation is associated.
operationID - The operation ID for this operation.
messageID - The message ID of the request with which this operation is associated.
requestControls - The set of controls included in the request.
entryDN - The DN for the entry.
objectClasses - The set of objectclasses for the entry.
userAttributes - The set of user attributes for the entry.
operationalAttributes - The set of operational attributes for the entry.
Method Detail

getRawEntryDN

public final ByteString getRawEntryDN()
Retrieves the DN of the entry to add in a raw, unparsed form as it was included in the request. This may or may not actually contain a valid DN, since no validation will have been performed on it.

Specified by:
getRawEntryDN in interface AddOperation
Specified by:
getRawEntryDN in interface PostResponseAddOperation
Specified by:
getRawEntryDN in interface PreParseAddOperation
Returns:
The DN of the entry in a raw, unparsed form.

setRawEntryDN

public final void setRawEntryDN(ByteString rawEntryDN)
Specifies the raw entry DN for the entry to add. This should only be called by pre-parse plugins to alter the DN before it has been processed. If the entry DN needs to be altered later in the process, then it should be done using the getEntryDN and setEntryDN methods.

Specified by:
setRawEntryDN in interface AddOperation
Specified by:
setRawEntryDN in interface PreParseAddOperation
Parameters:
rawEntryDN - The raw entry DN for the entry to add.

getEntryDN

public final DN getEntryDN()
Retrieves the DN of the entry to add. This method should not be called by pre-parse plugins because the parsed DN will not be available at that time.

Specified by:
getEntryDN in interface AddOperation
Specified by:
getEntryDN in interface PostResponseAddOperation
Returns:
The DN of the entry to add, or null if it has not yet been parsed from the raw DN.

getRawAttributes

public final java.util.List<RawAttribute> getRawAttributes()
Retrieves the set of attributes in their raw, unparsed form as read from the client request. Some of these attributes may be invalid as no validation will have been performed on them. The returned list must not be altered by the caller.

Specified by:
getRawAttributes in interface AddOperation
Specified by:
getRawAttributes in interface PostResponseAddOperation
Specified by:
getRawAttributes in interface PreParseAddOperation
Returns:
The set of attributes in their raw, unparsed form as read from the client request.

addRawAttribute

public final void addRawAttribute(RawAttribute rawAttribute)
Adds the provided attribute to the set of raw attributes for this add operation. This should only be called by pre-parse plugins.

Specified by:
addRawAttribute in interface AddOperation
Specified by:
addRawAttribute in interface PreParseAddOperation
Parameters:
rawAttribute - The attribute to add to the set of raw attributes for this add operation.

setRawAttributes

public final void setRawAttributes(java.util.List<RawAttribute> rawAttributes)
Replaces the set of raw attributes for this add operation. This should only be called by pre-parse plugins.

Specified by:
setRawAttributes in interface AddOperation
Specified by:
setRawAttributes in interface PreParseAddOperation
Parameters:
rawAttributes - The set of raw attributes for this add operation.

getObjectClasses

public final java.util.Map<ObjectClass,java.lang.String> getObjectClasses()
Retrieves the set of processed objectclasses for the entry to add. This should not be called by pre-parse plugins because this information will not yet be available. The contents of the returned map may not be altered by the caller.

Specified by:
getObjectClasses in interface AddOperation
Specified by:
getObjectClasses in interface PostResponseAddOperation
Returns:
The set of processed objectclasses for the entry to add, or null if that information is not yet available.

addObjectClass

public final void addObjectClass(ObjectClass objectClass,
                                 java.lang.String name)
Adds the provided objectclass to the entry to add. This should only be called from pre-operation plugins. Note that pre-operation plugin processing is invoked after access control and schema validation, so plugins should be careful to only make changes that will not violate either schema or access control rules.

Specified by:
addObjectClass in interface AddOperation
Parameters:
objectClass - The objectclass to add to the entry.
name - The name to use for the objectclass.

removeObjectClass

public final void removeObjectClass(ObjectClass objectClass)
Removes the provided objectclass from the entry to add. This should only be called from pre-operation plugins. Note that pre-operation plugin processing is invoked after access control and schema validation, so plugins should be careful to only make changes that will not violate either schema or access control rules.

Specified by:
removeObjectClass in interface AddOperation
Parameters:
objectClass - The objectclass to remove from the entry.

getUserAttributes

public final java.util.Map<AttributeType,java.util.List<Attribute>> getUserAttributes()
Retrieves the set of processed user attributes for the entry to add. This should not be called by pre-parse plugins because this information will not yet be available. The contents of the returned map may be altered by the caller.

Specified by:
getUserAttributes in interface AddOperation
Specified by:
getUserAttributes in interface PostResponseAddOperation
Returns:
The set of processed user attributes for the entry to add, or null if that information is not yet available.

getOperationalAttributes

public final java.util.Map<AttributeType,java.util.List<Attribute>> getOperationalAttributes()
Retrieves the set of processed operational attributes for the entry to add. This should not be called by pre-parse plugins because this information will not yet be available. The contents of the returned map may be altered by the caller.

Specified by:
getOperationalAttributes in interface AddOperation
Specified by:
getOperationalAttributes in interface PostResponseAddOperation
Returns:
The set of processed operational attributes for the entry to add, or null if that information is not yet available.

setAttribute

public final void setAttribute(AttributeType attributeType,
                               java.util.List<Attribute> attributeList)
Sets the specified attribute in the entry to add, overwriting any existing attribute of the specified type if necessary. This should only be called from pre-operation plugins. Note that pre-operation plugin processing is invoked after access control and schema validation, so plugins should be careful to only make changes that will not violate either schema or access control rules.

Specified by:
setAttribute in interface AddOperation
Parameters:
attributeType - The attribute type for the attribute.
attributeList - The attribute list for the provided attribute type.

removeAttribute

public final void removeAttribute(AttributeType attributeType)
Removes the specified attribute from the entry to add. This should only be called from pre-operation plugins. Note that pre-operation processing is invoked after access control and schema validation, so plugins should be careful to only make changes that will not violate either schema or access control rules.

Specified by:
removeAttribute in interface AddOperation
Parameters:
attributeType - The attribute tyep for the attribute to remove.

getChangeNumber

public final long getChangeNumber()
Retrieves the change number that has been assigned to this operation.

Specified by:
getChangeNumber in interface AddOperation
Returns:
The change number that has been assigned to this operation, or -1 if none has been assigned yet or if there is no applicable synchronization mechanism in place that uses change numbers.

setChangeNumber

public final void setChangeNumber(long changeNumber)
Specifies the change number that has been assigned to this operation by the synchronization mechanism.

Specified by:
setChangeNumber in interface AddOperation
Parameters:
changeNumber - The change number that has been assigned to this operation by the synchronization mechanism.

getOperationType

public final OperationType getOperationType()
Retrieves the operation type for this operation.

Specified by:
getOperationType in interface Operation
Specified by:
getOperationType in interface PluginOperation
Specified by:
getOperationType in class AbstractOperation
Returns:
The operation type for this operation.

disconnectClient

public final void disconnectClient(DisconnectReason disconnectReason,
                                   boolean sendNotification,
                                   Message message)
Terminates the client connection being used to process this operation. If this is called by a plugin, then that plugin must return a result indicating that the client connection has been teriminated.

Specified by:
disconnectClient in interface Operation
Specified by:
disconnectClient in interface PluginOperation
Specified by:
disconnectClient in class AbstractOperation
Parameters:
disconnectReason - The disconnect reason that provides the generic cause for the disconnect.
sendNotification - Indicates whether to try to provide notification to the client that the connection will be closed.
message - The message to send to the client. It may be null if no notification is to be sent.

getRequestLogElements

public final java.lang.String[][] getRequestLogElements()
Retrieves a standard set of elements that should be logged in requests for this type of operation. Each element in the array will itself be a two-element array in which the first element is the name of the field and the second is a string representation of the value, or null if there is no value for that field.

Specified by:
getRequestLogElements in interface Operation
Specified by:
getRequestLogElements in class AbstractOperation
Returns:
A standard set of elements that should be logged in requests for this type of operation.

getResponseLogElements

public final java.lang.String[][] getResponseLogElements()
Retrieves a standard set of elements that should be logged in responses for this type of operation. Each element in the array will itself be a two-element array in which the first element is the name of the field and the second is a string representation of the value, or null if there is no value for that field.

Specified by:
getResponseLogElements in interface Operation
Specified by:
getResponseLogElements in class AbstractOperation
Returns:
A standard set of elements that should be logged in responses for this type of operation.

getProxiedAuthorizationDN

public DN getProxiedAuthorizationDN()
Retrieves the proxied authorization DN for this operation if proxied authorization has been requested.

Specified by:
getProxiedAuthorizationDN in interface AddOperation
Returns:
The proxied authorization DN for this operation if proxied authorization has been requested, or null if proxied authorization has not been requested.

getResponseControls

public final java.util.ArrayList<Control> getResponseControls()
Retrieves the set of controls to include in the response to the client. The contents of this list must not be altered.

Specified by:
getResponseControls in interface Operation
Specified by:
getResponseControls in interface PluginOperation
Specified by:
getResponseControls in class AbstractOperation
Returns:
The set of controls to include in the response to the client.

addResponseControl

public final void addResponseControl(Control control)
Adds the provided control to the set of controls to include in the response to the client. This method may not be called by post-response plugins.

Specified by:
addResponseControl in interface Operation
Specified by:
addResponseControl in interface PreParseOperation
Specified by:
addResponseControl in class AbstractOperation
Parameters:
control - The control to add to the set of controls to include in the response to the client.

removeResponseControl

public final void removeResponseControl(Control control)
Removes the provided control from the set of controls to include in the response to the client. This method may not be called by post-response plugins.

Specified by:
removeResponseControl in interface Operation
Specified by:
removeResponseControl in interface PreParseOperation
Specified by:
removeResponseControl in class AbstractOperation
Parameters:
control - The control to remove from the set of controls to include in the response to the client.

cancel

public final CancelResult cancel(CancelRequest cancelRequest)
Attempts to cancel this operation before processing has completed.

Specified by:
cancel in interface Operation
Specified by:
cancel in class AbstractOperation
Parameters:
cancelRequest - Information about the way in which the operation should be canceled.
Returns:
A code providing information on the result of the cancellation.

getCancelRequest

public final CancelRequest getCancelRequest()
Retrieves the cancel request that has been issued for this operation, if there is one. This method should not be called by post-operation or post-response plugins.

Specified by:
getCancelRequest in interface Operation
Specified by:
getCancelRequest in interface PluginOperation
Specified by:
getCancelRequest in class AbstractOperation
Returns:
The cancel request that has been issued for this operation, or null if there has not been any request to cancel.

setCancelRequest

public boolean setCancelRequest(CancelRequest cancelRequest)
Sets the cancel request for this operation, if applicable. This should only be used for testing purposes (e.g., for ensuring a cancel request is submitted before processing begins on an operation, or to allow for cancelling an internal operation). It must not be used for any other purpose.

Specified by:
setCancelRequest in interface Operation
Specified by:
setCancelRequest in class AbstractOperation
Parameters:
cancelRequest - The cancel request to set for this operation.
Returns:
true if the cancel request was set, or false if it was not for some reason (e.g., the specified operation cannot be cancelled).

toString

public final void toString(java.lang.StringBuilder buffer)
Appends a string representation of this operation to the provided buffer.

Specified by:
toString in interface Operation
Specified by:
toString in interface PluginOperation
Specified by:
toString in class AbstractOperation
Parameters:
buffer - The buffer into which a string representation of this operation should be appended.

setProxiedAuthorizationDN

public void setProxiedAuthorizationDN(DN proxiedAuthorizationDN)
Set the proxied authorization DN for this operation if proxied authorization has been requested.

Specified by:
setProxiedAuthorizationDN in interface AddOperation
Parameters:
proxiedAuthorizationDN - The proxied authorization DN for this operation if proxied authorization has been requested, or null if proxied authorization has not been requested.

run

public final void run()
Performs the work of actually processing this operation. This should include all processing for the operation, including invoking pre-parse and post-response plugins, logging messages and any other work that might need to be done in the course of processing.

Specified by:
run in interface java.lang.Runnable
Specified by:
run in class AbstractOperation

getEntryToAdd

public Entry getEntryToAdd()
Retrieves the entry to be added to the server. The contents of the returned entry must not be altered by the caller. This method always returns null.

Specified by:
getEntryToAdd in interface PostResponseAddOperation
Returns:
The entry to be added to the server.