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

neil_a_wilson
10.30.2007 7b09f76c7501f692657385025ccb10be5d974c7a
Update all of the tools provided with OpenDS to ensure that they are easier
to invoke programmatically. This includes:

- Providing an alternate static method that returns an integer value and
doesn't use System.exit

- Making sure that method provides the ability to control whether the server
should be initialized (not necessary for all types of tools)

- Making sure that method provides the ability to specify alternate output and
error streams.

OpenDS Issue Number: 987
14 files modified
1230 ■■■■■ changed files
opends/src/server/org/opends/server/loggers/TextWriter.java 53 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/BackUpDB.java 80 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/ExportLDIF.java 77 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/ImportLDIF.java 87 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDIFDiff.java 58 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDIFModify.java 59 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDIFSearch.java 77 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/RebuildIndex.java 295 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/RestoreDB.java 89 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/VerifyIndex.java 297 ●●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/authorization/dseecompat/AciTests.java 2 ●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/tools/ImportLDIFTestCase.java 18 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDIFDiffTestCase.java 30 ●●●● patch | view | raw | blame | history
opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDIFSearchTestCase.java 8 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/loggers/TextWriter.java
@@ -26,6 +26,7 @@
 */
package org.opends.server.loggers;
import java.io.OutputStream;
import java.io.PrintWriter;
/**
@@ -139,4 +140,56 @@
      return stream.written;
    }
  }
  /**
   * A TextWriter implementation which writes to a given output stream.
   */
  public class STREAM implements TextWriter
  {
    private MeteredStream stream;
    private PrintWriter writer;
    /**
     * Creates a new text writer that will write to the provided output stream.
     *
     * @param  outputStream  The output stream to which
     */
    public STREAM(OutputStream outputStream)
    {
      stream = new MeteredStream(outputStream, 0);
      writer = new PrintWriter(stream, true);
    }
    /**
     * {@inheritDoc}
     */
    public void writeRecord(String record)
    {
      writer.println(record);
    }
    /**
     * {@inheritDoc}
     */
    public void flush()
    {
      writer.flush();
    }
    /**
     * {@inheritDoc}
     */
    public void shutdown()
    {
      // Should never close the system error stream.
    }
    /**
     * {@inheritDoc}
     */
    public long getBytesWritten()
    {
      return stream.written;
    }
  }
}
opends/src/server/org/opends/server/tools/BackUpDB.java
@@ -29,6 +29,8 @@
import java.io.File;
import java.io.OutputStream;
import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -54,6 +56,7 @@
import org.opends.server.types.ErrorLogCategory;
import org.opends.server.types.ErrorLogSeverity;
import org.opends.server.types.InitializationException;
import org.opends.server.types.NullOutputStream;
import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.ArgumentParser;
import org.opends.server.util.args.BooleanArgument;
@@ -86,7 +89,7 @@
   */
  public static void main(String[] args)
  {
    int retCode = mainBackUpDB(args);
    int retCode = mainBackUpDB(args, true, System.out, System.err);
    if(errorLogPublisher != null)
    {
@@ -108,7 +111,7 @@
   */
  public static int mainBackUpDB(String[] args)
  {
    return mainBackUpDB(args, true);
    return mainBackUpDB(args, true, System.out, System.err);
  }
  /**
@@ -117,11 +120,36 @@
   * @param  args              The command-line arguments provided to this
   *                           program.
   * @param  initializeServer  Indicates whether to initialize the server.
   * @param  outStream         The output stream to use for standard output, or
   *                           {@code null} if standard output is not needed.
   * @param  errStream         The output stream to use for standard error, or
   *                           {@code null} if standard error is not needed.
   *
   * @return The error code.
   */
  public static int mainBackUpDB(String[] args, boolean initializeServer)
  public static int mainBackUpDB(String[] args, boolean initializeServer,
                                 OutputStream outStream, OutputStream errStream)
  {
    PrintStream out;
    if (outStream == null)
    {
      out = NullOutputStream.printStream();
    }
    else
    {
      out = new PrintStream(outStream);
    }
    PrintStream err;
    if (errStream == null)
    {
      err = NullOutputStream.printStream();
    }
    else
    {
      err = new PrintStream(errStream);
    }
    // Define the command-line arguments that may be used with this program.
    BooleanArgument backUpAll         = null;
    BooleanArgument compress          = null;
@@ -239,7 +267,7 @@
      int    msgID   = MSGID_CANNOT_INITIALIZE_ARGS;
      String message = getMessage(msgID, ae.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
@@ -254,8 +282,8 @@
      int    msgID   = MSGID_ERROR_PARSING_ARGS;
      String message = getMessage(msgID, ae.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      System.err.println(argParser.getUsage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      err.println(argParser.getUsage());
      return 1;
    }
@@ -277,7 +305,7 @@
        int    msgID   = MSGID_BACKUPDB_CANNOT_MIX_BACKUP_ALL_AND_BACKEND_ID;
        String message = getMessage(msgID, backUpAll.getLongIdentifier(),
                                    backendID.getLongIdentifier());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
    }
@@ -286,7 +314,7 @@
      int    msgID   = MSGID_BACKUPDB_NEED_BACKUP_ALL_OR_BACKEND_ID;
      String message = getMessage(msgID, backUpAll.getLongIdentifier(),
                                  backendID.getLongIdentifier());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
@@ -316,7 +344,7 @@
        String message = getMessage(msgID,
                                    incrementalBaseID.getLongIdentifier(),
                                    incremental.getLongIdentifier());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
@@ -335,7 +363,7 @@
      int    msgID   = MSGID_BACKUPDB_SIGN_REQUIRES_HASH;
      String message = getMessage(msgID, signHash.getLongIdentifier(),
                                  hash.getLongIdentifier());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
@@ -353,7 +381,7 @@
        int    msgID   = MSGID_BACKUPDB_CANNOT_CREATE_BACKUP_DIR;
        String message = getMessage(msgID, backupDirectory.getValue(),
                                    getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
    }
@@ -373,7 +401,7 @@
      {
        int    msgID   = MSGID_SERVER_BOOTSTRAP_ERROR;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
@@ -386,14 +414,14 @@
      {
        int    msgID   = MSGID_CANNOT_LOAD_CONFIG;
        String message = getMessage(msgID, ie.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_LOAD_CONFIG;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
@@ -408,21 +436,21 @@
      {
        int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
        String message = getMessage(msgID, ce.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
        String message = getMessage(msgID, ie.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
@@ -437,21 +465,21 @@
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
        String message = getMessage(msgID, ce.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
        String message = getMessage(msgID, ie.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
@@ -465,21 +493,21 @@
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
        String message = getMessage(msgID, ce.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
        String message = getMessage(msgID, ie.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
@@ -490,14 +518,14 @@
      {
        errorLogPublisher =
            new ThreadFilterTextErrorLogPublisher(Thread.currentThread(),
                                                  new TextWriter.STDOUT());
                                                  new TextWriter.STREAM(out));
        ErrorLogger.addErrorLogPublisher(errorLogPublisher);
      }
      catch(Exception e)
      {
        System.err.println("Error installing the custom error logger: " +
                           stackTraceToSingleLineString(e));
        err.println("Error installing the custom error logger: " +
                    stackTraceToSingleLineString(e));
      }
    }
opends/src/server/org/opends/server/tools/ExportLDIF.java
@@ -28,6 +28,8 @@
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -51,6 +53,7 @@
import org.opends.server.types.ExistingFileBehavior;
import org.opends.server.types.InitializationException;
import org.opends.server.types.LDIFExportConfig;
import org.opends.server.types.NullOutputStream;
import org.opends.server.types.SearchFilter;
import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.ArgumentParser;
@@ -84,7 +87,7 @@
  public static void main(String[] args)
  {
    int retCode = mainExportLDIF(args);
    int retCode = mainExportLDIF(args, true, System.out, System.err);
    if(errorLogPublisher != null)
    {
@@ -106,7 +109,7 @@
   */
  public static int mainExportLDIF(String[] args)
  {
    return mainExportLDIF(args, true);
    return mainExportLDIF(args, true, System.out, System.err);
  }
  /**
@@ -115,11 +118,37 @@
   * @param  args              The command-line arguments provided to this
   *                           program.
   * @param  initializeServer  Indicates whether to initialize the server.
   * @param  outStream         The output stream to use for standard output, or
   *                           {@code null} if standard output is not needed.
   * @param  errStream         The output stream to use for standard error, or
   *                           {@code null} if standard error is not needed.
   *
   * @return The error code.
   */
  public static int mainExportLDIF(String[] args, boolean initializeServer)
  public static int mainExportLDIF(String[] args, boolean initializeServer,
                                   OutputStream outStream,
                                   OutputStream errStream)
  {
    PrintStream out;
    if (outStream == null)
    {
      out = NullOutputStream.printStream();
    }
    else
    {
      out = new PrintStream(outStream);
    }
    PrintStream err;
    if (errStream == null)
    {
      err = NullOutputStream.printStream();
    }
    else
    {
      err = new PrintStream(errStream);
    }
    // Define the command-line arguments that may be used with this program.
    BooleanArgument appendToLDIF            = null;
    BooleanArgument compressLDIF            = null;
@@ -276,7 +305,7 @@
      int    msgID   = MSGID_CANNOT_INITIALIZE_ARGS;
      String message = getMessage(msgID, ae.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
@@ -291,8 +320,8 @@
      int    msgID   = MSGID_ERROR_PARSING_ARGS;
      String message = getMessage(msgID, ae.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      System.err.println(argParser.getUsage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      err.println(argParser.getUsage());
      return 1;
    }
@@ -319,7 +348,7 @@
      {
        int    msgID   = MSGID_SERVER_BOOTSTRAP_ERROR;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
@@ -332,14 +361,14 @@
      {
        int    msgID   = MSGID_CANNOT_LOAD_CONFIG;
        String message = getMessage(msgID, ie.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_LOAD_CONFIG;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
@@ -354,21 +383,21 @@
      {
        int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
        String message = getMessage(msgID, ce.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
        String message = getMessage(msgID, ie.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
@@ -383,21 +412,21 @@
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
        String message = getMessage(msgID, ce.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
        String message = getMessage(msgID, ie.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
@@ -411,21 +440,21 @@
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
        String message = getMessage(msgID, ce.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
        String message = getMessage(msgID, ie.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
@@ -436,14 +465,14 @@
      {
        errorLogPublisher =
            new ThreadFilterTextErrorLogPublisher(Thread.currentThread(),
                                                  new TextWriter.STDOUT());
                                                  new TextWriter.STREAM(out));
        ErrorLogger.addErrorLogPublisher(errorLogPublisher);
      }
      catch(Exception e)
      {
        System.err.println("Error installing the custom error logger: " +
                           stackTraceToSingleLineString(e));
        err.println("Error installing the custom error logger: " +
                    stackTraceToSingleLineString(e));
      }
@@ -459,21 +488,21 @@
      {
        int    msgID   = MSGID_LDIFEXPORT_CANNOT_INITIALIZE_PLUGINS;
        String message = getMessage(msgID, ce.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_LDIFEXPORT_CANNOT_INITIALIZE_PLUGINS;
        String message = getMessage(msgID, ie.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_LDIFEXPORT_CANNOT_INITIALIZE_PLUGINS;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
    }
opends/src/server/org/opends/server/tools/ImportLDIF.java
@@ -29,6 +29,8 @@
import java.io.File;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@@ -56,6 +58,7 @@
import org.opends.server.types.InitializationException;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.LDIFImportResult;
import org.opends.server.types.NullOutputStream;
import org.opends.server.types.SearchFilter;
import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.ArgumentParser;
@@ -95,7 +98,7 @@
   */
  public static void main(String[] args)
  {
    int retCode = mainImportLDIF(args);
    int retCode = mainImportLDIF(args, true, System.out, System.err);
    if(errorLogPublisher != null)
    {
@@ -117,7 +120,7 @@
   */
  public static int mainImportLDIF(String[] args)
  {
    return mainImportLDIF(args, true);
    return mainImportLDIF(args, true, System.out, System.err);
  }
  /**
@@ -126,11 +129,37 @@
   * @param  args              The command-line arguments provided to this
   *                           program.
   * @param  initializeServer  Indicates whether to initialize the server.
   * @param  outStream         The output stream to use for standard output, or
   *                           {@code null} if standard output is not needed.
   * @param  errStream         The output stream to use for standard error, or
   *                           {@code null} if standard error is not needed.
   *
   * @return The error code.
   */
  public static int mainImportLDIF(String[] args, boolean initializeServer)
  public static int mainImportLDIF(String[] args, boolean initializeServer,
                                   OutputStream outStream,
                                   OutputStream errStream)
  {
    PrintStream out;
    if (outStream == null)
    {
      out = NullOutputStream.printStream();
    }
    else
    {
      out = new PrintStream(outStream);
    }
    PrintStream err;
    if (errStream == null)
    {
      err = NullOutputStream.printStream();
    }
    else
    {
      err = new PrintStream(errStream);
    }
    // FIXME -- Need to add a mechanism for verifying the file signature.
    // Define the command-line arguments that may be used with this program.
@@ -333,7 +362,7 @@
      int    msgID   = MSGID_CANNOT_INITIALIZE_ARGS;
      String message = getMessage(msgID, ae.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
@@ -348,8 +377,8 @@
      int    msgID   = MSGID_ERROR_PARSING_ARGS;
      String message = getMessage(msgID, ae.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      System.err.println(argParser.getUsage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      err.println(argParser.getUsage());
      return 1;
    }
@@ -371,7 +400,7 @@
        int    msgID   = MSGID_LDIFIMPORT_CONFLICTING_OPTIONS;
        String message = getMessage(msgID, ldifFiles.getLongIdentifier(),
                                    templateFile.getLongIdentifier());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
    }
@@ -380,7 +409,7 @@
      int    msgID   = MSGID_LDIFIMPORT_MISSING_REQUIRED_ARGUMENT;
      String message = getMessage(msgID, ldifFiles.getLongIdentifier(),
                                  templateFile.getLongIdentifier());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
@@ -399,7 +428,7 @@
      {
        int    msgID   = MSGID_SERVER_BOOTSTRAP_ERROR;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
@@ -412,14 +441,14 @@
      {
        int    msgID   = MSGID_CANNOT_LOAD_CONFIG;
        String message = getMessage(msgID, ie.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_LOAD_CONFIG;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
@@ -434,21 +463,21 @@
      {
        int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
        String message = getMessage(msgID, ce.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
        String message = getMessage(msgID, ie.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
@@ -463,21 +492,21 @@
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
        String message = getMessage(msgID, ce.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
        String message = getMessage(msgID, ie.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
@@ -491,21 +520,21 @@
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
        String message = getMessage(msgID, ce.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
        String message = getMessage(msgID, ie.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
@@ -518,14 +547,14 @@
        {
          errorLogPublisher =
              new ThreadFilterTextErrorLogPublisher(Thread.currentThread(),
                                                    new TextWriter.STDOUT());
                                                    new TextWriter.STREAM(out));
          ErrorLogger.addErrorLogPublisher(errorLogPublisher);
        }
        catch(Exception e)
        {
          System.err.println("Error installing the custom error logger: " +
                             stackTraceToSingleLineString(e));
          err.println("Error installing the custom error logger: " +
                      stackTraceToSingleLineString(e));
        }
      }
@@ -539,21 +568,21 @@
      {
        int    msgID   = MSGID_LDIFIMPORT_CANNOT_INITIALIZE_PWPOLICY;
        String message = getMessage(msgID, ce.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_LDIFIMPORT_CANNOT_INITIALIZE_PWPOLICY;
        String message = getMessage(msgID, ie.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_LDIFIMPORT_CANNOT_INITIALIZE_PWPOLICY;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
@@ -569,21 +598,21 @@
      {
        int    msgID   = MSGID_LDIFIMPORT_CANNOT_INITIALIZE_PLUGINS;
        String message = getMessage(msgID, ce.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_LDIFIMPORT_CANNOT_INITIALIZE_PLUGINS;
        String message = getMessage(msgID, ie.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_LDIFIMPORT_CANNOT_INITIALIZE_PLUGINS;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
    }
opends/src/server/org/opends/server/tools/LDIFDiff.java
@@ -29,6 +29,8 @@
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
@@ -48,6 +50,7 @@
import org.opends.server.types.LDIFExportConfig;
import org.opends.server.types.Modification;
import org.opends.server.types.ModificationType;
import org.opends.server.types.NullOutputStream;
import org.opends.server.types.ObjectClass;
import org.opends.server.util.LDIFReader;
import org.opends.server.util.LDIFWriter;
@@ -105,7 +108,7 @@
   */
  public static void main(String[] args)
  {
    int exitCode = mainDiff(args, false);
    int exitCode = mainDiff(args, false, System.out, System.err);
    if (exitCode != 0)
    {
      System.exit(filterExitCode(exitCode));
@@ -123,13 +126,38 @@
   * @param  serverInitialized  Indicates whether the Directory Server has
   *                            already been initialized (and therefore should
   *                            not be initialized a second time).
   * @param  outStream          The output stream to use for standard output, or
   *                            {@code null} if standard output is not needed.
   * @param  errStream          The output stream to use for standard error, or
   *                            {@code null} if standard error is not needed.
   *
   * @return  The return code for this operation.  A value of zero indicates
   *          that all processing completed successfully.  A nonzero value
   *          indicates that some problem occurred during processing.
   */
  public static int mainDiff(String[] args, boolean serverInitialized)
  public static int mainDiff(String[] args, boolean serverInitialized,
                             OutputStream outStream, OutputStream errStream)
  {
    PrintStream out;
    if (outStream == null)
    {
      out = NullOutputStream.printStream();
    }
    else
    {
      out = new PrintStream(outStream);
    }
    PrintStream err;
    if (errStream == null)
    {
      err = NullOutputStream.printStream();
    }
    else
    {
      err = new PrintStream(errStream);
    }
    BooleanArgument overwriteExisting;
    BooleanArgument showUsage;
    BooleanArgument singleValueChanges;
@@ -195,7 +223,7 @@
    {
      int    msgID   = MSGID_CANNOT_INITIALIZE_ARGS;
      String message = getMessage(msgID, ae.getMessage());
      System.err.println(message);
      err.println(message);
      return 1;
    }
@@ -210,8 +238,8 @@
      int    msgID   = MSGID_ERROR_PARSING_ARGS;
      String message = getMessage(msgID, ae.getMessage());
      System.err.println(message);
      System.err.println(argParser.getUsage());
      err.println(message);
      err.println(argParser.getUsage());
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
    }
@@ -246,7 +274,7 @@
          String message = getMessage(msgID,
                                      String.valueOf(configFile.getValue()),
                                      e.getMessage());
          System.err.println(message);
          err.println(message);
          return 1;
        }
@@ -261,7 +289,7 @@
          String message = getMessage(msgID,
                                      String.valueOf(configFile.getValue()),
                                      e.getMessage());
          System.err.println(message);
          err.println(message);
          return 1;
        }
@@ -275,7 +303,7 @@
          String message = getMessage(msgID,
                                      String.valueOf(configFile.getValue()),
                                      e.getMessage());
          System.err.println(message);
          err.println(message);
          return 1;
        }
      }
@@ -294,7 +322,7 @@
      int    msgID   = MSGID_LDIFDIFF_CANNOT_OPEN_SOURCE_LDIF;
      String message = getMessage(msgID, sourceLDIF.getValue(),
                                  String.valueOf(e));
      System.err.println(message);
      err.println(message);
      return 1;
    }
@@ -317,7 +345,7 @@
      int    msgID   = MSGID_LDIFDIFF_ERROR_READING_SOURCE_LDIF;
      String message = getMessage(msgID, sourceLDIF.getValue(),
                                  String.valueOf(e));
      System.err.println(message);
      err.println(message);
      return 1;
    }
    finally
@@ -340,7 +368,7 @@
      int    msgID   = MSGID_LDIFDIFF_CANNOT_OPEN_TARGET_LDIF;
      String message = getMessage(msgID, targetLDIF.getValue(),
                                  String.valueOf(e));
      System.err.println(message);
      err.println(message);
      return 1;
    }
@@ -363,7 +391,7 @@
      int    msgID   = MSGID_LDIFDIFF_ERROR_READING_TARGET_LDIF;
      String message = getMessage(msgID, targetLDIF.getValue(),
                                  String.valueOf(e));
      System.err.println(message);
      err.println(message);
      return 1;
    }
    finally
@@ -395,7 +423,7 @@
      }
      else
      {
        exportConfig = new LDIFExportConfig(System.out);
        exportConfig = new LDIFExportConfig(out);
      }
      writer = new LDIFWriter(exportConfig);
@@ -404,7 +432,7 @@
    {
      int    msgID   = MSGID_LDIFDIFF_CANNOT_OPEN_OUTPUT;
      String message = getMessage(msgID, String.valueOf(e));
      System.err.println(message);
      err.println(message);
      return 1;
    }
@@ -581,7 +609,7 @@
    {
      int    msgID   = MSGID_LDIFDIFF_ERROR_WRITING_OUTPUT;
      String message = getMessage(msgID, String.valueOf(e));
      System.err.println(message);
      err.println(message);
      return 1;
    }
    finally
opends/src/server/org/opends/server/tools/LDIFModify.java
@@ -30,6 +30,8 @@
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
@@ -51,6 +53,7 @@
import org.opends.server.types.LDIFExportConfig;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.Modification;
import org.opends.server.types.NullOutputStream;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.RawModification;
import org.opends.server.util.AddChangeRecordEntry;
@@ -395,7 +398,7 @@
   */
  public static void main(String[] args)
  {
    int returnCode = ldifModifyMain(args, false);
    int returnCode = ldifModifyMain(args, false, System.out, System.err);
    if (returnCode != 0)
    {
      System.exit(filterExitCode(returnCode));
@@ -413,12 +416,38 @@
   * @param  serverInitialized  Indicates whether the Directory Server has
   *                            already been initialized (and therefore should
   *                            not be initialized a second time).
   * @param  outStream          The output stream to use for standard output, or
   *                            {@code null} if standard output is not needed.
   * @param  errStream          The output stream to use for standard error, or
   *                            {@code null} if standard error is not needed.
   *
   * @return  A value of zero if everything completed properly, or nonzero if
   *          any problem(s) occurred.
   */
  public static int ldifModifyMain(String[] args, boolean serverInitialized)
  public static int ldifModifyMain(String[] args, boolean serverInitialized,
                                   OutputStream outStream,
                                   OutputStream errStream)
  {
    PrintStream out;
    if (outStream == null)
    {
      out = NullOutputStream.printStream();
    }
    else
    {
      out = new PrintStream(outStream);
    }
    PrintStream err;
    if (errStream == null)
    {
      err = NullOutputStream.printStream();
    }
    else
    {
      err = new PrintStream(errStream);
    }
    // Prepare the argument parser.
    BooleanArgument showUsage;
    StringArgument  changesFile;
@@ -477,7 +506,7 @@
    {
      int    msgID   = MSGID_CANNOT_INITIALIZE_ARGS;
      String message = getMessage(msgID, ae.getMessage());
      System.err.println(message);
      err.println(message);
      return 1;
    }
@@ -492,8 +521,8 @@
      int    msgID   = MSGID_ERROR_PARSING_ARGS;
      String message = getMessage(msgID, ae.getMessage());
      System.err.println(message);
      System.err.println(argParser.getUsage());
      err.println(message);
      err.println(argParser.getUsage());
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
    }
@@ -528,7 +557,7 @@
          String message = getMessage(msgID,
                                      String.valueOf(configFile.getValue()),
                                      e.getMessage());
          System.err.println(message);
          err.println(message);
          return 1;
        }
@@ -543,7 +572,7 @@
          String message = getMessage(msgID,
                                      String.valueOf(configFile.getValue()),
                                      e.getMessage());
          System.err.println(message);
          err.println(message);
          return 1;
        }
@@ -557,7 +586,7 @@
          String message = getMessage(msgID,
                                      String.valueOf(configFile.getValue()),
                                      e.getMessage());
          System.err.println(message);
          err.println(message);
          return 1;
        }
      }
@@ -570,7 +599,7 @@
    {
      int    msgID   = MSGID_LDIFMODIFY_SOURCE_DOES_NOT_EXIST;
      String message = getMessage(msgID, sourceFile.getValue());
      System.err.println(message);
      err.println(message);
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
    }
@@ -585,7 +614,7 @@
      int    msgID   = MSGID_LDIFMODIFY_CANNOT_OPEN_SOURCE;
      String message = getMessage(msgID, sourceFile.getValue(),
                                  String.valueOf(ioe));
      System.err.println(message);
      err.println(message);
      return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR;
    }
@@ -595,7 +624,7 @@
    {
      int    msgID   = MSGID_LDIFMODIFY_CHANGES_DOES_NOT_EXIST;
      String message = getMessage(msgID, changesFile.getValue());
      System.err.println(message);
      err.println(message);
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
    }
@@ -609,7 +638,7 @@
    {
      int    msgID   = MSGID_LDIFMODIFY_CANNOT_OPEN_CHANGES;
      String message = getMessage(msgID, sourceFile.getValue());
      System.err.println(message);
      err.println(message);
      return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR;
    }
@@ -626,7 +655,7 @@
    {
      int    msgID   = MSGID_LDIFMODIFY_CANNOT_OPEN_TARGET;
      String message = getMessage(msgID, sourceFile.getValue());
      System.err.println(message);
      err.println(message);
      return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR;
    }
@@ -643,7 +672,7 @@
    {
      int    msgID   = MSGID_LDIFMODIFY_ERROR_PROCESSING_LDIF;
      String message = getMessage(msgID, String.valueOf(e));
      System.err.println(message);
      err.println(message);
      successful = false;
    }
@@ -665,7 +694,7 @@
    for (String s : errorList)
    {
      System.err.println(s);
      err.println(s);
    }
    return (successful ? 0 : 1);
  }
opends/src/server/org/opends/server/tools/LDIFSearch.java
@@ -28,6 +28,8 @@
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -42,6 +44,7 @@
import org.opends.server.types.ExistingFileBehavior;
import org.opends.server.types.LDIFExportConfig;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.NullOutputStream;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.SearchFilter;
import org.opends.server.types.SearchScope;
@@ -116,7 +119,7 @@
   */
  public static void main(String[] args)
  {
    int exitCode = mainSearch(args, true);
    int exitCode = mainSearch(args, true, System.out, System.err);
    if (exitCode != 0)
    {
      System.exit(filterExitCode(exitCode));
@@ -129,16 +132,41 @@
   * Parses the provided command line arguments and performs the appropriate
   * search operation.
   *
   * @param  args  The command line arguments provided to this program.
   *
   * @param initializeServer True if server initialization should be done.
   * @param  args              The command line arguments provided to this
   *                           program.
   * @param  initializeServer  True if server initialization should be done.
   * @param  outStream         The output stream to use for standard output, or
   *                           {@code null} if standard output is not needed.
   * @param  errStream         The output stream to use for standard error, or
   *                           {@code null} if standard error is not needed.
   *
   * @return  The return code for this operation.  A value of zero indicates
   *          that all processing completed successfully.  A nonzero value
   *          indicates that some problem occurred during processing.
   */
  public static int mainSearch(String[] args, boolean initializeServer)
  public static int mainSearch(String[] args, boolean initializeServer,
                               OutputStream outStream, OutputStream errStream)
  {
    PrintStream out;
    if (outStream == null)
    {
      out = NullOutputStream.printStream();
    }
    else
    {
      out = new PrintStream(outStream);
    }
    PrintStream err;
    if (errStream == null)
    {
      err = NullOutputStream.printStream();
    }
    else
    {
      err = new PrintStream(errStream);
    }
    LinkedHashSet<String> scopeStrings = new LinkedHashSet<String>(4);
    scopeStrings.add(SCOPE_STRING_BASE);
    scopeStrings.add(SCOPE_STRING_ONE);
@@ -240,7 +268,7 @@
    {
      int    msgID   = MSGID_CANNOT_INITIALIZE_ARGS;
      String message = getMessage(msgID, ae.getMessage());
      System.err.println(message);
      err.println(message);
      return 1;
    }
@@ -255,8 +283,8 @@
      int    msgID   = MSGID_ERROR_PARSING_ARGS;
      String message = getMessage(msgID, ae.getMessage());
      System.err.println(message);
      System.err.println(argParser.getUsage());
      err.println(message);
      err.println(argParser.getUsage());
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
    }
@@ -321,7 +349,7 @@
      {
        int    msgID   = MSGID_LDIFSEARCH_NO_FILTER;
        String message = getMessage(msgID);
        System.err.println(message);
        err.println(message);
        return 1;
      }
      else
@@ -400,7 +428,7 @@
        String message = getMessage(msgID,
                                    String.valueOf(configFile.getValue()),
                                    e.getMessage());
        System.err.println(message);
        err.println(message);
        return 1;
      }
@@ -415,7 +443,7 @@
        String message = getMessage(msgID,
                                    String.valueOf(configFile.getValue()),
                                    e.getMessage());
        System.err.println(message);
        err.println(message);
        return 1;
      }
@@ -429,7 +457,7 @@
        String message = getMessage(msgID,
                                    String.valueOf(configFile.getValue()),
                                    e.getMessage());
        System.err.println(message);
        err.println(message);
        return 1;
      }
    }
@@ -475,7 +503,7 @@
      {
        int    msgID   = MSGID_LDIFSEARCH_CANNOT_PARSE_FILTER;
        String message = getMessage(msgID, filterString, e.getMessage());
        System.err.println(message);
        err.println(message);
        return 1;
      }
    }
@@ -542,7 +570,7 @@
        {
          int    msgID   = MSGID_LDIFSEARCH_CANNOT_PARSE_BASE_DN;
          String message = getMessage(msgID, dnString, e.getMessage());
          System.err.println(message);
          err.println(message);
          return 1;
        }
      }
@@ -570,7 +598,7 @@
    {
      int    msgID   = MSGID_LDIFSEARCH_CANNOT_PARSE_TIME_LIMIT;
      String message = getMessage(msgID, String.valueOf(e));
      System.err.println(message);
      err.println(message);
      return 1;
    }
@@ -592,7 +620,7 @@
    {
      int    msgID   = MSGID_LDIFSEARCH_CANNOT_PARSE_SIZE_LIMIT;
      String message = getMessage(msgID, String.valueOf(e));
      System.err.println(message);
      err.println(message);
      return 1;
    }
@@ -628,7 +656,7 @@
    }
    else
    {
      exportConfig = new LDIFExportConfig(System.out);
      exportConfig = new LDIFExportConfig(out);
    }
    exportConfig.setIncludeObjectClasses(includeObjectclassAttrs);
@@ -653,7 +681,7 @@
    {
      int    msgID   = MSGID_LDIFSEARCH_CANNOT_CREATE_READER;
      String message = getMessage(msgID, String.valueOf(e));
      System.err.println(message);
      err.println(message);
      return 1;
    }
@@ -670,7 +698,7 @@
      int    msgID   = MSGID_LDIFSEARCH_CANNOT_CREATE_WRITER;
      String message = getMessage(msgID, String.valueOf(e));
      System.err.println(message);
      err.println(message);
      return 1;
    }
@@ -689,7 +717,7 @@
        int    msgID   = MSGID_LDIFSEARCH_TIME_LIMIT_EXCEEDED;
        String message = getMessage(msgID);
        System.err.println(message);
        err.println(message);
        break;
      }
@@ -777,7 +805,7 @@
          int    msgID   = MSGID_LDIFSEARCH_SIZE_LIMIT_EXCEEDED;
          String message = getMessage(msgID);
          System.err.println(message);
          err.println(message);
          break;
        }
      }
@@ -787,13 +815,13 @@
        {
          int    msgID   = MSGID_LDIFSEARCH_CANNOT_READ_ENTRY_RECOVERABLE;
          String message = getMessage(msgID, le.getMessage());
          System.err.println(message);
          err.println(message);
        }
        else
        {
          int    msgID   = MSGID_LDIFSEARCH_CANNOT_READ_ENTRY_FATAL;
          String message = getMessage(msgID, le.getMessage());
          System.err.println(message);
          err.println(message);
          resultCode = LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR;
          break;
        }
@@ -802,7 +830,7 @@
      {
        int    msgID   = MSGID_LDIFSEARCH_ERROR_DURING_PROCESSING;
        String message = getMessage(msgID, String.valueOf(e));
        System.err.println(message);
        err.println(message);
        resultCode = LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR;
        break;
      }
@@ -825,4 +853,3 @@
  }
}
opends/src/server/org/opends/server/tools/RebuildIndex.java
@@ -52,6 +52,8 @@
import org.opends.server.backends.jeb.RebuildConfig;
import org.opends.server.admin.std.server.BackendCfg;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
@@ -73,7 +75,7 @@
   */
  public static void main(String[] args)
  {
    int retCode = mainRebuildIndex(args);
    int retCode = mainRebuildIndex(args, true, System.out, System.err);
    if(errorLogPublisher != null)
    {
@@ -89,12 +91,40 @@
  /**
   * Processes the command-line arguments and invokes the rebuild process.
   *
   * @param  args  The command-line arguments provided to this program.
   * @param  args              The command-line arguments provided to this
   *                           program.
   * @param  initializeServer  Indicates whether to initialize the server.
   * @param  outStream         The output stream to use for standard output, or
   *                           {@code null} if standard output is not needed.
   * @param  errStream         The output stream to use for standard error, or
   *                           {@code null} if standard error is not needed.
   *
   * @return The error code.
   */
  public static int mainRebuildIndex(String[] args)
  public static int mainRebuildIndex(String[] args, boolean initializeServer,
                                     OutputStream outStream,
                                     OutputStream errStream)
  {
    PrintStream out;
    if (outStream == null)
    {
      out = NullOutputStream.printStream();
    }
    else
    {
      out = new PrintStream(outStream);
    }
    PrintStream err;
    if (errStream == null)
    {
      err = NullOutputStream.printStream();
    }
    else
    {
      err = new PrintStream(errStream);
    }
    // Define the command-line arguments that may be used with this program.
    StringArgument  configClass             = null;
    StringArgument  configFile              = null;
@@ -157,7 +187,7 @@
      int    msgID   = MSGID_CANNOT_INITIALIZE_ARGS;
      String message = getMessage(msgID, ae.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
@@ -172,8 +202,8 @@
      int    msgID   = MSGID_ERROR_PARSING_ARGS;
      String message = getMessage(msgID, ae.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      System.err.println(argParser.getUsage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      err.println(argParser.getUsage());
      return 1;
    }
@@ -192,7 +222,7 @@
    int numArgs = args.length;
    if (numArgs == 0)
    {
      System.out.println(argParser.getUsage());
      out.println(argParser.getUsage());
      return 1;
    }
@@ -202,8 +232,8 @@
      int    msgID   = MSGID_REBUILDINDEX_REQUIRES_AT_LEAST_ONE_INDEX;
      String message = getMessage(msgID);
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      System.out.println(argParser.getUsage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      out.println(argParser.getUsage());
      return 1;
    }
@@ -211,141 +241,144 @@
    // configuration.
    DirectoryServer directoryServer = DirectoryServer.getInstance();
    try
    if (initializeServer)
    {
      DirectoryServer.bootstrapClient();
      DirectoryServer.initializeJMX();
    }
    catch (Exception e)
    {
      int    msgID   = MSGID_SERVER_BOOTSTRAP_ERROR;
      String message = getMessage(msgID, getExceptionMessage(e));
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
      try
      {
        DirectoryServer.bootstrapClient();
        DirectoryServer.initializeJMX();
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_SERVER_BOOTSTRAP_ERROR;
        String message = getMessage(msgID, getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
    try
    {
      directoryServer.initializeConfiguration(configClass.getValue(),
                                              configFile.getValue());
    }
    catch (InitializationException ie)
    {
      int    msgID   = MSGID_CANNOT_LOAD_CONFIG;
      String message = getMessage(msgID, ie.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
    catch (Exception e)
    {
      int    msgID   = MSGID_CANNOT_LOAD_CONFIG;
      String message = getMessage(msgID, getExceptionMessage(e));
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
      try
      {
        directoryServer.initializeConfiguration(configClass.getValue(),
                                                configFile.getValue());
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_CANNOT_LOAD_CONFIG;
        String message = getMessage(msgID, ie.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_LOAD_CONFIG;
        String message = getMessage(msgID, getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
    // Initialize the Directory Server schema elements.
    try
    {
      directoryServer.initializeSchema();
    }
    catch (ConfigException ce)
    {
      int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
      String message = getMessage(msgID, ce.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
    catch (InitializationException ie)
    {
      int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
      String message = getMessage(msgID, ie.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
    catch (Exception e)
    {
      int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
      String message = getMessage(msgID, getExceptionMessage(e));
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
      // Initialize the Directory Server schema elements.
      try
      {
        directoryServer.initializeSchema();
      }
      catch (ConfigException ce)
      {
        int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
        String message = getMessage(msgID, ce.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
        String message = getMessage(msgID, ie.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
        String message = getMessage(msgID, getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
    // Initialize the Directory Server core configuration.
    try
    {
      CoreConfigManager coreConfigManager = new CoreConfigManager();
      coreConfigManager.initializeCoreConfig();
    }
    catch (ConfigException ce)
    {
      int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
      String message = getMessage(msgID, ce.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
    catch (InitializationException ie)
    {
      int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
      String message = getMessage(msgID, ie.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
    catch (Exception e)
    {
      int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
      String message = getMessage(msgID, getExceptionMessage(e));
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
      // Initialize the Directory Server core configuration.
      try
      {
        CoreConfigManager coreConfigManager = new CoreConfigManager();
        coreConfigManager.initializeCoreConfig();
      }
      catch (ConfigException ce)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
        String message = getMessage(msgID, ce.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
        String message = getMessage(msgID, ie.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
        String message = getMessage(msgID, getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
    // Initialize the Directory Server crypto manager.
    try
    {
      directoryServer.initializeCryptoManager();
    }
    catch (ConfigException ce)
    {
      int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
      String message = getMessage(msgID, ce.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
    catch (InitializationException ie)
    {
      int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
      String message = getMessage(msgID, ie.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
    catch (Exception e)
    {
      int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
      String message = getMessage(msgID, getExceptionMessage(e));
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
      // Initialize the Directory Server crypto manager.
      try
      {
        directoryServer.initializeCryptoManager();
      }
      catch (ConfigException ce)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
        String message = getMessage(msgID, ce.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
        String message = getMessage(msgID, ie.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
        String message = getMessage(msgID, getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
    // FIXME -- Install a custom logger to capture information about the state
    // of the verify process.
    try
    {
      errorLogPublisher =
          new ThreadFilterTextErrorLogPublisher(Thread.currentThread(),
                                                new TextWriter.STDOUT());
      ErrorLogger.addErrorLogPublisher(errorLogPublisher);
      // FIXME -- Install a custom logger to capture information about the state
      // of the verify process.
      try
      {
        errorLogPublisher =
            new ThreadFilterTextErrorLogPublisher(Thread.currentThread(),
                                                  new TextWriter.STREAM(out));
        ErrorLogger.addErrorLogPublisher(errorLogPublisher);
    }
    catch(Exception e)
    {
      System.err.println("Error installing the custom error logger: " +
                         stackTraceToSingleLineString(e));
      }
      catch(Exception e)
      {
        err.println("Error installing the custom error logger: " +
                    stackTraceToSingleLineString(e));
      }
    }
    // Decode the base DN provided by the user.
opends/src/server/org/opends/server/tools/RestoreDB.java
@@ -28,6 +28,8 @@
import java.io.OutputStream;
import java.io.PrintStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -52,6 +54,7 @@
import org.opends.server.types.ErrorLogCategory;
import org.opends.server.types.ErrorLogSeverity;
import org.opends.server.types.InitializationException;
import org.opends.server.types.NullOutputStream;
import org.opends.server.types.RestoreConfig;
import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.ArgumentParser;
@@ -84,7 +87,7 @@
  public static void main(String[] args)
  {
    int retCode = mainRestoreDB(args);
    int retCode = mainRestoreDB(args, true, System.out, System.err);
    if(errorLogPublisher != null)
    {
@@ -106,7 +109,7 @@
   */
  public static int mainRestoreDB(String[] args)
  {
    return mainRestoreDB(args, true);
    return mainRestoreDB(args, true, System.out, System.err);
  }
  /**
@@ -115,11 +118,37 @@
   * @param  args              The command-line arguments provided to this
   *                           program.
   * @param  initializeServer  Indicates whether to initialize the server.
   * @param  outStream         The output stream to use for standard output, or
   *                           {@code null} if standard output is not needed.
   * @param  errStream         The output stream to use for standard error, or
   *                           {@code null} if standard error is not needed.
   *
   * @return The error code.
   */
  public static int mainRestoreDB(String[] args, boolean initializeServer)
  public static int mainRestoreDB(String[] args, boolean initializeServer,
                                  OutputStream outStream,
                                  OutputStream errStream)
  {
    PrintStream out;
    if (outStream == null)
    {
      out = NullOutputStream.printStream();
    }
    else
    {
      out = new PrintStream(outStream);
    }
    PrintStream err;
    if (errStream == null)
    {
      err = NullOutputStream.printStream();
    }
    else
    {
      err = new PrintStream(errStream);
    }
    // Define the command-line arguments that may be used with this program.
    BooleanArgument displayUsage      = null;
    BooleanArgument listBackups          = null;
@@ -195,7 +224,7 @@
      int    msgID   = MSGID_CANNOT_INITIALIZE_ARGS;
      String message = getMessage(msgID, ae.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
@@ -210,8 +239,8 @@
      int    msgID   = MSGID_ERROR_PARSING_ARGS;
      String message = getMessage(msgID, ae.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      System.err.println(argParser.getUsage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      err.println(argParser.getUsage());
      return 1;
    }
@@ -238,7 +267,7 @@
      {
        int    msgID   = MSGID_SERVER_BOOTSTRAP_ERROR;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
@@ -251,14 +280,14 @@
      {
        int    msgID   = MSGID_CANNOT_LOAD_CONFIG;
        String message = getMessage(msgID, ie.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_LOAD_CONFIG;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
@@ -273,21 +302,21 @@
      {
        int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
        String message = getMessage(msgID, ce.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
        String message = getMessage(msgID, ie.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
@@ -302,21 +331,21 @@
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
        String message = getMessage(msgID, ce.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
        String message = getMessage(msgID, ie.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
@@ -330,21 +359,21 @@
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
        String message = getMessage(msgID, ce.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
        String message = getMessage(msgID, ie.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
        String message = getMessage(msgID, getExceptionMessage(e));
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
@@ -355,14 +384,14 @@
      {
        errorLogPublisher =
            new ThreadFilterTextErrorLogPublisher(Thread.currentThread(),
                                                  new TextWriter.STDOUT());
                                                  new TextWriter.STREAM(out));
        ErrorLogger.addErrorLogPublisher(errorLogPublisher);
      }
      catch(Exception e)
      {
        System.err.println("Error installing the custom error logger: " +
                           stackTraceToSingleLineString(e));
        err.println("Error installing the custom error logger: " +
                    stackTraceToSingleLineString(e));
      }
    }
@@ -393,34 +422,34 @@
      {
        int    msgID   = MSGID_RESTOREDB_LIST_BACKUP_ID;
        String message = getMessage(msgID, backupInfo.getBackupID());
        System.out.println(message);
        out.println(message);
        msgID   = MSGID_RESTOREDB_LIST_BACKUP_DATE;
        message = getMessage(msgID,
                             dateFormat.format(backupInfo.getBackupDate()));
        System.out.println(message);
        out.println(message);
        msgID   = MSGID_RESTOREDB_LIST_INCREMENTAL;
        message = getMessage(msgID, String.valueOf(backupInfo.isIncremental()));
        System.out.println(message);
        out.println(message);
        msgID   = MSGID_RESTOREDB_LIST_COMPRESSED;
        message = getMessage(msgID, String.valueOf(backupInfo.isCompressed()));
        System.out.println(message);
        out.println(message);
        msgID   = MSGID_RESTOREDB_LIST_ENCRYPTED;
        message = getMessage(msgID, String.valueOf(backupInfo.isEncrypted()));
        System.out.println(message);
        out.println(message);
        byte[] hash = backupInfo.getUnsignedHash();
        msgID   = MSGID_RESTOREDB_LIST_HASHED;
        message = getMessage(msgID, String.valueOf(hash != null));
        System.out.println(message);
        out.println(message);
        byte[] signature = backupInfo.getSignedHash();
        msgID   = MSGID_RESTOREDB_LIST_SIGNED;
        message = getMessage(msgID, String.valueOf(signature != null));
        System.out.println(message);
        out.println(message);
        StringBuilder dependencyList = new StringBuilder();
        HashSet<String> dependencyIDs = backupInfo.getDependencies();
@@ -442,9 +471,9 @@
        msgID   = MSGID_RESTOREDB_LIST_DEPENDENCIES;
        message = getMessage(msgID, dependencyList.toString());
        System.out.println(message);
        out.println(message);
        System.out.println();
        out.println();
      }
      return 1;
opends/src/server/org/opends/server/tools/VerifyIndex.java
@@ -45,11 +45,14 @@
import org.opends.server.types.ErrorLogCategory;
import org.opends.server.types.ErrorLogSeverity;
import org.opends.server.types.InitializationException;
import org.opends.server.types.NullOutputStream;
import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.ArgumentParser;
import org.opends.server.util.args.BooleanArgument;
import org.opends.server.util.args.StringArgument;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;
@@ -78,7 +81,7 @@
   */
  public static void main(String[] args)
  {
    int retCode = mainVerifyIndex(args);
    int retCode = mainVerifyIndex(args, true, System.out, System.err);
    if(errorLogPublisher != null)
    {
@@ -94,11 +97,40 @@
  /**
   * Processes the command-line arguments and invokes the verify process.
   *
   * @param  args  The command-line arguments provided to this program.
   * @param  args              The command-line arguments provided to this
   *                           program.
   * @param  initializeServer  Indicates whether to initialize the server.
   * @param  outStream         The output stream to use for standard output, or
   *                           {@code null} if standard output is not needed.
   * @param  errStream         The output stream to use for standard error, or
   *                           {@code null} if standard error is not needed.
   *
   * @return The error code.
   */
  public static int mainVerifyIndex(String[] args)
  public static int mainVerifyIndex(String[] args, boolean initializeServer,
                                    OutputStream outStream,
                                    OutputStream errStream)
  {
    PrintStream out;
    if (outStream == null)
    {
      out = NullOutputStream.printStream();
    }
    else
    {
      out = new PrintStream(outStream);
    }
    PrintStream err;
    if (errStream == null)
    {
      err = NullOutputStream.printStream();
    }
    else
    {
      err = new PrintStream(errStream);
    }
    // Define the command-line arguments that may be used with this program.
    StringArgument  configClass             = null;
    StringArgument  configFile              = null;
@@ -169,7 +201,7 @@
      int    msgID   = MSGID_CANNOT_INITIALIZE_ARGS;
      String message = getMessage(msgID, ae.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
@@ -184,8 +216,8 @@
      int    msgID   = MSGID_ERROR_PARSING_ARGS;
      String message = getMessage(msgID, ae.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      System.err.println(argParser.getUsage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      err.println(argParser.getUsage());
      return 1;
    }
@@ -204,7 +236,7 @@
    int numArgs = args.length;
    if (numArgs == 0)
    {
      System.out.println(argParser.getUsage());
      out.println(argParser.getUsage());
      return 1;
    }
@@ -214,8 +246,8 @@
      int    msgID   = MSGID_VERIFYINDEX_VERIFY_CLEAN_REQUIRES_SINGLE_INDEX;
      String message = getMessage(msgID);
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      System.out.println(argParser.getUsage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      out.println(argParser.getUsage());
      return 1;
    }
@@ -223,140 +255,143 @@
    // configuration.
    DirectoryServer directoryServer = DirectoryServer.getInstance();
    try
    if (initializeServer)
    {
      DirectoryServer.bootstrapClient();
      DirectoryServer.initializeJMX();
    }
    catch (Exception e)
    {
      int    msgID   = MSGID_SERVER_BOOTSTRAP_ERROR;
      String message = getMessage(msgID, getExceptionMessage(e));
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
      try
      {
        DirectoryServer.bootstrapClient();
        DirectoryServer.initializeJMX();
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_SERVER_BOOTSTRAP_ERROR;
        String message = getMessage(msgID, getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
    try
    {
      directoryServer.initializeConfiguration(configClass.getValue(),
                                              configFile.getValue());
    }
    catch (InitializationException ie)
    {
      int    msgID   = MSGID_CANNOT_LOAD_CONFIG;
      String message = getMessage(msgID, ie.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
    catch (Exception e)
    {
      int    msgID   = MSGID_CANNOT_LOAD_CONFIG;
      String message = getMessage(msgID, getExceptionMessage(e));
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
      try
      {
        directoryServer.initializeConfiguration(configClass.getValue(),
                                                configFile.getValue());
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_CANNOT_LOAD_CONFIG;
        String message = getMessage(msgID, ie.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_LOAD_CONFIG;
        String message = getMessage(msgID, getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
    // Initialize the Directory Server schema elements.
    try
    {
      directoryServer.initializeSchema();
    }
    catch (ConfigException ce)
    {
      int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
      String message = getMessage(msgID, ce.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
    catch (InitializationException ie)
    {
      int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
      String message = getMessage(msgID, ie.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
    catch (Exception e)
    {
      int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
      String message = getMessage(msgID, getExceptionMessage(e));
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
      // Initialize the Directory Server schema elements.
      try
      {
        directoryServer.initializeSchema();
      }
      catch (ConfigException ce)
      {
        int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
        String message = getMessage(msgID, ce.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
        String message = getMessage(msgID, ie.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_LOAD_SCHEMA;
        String message = getMessage(msgID, getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
    // Initialize the Directory Server core configuration.
    try
    {
      CoreConfigManager coreConfigManager = new CoreConfigManager();
      coreConfigManager.initializeCoreConfig();
    }
    catch (ConfigException ce)
    {
      int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
      String message = getMessage(msgID, ce.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
    catch (InitializationException ie)
    {
      int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
      String message = getMessage(msgID, ie.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
    catch (Exception e)
    {
      int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
      String message = getMessage(msgID, getExceptionMessage(e));
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
      // Initialize the Directory Server core configuration.
      try
      {
        CoreConfigManager coreConfigManager = new CoreConfigManager();
        coreConfigManager.initializeCoreConfig();
      }
      catch (ConfigException ce)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
        String message = getMessage(msgID, ce.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
        String message = getMessage(msgID, ie.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CORE_CONFIG;
        String message = getMessage(msgID, getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
    // Initialize the Directory Server crypto manager.
    try
    {
      directoryServer.initializeCryptoManager();
    }
    catch (ConfigException ce)
    {
      int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
      String message = getMessage(msgID, ce.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
    catch (InitializationException ie)
    {
      int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
      String message = getMessage(msgID, ie.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
    catch (Exception e)
    {
      int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
      String message = getMessage(msgID, getExceptionMessage(e));
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
      // Initialize the Directory Server crypto manager.
      try
      {
        directoryServer.initializeCryptoManager();
      }
      catch (ConfigException ce)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
        String message = getMessage(msgID, ce.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (InitializationException ie)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
        String message = getMessage(msgID, ie.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
      catch (Exception e)
      {
        int    msgID   = MSGID_CANNOT_INITIALIZE_CRYPTO_MANAGER;
        String message = getMessage(msgID, getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return 1;
      }
    // FIXME -- Install a custom logger to capture information about the state
    // of the verify process.
    try
    {
      errorLogPublisher =
          new ThreadFilterTextErrorLogPublisher(Thread.currentThread(),
                                                new TextWriter.STDOUT());
      ErrorLogger.addErrorLogPublisher(errorLogPublisher);
      // FIXME -- Install a custom logger to capture information about the state
      // of the verify process.
      try
      {
        errorLogPublisher =
            new ThreadFilterTextErrorLogPublisher(Thread.currentThread(),
                                                  new TextWriter.STREAM(out));
        ErrorLogger.addErrorLogPublisher(errorLogPublisher);
    }
    catch(Exception e)
    {
      System.err.println("Error installing the custom error logger: " +
                         stackTraceToSingleLineString(e));
      }
      catch(Exception e)
      {
        err.println("Error installing the custom error logger: " +
                    stackTraceToSingleLineString(e));
      }
    }
opends/tests/unit-tests-testng/src/server/org/opends/server/authorization/dseecompat/AciTests.java
@@ -2281,7 +2281,7 @@
      "--outputLDIF", diffLdifFile.getAbsolutePath()
    };
    int retVal = LDIFDiff.mainDiff(args, true);
    int retVal = LDIFDiff.mainDiff(args, true, System.out, System.err);
    assertEquals(retVal, 0, "LDIFDiff failed");
    if (diffLdifFile.exists()) {
opends/tests/unit-tests-testng/src/server/org/opends/server/tools/ImportLDIFTestCase.java
@@ -119,7 +119,7 @@
      "-n", beID,
      "-i", "+"
    };
    assertEquals(ImportLDIF.mainImportLDIF(args,false), 0);
    assertEquals(ImportLDIF.mainImportLDIF(args,false,System.out,System.err),0);
    //Expecting a non-empty reject file.
    assertRejectedFile(reject,false);
  }
@@ -146,7 +146,7 @@
      "-n", beID,
      "-i", "*"
    };
    assertEquals(ImportLDIF.mainImportLDIF(args,false), 0);
    assertEquals(ImportLDIF.mainImportLDIF(args,false,System.out,System.err),0);
    //Expecting an empty reject file.
    assertRejectedFile(reject,true);
@@ -181,7 +181,7 @@
      "-n", beID,
      "-R", rejectFilePath
    };
    assertEquals(ImportLDIF.mainImportLDIF(args,false),0);
    assertEquals(ImportLDIF.mainImportLDIF(args,false,System.out,System.err),0);
    //Reject file should be empty.
    assertRejectedFile(reject,true);
    //check the presence of some random attributes.
@@ -221,7 +221,7 @@
      "-e", "description"
    };
    assertEquals(ImportLDIF.mainImportLDIF(args,false), 0);
    assertEquals(ImportLDIF.mainImportLDIF(args,false,System.out,System.err),0);
    assertRejectedFile(reject,true);
    Attribute[] attr =
     {
@@ -252,7 +252,7 @@
      "-e", "*"
    };
    assertEquals(ImportLDIF.mainImportLDIF(args,false), 0);
    assertEquals(ImportLDIF.mainImportLDIF(args,false,System.out,System.err),0);
    assertRejectedFile(reject,false);
  }
@@ -277,7 +277,7 @@
      "-R",rejectFilePath,
      "-e", "+"
    };
    assertEquals(ImportLDIF.mainImportLDIF(args,false), 0);
    assertEquals(ImportLDIF.mainImportLDIF(args,false,System.out,System.err),0);
    assertRejectedFile(reject,true);
    Attribute[] attrs = {
       new Attribute ("creatorsname", "cn=Import") ,
@@ -309,7 +309,7 @@
      "-i", "*",
      "-i","creatorsname"
    };
    assertEquals(ImportLDIF.mainImportLDIF(args,false), 0);
    assertEquals(ImportLDIF.mainImportLDIF(args,false,System.out,System.err),0);
    assertRejectedFile(reject,true);
    Attribute[] attrs = {
       new Attribute ("creatorsname", "cn=Import")
@@ -343,7 +343,7 @@
      "-i", "sn",
      "-i","creatorsname"
    };
    assertEquals(ImportLDIF.mainImportLDIF(args,false), 0);
    assertEquals(ImportLDIF.mainImportLDIF(args,false,System.out,System.err),0);
    assertRejectedFile(reject,true);
    Attribute[] attrsPr = {
       new Attribute ("creatorsname", "cn=Import")
@@ -379,7 +379,7 @@
      "-e", "givenName",
      "-e","creatorsname"
    };
    assertEquals(ImportLDIF.mainImportLDIF(args,false), 0);
    assertEquals(ImportLDIF.mainImportLDIF(args,false,System.out,System.err),0);
    assertRejectedFile(reject,true);
    Attribute[] attrsPr = {
       new Attribute ("modifiersname", "cn=Import"),
opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDIFDiffTestCase.java
@@ -86,13 +86,13 @@
  public void testUsage()
  {
    String[] args = { "--help" };
    assertEquals(LDIFDiff.mainDiff(args, true), 0);
    assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0);
    args = new String[] { "-H" };
    assertEquals(LDIFDiff.mainDiff(args, true), 0);
    assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0);
    args = new String[] { "-?" };
    assertEquals(LDIFDiff.mainDiff(args, true), 0);
    assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0);
  }
@@ -108,7 +108,7 @@
      "--invalid"
    };
    assertFalse(LDIFDiff.mainDiff(args, true) == 0);
    assertFalse(LDIFDiff.mainDiff(args, true, System.out, System.err) == 0);
  }
@@ -279,12 +279,12 @@
    if (normalDiffFile == null)
    {
      // We expect this to fail, so just make sure that it does.
      assertFalse(LDIFDiff.mainDiff(args, true) == 0);
      assertFalse(LDIFDiff.mainDiff(args, true, System.out, System.err) == 0);
      outputFile.delete();
      return;
    }
    assertEquals(LDIFDiff.mainDiff(args, true), 0);
    assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0);
    long outputChecksum = 0L;
    BufferedReader reader = new BufferedReader(new FileReader(outputFile));
@@ -358,12 +358,12 @@
    if (singleValueDiffFile == null)
    {
      // We expect this to fail, so just make sure that it does.
      assertFalse(LDIFDiff.mainDiff(args, true) == 0);
      assertFalse(LDIFDiff.mainDiff(args, true, System.out, System.err) == 0);
      outputFile.delete();
      return;
    }
    assertEquals(LDIFDiff.mainDiff(args, true), 0);
    assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0);
    long outputChecksum = 0L;
    BufferedReader reader = new BufferedReader(new FileReader(outputFile));
@@ -438,7 +438,7 @@
      "-o", diffOutputFile.getAbsolutePath()
    };
    assertEquals(LDIFDiff.mainDiff(args, true), 0);
    assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0);
    // Use LDIFModify to generate a new target file.
@@ -453,7 +453,8 @@
      "-t", newTargetFile.getAbsolutePath()
    };
    assertEquals(LDIFModify.ldifModifyMain(args, true), 0);
    assertEquals(LDIFModify.ldifModifyMain(args, true, System.out, System.err),
                 0);
    // Use LDIFDiff again to verify that there are effectively no differences
@@ -468,7 +469,7 @@
      "-o", newDiffFile.getAbsolutePath()
    };
    assertEquals(LDIFDiff.mainDiff(args, true), 0);
    assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0);
    // Read the contents of the new diff file and make sure it matches the
@@ -549,7 +550,7 @@
      "-S"
    };
    assertEquals(LDIFDiff.mainDiff(args, true), 0);
    assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0);
    // Use LDIFModify to generate a new target file.
@@ -564,7 +565,8 @@
      "-t", newTargetFile.getAbsolutePath()
    };
    assertEquals(LDIFModify.ldifModifyMain(args, true), 0);
    assertEquals(LDIFModify.ldifModifyMain(args, true, System.out, System.err),
                 0);
    // Use LDIFDiff again to verify that there are effectively no differences
@@ -579,7 +581,7 @@
      "-o", newDiffFile.getAbsolutePath()
    };
    assertEquals(LDIFDiff.mainDiff(args, true), 0);
    assertEquals(LDIFDiff.mainDiff(args, true, System.out, System.err), 0);
    // Read the contents of the new diff file and make sure it matches the
opends/tests/unit-tests-testng/src/server/org/opends/server/tools/LDIFSearchTestCase.java
@@ -119,7 +119,7 @@
      "(objectclass=*)",
      "*", "+"
    };
    assertEquals(LDIFSearch.mainSearch(args, false), 0);
    assertEquals(LDIFSearch.mainSearch(args, false, System.out, System.err), 0);
    LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath);
    ldifConfig.setValidateSchema(false);
    LDIFReader reader = new LDIFReader(ldifConfig);
@@ -145,7 +145,7 @@
      "(objectclass=*)",
      "+"
    };
    assertEquals(LDIFSearch.mainSearch(args, false), 0);
    assertEquals(LDIFSearch.mainSearch(args, false, System.out, System.err), 0);
    LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath);
    ldifConfig.setValidateSchema(false);
    LDIFReader reader = new LDIFReader(ldifConfig);
@@ -172,7 +172,7 @@
      "(objectclass=*)",
      "+", "mail", "uid"
    };
    assertEquals(LDIFSearch.mainSearch(args, false), 0);
    assertEquals(LDIFSearch.mainSearch(args, false, System.out, System.err), 0);
    LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath);
    ldifConfig.setValidateSchema(false);
    LDIFReader reader = new LDIFReader(ldifConfig);
@@ -203,7 +203,7 @@
      "(objectclass=*)",
      "mail", "uid"
    };
    assertEquals(LDIFSearch.mainSearch(args, false), 0);
    assertEquals(LDIFSearch.mainSearch(args, false, System.out, System.err), 0);
    LDIFImportConfig ldifConfig = new LDIFImportConfig(outLdifFilePath);
    ldifConfig.setValidateSchema(false);
    LDIFReader reader = new LDIFReader(ldifConfig);