| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011 ForgeRock AS |
| | | * Portions Copyright 2011-2013 ForgeRock AS |
| | | */ |
| | | package org.opends.server.types; |
| | | import org.opends.messages.Message; |
| | | import org.opends.messages.MessageBuilder; |
| | | |
| | | |
| | | import static org.opends.server.core.CoreConstants.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.*; |
| | | |
| | | import java.util.*; |
| | | |
| | | import org.opends.messages.Message; |
| | | import org.opends.messages.MessageBuilder; |
| | | import org.opends.server.api.ClientConnection; |
| | | import org.opends.server.controls.ControlDecoder; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | import org.opends.server.types.operation.PostResponseOperation; |
| | | import org.opends.server.types.operation.PreParseOperation; |
| | | import org.opends.server.util.Validator; |
| | | import org.opends.server.core.DirectoryServer; |
| | | |
| | | import static org.opends.server.loggers.debug. |
| | | DebugLogger.debugEnabled; |
| | | import static org.opends.server.loggers.debug.DebugLogger.getTracer; |
| | | import org.opends.server.loggers.debug.DebugTracer; |
| | | import org.opends.server.controls.ControlDecoder; |
| | | import org.opends.server.protocols.ldap.LDAPControl; |
| | | |
| | | |
| | | /** |
| | |
| | | mayExtend=false, |
| | | mayInvoke=true) |
| | | public abstract class AbstractOperation |
| | | implements Operation, PreParseOperation, PostResponseOperation, |
| | | Runnable |
| | | implements Operation, PreParseOperation, PostResponseOperation |
| | | { |
| | | /** |
| | | * The tracer object for the debug logger. |
| | |
| | | * |
| | | * @return The operation type for this operation. |
| | | */ |
| | | @Override |
| | | public abstract OperationType getOperationType(); |
| | | |
| | | |
| | |
| | | * may be {@code null} if no notification |
| | | * is to be sent. |
| | | */ |
| | | @Override |
| | | public void disconnectClient(DisconnectReason disconnectReason, |
| | | boolean sendNotification, |
| | | Message message) |
| | |
| | | * @return A standard set of elements that should be logged in |
| | | * requests and responses for all types of operations. |
| | | */ |
| | | @Override |
| | | public final String[][] getCommonLogElements() |
| | | { |
| | | // Note that no debugging will be done in this method because |
| | |
| | | * @return A standard set of elements that should be logged in |
| | | * requests for this type of operation. |
| | | */ |
| | | @Override |
| | | public abstract String[][] getRequestLogElements(); |
| | | |
| | | |
| | |
| | | * @return A standard set of elements that should be logged in |
| | | * responses for this type of operation. |
| | | */ |
| | | @Override |
| | | public abstract String[][] getResponseLogElements(); |
| | | |
| | | |
| | |
| | | * @return The client connection with which this operation is |
| | | * associated. |
| | | */ |
| | | @Override |
| | | public final ClientConnection getClientConnection() |
| | | { |
| | | return clientConnection; |
| | |
| | | * @return The unique identifier that is assigned to the client |
| | | * connection that submitted this operation. |
| | | */ |
| | | @Override |
| | | public final long getConnectionID() |
| | | { |
| | | return clientConnection.getConnectionID(); |
| | |
| | | * |
| | | * @return The operation ID for this operation. |
| | | */ |
| | | @Override |
| | | public final long getOperationID() |
| | | { |
| | | return operationID; |
| | |
| | | * |
| | | * @return The message ID assigned to this operation. |
| | | */ |
| | | @Override |
| | | public final int getMessageID() |
| | | { |
| | | return messageID; |
| | |
| | | * @return The set of controls included in the request from the |
| | | * client. |
| | | */ |
| | | @Override |
| | | public final List<Control> getRequestControls() |
| | | { |
| | | return requestControls; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | @SuppressWarnings("unchecked") |
| | | public final <T extends Control> T getRequestControl( |
| | | ControlDecoder<T> d) throws DirectoryException |
| | |
| | | * @param control The control to add to the set of request |
| | | * controls for this operation. |
| | | */ |
| | | @Override |
| | | public final void addRequestControl(Control control) |
| | | { |
| | | requestControls.add(control); |
| | |
| | | * @param control The control to remove from the set of request |
| | | * controls for this operation. |
| | | */ |
| | | @Override |
| | | public final void removeRequestControl(Control control) |
| | | { |
| | | requestControls.remove(control); |
| | |
| | | * @return The set of controls to include in the response to the |
| | | * client. |
| | | */ |
| | | @Override |
| | | public abstract List<Control> getResponseControls(); |
| | | |
| | | |
| | |
| | | * @param control The control to add to the set of controls to |
| | | * include in the response to the client. |
| | | */ |
| | | @Override |
| | | public abstract void addResponseControl(Control control); |
| | | |
| | | |
| | |
| | | * @param control The control to remove from the set of controls |
| | | * to include in the response to the client. |
| | | */ |
| | | @Override |
| | | public abstract void removeResponseControl(Control control); |
| | | |
| | | |
| | |
| | | * {@code UNDEFINED} if the operation has not yet |
| | | * completed. |
| | | */ |
| | | @Override |
| | | public final ResultCode getResultCode() |
| | | { |
| | | return resultCode; |
| | |
| | | * |
| | | * @param resultCode The result code for this operation. |
| | | */ |
| | | @Override |
| | | public final void setResultCode(ResultCode resultCode) |
| | | { |
| | | this.resultCode = resultCode; |
| | |
| | | * |
| | | * @return The error message for this operation. |
| | | */ |
| | | @Override |
| | | public final MessageBuilder getErrorMessage() |
| | | { |
| | | return errorMessage; |
| | |
| | | * |
| | | * @param errorMessage The error message for this operation. |
| | | */ |
| | | @Override |
| | | public final void setErrorMessage(MessageBuilder errorMessage) |
| | | { |
| | | if (errorMessage == null) |
| | |
| | | * @param message The message to append to the error message |
| | | * buffer. |
| | | */ |
| | | @Override |
| | | public final void appendErrorMessage(Message message) |
| | | { |
| | | if (errorMessage == null) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public List<AdditionalLogItem> getAdditionalLogItems() |
| | | { |
| | | if (additionalLogItems == null) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public void addAdditionalLogItem(AdditionalLogItem item) |
| | | { |
| | | Validator.ensureNotNull(item); |
| | |
| | | * @return The matched DN for this operation, or {@code null} if the operation |
| | | * has not yet completed or does not have a matched DN. |
| | | */ |
| | | @Override |
| | | public final DN getMatchedDN() |
| | | { |
| | | return matchedDN; |
| | |
| | | * |
| | | * @param matchedDN The matched DN for this operation. |
| | | */ |
| | | @Override |
| | | public final void setMatchedDN(DN matchedDN) |
| | | { |
| | | this.matchedDN = matchedDN; |
| | |
| | | * {@code null} if the operation is not yet complete or |
| | | * does not have a set of referral URLs. |
| | | */ |
| | | @Override |
| | | public final List<String> getReferralURLs() |
| | | { |
| | | return referralURLs; |
| | |
| | | * @param referralURLs The set of referral URLs for this |
| | | * operation. |
| | | */ |
| | | @Override |
| | | public final void setReferralURLs(List<String> referralURLs) |
| | | { |
| | | this.referralURLs = referralURLs; |
| | |
| | | * information to use for the response |
| | | * elements. |
| | | */ |
| | | @Override |
| | | public final void setResponseData( |
| | | DirectoryException directoryException) |
| | | { |
| | |
| | | * @return {@code true} if this is an internal operation, or |
| | | * {@code false} if it is not. |
| | | */ |
| | | @Override |
| | | public final boolean isInternalOperation() |
| | | { |
| | | return isInternalOperation; |
| | |
| | | * that was requested by an external |
| | | * client. |
| | | */ |
| | | @Override |
| | | public final void setInternalOperation(boolean isInternalOperation) |
| | | { |
| | | this.isInternalOperation = isInternalOperation; |
| | |
| | | * @return {@code true} if this is a data synchronization |
| | | * operation, or {@code false} if it is not. |
| | | */ |
| | | @Override |
| | | public final boolean isSynchronizationOperation() |
| | | { |
| | | return isSynchronizationOperation; |
| | |
| | | * requested by an external |
| | | * client. |
| | | */ |
| | | @Override |
| | | public final void setSynchronizationOperation( |
| | | boolean isSynchronizationOperation) |
| | | { |
| | |
| | | * synchronized, or {@code false} if it should be |
| | | * synchronized. |
| | | */ |
| | | @Override |
| | | public boolean dontSynchronize() |
| | | { |
| | | return dontSynchronizeFlag; |
| | |
| | | * synchronized to other copies |
| | | * of the data. |
| | | */ |
| | | @Override |
| | | public final void setDontSynchronize(boolean dontSynchronize) |
| | | { |
| | | this.dontSynchronizeFlag = dontSynchronize; |
| | |
| | | * {@code null} if the authorization identity should be the |
| | | * unauthenticated user. |
| | | */ |
| | | @Override |
| | | public final Entry getAuthorizationEntry() |
| | | { |
| | | return authorizationEntry; |
| | |
| | | * if it should be the unauthenticated |
| | | * user. |
| | | */ |
| | | @Override |
| | | public final void setAuthorizationEntry(Entry authorizationEntry) |
| | | { |
| | | this.authorizationEntry = authorizationEntry; |
| | |
| | | * @return The authorization DN for this operation, or the null DN |
| | | * if it should be the unauthenticated user.. |
| | | */ |
| | | @Override |
| | | public final DN getAuthorizationDN() |
| | | { |
| | | if (authorizationEntry == null) |
| | |
| | | * |
| | | * @return The set of attachments defined for this operation. |
| | | */ |
| | | @Override |
| | | public final Map<String,Object> getAttachments() |
| | | { |
| | | return attachments; |
| | |
| | | * @param attachments - Attachments to register within the |
| | | * operation |
| | | */ |
| | | @Override |
| | | public final void setAttachments(Map<String, Object> attachments) |
| | | { |
| | | this.attachments = attachments; |
| | |
| | | * @return The requested attachment object, or {@code null} if it |
| | | * does not exist. |
| | | */ |
| | | @Override |
| | | public final Object getAttachment(String name) |
| | | { |
| | | return attachments.get(name); |
| | |
| | | * @return The attachment that was removed, or {@code null} if it |
| | | * does not exist. |
| | | */ |
| | | @Override |
| | | public final Object removeAttachment(String name) |
| | | { |
| | | return attachments.remove(name); |
| | |
| | | * name, or {@code null} if there was previously no such |
| | | * attachment. |
| | | */ |
| | | @Override |
| | | public final Object setAttachment(String name, Object value) |
| | | { |
| | | return attachments.put(name, value); |
| | |
| | | * successfully and that the client should perform any associated |
| | | * cleanup work. |
| | | */ |
| | | @Override |
| | | public final void operationCompleted() |
| | | { |
| | | // Notify the client connection that this operation is complete |
| | |
| | | * @return A code providing information on the result of the |
| | | * cancellation. |
| | | */ |
| | | @Override |
| | | public CancelResult cancel(CancelRequest cancelRequest) |
| | | { |
| | | abort(cancelRequest); |
| | |
| | | * @param cancelRequest Information about the way in which the |
| | | * operation should be canceled. |
| | | */ |
| | | @Override |
| | | public synchronized void abort(CancelRequest cancelRequest) |
| | | { |
| | | if(cancelResult == null && this.cancelRequest == null) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public synchronized final void |
| | | checkIfCanceled(boolean signalTooLate) |
| | | throws CanceledOperationException { |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final CancelRequest getCancelRequest() |
| | | { |
| | | return cancelRequest; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final CancelResult getCancelResult() |
| | | { |
| | | return cancelResult; |
| | |
| | | * |
| | | * @return A string representation of this operation. |
| | | */ |
| | | @Override |
| | | public final String toString() |
| | | { |
| | | StringBuilder buffer = new StringBuilder(); |
| | |
| | | * @param buffer The buffer into which a string representation of |
| | | * this operation should be appended. |
| | | */ |
| | | @Override |
| | | public abstract void toString(StringBuilder buffer); |
| | | |
| | | |
| | |
| | | * |
| | | * @return The time that processing started for this operation. |
| | | */ |
| | | @Override |
| | | public final long getProcessingStartTime() |
| | | { |
| | | return processingStartTime; |
| | |
| | | * |
| | | * @return The time that processing stopped for this operation. |
| | | */ |
| | | @Override |
| | | public final long getProcessingStopTime() |
| | | { |
| | | return processingStopTime; |
| | |
| | | * @return The length of time in milliseconds that |
| | | * the server spent processing this operation. |
| | | */ |
| | | @Override |
| | | public final long getProcessingTime() |
| | | { |
| | | return (processingStopTime - processingStartTime); |
| | |
| | | * spent processing this operation or -1 if its not |
| | | * available. |
| | | */ |
| | | @Override |
| | | public final long getProcessingNanoTime() |
| | | { |
| | | if(useNanoTime) |
| | |
| | | * and any other work that might need to be done in the course of |
| | | * processing. |
| | | */ |
| | | @Override |
| | | public abstract void run(); |
| | | |
| | | |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final void registerPostResponseCallback(Runnable callback) |
| | | { |
| | | if (postResponseCallbacks == null) |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final int hashCode() |
| | | { |
| | | return clientConnection.hashCode() * (int) operationID; |
| | |
| | | /** |
| | | * {@inheritDoc} |
| | | */ |
| | | @Override |
| | | public final boolean equals(Object obj) |
| | | { |
| | | if (this == obj) |