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

neil_a_wilson
02.51.2007 2811274062184e78e27d610a38b4edb84f15b837
Make the import-ldif, export-ldif, backup, and restore tools easier to invoke
programmatically from within the same JVM as the server. This will make it
much easier to call them from unit tests.

OpenDS Issue Number: 1311
4 files modified
76 ■■■■■ changed files
opends/src/server/org/opends/server/tools/BackUpDB.java 18 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/ExportLDIF.java 18 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/ImportLDIF.java 22 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/RestoreDB.java 18 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/BackUpDB.java
@@ -103,6 +103,20 @@
   */
  public static int mainBackUpDB(String[] args)
  {
    return mainBackUpDB(args, true);
  }
  /**
   * Processes the command-line arguments and invokes the backup process.
   *
   * @param  args              The command-line arguments provided to this
   *                           program.
   * @param  initializeServer  Indicates whether to initialize the server.
   *
   * @return The error code.
   */
  public static int mainBackUpDB(String[] args, boolean initializeServer)
  {
    // Define the command-line arguments that may be used with this program.
    BooleanArgument backUpAll         = null;
    BooleanArgument compress          = null;
@@ -339,7 +353,8 @@
    // Perform the initial bootstrap of the Directory Server and process the
    // configuration.
    DirectoryServer directoryServer = DirectoryServer.getInstance();
    if (initializeServer)
    {
    try
    {
      directoryServer.bootstrapClient();
@@ -465,6 +480,7 @@
    StartupErrorLogger startupLogger = new StartupErrorLogger();
    startupLogger.initializeErrorLogger(null);
    addErrorLogger(startupLogger);
    }
    // Get information about the backends defined in the server, and determine
opends/src/server/org/opends/server/tools/ExportLDIF.java
@@ -101,6 +101,20 @@
   */
  public static int mainExportLDIF(String[] args)
  {
    return mainExportLDIF(args, true);
  }
  /**
   * Processes the command-line arguments and invokes the export process.
   *
   * @param  args              The command-line arguments provided to this
   *                           program.
   * @param  initializeServer  Indicates whether to initialize the server.
   *
   * @return The error code.
   */
  public static int mainExportLDIF(String[] args, boolean initializeServer)
  {
    // Define the command-line arguments that may be used with this program.
    BooleanArgument appendToLDIF            = null;
    BooleanArgument compressLDIF            = null;
@@ -284,7 +298,8 @@
    // Perform the initial bootstrap of the Directory Server and process the
    // configuration.
    DirectoryServer directoryServer = DirectoryServer.getInstance();
    if (initializeServer)
    {
    try
    {
      directoryServer.bootstrapClient();
@@ -440,6 +455,7 @@
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
    }
    // See if there were any user-defined sets of include/exclude attributes or
opends/src/server/org/opends/server/tools/ImportLDIF.java
@@ -110,6 +110,20 @@
   */
  public static int mainImportLDIF(String[] args)
  {
    return mainImportLDIF(args, true);
  }
  /**
   * Processes the command-line arguments and invokes the import process.
   *
   * @param  args              The command-line arguments provided to this
   *                           program.
   * @param  initializeServer  Indicates whether to initialize the server.
   *
   * @return The error code.
   */
  public static int mainImportLDIF(String[] args, boolean initializeServer)
  {
    // FIXME -- Need to add a mechanism for verifying the file signature.
    // Define the command-line arguments that may be used with this program.
@@ -347,7 +361,8 @@
    // Perform the initial bootstrap of the Directory Server and process the
    // configuration.
    DirectoryServer directoryServer = DirectoryServer.getInstance();
    if (initializeServer)
    {
    try
    {
      DirectoryServer.bootstrapClient();
@@ -470,8 +485,8 @@
    if (! quietMode.isPresent())
    {
      // FIXME -- Install a custom logger to capture information about the state
      // of the import.
        // FIXME -- Install a custom logger to capture information about the
        // state of the import.
      StartupErrorLogger startupLogger = new StartupErrorLogger();
      startupLogger.initializeErrorLogger(null);
      addErrorLogger(startupLogger);
@@ -534,6 +549,7 @@
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
    }
    // See if there were any user-defined sets of include/exclude attributes or
opends/src/server/org/opends/server/tools/RestoreDB.java
@@ -101,6 +101,20 @@
   */
  public static int mainRestoreDB(String[] args)
  {
    return mainRestoreDB(args, true);
  }
  /**
   * Processes the command-line arguments and invokes the restore process.
   *
   * @param  args              The command-line arguments provided to this
   *                           program.
   * @param  initializeServer  Indicates whether to initialize the server.
   *
   * @return The error code.
   */
  public static int mainRestoreDB(String[] args, boolean initializeServer)
  {
    // Define the command-line arguments that may be used with this program.
    BooleanArgument displayUsage      = null;
    BooleanArgument listBackups          = null;
@@ -205,7 +219,8 @@
    // Perform the initial bootstrap of the Directory Server and process the
    // configuration.
    DirectoryServer directoryServer = DirectoryServer.getInstance();
    if (initializeServer)
    {
    try
    {
      directoryServer.bootstrapClient();
@@ -331,6 +346,7 @@
    StartupErrorLogger startupLogger = new StartupErrorLogger();
    startupLogger.initializeErrorLogger(null);
    addErrorLogger(startupLogger);
    }
    // Open the backup directory and make sure it is valid.