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

kenneth_suter
16.19.2007 eee90cc3e34f4e5a7d562ee9e60c66a61816985c
opends/src/server/org/opends/server/tasks/ExportTask.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.core.DirectoryServer.getAttributeType;
import static org.opends.server.config.ConfigConstants.*;
@@ -55,6 +56,7 @@
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.io.File;
/**
 * This class provides an implementation of a Directory Server task that can
@@ -136,6 +138,7 @@
  private ArrayList<String> includeBranchStrings;
  private ArrayList<String> excludeBranchStrings;
  private LDIFExportConfig exportConfig;
  /**
   * {@inheritDoc}
@@ -259,6 +262,31 @@
  }
  /**
   * {@inheritDoc}
   */
  public void interruptTask(TaskState interruptState, Message interruptReason)
  {
    if (TaskState.STOPPED_BY_ADMINISTRATOR.equals(interruptState) &&
            exportConfig != null)
    {
      addLogMessage(TaskMessages.INFO_TASK_STOPPED_BY_ADMIN.get(
              interruptReason));
      setTaskInterruptState(interruptState);
      exportConfig.cancel();
    }
  }
  /**
   * {@inheritDoc}
   */
  public boolean isInterruptable() {
    return true;
  }
  /**
   * {@inheritDoc}
   */
@@ -483,8 +511,7 @@
      existingBehavior = ExistingFileBehavior.OVERWRITE;
    }
    LDIFExportConfig exportConfig =
         new LDIFExportConfig(ldifFile, existingBehavior);
    exportConfig = new LDIFExportConfig(ldifFile, existingBehavior);
    exportConfig.setCompressData(compressLDIF);
    exportConfig.setEncryptData(encryptLDIF);
    exportConfig.setExcludeAttributes(excludeAttributes);
@@ -587,7 +614,19 @@
      exportConfig.close();
    }
    // If the operation was cancelled delete the export file since
    // if will be incomplete.
    if (exportConfig.isCancelled())
    {
      File f = new File(ldifFile);
      if (f.exists())
      {
        f.delete();
      }
    }
    return TaskState.COMPLETED_SUCCESSFULLY;
    // If we got here the task either completed successfully or
    // was interrupted
    return getFinalTaskState();
  }
}