mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jdemendi
19.46.2007 1ad53161c35dfbd2c08b1f124d237f5f3cad9110
This set of changes is aiming at having a more consistent
and clean code when an operation is canceled.

With the refactoring, the processing of an operation is split
into a global processing (in XxxOperationBasis) and a local
processing (in LocalBackendWorkflowElement). Because of
that split, we have some piece of code that are duplicated
at the global level and at the local level. For example, whenever
an operation is canceled we have to call indicateCancelled()
then stop the processing time, then log the response and
then invoke the post response plugins. Moreover, the call
to startProcessingTime is done at the global level while the
stopProcessingTime may be called at the local level, which
is not a good thing.

With the new code:
- do not process canceled operation in local processing
- try to not duplicated the code when an operation is canceled
- try to not duplicated the code when a connection is terminated
- When a terminated connection or a canceled operation is
detected in the local processing we just return to the global
processing and let the global processing handle the case

Now, right after the processing bloc at the global level:

- if a connection is terminated
-- call stopProcessingTime
-- log the response

- elsif the operation has been canceled
-- call indicateCancelled
-- call stopProcessingTime
-- log the response
-- invoke the post response plugins

- else (normal case)
-- call stopProcessingTime
-- send the response
-- log the response
-- notify the persistent searches (for Add, Delete, Modify, ModifyDN)
-- invoke the post response plugins

8 files modified
915 ■■■■■ changed files
opends/src/server/org/opends/server/core/AddOperationBasis.java 159 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/BindOperationBasis.java 76 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/CompareOperationBasis.java 66 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/DeleteOperationBasis.java 152 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/ModifyDNOperationBasis.java 154 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/ModifyOperationBasis.java 151 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/SearchOperationBasis.java 62 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java 95 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/core/AddOperationBasis.java
@@ -796,9 +796,9 @@
    // Check for and handle a request to cancel this operation.
    if (getCancelRequest() != null)
    if (cancelRequest != null)
    {
      indicateCancelled(getCancelRequest());
      indicateCancelled(cancelRequest);
      setProcessingStopTime();
      return;
    }
@@ -808,6 +808,11 @@
    PluginConfigManager pluginConfigManager =
      DirectoryServer.getPluginConfigManager();
    // This flag is set to true as soon as a workflow has been executed.
    boolean workflowExecuted = false;
    // Create a labeled block of code that we can break out of if a problem is
    // detected.
    addProcessing:
@@ -845,14 +850,10 @@
      logAddRequest(this);
      // Check for and handle a request to cancel this operation.
      if (getCancelRequest() != null)
      // Check for a request to cancel this operation.
      if (cancelRequest != null)
      {
        indicateCancelled(getCancelRequest());
        setProcessingStopTime();
        logAddResponse(this);
        pluginConfigManager.invokePostResponseAddPlugins(this);
        return;
        break addProcessing;
      }
@@ -877,18 +878,37 @@
        break addProcessing;
      }
      workflow.execute(this);
      workflowExecuted = true;
    } // end of processing block
    // Check for a terminated connection.
    if (getCancelResult() == CancelResult.CANCELED)
    {
      // Stop the processing timer.
      setProcessingStopTime();
      // Log the add response message.
      logAddResponse(this);
      return;
    }
    // Check for and handle a request to cancel this operation.
    if ((getCancelRequest() != null) ||
        (getCancelResult() == CancelResult.CANCELED))
    if (cancelRequest != null)
    {
      if (getCancelRequest() != null){
        indicateCancelled(getCancelRequest());
      }
      indicateCancelled(cancelRequest);
      // Stop the processing timer.
      setProcessingStopTime();
      // Log the add response message.
      logAddResponse(this);
      invokePostResponsePlugins();
      // Invoke the post-response add plugins.
      invokePostResponsePlugins(workflowExecuted);
      return;
    }
@@ -899,21 +919,86 @@
    setProcessingStopTime();
    // Send the add response to the client.
    getClientConnection().sendResponse(this);
    clientConnection.sendResponse(this);
    // Log the add response.
    // Log the add response message.
    logAddResponse(this);
    // Check wether there are local operations in attachments
    // Notifies any persistent searches that might be registered with the
    // server.
    notifyPersistentSearches(workflowExecuted);
    // Invoke the post-response add plugins.
    invokePostResponsePlugins(workflowExecuted);
  }
  /**
   * Invokes the post response plugins. If a workflow has been executed
   * then invoke the post response plugins provided by the workflow
   * elements of the worklfow, otherwise invoke the post reponse plugins
   * that have been registered with the current operation.
   *
   * @param workflowExecuted <code>true</code> if a workflow has been
   *                         executed
   */
  private void invokePostResponsePlugins(boolean workflowExecuted)
  {
    // Get the plugin config manager that will be used for invoking plugins.
    PluginConfigManager pluginConfigManager =
      DirectoryServer.getPluginConfigManager();
    // Invoke the post response plugins
    if (workflowExecuted)
    {
      // Invoke the post response plugins that have been registered by
      // the workflow elements
    List localOperations =
      (List)getAttachment(Operation.LOCALBACKENDOPERATIONS);
    if (localOperations != null && (! localOperations.isEmpty())){
      if (localOperations != null)
      {
      for (Object localOp : localOperations)
      {
        LocalBackendAddOperation localOperation =
          (LocalBackendAddOperation)localOp;
        // Notify any persistent searches that might be registered with the
        // server.
          pluginConfigManager.invokePostResponseAddPlugins(localOperation);
        }
      }
    }
    else
    {
      // Invoke the post response plugins that have been registered with
      // the current operation
      pluginConfigManager.invokePostResponseAddPlugins(this);
    }
  }
  /**
   * Notifies any persistent searches that might be registered with the server.
   * If no workflow has been executed then don't notify persistent searches.
   *
   * @param workflowExecuted <code>true</code> if a workflow has been
   *                         executed
   */
  private void notifyPersistentSearches(boolean workflowExecuted)
  {
    if (! workflowExecuted)
    {
      return;
    }
    List localOperations =
      (List)getAttachment(Operation.LOCALBACKENDOPERATIONS);
    if (localOperations != null)
    {
      for (Object localOp : localOperations)
      {
        LocalBackendAddOperation localOperation =
          (LocalBackendAddOperation)localOp;
        if ((getResultCode() == ResultCode.SUCCESS) &&
            (localOperation.getEntryToAdd() != null))
        {
@@ -944,12 +1029,10 @@
            }
          }
        }
      }
    }
  }
        // Invoke the post-response add plugins.
        pluginConfigManager.invokePostResponseAddPlugins(localOperation);
      }
    }
  }
  /**
   * Updates the error message and the result code of the operation.
@@ -985,30 +1068,6 @@
    }
  }
  /**
   * Execute the postResponseAddPlugins.
   */
  private void invokePostResponsePlugins()
  {
    // Get the plugin config manager that will be used for invoking plugins.
    PluginConfigManager pluginConfigManager =
      DirectoryServer.getPluginConfigManager();
    // Check wether there are local operations in attachments
    List localOperations =
      (List)getAttachment(Operation.LOCALBACKENDOPERATIONS);
    if (localOperations != null && (! localOperations.isEmpty()))
    {
      for (Object localOp : localOperations)
      {
        LocalBackendAddOperation localOperation =
          (LocalBackendAddOperation)localOp;
        // Invoke the post-response add plugins.
        pluginConfigManager.invokePostResponseAddPlugins(localOperation);
      }
    }
  }
  /**
   * {@inheritDoc}
opends/src/server/org/opends/server/core/BindOperationBasis.java
@@ -807,6 +807,10 @@
      DirectoryServer.getPluginConfigManager();
    // This flag is set to true as soon as a workflow has been executed.
    boolean workflowExecuted = false;
    // Create a labeled block of code that we can break out of if a problem is
    // detected.
    bindProcessing:
@@ -877,15 +881,19 @@
        break bindProcessing;
      }
      workflow.execute(this);
    }
      workflowExecuted = true;
    // Check for and handle a request to cancel this operation.
    } // end of processing block
    // Check for a terminated connection.
    if (getCancelResult() == CancelResult.CANCELED)
    {
      // Stop the processing timer.
      setProcessingStopTime();
      // Log the bind response message.
      logBindResponse(this);
      invokePostResponsePlugins();
      clientConnection.setBindInProgress(false);
      return;
    }
@@ -905,10 +913,35 @@
    // Log the bind response.
    logBindResponse(this);
    // Check wether there are local operations in attachments
    // Invoke the post-response bind plugins.
    invokePostResponsePlugins(workflowExecuted);
  }
  /**
   * Invokes the post response plugins. If a workflow has been executed
   * then invoke the post response plugins provided by the workflow
   * elements of the worklfow, otherwise invoke the post reponse plugins
   * that have been registered with the current operation.
   *
   * @param workflowExecuted <code>true</code> if a workflow has been
   *                         executed
   */
  private void invokePostResponsePlugins(boolean workflowExecuted)
  {
    // Get the plugin config manager that will be used for invoking plugins.
    PluginConfigManager pluginConfigManager =
      DirectoryServer.getPluginConfigManager();
    // Invoke the post response plugins
    if (workflowExecuted)
    {
      // The post responses are provided by the workflow elements of the
      // workflow.
    List localOperations =
      (List)getAttachment(Operation.LOCALBACKENDOPERATIONS);
    if (localOperations != null && (! localOperations.isEmpty())){
      if (localOperations != null)
      {
      for (Object localOp : localOperations)
      {
        LocalBackendBindOperation localOperation =
@@ -917,7 +950,14 @@
        pluginConfigManager.invokePostResponseBindPlugins(localOperation);
      }
    }
      else
      {
        // The current operation does not implement any bind post response
        // interface so we cannot invoke any post-response plugin.
  }
    }
  }
  /**
   * Updates the error message and the result code of the operation.
@@ -934,29 +974,5 @@
    setAuthFailureReason(msgID, message);
  }
  /**
   * Execute the postResponseBindPlugins.
   */
  private void invokePostResponsePlugins()
  {
    // Get the plugin config manager that will be used for invoking plugins.
    PluginConfigManager pluginConfigManager =
      DirectoryServer.getPluginConfigManager();
    // Check wether there are local operations in attachments
    List localOperations =
      (List)getAttachment(Operation.LOCALBACKENDOPERATIONS);
    if (localOperations != null && (! localOperations.isEmpty())){
      for (Object localOp : localOperations)
      {
        LocalBackendBindOperation localOperation =
          (LocalBackendBindOperation)localOp;
        // Invoke the post-response bind plugins.
        pluginConfigManager.invokePostResponseBindPlugins(localOperation);
      }
    }
  }
}
opends/src/server/org/opends/server/core/CompareOperationBasis.java
@@ -473,10 +473,11 @@
    PluginConfigManager pluginConfigManager =
         DirectoryServer.getPluginConfigManager();
    // This flag is set to true as soon as a workflow has been executed.
    boolean workflowExecuted = false;
    // Create a labeled block of code that we can break out of if a problem is
    // detected.
    boolean workflowExecuted = false;
compareProcessing:
    {
      // Invoke the pre-parse compare plugins.
@@ -513,14 +514,10 @@
      logCompareRequest(this);
      // Check for and handle a request to cancel this operation.
      // Check for a request to cancel this operation.
      if (cancelRequest != null)
      {
        indicateCancelled(cancelRequest);
        setProcessingStopTime();
        logCompareResponse(this);
        pluginConfigManager.invokePostResponseComparePlugins(this);
        return;
        break compareProcessing;
      }
@@ -560,15 +557,36 @@
      }
      workflow.execute(this);
      workflowExecuted = true;
    } // end of processing block
    // Check for a terminated connection.
    if (getCancelResult() == CancelResult.CANCELED)
    {
      // Stop the processing timer.
      setProcessingStopTime();
      // Log the add response message.
      logCompareResponse(this);
      return;
    }
    // Check for and handle a request to cancel this operation.
    if (cancelRequest != null)
    {
      indicateCancelled(cancelRequest);
      // Stop the processing timer.
      setProcessingStopTime();
      // Log the compare response message.
      logCompareResponse(this);
      pluginConfigManager.invokePostResponseComparePlugins(this);
      // Invoke the post-response compare plugins.
      invokePostResponsePlugins(workflowExecuted);
      return;
    }
@@ -578,21 +596,41 @@
    // Stop the processing timer.
    setProcessingStopTime();
    // Send the compare response to the client unless the operation result
    // code is CANCELED
    if (getResultCode() != ResultCode.CANCELED)
    {
    // Send the compare response to the client.
      clientConnection.sendResponse(this);
    }
    // Log the compare response message.
    logCompareResponse(this);
    // Invoke the post-response compare plugins.
    invokePostResponsePlugins(workflowExecuted);
  }
  /**
   * Invokes the post response plugins. If a workflow has been executed
   * then invoke the post response plugins provided by the workflow
   * elements of the worklfow, otherwise invoke the post reponse plugins
   * that have been registered with the current operation.
   *
   * @param workflowExecuted <code>true</code> if a workflow has been
   *                         executed
   */
  private void invokePostResponsePlugins(boolean workflowExecuted)
  {
    // Get the plugin config manager that will be used for invoking plugins.
    PluginConfigManager pluginConfigManager =
      DirectoryServer.getPluginConfigManager();
    // Invoke the post response plugins
    if (workflowExecuted)
    {
      // Invoke the post response plugins that have been registered by
      // the workflow elements
      List localOperations =
        (List)getAttachment(Operation.LOCALBACKENDOPERATIONS);
      if (localOperations != null)
      {
        for (Object localOp : localOperations)
@@ -605,6 +643,8 @@
    }
    else
    {
      // Invoke the post response plugins that have been registered with
      // the current operation
      pluginConfigManager.invokePostResponseComparePlugins(this);
    }
  }
opends/src/server/org/opends/server/core/DeleteOperationBasis.java
@@ -469,13 +469,17 @@
    setProcessingStartTime();
    // Check for and handle a request to cancel this operation.
    if (getCancelRequest() != null)
    if (cancelRequest != null)
    {
      indicateCancelled(getCancelRequest());
      indicateCancelled(cancelRequest);
      setProcessingStopTime();
      return;
    }
    // This flag is set to true as soon as a workflow has been executed.
    boolean workflowExecuted = false;
    // Create a labeled block of code that we can break out of if a problem is
    // detected.
deleteProcessing:
@@ -514,14 +518,10 @@
      logDeleteRequest(this);
      // Check for and handle a request to cancel this operation.
      if (getCancelRequest() != null)
      // Check for a request to cancel this operation.
      if (cancelRequest != null)
      {
        indicateCancelled(getCancelRequest());
        setProcessingStopTime();
        logDeleteResponse(this);
        pluginConfigManager.invokePostResponseDeletePlugins(this);
        return;
        break deleteProcessing;
      }
@@ -545,18 +545,37 @@
        break deleteProcessing;
      }
      workflow.execute(this);
      workflowExecuted = true;
    } // end of processing block
    // Check for a terminated connection.
    if (getCancelResult() == CancelResult.CANCELED)
    {
      // Stop the processing timer.
      setProcessingStopTime();
      // Log the add response message.
      logDeleteResponse(this);
      return;
    }
    // Check for and handle a request to cancel this operation.
    if ((getCancelRequest() != null) ||
        (getCancelResult() == CancelResult.CANCELED))
    if (cancelRequest != null)
    {
      if (getCancelRequest() != null){
        indicateCancelled(getCancelRequest());
      }
      indicateCancelled(cancelRequest);
      // Stop the processing timer.
      setProcessingStopTime();
      // Log the delete response message.
      logDeleteResponse(this);
      invokePostResponsePlugins();
      // Invoke the post-response delete plugins.
      invokePostResponsePlugins(workflowExecuted);
      return;
    }
@@ -566,18 +585,82 @@
    // Stop the processing timer.
    setProcessingStopTime();
    // Send the delete response to the client.
    getClientConnection().sendResponse(this);
    // Log the delete response.
    logDeleteResponse(this);
    // Check wether there are local operations in attachments
    // Notifies any persistent searches that might be registered with the
    // server.
    notifyPersistentSearches(workflowExecuted);
    // Invoke the post-response delete plugins.
    invokePostResponsePlugins(workflowExecuted);
  }
  /**
   * Invokes the post response plugins. If a workflow has been executed
   * then invoke the post response plugins provided by the workflow
   * elements of the worklfow, otherwise invoke the post reponse plugins
   * that have been registered with the current operation.
   *
   * @param workflowExecuted <code>true</code> if a workflow has been
   *                         executed
   */
  private void invokePostResponsePlugins(boolean workflowExecuted)
  {
    // Get the plugin config manager that will be used for invoking plugins.
    PluginConfigManager pluginConfigManager =
      DirectoryServer.getPluginConfigManager();
    // Invoke the post response plugins
    if (workflowExecuted)
    {
      // Invoke the post response plugins that have been registered by
      // the workflow elements
    List localOperations =
      (List)getAttachment(Operation.LOCALBACKENDOPERATIONS);
    if (localOperations != null && (! localOperations.isEmpty())){
      if (localOperations != null)
      {
        for (Object localOp : localOperations)
        {
          LocalBackendDeleteOperation localOperation =
            (LocalBackendDeleteOperation)localOp;
          pluginConfigManager.invokePostResponseDeletePlugins(localOperation);
        }
      }
    }
    else
    {
      // Invoke the post response plugins that have been registered with
      // the current operation
      pluginConfigManager.invokePostResponseDeletePlugins(this);
    }
  }
  /**
   * Notifies any persistent searches that might be registered with the server.
   * If no workflow has been executed then don't notify persistent searches.
   *
   * @param workflowExecuted <code>true</code> if a workflow has been
   *                         executed
   */
  private void notifyPersistentSearches(boolean workflowExecuted)
  {
    if (! workflowExecuted)
    {
      return;
    }
    List localOperations =
      (List)getAttachment(Operation.LOCALBACKENDOPERATIONS);
    if (localOperations != null)
    {
      for (Object localOp : localOperations)
      {
        LocalBackendDeleteOperation localOperation =
@@ -613,12 +696,10 @@
            }
          }
        }
      }
    }
  }
        // Invoke the post-response delete plugins.
        pluginConfigManager.invokePostResponseDeletePlugins(localOperation);
      }
    }
  }
  /**
   * Updates the error message and the result code of the operation.
@@ -633,29 +714,6 @@
                                  String.valueOf(getEntryDN())));
  }
  /**
   * Execute the postResponseDeletePlugins.
   */
  private void invokePostResponsePlugins()
  {
    // Get the plugin config manager that will be used for invoking plugins.
    PluginConfigManager pluginConfigManager =
      DirectoryServer.getPluginConfigManager();
    // Check wether there are local operations in attachments
    List localOperations =
      (List)getAttachment(Operation.LOCALBACKENDOPERATIONS);
    if (localOperations != null && (! localOperations.isEmpty())){
      for (Object localOp : localOperations)
      {
        LocalBackendDeleteOperation localOperation =
          (LocalBackendDeleteOperation)localOp;
        // Invoke the post-response delete plugins.
        pluginConfigManager.invokePostResponseDeletePlugins(localOperation);
      }
    }
  }
  /**
   * {@inheritDoc}
opends/src/server/org/opends/server/core/ModifyDNOperationBasis.java
@@ -52,10 +52,13 @@
import org.opends.server.types.operation.PreParseModifyDNOperation;
import static org.opends.server.core.CoreConstants.*;
import static org.opends.server.loggers.AccessLogger.*;
import org.opends.server.types.DebugLogLevel;
import org.opends.server.workflowelement.localbackend.*;
import static org.opends.server.loggers.ErrorLogger.*;
import static org.opends.server.loggers.debug.DebugLogger.*;
import org.opends.server.loggers.debug.DebugLogger;
import org.opends.server.loggers.debug.DebugTracer;
import static org.opends.server.messages.CoreMessages.*;
@@ -610,7 +613,6 @@
  public final void run()
  {
    setResultCode(ResultCode.UNDEFINED);
    boolean workflowExecuted = false;
    // Get the plugin config manager that will be used for invoking plugins.
    PluginConfigManager pluginConfigManager =
@@ -627,6 +629,11 @@
      return;
    }
    // This flag is set to true as soon as a workflow has been executed.
    boolean workflowExecuted = false;
    // Create a labeled block of code that we can break out of if a problem is
    // detected.
    modifyDNProcessing:
@@ -665,14 +672,10 @@
      logModifyDNRequest(this);
      // Check for and handle a request to cancel this operation.
      // Check for a request to cancel this operation.
      if (cancelRequest != null)
      {
        indicateCancelled(cancelRequest);
        setProcessingStopTime();
        logModifyDNResponse(this);
        pluginConfigManager.invokePostResponseModifyDNPlugins(this);
        return;
        break modifyDNProcessing;
      }
      // Process the entry DN, newRDN, and newSuperior elements from their raw
@@ -699,38 +702,117 @@
      workflowExecuted = true;
    }
    // Check for and handle a request to cancel this operation.
    if ((getCancelRequest() != null) ||
        (getCancelResult() == CancelResult.CANCELED))
    // Check for a terminated connection.
    if (getCancelResult() == CancelResult.CANCELED)
    {
      if (getCancelRequest() != null){
        indicateCancelled(getCancelRequest());
      }
      // Stop the processing timer.
      setProcessingStopTime();
      // Log the add response message.
      logModifyDNResponse(this);
      invokePostResponsePlugins();
      return;
    }
    // Check for and handle a request to cancel this operation.
    if (cancelRequest != null)
    {
      indicateCancelled(cancelRequest);
      // Stop the processing timer.
      setProcessingStopTime();
      // Log the modify DN response message.
      logModifyDNResponse(this);
      // Invoke the post-response modify DN plugins.
      invokePostResponsePlugins(workflowExecuted);
      return;
    }
    // Indicate that it is now too late to attempt to cancel the operation.
    setCancelResult(CancelResult.TOO_LATE);
    // Stop the processing timer.
    setProcessingStopTime();
    // Send the modify DN response to the client.
    clientConnection.sendResponse(this);
    // Log the modify DN response.
    logModifyDNResponse(this);
    // If a workflow has been executed to process the operation, then
    // call the post response plugins against the operations attached
    // to this operation.
    // Notifies any persistent searches that might be registered with the
    // server.
    notifyPersistentSearches(workflowExecuted);
    // Invoke the post-response modify DN plugins.
    invokePostResponsePlugins(workflowExecuted);
  }
  /**
   * Invokes the post response plugins. If a workflow has been executed
   * then invoke the post response plugins provided by the workflow
   * elements of the worklfow, otherwise invoke the post reponse plugins
   * that have been registered with the current operation.
   *
   * @param workflowExecuted <code>true</code> if a workflow has been
   *                         executed
   */
  private void invokePostResponsePlugins(boolean workflowExecuted)
  {
    // Get the plugin config manager that will be used for invoking plugins.
    PluginConfigManager pluginConfigManager =
      DirectoryServer.getPluginConfigManager();
    // Invoke the post response plugins
    if (workflowExecuted)
    {
      // Check wether there are local operations in attachments
      // Invoke the post response plugins that have been registered by
      // the workflow elements
      List localOperations =
        (List)getAttachment(Operation.LOCALBACKENDOPERATIONS);
      if (localOperations != null && (! localOperations.isEmpty())){
      if (localOperations != null)
      {
        for (Object localOp : localOperations)
        {
          LocalBackendModifyDNOperation localOperation =
            (LocalBackendModifyDNOperation)localOp;
          pluginConfigManager.invokePostResponseModifyDNPlugins(localOperation);
        }
      }
    }
    else
    {
      // Invoke the post response plugins that have been registered with
      // the current operation
      pluginConfigManager.invokePostResponseModifyDNPlugins(this);
    }
  }
  /**
   * Notifies any persistent searches that might be registered with the server.
   * If no workflow has been executed then don't notify persistent searches.
   *
   * @param workflowExecuted <code>true</code> if a workflow has been
   *                         executed
   */
  private void notifyPersistentSearches(boolean workflowExecuted)
  {
    if (! workflowExecuted)
    {
      return;
    }
    List localOperations =
      (List)getAttachment(Operation.LOCALBACKENDOPERATIONS);
    if (localOperations != null)
    {
        for (Object localOperation : localOperations)
        {
          LocalBackendModifyDNOperation localOp =
@@ -768,17 +850,9 @@
              }
            }
          }
          // Invoke the post-response modify DN plugins.
          pluginConfigManager.invokePostResponseModifyDNPlugins(localOp);
        }
      }
    }
    else {
      // Invoke the post-response modify DN plugins.
      pluginConfigManager.invokePostResponseModifyDNPlugins(this);
    }
  }
  /**
@@ -893,30 +967,6 @@
  /**
   * Execute the postResponseModifyPlugins.
   */
  private void invokePostResponsePlugins()
  {
    // Get the plugin config manager that will be used for invoking plugins.
    PluginConfigManager pluginConfigManager =
      DirectoryServer.getPluginConfigManager();
    // Check wether there are local operations in attachments
    List localOperations =
      (List)getAttachment(Operation.LOCALBACKENDOPERATIONS);
    if (localOperations != null && (! localOperations.isEmpty())){
      for (Object localOp : localOperations)
      {
        LocalBackendModifyDNOperation localOperation =
          (LocalBackendModifyDNOperation)localOp;
        // Invoke the post-response add plugins.
        pluginConfigManager.invokePostResponseModifyDNPlugins(localOperation);
      }
    }
  }
  /**
   * {@inheritDoc}
   */
  public DN getNewDN()
opends/src/server/org/opends/server/core/ModifyOperationBasis.java
@@ -540,14 +540,18 @@
    setProcessingStartTime();
    // Check for and handle a request to cancel this operation.
    if (getCancelRequest() != null)
    if (cancelRequest != null)
    {
      indicateCancelled(getCancelRequest());
      indicateCancelled(cancelRequest);
      setProcessingStopTime();
      return;
    }
    // This flag is set to true as soon as a workflow has been executed.
    boolean workflowExecuted = false;
    // Create a labeled block of code that we can break out of if a problem is
    // detected.
modifyProcessing:
@@ -584,13 +588,10 @@
      // Log the modify request message.
      logModifyRequest(this);
      // Check for and handle a request to cancel this operation.
      // Check for a request to cancel this operation.
      if (getCancelRequest() != null)
      {
        indicateCancelled(getCancelRequest());
        setProcessingStopTime();
        pluginConfigManager.invokePostResponseModifyPlugins(this);
        return;
        break modifyProcessing;
      }
@@ -614,28 +615,43 @@
        break modifyProcessing;
      }
      workflow.execute(this);
      workflowExecuted = true;
    } // end of processing block
    // Check for a terminated connection.
    if (getCancelResult() == CancelResult.CANCELED)
    {
      // Stop the processing timer.
      setProcessingStopTime();
      // Log the add response message.
      logModifyResponse(this);
      return;
    }
    // Check for and handle a request to cancel this operation.
    if ((getCancelRequest() != null) ||
        (getCancelResult() == CancelResult.CANCELED))
    if (cancelRequest != null)
    {
      if (getCancelRequest() != null){
        indicateCancelled(getCancelRequest());
      }
      indicateCancelled(cancelRequest);
      // Stop the processing timer.
      setProcessingStopTime();
      // Log the modify response message.
      logModifyResponse(this);
      invokePostResponsePlugins();
      // Invoke the post-response modify plugins.
      invokePostResponsePlugins(workflowExecuted);
      return;
    }
    // Indicate that it is now too late to attempt to cancel the operation.
    setCancelResult(CancelResult.TOO_LATE);
    // -- DONE AT A LOWER LEVEL --
    // Notify any change notification listeners that might be registered with
    // the server.
    // Stop the processing timer.
    setProcessingStopTime();
@@ -645,10 +661,76 @@
    // Log the modify response.
    logModifyResponse(this);
    // Check wether there are local operations in attachments
    // Notifies any persistent searches that might be registered with the
    // server.
    notifyPersistentSearches(workflowExecuted);
    // Invoke the post-response modify plugins.
    invokePostResponsePlugins(workflowExecuted);
  }
  /**
   * Invokes the post response plugins. If a workflow has been executed
   * then invoke the post response plugins provided by the workflow
   * elements of the worklfow, otherwise invoke the post reponse plugins
   * that have been registered with the current operation.
   *
   * @param workflowExecuted <code>true</code> if a workflow has been
   *                         executed
   */
  private void invokePostResponsePlugins(boolean workflowExecuted)
  {
    // Get the plugin config manager that will be used for invoking plugins.
    PluginConfigManager pluginConfigManager =
      DirectoryServer.getPluginConfigManager();
    // Invoke the post response plugins
    if (workflowExecuted)
    {
      // Invoke the post response plugins that have been registered by
      // the workflow elements
    List localOperations =
      (List)getAttachment(Operation.LOCALBACKENDOPERATIONS);
    if (localOperations != null && (! localOperations.isEmpty())){
      if (localOperations != null)
      {
        for (Object localOp : localOperations)
        {
          LocalBackendModifyOperation localOperation =
            (LocalBackendModifyOperation)localOp;
          pluginConfigManager.invokePostResponseModifyPlugins(localOperation);
        }
      }
    }
    else
    {
      // Invoke the post response plugins that have been registered with
      // the current operation
      pluginConfigManager.invokePostResponseModifyPlugins(this);
    }
  }
  /**
   * Notifies any persistent searches that might be registered with the server.
   * If no workflow has been executed then don't notify persistent searches.
   *
   * @param workflowExecuted <code>true</code> if a workflow has been
   *                         executed
   */
  private void notifyPersistentSearches(boolean workflowExecuted)
  {
    if (! workflowExecuted)
    {
      return;
    }
    List localOperations =
      (List)getAttachment(Operation.LOCALBACKENDOPERATIONS);
    if (localOperations != null)
    {
      for (Object localOp : localOperations)
      {
        LocalBackendModifyOperation localOperation =
@@ -685,12 +767,10 @@
            }
          }
        }
      }
    }
  }
        // Invoke the post-response modify plugins.
        pluginConfigManager.invokePostResponseModifyPlugins(localOperation);
      }
    }
  }
  /**
   * Updates the error message and the result code of the operation.
@@ -705,29 +785,6 @@
                                  String.valueOf(getEntryDN())));
  }
  /**
   * Execute the postResponseModifyPlugins.
   */
  private void invokePostResponsePlugins()
  {
    // Get the plugin config manager that will be used for invoking plugins.
    PluginConfigManager pluginConfigManager =
      DirectoryServer.getPluginConfigManager();
    // Check wether there are local operations in attachments
    List localOperations =
      (List)getAttachment(Operation.LOCALBACKENDOPERATIONS);
    if (localOperations != null && (! localOperations.isEmpty())){
      for (Object localOp : localOperations)
      {
        LocalBackendModifyOperation localOperation =
          (LocalBackendModifyOperation)localOp;
        // Invoke the post-response add plugins.
        pluginConfigManager.invokePostResponseModifyPlugins(localOperation);
      }
    }
  }
  /**
   * {@inheritDoc}
opends/src/server/org/opends/server/core/SearchOperationBasis.java
@@ -1151,8 +1151,7 @@
      // Invoke the post-response search plugins.
      DirectoryServer.getPluginConfigManager().
           invokePostResponseSearchPlugins(this);
      invokePostResponsePlugins();
    }
  }
@@ -1631,14 +1630,15 @@
    setTimeLimitExpiration(timeLimitExpiration);
    // Check for and handle a request to cancel this operation.
    if (getCancelRequest() != null)
    if (cancelRequest != null)
    {
      indicateCancelled(getCancelRequest());
      indicateCancelled(cancelRequest);
      setProcessingStopTime();
      logSearchResultDone(this);
      return;
    }
    // Create a labeled block of code that we can break out of if a problem is
    // detected.
    searchProcessing:
@@ -1677,13 +1677,9 @@
      // Check for and handle a request to cancel this operation.
      if (getCancelRequest() != null)
      if (cancelRequest != null)
      {
        indicateCancelled(getCancelRequest());
        setProcessingStopTime();
        logSearchResultDone(this);
        pluginConfigManager.invokePostResponseSearchPlugins(this);
        return;
        break searchProcessing;
      }
@@ -1710,17 +1706,37 @@
      workflow.execute(this);
    }
    // Check for and handle a request to cancel this operation.
    if ((getCancelRequest() != null) ||
        (getCancelResult() == CancelResult.CANCELED))
    // Check for a terminated connection.
    if (getCancelResult() == CancelResult.CANCELED)
    {
      indicateCancelled(getCancelRequest());
      // Stop the processing timer.
      setProcessingStopTime();
      // Log the add response message.
      logSearchResultDone(this);
      pluginConfigManager.invokePostResponseSearchPlugins(this);
      return;
    }
    // Check for and handle a request to cancel this operation.
    if (cancelRequest != null)
    {
      indicateCancelled(cancelRequest);
      // Stop the processing timer.
      setProcessingStopTime();
      // Log the search response message.
      logSearchResultDone(this);
      // Invoke the post-response search plugins.
      invokePostResponsePlugins();
      return;
    }
    // Indicate that it is now too late to attempt to cancel the operation.
    setCancelResult(CancelResult.TOO_LATE);
@@ -1743,6 +1759,22 @@
    }
  }
  /**
   * Invokes the post response plugins.
   */
  private void invokePostResponsePlugins()
  {
    // Get the plugin config manager that will be used for invoking plugins.
    PluginConfigManager pluginConfigManager =
      DirectoryServer.getPluginConfigManager();
    // Invoke the post response plugins that have been registered with
    // the current operation
    pluginConfigManager.invokePostResponseSearchPlugins(this);
  }
  /**
   * Updates the error message and the result code of the operation.
   *
opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendWorkflowElement.java
@@ -272,11 +272,10 @@
      }
      // Check for and handle a request to cancel this operation.
      // Check for a request to cancel this operation.
      if (localOp.getCancelRequest() != null)
      {
        localOp.indicateCancelled(localOp.getCancelRequest());
        localOp.setProcessingStopTime();
        return;
      }
      // Acquire a write lock on the target entry.
@@ -304,11 +303,9 @@
      try
      {
        // Check for and handle a request to cancel this operation.
        // Check for a request to cancel this operation.
        if (localOp.getCancelRequest() != null)
        {
          localOp.indicateCancelled(localOp.getCancelRequest());
          localOp.setProcessingStopTime();
          return;
        }
@@ -2000,11 +1997,9 @@
        }
        // Check for and handle a request to cancel this operation.
        // Check for a request to cancel this operation.
        if (localOp.getCancelRequest() != null)
        {
          localOp.indicateCancelled(localOp.getCancelRequest());
          localOp.setProcessingStopTime();
          return;
        }
@@ -2040,11 +2035,9 @@
        }
        // Check for and handle a request to cancel this operation.
        // Check for a request to cancel this operation.
        if (localOp.getCancelRequest() != null)
        {
          localOp.indicateCancelled(localOp.getCancelRequest());
          localOp.setProcessingStopTime();
          return;
        }
@@ -2905,11 +2898,9 @@
        break searchProcessing;
      }
      // Check for and handle a request to cancel this operation.
      // Check for a request to cancel this operation.
      if (localOp.getCancelRequest() != null)
      {
        localOp.indicateCancelled(localOp.getCancelRequest());
        localOp.setProcessingStopTime();
        return;
      }
@@ -2941,11 +2932,9 @@
      }
      // Check for and handle a request to cancel this operation.
      // Check for a request to cancel this operation.
      if (localOp.getCancelRequest() != null)
      {
        localOp.indicateCancelled(localOp.getCancelRequest());
        localOp.setProcessingStopTime();
        return;
      }
@@ -3056,11 +3045,9 @@
    }
    // Check for and handle a request to cancel this operation.
    // Check for a request to cancel this operation.
    if (localOp.getCancelRequest() != null)
    {
      localOp.indicateCancelled(localOp.getCancelRequest());
      localOp.setProcessingStopTime();
      return;
    }
@@ -3262,7 +3249,6 @@
              int msgID = MSGID_CANCELED_BY_PREOP_DISCONNECT;
              localOp.appendErrorMessage(getMessage(msgID));
              localOp.setProcessingStopTime();
              return;
            }
            else if (preOpResult.sendResponseImmediately())
@@ -3587,7 +3573,6 @@
              int msgID = MSGID_CANCELED_BY_PREOP_DISCONNECT;
              localOp.appendErrorMessage(getMessage(msgID));
              localOp.setProcessingStopTime();
              return;
            }
            else if (preOpResult.sendResponseImmediately())
@@ -3885,7 +3870,6 @@
            int msgID = MSGID_CANCELED_BY_PREOP_DISCONNECT;
            localOp.appendErrorMessage(getMessage(msgID));
            localOp.setProcessingStopTime();
            return;
          }
          else if (preOpResult.sendResponseImmediately())
@@ -4420,7 +4404,6 @@
        int msgID = MSGID_CANCELED_BY_PREOP_DISCONNECT;
        localOp.appendErrorMessage(getMessage(msgID));
        localOp.setProcessingStopTime();
        return;
      }
    }
@@ -4524,11 +4507,9 @@
         DirectoryServer.getPluginConfigManager();
    boolean skipPostOperation = false;
    // Check for and handle a request to cancel this operation.
    // Check for a request to cancel this operation.
    if (localOp.getCancelRequest() != null)
    {
      localOp.indicateCancelled(localOp.getCancelRequest());
      localOp.setProcessingStopTime();
      return;
    }
@@ -4557,11 +4538,9 @@
        break addProcessing;
      }
      // Check for and handle a request to cancel this operation.
      // Check for a request to cancel this operation.
      if (localOp.getCancelRequest() != null)
      {
        localOp.indicateCancelled(localOp.getCancelRequest());
        localOp.setProcessingStopTime();
        return;
      }
@@ -4625,11 +4604,9 @@
      try
      {
        // Check for and handle a request to cancel this operation.
        // Check for a request to cancel this operation.
        if (localOp.getCancelRequest() != null)
        {
          localOp.indicateCancelled(localOp.getCancelRequest());
          localOp.setProcessingStopTime();
          return;
        }
@@ -5552,11 +5529,9 @@
          break addProcessing;
        }
        // Check for and handle a request to cancel this operation.
        // Check for a request to cancel this operation.
        if (localOp.getCancelRequest() != null)
        {
          localOp.indicateCancelled(localOp.getCancelRequest());
          localOp.setProcessingStopTime();
          return;
        }
@@ -5576,7 +5551,6 @@
            int msgID = MSGID_CANCELED_BY_PREOP_DISCONNECT;
            localOp.appendErrorMessage(getMessage(msgID));
            localOp.setProcessingStopTime();
            return;
          }
          else if (preOpResult.sendResponseImmediately())
@@ -5592,11 +5566,9 @@
        }
        // Check for and handle a request to cancel this operation.
        // Check for a request to cancel this operation.
        if (localOp.getCancelRequest() != null)
        {
          localOp.indicateCancelled(localOp.getCancelRequest());
          localOp.setProcessingStopTime();
          return;
        }
@@ -5857,7 +5829,6 @@
        int msgID = MSGID_CANCELED_BY_PREOP_DISCONNECT;
        localOp.appendErrorMessage(getMessage(msgID));
        localOp.setProcessingStopTime();
        return;
      }
    }
@@ -5889,11 +5860,6 @@
        }
      }
    }
    // Stop the processing timer.
    localOp.setProcessingStopTime();
  }
@@ -5922,11 +5888,9 @@
         DirectoryServer.getPluginConfigManager();
    boolean skipPostOperation = false;
    // Check for and handle a request to cancel this operation.
    // Check for a request to cancel this operation.
    if (localOp.getCancelRequest() != null)
    {
      localOp.indicateCancelled(localOp.getCancelRequest());
      localOp.setProcessingStopTime();
      return;
    }
@@ -6355,11 +6319,9 @@
          break deleteProcessing;
        }
        // Check for and handle a request to cancel this operation.
        // Check for a request to cancel this operation.
        if (localOp.getCancelRequest() != null)
        {
          localOp.indicateCancelled(localOp.getCancelRequest());
          localOp.setProcessingStopTime();
          return;
        }
@@ -6395,11 +6357,9 @@
        }
        // Check for and handle a request to cancel this operation.
        // Check for a request to cancel this operation.
        if (localOp.getCancelRequest() != null)
        {
          localOp.indicateCancelled(localOp.getCancelRequest());
          localOp.setProcessingStopTime();
          return;
        }
@@ -6741,7 +6701,7 @@
    ClientConnection clientConnection = localOp.getClientConnection();
    // Check for and handle a request to cancel this operation.
    // Check for a request to cancel this operation.
    if (localOp.getCancelRequest() != null)
    {
      return;
@@ -6775,7 +6735,7 @@
      }
      // Check for and handle a request to cancel this operation.
      // Check for a request to cancel this operation.
      if (localOp.getCancelRequest() != null)
      {
        return;
@@ -7131,7 +7091,7 @@
          break compareProcessing;
        }
        // Check for and handle a request to cancel this operation.
        // Check for a request to cancel this operation.
        if (localOp.getCancelRequest() != null)
        {
          return;
@@ -7256,7 +7216,7 @@
    }
    // Check for and handle a request to cancel this operation.
    // Check for a request to cancel this operation.
    if (localOp.getCancelRequest() != null)
    {
      return;
@@ -7307,10 +7267,9 @@
         DirectoryServer.getPluginConfigManager();
    boolean skipPostOperation = false;
    // Check for and handle a request to cancel this operation.
    // Check for a request to cancel this operation.
    if (op.getCancelRequest() != null)
    {
      op.indicateCancelled(op.getCancelRequest());
      return;
    }
@@ -7390,10 +7349,9 @@
      }
      // Check for and handle a request to cancel this operation.
      // Check for a request to cancel this operation.
      if (op.getCancelRequest() != null)
      {
        op.indicateCancelled(op.getCancelRequest());
        return;
      }
@@ -7471,10 +7429,9 @@
      Entry currentEntry = null;
      try
      {
        // Check for and handle a request to cancel this operation.
        // Check for a request to cancel this operation.
        if (op.getCancelRequest() != null)
        {
          op.indicateCancelled(op.getCancelRequest());
          return;
        }
@@ -8025,10 +7982,9 @@
        }
        // Check for and handle a request to cancel this operation.
        // Check for a request to cancel this operation.
        if (op.getCancelRequest() != null)
        {
          op.indicateCancelled(op.getCancelRequest());
          return;
        }
@@ -8253,10 +8209,9 @@
        }
        // Check for and handle a request to cancel this operation.
        // Check for a request to cancel this operation.
        if (op.getCancelRequest() != null)
        {
          op.indicateCancelled(op.getCancelRequest());
          return;
        }