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

kenneth_suter
16.19.2007 eee90cc3e34f4e5a7d562ee9e60c66a61816985c
opends/src/server/org/opends/server/tasks/BackupTask.java
@@ -26,6 +26,7 @@
 */
package org.opends.server.tasks;
import org.opends.messages.Message;
import org.opends.messages.TaskMessages;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.core.DirectoryServer.getAttributeType;
@@ -133,6 +134,8 @@
  private File    backupDirectory;
  private String  incrementalBase;
  private BackupConfig backupConfig;
  /**
   * All the backend configuration entries defined in the server mapped
   * by their backend ID.
@@ -460,7 +463,7 @@
    // Create a backup configuration.
    BackupConfig backupConfig = new BackupConfig(backupDir, backupID,
    backupConfig = new BackupConfig(backupDir, backupID,
                                                 incremental);
    backupConfig.setCompressData(compress);
    backupConfig.setEncryptData(encrypt);
@@ -560,6 +563,30 @@
  /**
   * {@inheritDoc}
   */
  public void interruptTask(TaskState interruptState, Message interruptReason)
  {
    if (TaskState.STOPPED_BY_ADMINISTRATOR.equals(interruptState) &&
            backupConfig != null)
    {
      addLogMessage(TaskMessages.INFO_TASK_STOPPED_BY_ADMIN.get(
              interruptReason));
      setTaskInterruptState(interruptState);
      backupConfig.cancel();
    }
  }
  /**
   * {@inheritDoc}
   */
  public boolean isInterruptable() {
    return true;
  }
  /**
   * {@inheritDoc}
   */
  protected TaskState runTask()
  {
    if (!argumentsAreValid())
@@ -585,6 +612,11 @@
    boolean errorsEncountered = false;
    for (Backend b : backendsToArchive)
    {
      if (isCancelled())
      {
        break;
      }
      // Acquire a shared lock for this backend.
      if (!lockBackend(b))
      {
@@ -639,6 +671,12 @@
      logError(message);
      return TaskState.COMPLETED_WITH_ERRORS;
    }
    else if (isCancelled())
    {
      Message message = NOTE_BACKUPDB_CANCELLED.get();
      logError(message);
      return getTaskInterruptState();
    }
    else
    {
      Message message = NOTE_BACKUPDB_COMPLETED_SUCCESSFULLY.get();