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

Gaetan Boismal
17.29.2015 4e4b322332130bf466e3bdbd9cd7c4ca832d1049
OPENDJ-2027 (CR-7617) Code cleanup

Factorize code for tools message printing.
* opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java
** Introduce handly methods to print a message/string on a stream.
* Other files uses the methods described above.
32 files modified
1895 ■■■■■ changed files
opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java 27 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/admin/client/cli/SecureConnectionCliParser.java 5 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/DBTest.java 160 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/BackUpDB.java 88 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/ConfigureDS.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/ConfigureWindowsService.java 94 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/CreateRCScript.java 17 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/EncodePassword.java 151 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java 54 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java 83 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPCompare.java 67 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPDelete.java 36 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPModify.java 63 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPPasswordModify.java 138 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPSearch.java 111 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPSearchOptions.java 14 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPToolUtils.java 19 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFDiff.java 32 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFModify.java 51 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFSearch.java 46 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/ListBackends.java 53 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/ManageAccount.java 129 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java 51 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/RestoreDB.java 47 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/StartWindowsService.java 17 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/StopDS.java 112 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/StopWindowsService.java 17 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/VerifyIndex.java 80 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/MakeLDIF.java 47 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskTool.java 72 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/util/args/LDAPConnectionArgumentParser.java 8 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/messages/org/opends/messages/tool.properties 2 ●●●●● patch | view | raw | blame | history
opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java
@@ -35,6 +35,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.security.GeneralSecurityException;
@@ -612,4 +613,30 @@
        }
        return host;
    }
    /**
     * Prints the provided string on the provided stream.
     *
     * @param stream
     *            The stream to print the message.
     * @param message
     *            The message to print.
     */
    public static void printWrappedText(final PrintStream stream, final String message) {
        if (stream != null && message != null) {
            stream.println(wrapText(message, MAX_LINE_WIDTH));
        }
    }
    /**
     * Print the provided message on the provided stream.
     *
     * @param stream
     *            The stream to print the message.
     * @param message
     *            The message to print.
     */
    public static void printWrappedText(final PrintStream stream, final LocalizableMessage message) {
        printWrappedText(stream, message != null ? message.toString() : null);
    }
}
opendj-server-legacy/src/main/java/org/opends/server/admin/client/cli/SecureConnectionCliParser.java
@@ -356,10 +356,7 @@
  {
    LocalizableMessageBuilder buf = new LocalizableMessageBuilder();
    int returnValue = validateGlobalOptions(buf);
    if (buf.length() > 0)
    {
      err.println(wrapText(buf.toString(), MAX_LINE_WIDTH));
    }
    printWrappedText(err, buf.toString());
    return returnValue;
  }
opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/DBTest.java
@@ -26,11 +26,12 @@
 */
package org.opends.server.backends.jeb;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.util.StaticUtils.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import java.io.OutputStream;
import java.io.PrintStream;
import java.text.ParseException;
@@ -185,15 +186,6 @@
    this.parser.setVersionHandler(new DirectoryServerVersionHandler());
  }
  /** Displays the provided message followed by a help usage reference. */
  private void displayMessageAndUsageReference(LocalizableMessage message) {
    printErrorMessage(message);
    printErrorMessage(LocalizableMessage.EMPTY);
    printErrorMessage(parser.getHelpUsageReference());
  }
  /**
   * Registers the global arguments with the argument parser.
   *
@@ -377,8 +369,7 @@
      initializeGlobalArguments();
      initializeSubCommands();
    } catch (ArgumentException e) {
      LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(e.getMessage());
      printErrorMessage(message);
      printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(e.getMessage()));
      return 1;
    }
@@ -386,8 +377,8 @@
    try {
      parser.parseArguments(args);
    } catch (ArgumentException ae) {
      LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
      displayMessageAndUsageReference(message);
      printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      err.println(parser.getUsage());
      return 1;
    }
@@ -404,7 +395,7 @@
    }
    catch (InitializationException e)
    {
      printErrorMessage(e.getMessageObject());
      printWrappedText(err, e.getMessageObject());
      return 1;
    }
@@ -421,9 +412,7 @@
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_SERVER_BOOTSTRAP_ERROR.get(
                getExceptionMessage(e));
        printErrorMessage(message);
        printWrappedText(err, ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e)));
        return 1;
      }
@@ -434,16 +423,12 @@
      }
      catch (InitializationException ie)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(
            ie.getMessage());
        printErrorMessage(message);
        printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(
            getExceptionMessage(e));
        printErrorMessage(message);
        printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e)));
        return 1;
      }
@@ -456,14 +441,12 @@
      }
      catch (ConfigException | InitializationException e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage());
        printErrorMessage(message);
        printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e));
        printErrorMessage(message);
        printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e)));
        return 1;
      }
@@ -477,14 +460,12 @@
      }
      catch (ConfigException | InitializationException e)
      {
        LocalizableMessage message = ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage());
        printErrorMessage(message);
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getExceptionMessage(e));
        printErrorMessage(message);
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getExceptionMessage(e)));
        return 1;
      }
@@ -496,14 +477,12 @@
      }
      catch (ConfigException | InitializationException e)
      {
        LocalizableMessage message = ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage());
        printErrorMessage(message);
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getExceptionMessage(e));
        printErrorMessage(message);
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getExceptionMessage(e)));
        return 1;
      }
    }
@@ -511,8 +490,8 @@
    // Make sure that we have a sub-command.
    if (parser.getSubCommand() == null)
    {
      LocalizableMessage message = ERR_DBTEST_MISSING_SUBCOMMAND.get();
      displayMessageAndUsageReference(message);
      printWrappedText(err, ERR_DBTEST_MISSING_SUBCOMMAND.get());
      err.println(parser.getUsage());
      return 1;
    }
@@ -551,7 +530,7 @@
      }
      return 0;
    } catch (Exception e) {
      printErrorMessage(LocalizableMessage.raw(StaticUtils.stackTraceToString(e)));
      printWrappedText(err, LocalizableMessage.raw(StaticUtils.stackTraceToString(e)));
      return 1;
    }
  }
@@ -598,13 +577,13 @@
      StringBuilder failureReason = new StringBuilder();
      if (! LockFileManager.acquireSharedLock(lockFile, failureReason))
      {
        printErrorMessage(ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), failureReason));
        printWrappedText(err, ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), failureReason));
        return 1;
      }
    }
    catch (Exception e)
    {
      printErrorMessage(ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e)));
      printWrappedText(err, ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e)));
      return 1;
    }
@@ -615,9 +594,8 @@
    }
    catch(Exception e)
    {
      printErrorMessage(ERR_DBTEST_ERROR_INITIALIZING_BACKEND.get(
          backend.getBackendID(),
          StaticUtils.stackTraceToSingleLineString(e)));
      printWrappedText(
          err, ERR_DBTEST_ERROR_INITIALIZING_BACKEND.get(backend.getBackendID(), stackTraceToSingleLineString(e)));
      return 1;
    }
@@ -648,8 +626,7 @@
    }
    catch(DatabaseException de)
    {
      printErrorMessage(ERR_DBTEST_ERROR_READING_DATABASE.get(
          StaticUtils.stackTraceToSingleLineString(de)));
      printWrappedText(err, ERR_DBTEST_ERROR_READING_DATABASE.get(stackTraceToSingleLineString(de)));
      return 1;
    }
    finally
@@ -676,8 +653,7 @@
      }
      catch(DirectoryException de)
      {
        printErrorMessage(ERR_DBTEST_DECODE_BASE_DN.get(baseDN.getValue(),
                                                   getExceptionMessage(de)));
        printWrappedText(err, ERR_DBTEST_DECODE_BASE_DN.get(baseDN.getValue(), getExceptionMessage(de)));
        return 1;
      }
    }
@@ -689,13 +665,13 @@
      StringBuilder failureReason = new StringBuilder();
      if (! LockFileManager.acquireSharedLock(lockFile, failureReason))
      {
        printErrorMessage(ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), failureReason));
        printWrappedText(err, ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), failureReason));
        return 1;
      }
    }
    catch (Exception e)
    {
      printErrorMessage(ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e)));
      printWrappedText(err, ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e)));
      return 1;
    }
@@ -706,9 +682,8 @@
    }
    catch(Exception e)
    {
      printErrorMessage(ERR_DBTEST_ERROR_INITIALIZING_BACKEND.get(
          backend.getBackendID(),
          StaticUtils.stackTraceToSingleLineString(e)));
      printWrappedText(
          err, ERR_DBTEST_ERROR_INITIALIZING_BACKEND.get(backend.getBackendID(), stackTraceToSingleLineString(e)));
      return 1;
    }
@@ -729,8 +704,7 @@
        EntryContainer ec = rc.getEntryContainer(base);
        if(ec == null)
        {
          printErrorMessage(ERR_DBTEST_NO_ENTRY_CONTAINERS_FOR_BASE_DN.get(
              base, backend.getBackendID()));
          printWrappedText(err, ERR_DBTEST_NO_ENTRY_CONTAINERS_FOR_BASE_DN.get(base, backend.getBackendID()));
          return 1;
        }
@@ -754,8 +728,7 @@
    }
    catch(DatabaseException de)
    {
      printErrorMessage(ERR_DBTEST_ERROR_READING_DATABASE.get(
          StaticUtils.stackTraceToSingleLineString(de)));
      printWrappedText(err, ERR_DBTEST_ERROR_READING_DATABASE.get(stackTraceToSingleLineString(de)));
      return 1;
    }
    finally
@@ -802,12 +775,12 @@
      StringBuilder failureReason = new StringBuilder();
      if (!LockFileManager.releaseLock(lockFile, failureReason))
      {
        printErrorMessage(WARN_DBTEST_CANNOT_UNLOCK_BACKEND.get(backend.getBackendID(), failureReason));
        printWrappedText(err, WARN_DBTEST_CANNOT_UNLOCK_BACKEND.get(backend.getBackendID(), failureReason));
      }
    }
    catch (Exception e)
    {
      printErrorMessage(WARN_DBTEST_CANNOT_UNLOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e)));
      printWrappedText(err, WARN_DBTEST_CANNOT_UNLOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e)));
    }
  }
@@ -829,12 +802,11 @@
    {
      if (b.getBackendID().equalsIgnoreCase(backendID))
      {
        printErrorMessage(ERR_DBTEST_NOT_JE_BACKEND.get(backendID));
        printWrappedText(err, ERR_DBTEST_NOT_JE_BACKEND.get(backendID));
        return null;
      }
    }
    printErrorMessage(ERR_DBTEST_NO_BACKENDS_FOR_ID.get(backendID));
    printWrappedText(err, ERR_DBTEST_NO_BACKENDS_FOR_ID.get(backendID));
    return null;
  }
@@ -855,8 +827,7 @@
      }
      catch(DirectoryException de)
      {
        printErrorMessage(ERR_DBTEST_DECODE_BASE_DN.get(baseDN.getValue(),
                                                   getExceptionMessage(de)));
        printWrappedText(err, ERR_DBTEST_DECODE_BASE_DN.get(baseDN.getValue(), getExceptionMessage(de)));
        return 1;
      }
    }
@@ -868,13 +839,13 @@
      StringBuilder failureReason = new StringBuilder();
      if (! LockFileManager.acquireSharedLock(lockFile, failureReason))
      {
        printErrorMessage(ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), failureReason));
        printWrappedText(err, ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), failureReason));
        return 1;
      }
    }
    catch (Exception e)
    {
      printErrorMessage(ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e)));
      printWrappedText(err, ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e)));
      return 1;
    }
@@ -885,9 +856,8 @@
    }
    catch(Exception e)
    {
      printErrorMessage(ERR_DBTEST_ERROR_INITIALIZING_BACKEND.get(
          backend.getBackendID(),
          StaticUtils.stackTraceToSingleLineString(e)));
      printWrappedText(
          err, ERR_DBTEST_ERROR_INITIALIZING_BACKEND.get(backend.getBackendID(), stackTraceToSingleLineString(e)));
      return 1;
    }
@@ -913,7 +883,7 @@
      EntryContainer ec = rc.getEntryContainer(base);
      if(ec == null)
      {
        printErrorMessage(ERR_DBTEST_NO_ENTRY_CONTAINERS_FOR_BASE_DN.get(base, backend.getBackendID()));
        printWrappedText(err, ERR_DBTEST_NO_ENTRY_CONTAINERS_FOR_BASE_DN.get(base, backend.getBackendID()));
        return 1;
      }
@@ -1026,8 +996,7 @@
    }
    catch(DatabaseException de)
    {
      printErrorMessage(ERR_DBTEST_ERROR_READING_DATABASE.get(
          StaticUtils.stackTraceToSingleLineString(de)));
      printWrappedText(err, ERR_DBTEST_ERROR_READING_DATABASE.get(stackTraceToSingleLineString(de)));
      return 1;
    }
    finally
@@ -1056,8 +1025,7 @@
    }
    catch(DirectoryException de)
    {
      printErrorMessage(ERR_DBTEST_DECODE_BASE_DN.get(baseDN.getValue(),
                                                 getExceptionMessage(de)));
      printWrappedText(err, ERR_DBTEST_DECODE_BASE_DN.get(baseDN.getValue(), getExceptionMessage(de)));
      return 1;
    }
@@ -1068,13 +1036,13 @@
      StringBuilder failureReason = new StringBuilder();
      if (! LockFileManager.acquireSharedLock(lockFile, failureReason))
      {
        printErrorMessage(ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), failureReason));
        printWrappedText(err, ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), failureReason));
        return 1;
      }
    }
    catch (Exception e)
    {
      printErrorMessage(ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e)));
      printWrappedText(err, ERR_DBTEST_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e)));
      return 1;
    }
@@ -1085,9 +1053,8 @@
    }
    catch(Exception e)
    {
      printErrorMessage(ERR_DBTEST_ERROR_INITIALIZING_BACKEND.get(
          backend.getBackendID(),
          StaticUtils.stackTraceToSingleLineString(e)));
      printWrappedText(
          err, ERR_DBTEST_ERROR_INITIALIZING_BACKEND.get(backend.getBackendID(), stackTraceToSingleLineString(e)));
      return 1;
    }
@@ -1096,7 +1063,7 @@
      EntryContainer ec = rc.getEntryContainer(base);
      if(ec == null)
      {
        printErrorMessage(ERR_DBTEST_NO_ENTRY_CONTAINERS_FOR_BASE_DN.get(base, backend.getBackendID()));
        printWrappedText(err, ERR_DBTEST_NO_ENTRY_CONTAINERS_FOR_BASE_DN.get(base, backend.getBackendID()));
        return 1;
      }
@@ -1115,8 +1082,8 @@
      if(databaseContainer == null)
      {
        printErrorMessage(ERR_DBTEST_NO_DATABASE_CONTAINERS_FOR_NAME.get(
            databaseName.getValue(), base, backend.getBackendID()));
        printWrappedText(
            err, ERR_DBTEST_NO_DATABASE_CONTAINERS_FOR_NAME.get(databaseName.getValue(), base, backend.getBackendID()));
        return 1;
      }
@@ -1145,8 +1112,7 @@
          }
          catch(Exception e)
          {
            printErrorMessage(ERR_DBTEST_CANNOT_DECODE_SIZE.get(
                maxDataSize.getValue(), getExceptionMessage(e)));
            printWrappedText(err, ERR_DBTEST_CANNOT_DECODE_SIZE.get(maxDataSize.getValue(), getExceptionMessage(e)));
            return 1;
          }
        }
@@ -1159,8 +1125,7 @@
          }
          catch(Exception e)
          {
            printErrorMessage(ERR_DBTEST_CANNOT_DECODE_SIZE.get(
                minDataSize.getValue(), getExceptionMessage(e)));
            printWrappedText(err, ERR_DBTEST_CANNOT_DECODE_SIZE.get(minDataSize.getValue(), getExceptionMessage(e)));
            return 1;
          }
        }
@@ -1174,8 +1139,7 @@
          }
          catch(Exception e)
          {
            printErrorMessage(ERR_DBTEST_CANNOT_DECODE_KEY.get(
                minKeyValue.getValue(), getExceptionMessage(e)));
            printWrappedText(err, ERR_DBTEST_CANNOT_DECODE_KEY.get(minKeyValue.getValue(), getExceptionMessage(e)));
            return 1;
          }
        }
@@ -1189,8 +1153,7 @@
          }
          catch(Exception e)
          {
            printErrorMessage(ERR_DBTEST_CANNOT_DECODE_KEY.get(
                maxKeyValue.getValue(), getExceptionMessage(e)));
            printWrappedText(err, ERR_DBTEST_CANNOT_DECODE_KEY.get(maxKeyValue.getValue(), getExceptionMessage(e)));
            return 1;
          }
        }
@@ -1243,7 +1206,7 @@
                }
                catch(Exception e)
                {
                  printErrorMessage(ERR_DBTEST_DECODE_FAIL.get(getExceptionMessage(e)));
                  printWrappedText(err, ERR_DBTEST_DECODE_FAIL.get(getExceptionMessage(e)));
                }
                formatedData = String.valueOf(
                  JebFormat.entryIDFromDatabase(data.getData()));
@@ -1264,7 +1227,7 @@
                }
                catch(Exception e)
                {
                  printErrorMessage(ERR_DBTEST_DECODE_FAIL.get(getExceptionMessage(e)));
                  printWrappedText(err, ERR_DBTEST_DECODE_FAIL.get(getExceptionMessage(e)));
                }
              }
              else if(databaseContainer instanceof DN2URI)
@@ -1276,7 +1239,7 @@
                }
                catch(Exception e)
                {
                  printErrorMessage(ERR_DBTEST_DECODE_FAIL.get(getExceptionMessage(e)));
                  printWrappedText(err, ERR_DBTEST_DECODE_FAIL.get(getExceptionMessage(e)));
                }
                formatedData = new String(key.getData());
                dataLabel = INFO_LABEL_DBTEST_URI.get();
@@ -1407,7 +1370,7 @@
                }
                catch(Exception e)
                {
                  printErrorMessage(ERR_DBTEST_DECODE_FAIL.get(getExceptionMessage(e)));
                  printWrappedText(err, ERR_DBTEST_DECODE_FAIL.get(getExceptionMessage(e)));
                }
              }
            }
@@ -1452,8 +1415,7 @@
    }
    catch(DatabaseException de)
    {
      printErrorMessage(ERR_DBTEST_ERROR_READING_DATABASE.get(
          StaticUtils.stackTraceToSingleLineString(de)));
      printWrappedText(err, ERR_DBTEST_ERROR_READING_DATABASE.get(stackTraceToSingleLineString(de)));
      return 1;
    }
    finally
@@ -1536,8 +1498,4 @@
    }
    return jeBackends;
  }
  private final void printErrorMessage(LocalizableMessage msg) {
    err.println(wrapText(msg.toString(), MAX_LINE_WIDTH));
  }
}
opendj-server-legacy/src/main/java/org/opends/server/tools/BackUpDB.java
@@ -45,7 +45,6 @@
import java.util.List;
import java.util.TimeZone;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.util.Utils;
@@ -271,9 +270,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
      return 1;
    }
@@ -295,17 +292,14 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      err.println(argParser.getUsage());
      return 1;
    }
    catch (ClientException ce)
    {
      // No need to display the usage since the problem comes with a provided
      // value.
      err.println(wrapText(ce.getMessageObject(), MAX_LINE_WIDTH));
      // No need to display the usage since the problem comes with a provided value.
      printWrappedText(err, ce.getMessageObject());
      return 1;
    }
@@ -323,20 +317,16 @@
    {
      if (backendID.isPresent())
      {
        LocalizableMessage message = ERR_BACKUPDB_CANNOT_MIX_BACKUP_ALL_AND_BACKEND_ID.get(
                backUpAll.getLongIdentifier(),
                backendID.getLongIdentifier());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_BACKUPDB_CANNOT_MIX_BACKUP_ALL_AND_BACKEND_ID.get(
                backUpAll.getLongIdentifier(), backendID.getLongIdentifier()));
        err.println(argParser.getUsage());
        return 1;
      }
    }
    else if (! backendID.isPresent())
    {
      LocalizableMessage message = ERR_BACKUPDB_NEED_BACKUP_ALL_OR_BACKEND_ID.get(
              backUpAll.getLongIdentifier(),
              backendID.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_BACKUPDB_NEED_BACKUP_ALL_OR_BACKEND_ID.get(
              backUpAll.getLongIdentifier(), backendID.getLongIdentifier()));
      err.println(argParser.getUsage());
      return 1;
    }
@@ -355,9 +345,7 @@
      }
      if (!repeatedBackendIds.isEmpty())
      {
        String repeatedBackends = Utils.joinAsString(", ", repeatedBackendIds);
        LocalizableMessage message = ERR_BACKUPDB_REPEATED_BACKEND_ID.get(repeatedBackends);
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_BACKUPDB_REPEATED_BACKEND_ID.get(Utils.joinAsString(", ", repeatedBackendIds)));
        err.println(argParser.getUsage());
        return 1;
      }
@@ -367,11 +355,8 @@
    // incremental backup.
    if (incrementalBaseID.isPresent() && ! incremental.isPresent())
    {
      LocalizableMessage message =
              ERR_BACKUPDB_INCREMENTAL_BASE_REQUIRES_INCREMENTAL.get(
                      incrementalBaseID.getLongIdentifier(),
                      incremental.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_BACKUPDB_INCREMENTAL_BASE_REQUIRES_INCREMENTAL.get(
              incrementalBaseID.getLongIdentifier(), incremental.getLongIdentifier()));
      err.println(argParser.getUsage());
      return 1;
    }
@@ -381,11 +366,8 @@
    //  are present, infer an offline backup.
    if ((encrypt.isPresent() || signHash.isPresent())
            && ! argParser.connectionArgumentsPresent()) {
      LocalizableMessage message =
              ERR_BACKUPDB_ENCRYPT_OR_SIGN_REQUIRES_ONLINE.get(
                      encrypt.getLongIdentifier(),
                      signHash.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_BACKUPDB_ENCRYPT_OR_SIGN_REQUIRES_ONLINE.get(
              encrypt.getLongIdentifier(), signHash.getLongIdentifier()));
      err.println(argParser.getUsage());
      return 1;
    }
@@ -394,10 +376,8 @@
    // was given.
    if (signHash.isPresent() && !hash.isPresent())
    {
      LocalizableMessage message = ERR_BACKUPDB_SIGN_REQUIRES_HASH.get(
              signHash.getLongIdentifier(),
              hash.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(
              err, ERR_BACKUPDB_SIGN_REQUIRES_HASH.get(signHash.getLongIdentifier(), hash.getLongIdentifier()));
      err.println(argParser.getUsage());
      return 1;
    }
@@ -410,7 +390,7 @@
    }
    catch (InitializationException e)
    {
      err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, e.getMessage());
      return 1;
    }
@@ -481,10 +461,8 @@
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_BACKUPDB_CANNOT_CREATE_BACKUP_DIR.get(
                backupDirectory.getValue(),
                getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(
                err, ERR_BACKUPDB_CANNOT_CREATE_BACKUP_DIR.get(backupDirectory.getValue(), getExceptionMessage(e)));
        return 1;
      }
    }
@@ -526,9 +504,7 @@
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_SERVER_BOOTSTRAP_ERROR.get(
                getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e)));
        return 1;
      }
@@ -539,14 +515,12 @@
      }
      catch (InitializationException ie)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e)));
        return 1;
      }
@@ -559,14 +533,12 @@
      }
      catch (ConfigException | InitializationException e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e)));
        return 1;
      }
@@ -579,16 +551,12 @@
      }
      catch (ConfigException | InitializationException e)
      {
        LocalizableMessage message =
                ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(
                getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getExceptionMessage(e)));
        return 1;
      }
@@ -600,14 +568,12 @@
      }
      catch (ConfigException | InitializationException e)
      {
        LocalizableMessage message = ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getExceptionMessage(e)));
        return 1;
      }
opendj-server-legacy/src/main/java/org/opends/server/tools/ConfigureDS.java
@@ -345,7 +345,7 @@
     {
       err.println(argParser.getUsage());
     }
     err.println(e.getErrorMessage());
     printWrappedText(err, e.getErrorMessage());
     return e.getErrorCode();
    }
    finally
@@ -1114,7 +1114,7 @@
    try
    {
      configHandler.writeUpdatedConfig();
      out.println(wrapText(INFO_CONFIGDS_WROTE_UPDATED_CONFIG.get(), MAX_LINE_WIDTH));
      printWrappedText(out, INFO_CONFIGDS_WROTE_UPDATED_CONFIG.get());
    }
    catch (final DirectoryException de)
    {
opendj-server-legacy/src/main/java/org/opends/server/tools/ConfigureWindowsService.java
@@ -195,9 +195,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
      return ERROR;
    }
@@ -207,9 +205,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      err.println(argParser.getUsage());
      return ERROR;
    }
@@ -240,7 +236,7 @@
      {
        LocalizableMessage message = nArgs == 0 ? ERR_CONFIGURE_WINDOWS_SERVICE_TOO_FEW_ARGS.get()
                                                : ERR_CONFIGURE_WINDOWS_SERVICE_TOO_MANY_ARGS.get();
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, message);
        err.println(argParser.getUsage());
        return ERROR;
      }
@@ -356,9 +352,7 @@
   */
  public static int enableService(PrintStream out, PrintStream err, String serviceName, String serviceDescription)
  {
    LocalizableMessage msg;
    String serverRoot = getServerRoot();
    String[] cmd;
    if (hasUAC())
@@ -404,38 +398,31 @@
          final int returnValue = StartWindowsService.startWindowsService(out, err);
          if (returnValue == 0)
          {
            msg = INFO_WINDOWS_SERVICE_SUCCESSULLY_ENABLED.get();
            out.println(wrapText(msg, MAX_LINE_WIDTH));
            printWrappedText(out, INFO_WINDOWS_SERVICE_SUCCESSULLY_ENABLED.get());
            return SERVICE_ENABLE_SUCCESS;
          }
          else
          {
            msg = ERR_WINDOWS_SERVICE_ENABLING_ERROR_STARTING_SERVER.get(returnValue);
            err.println(wrapText(msg, MAX_LINE_WIDTH));
            printWrappedText(err, ERR_WINDOWS_SERVICE_ENABLING_ERROR_STARTING_SERVER.get(SERVICE_ENABLE_ERROR));
            return SERVICE_ENABLE_ERROR;
          }
        }
        else
        {
          msg = INFO_WINDOWS_SERVICE_SUCCESSULLY_ENABLED.get();
          out.println(wrapText(msg, MAX_LINE_WIDTH));
          printWrappedText(out, INFO_WINDOWS_SERVICE_SUCCESSULLY_ENABLED.get());
          return SERVICE_ENABLE_SUCCESS;
        }
      case 1:
        msg = INFO_WINDOWS_SERVICE_ALREADY_ENABLED.get();
        out.println(wrapText(msg, MAX_LINE_WIDTH));
        printWrappedText(out, INFO_WINDOWS_SERVICE_ALREADY_ENABLED.get());
        return SERVICE_ALREADY_ENABLED;
      case 2:
        msg = ERR_WINDOWS_SERVICE_NAME_ALREADY_IN_USE.get();
        err.println(wrapText(msg, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_WINDOWS_SERVICE_NAME_ALREADY_IN_USE.get());
        return SERVICE_NAME_ALREADY_IN_USE;
      case 3:
        msg = ERR_WINDOWS_SERVICE_ENABLE_ERROR.get();
        err.println(wrapText(msg, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_WINDOWS_SERVICE_ENABLE_ERROR.get());
        return SERVICE_ENABLE_ERROR;
      default:
        msg = ERR_WINDOWS_SERVICE_ENABLE_ERROR.get();
        err.println(wrapText(msg, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_WINDOWS_SERVICE_ENABLE_ERROR.get());
        return SERVICE_ENABLE_ERROR;
      }
    }
@@ -443,8 +430,7 @@
    {
      err.println("Unexpected throwable: "+t);
      t.printStackTrace();
      msg = ERR_WINDOWS_SERVICE_ENABLE_ERROR.get();
      err.println(wrapText(msg, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_WINDOWS_SERVICE_ENABLE_ERROR.get());
      return SERVICE_ENABLE_ERROR;
    }
  }
@@ -464,7 +450,6 @@
   */
  public static int disableService(PrintStream out, PrintStream err)
  {
    LocalizableMessage msg;
    String serverRoot = getServerRoot();
    String[] cmd;
    if (hasUAC())
@@ -495,32 +480,26 @@
      switch (resultCode)
      {
      case 0:
        msg = INFO_WINDOWS_SERVICE_SUCCESSULLY_DISABLED.get();
        out.println(msg);
        printWrappedText(out, INFO_WINDOWS_SERVICE_SUCCESSULLY_DISABLED.get());
        return SERVICE_DISABLE_SUCCESS;
      case 1:
        msg = INFO_WINDOWS_SERVICE_ALREADY_DISABLED.get();
        out.println(msg);
        printWrappedText(out, INFO_WINDOWS_SERVICE_ALREADY_DISABLED.get());
        return SERVICE_ALREADY_DISABLED;
      case 2:
        msg = WARN_WINDOWS_SERVICE_MARKED_FOR_DELETION.get();
        out.println(msg);
        printWrappedText(out, WARN_WINDOWS_SERVICE_MARKED_FOR_DELETION.get());
        return SERVICE_MARKED_FOR_DELETION;
      case 3:
        msg = ERR_WINDOWS_SERVICE_DISABLE_ERROR.get();
        err.println(msg);
        printWrappedText(err, ERR_WINDOWS_SERVICE_DISABLE_ERROR.get());
        return SERVICE_DISABLE_ERROR;
      default:
        msg = ERR_WINDOWS_SERVICE_DISABLE_ERROR.get();
        err.println(msg);
        printWrappedText(err, ERR_WINDOWS_SERVICE_DISABLE_ERROR.get());
        return SERVICE_DISABLE_ERROR;
      }
    }
    catch (Throwable t)
    {
      t.printStackTrace();
      msg = ERR_WINDOWS_SERVICE_DISABLE_ERROR.get();
      err.println(msg);
      printWrappedText(err, ERR_WINDOWS_SERVICE_DISABLE_ERROR.get());
      return SERVICE_DISABLE_ERROR;
    }
  }
@@ -543,7 +522,6 @@
  public static int cleanupService(String serviceName, PrintStream out,
      PrintStream err)
  {
    LocalizableMessage msg;
    String[] cmd;
    if (hasUAC())
    {
@@ -573,32 +551,26 @@
      switch (resultCode)
      {
      case 0:
        msg = INFO_WINDOWS_SERVICE_CLEANUP_SUCCESS.get(serviceName);
        out.println(msg);
        printWrappedText(out, INFO_WINDOWS_SERVICE_CLEANUP_SUCCESS.get(serviceName));
        return SERVICE_CLEANUP_SUCCESS;
      case 1:
        msg = ERR_WINDOWS_SERVICE_CLEANUP_NOT_FOUND.get(serviceName);
        err.println(msg);
        printWrappedText(err, ERR_WINDOWS_SERVICE_CLEANUP_NOT_FOUND.get(serviceName));
        return SERVICE_NOT_FOUND;
      case 2:
        msg = WARN_WINDOWS_SERVICE_CLEANUP_MARKED_FOR_DELETION.get(serviceName);
        out.println(msg);
        printWrappedText(out, WARN_WINDOWS_SERVICE_CLEANUP_MARKED_FOR_DELETION.get(serviceName));
        return SERVICE_CLEANUP_MARKED_FOR_DELETION;
      case 3:
        msg = ERR_WINDOWS_SERVICE_CLEANUP_ERROR.get(serviceName);
        err.println(msg);
        printWrappedText(err, ERR_WINDOWS_SERVICE_CLEANUP_ERROR.get(serviceName));
        return SERVICE_CLEANUP_ERROR;
      default:
        msg = ERR_WINDOWS_SERVICE_CLEANUP_ERROR.get(serviceName);
        err.println(msg);
        printWrappedText(err, ERR_WINDOWS_SERVICE_CLEANUP_ERROR.get(serviceName));
        return SERVICE_CLEANUP_ERROR;
      }
    }
    catch (Throwable t)
    {
      msg = ERR_WINDOWS_SERVICE_CLEANUP_ERROR.get(serviceName);
      err.println(msg);
      err.println("Exception:" + t);
      err.println(ERR_WINDOWS_SERVICE_CLEANUP_ERROR.get(serviceName));
      printWrappedText(err, "Exception:" + t);
      return SERVICE_CLEANUP_ERROR;
    }
  }
@@ -631,7 +603,6 @@
   */
  public static int serviceState(PrintStream out, PrintStream err)
  {
    LocalizableMessage msg;
    String serviceName = null;
    String serverRoot = getServerRoot();
@@ -671,28 +642,23 @@
      switch (resultCode)
      {
      case 0:
        msg = INFO_WINDOWS_SERVICE_ENABLED.get(serviceName);
        out.println(msg);
        printWrappedText(out, INFO_WINDOWS_SERVICE_ENABLED.get(serviceName));
        return SERVICE_STATE_ENABLED;
      case 1:
        msg = INFO_WINDOWS_SERVICE_DISABLED.get();
        out.println(msg);
        printWrappedText(out, INFO_WINDOWS_SERVICE_DISABLED.get());
        return SERVICE_STATE_DISABLED;
      case 2:
        msg = ERR_WINDOWS_SERVICE_STATE_ERROR.get();
        err.println(msg);
        printWrappedText(err, ERR_WINDOWS_SERVICE_STATE_ERROR.get());
        return SERVICE_STATE_ERROR;
      default:
        msg = ERR_WINDOWS_SERVICE_STATE_ERROR.get();
        err.println(msg);
        printWrappedText(err, ERR_WINDOWS_SERVICE_STATE_ERROR.get());
        return SERVICE_STATE_ERROR;
      }
    }
    catch (Throwable t)
    {
      msg = ERR_WINDOWS_SERVICE_STATE_ERROR.get();
      err.println(msg);
      err.println(wrapText(t.toString(), MAX_LINE_WIDTH));
      printWrappedText(err, ERR_WINDOWS_SERVICE_STATE_ERROR.get());
      printWrappedText(err, t.toString());
      return SERVICE_STATE_ERROR;
    }
  }
opendj-server-legacy/src/main/java/org/opends/server/tools/CreateRCScript.java
@@ -32,6 +32,8 @@
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static com.forgerock.opendj.cli.Utils.*;
import java.io.File;
import java.io.OutputStream;
import java.io.PrintStream;
@@ -103,15 +105,15 @@
    if (! OperatingSystem.isUnixBased())
    {
      err.println(ERR_CREATERC_ONLY_RUNS_ON_UNIX.get());
      printWrappedText(err, ERR_CREATERC_ONLY_RUNS_ON_UNIX.get());
      return 1;
    }
    File serverRoot = DirectoryServer.getEnvironmentConfig().getServerRoot();
    if (serverRoot == null)
    {
      err.println(ERR_CREATERC_UNABLE_TO_DETERMINE_SERVER_ROOT.get(
                       PROPERTY_SERVER_ROOT, ENV_VAR_INSTALL_ROOT));
      printWrappedText(
          err, ERR_CREATERC_UNABLE_TO_DETERMINE_SERVER_ROOT.get(PROPERTY_SERVER_ROOT, ENV_VAR_INSTALL_ROOT));
      return 1;
    }
@@ -164,7 +166,7 @@
    }
    catch (ArgumentException ae)
    {
      err.println(ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
      printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
      return 1;
    }
@@ -174,7 +176,8 @@
    }
    catch (ArgumentException ae)
    {
      err.println(ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      err.println(argParser.getUsage());
      return 1;
    }
@@ -190,7 +193,7 @@
      File f = new File(javaHome.getValue());
      if (!f.exists() || !f.isDirectory())
      {
        err.println(ERR_CREATERC_JAVA_HOME_DOESNT_EXIST.get(javaHome.getValue()));
        printWrappedText(err, ERR_CREATERC_JAVA_HOME_DOESNT_EXIST.get(javaHome.getValue()));
        return 1;
      }
@@ -299,7 +302,7 @@
    }
    catch (Exception e)
    {
      err.println(ERR_CREATERC_CANNOT_WRITE.get(getExceptionMessage(e)));
      printWrappedText(err, ERR_CREATERC_CANNOT_WRITE.get(getExceptionMessage(e)));
      return 1;
    }
opendj-server-legacy/src/main/java/org/opends/server/tools/EncodePassword.java
@@ -251,9 +251,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
      return OPERATIONS_ERROR;
    }
@@ -265,9 +263,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      err.println(argParser.getUsage());
      return OPERATIONS_ERROR;
    }
@@ -287,45 +283,36 @@
    }
    catch (InitializationException e)
    {
      err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, e.getMessage());
      return 1;
    }
    // Check for conflicting arguments.
    if (clearPassword.isPresent() && clearPasswordFile.isPresent())
    {
      LocalizableMessage message =
              ERR_TOOL_CONFLICTING_ARGS.get(clearPassword.getLongIdentifier(),
                                  clearPasswordFile.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err,
          ERR_TOOL_CONFLICTING_ARGS.get(clearPassword.getLongIdentifier(), clearPasswordFile.getLongIdentifier()));
      return OPERATIONS_ERROR;
    }
    if (clearPassword.isPresent() && interactivePassword.isPresent())
    {
      LocalizableMessage message =
              ERR_TOOL_CONFLICTING_ARGS.get(clearPassword.getLongIdentifier(),
                  interactivePassword.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err,
          ERR_TOOL_CONFLICTING_ARGS.get(clearPassword.getLongIdentifier(), interactivePassword.getLongIdentifier()));
      return OPERATIONS_ERROR;
    }
    if (clearPasswordFile.isPresent() && interactivePassword.isPresent())
    {
      LocalizableMessage message =
              ERR_TOOL_CONFLICTING_ARGS.get(
                  clearPasswordFile.getLongIdentifier(),
                  interactivePassword.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get(clearPasswordFile.getLongIdentifier(),
                                                          interactivePassword.getLongIdentifier()));
      return OPERATIONS_ERROR;
    }
    if (encodedPassword.isPresent() && encodedPasswordFile.isPresent())
    {
      LocalizableMessage message =
              ERR_TOOL_CONFLICTING_ARGS.get(encodedPassword.getLongIdentifier(),
                                  encodedPasswordFile.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err,
          ERR_TOOL_CONFLICTING_ARGS.get(encodedPassword.getLongIdentifier(), encodedPasswordFile.getLongIdentifier()));
      return OPERATIONS_ERROR;
    }
@@ -338,8 +325,7 @@
        && !encodedPasswordFile.isPresent()
        && !schemeName.isPresent())
    {
      LocalizableMessage message = ERR_ENCPW_NO_SCHEME.get(schemeName.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_ENCPW_NO_SCHEME.get(schemeName.getLongIdentifier()));
      err.println(argParser.getUsage());
      return OPERATIONS_ERROR;
    }
@@ -378,9 +364,7 @@
      }
      catch (Exception e)
      {
        LocalizableMessage message =
                ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e)));
        return OPERATIONS_ERROR;
      }
@@ -391,14 +375,12 @@
      }
      catch (InitializationException ie)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage()));
        return OPERATIONS_ERROR;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e)));
        return OPERATIONS_ERROR;
      }
@@ -411,14 +393,12 @@
      }
      catch (ConfigException | InitializationException e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage()));
        return OPERATIONS_ERROR;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e)));
        return OPERATIONS_ERROR;
      }
@@ -431,16 +411,12 @@
      }
      catch (ConfigException | InitializationException e)
      {
        LocalizableMessage message =
                ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage()));
        return OPERATIONS_ERROR;
      }
      catch (Exception e)
      {
        LocalizableMessage message =
                ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getExceptionMessage(e)));
        return OPERATIONS_ERROR;
      }
@@ -459,14 +435,12 @@
      }
      catch (ConfigException | InitializationException e)
      {
        LocalizableMessage message = ERR_ENCPW_CANNOT_INITIALIZE_STORAGE_SCHEMES.get(e.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_ENCPW_CANNOT_INITIALIZE_STORAGE_SCHEMES.get(e.getMessage()));
        return OPERATIONS_ERROR;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_ENCPW_CANNOT_INITIALIZE_STORAGE_SCHEMES.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_ENCPW_CANNOT_INITIALIZE_STORAGE_SCHEMES.get(getExceptionMessage(e)));
        return OPERATIONS_ERROR;
      }
    }
@@ -511,14 +485,12 @@
        }
        catch (DirectoryException de)
        {
          LocalizableMessage message = ERR_ENCPW_INVALID_ENCODED_AUTHPW.get(
                  de.getMessageObject());
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_ENCPW_INVALID_ENCODED_AUTHPW.get(de.getMessageObject()));
          return OPERATIONS_ERROR;
        }
        catch (Exception e)
        {
          err.println(wrapText(ERR_ENCPW_INVALID_ENCODED_AUTHPW.get(e), MAX_LINE_WIDTH));
          printWrappedText(err, ERR_ENCPW_INVALID_ENCODED_AUTHPW.get(e));
          return OPERATIONS_ERROR;
        }
@@ -526,9 +498,7 @@
             DirectoryServer.getAuthPasswordStorageScheme(scheme);
        if (storageScheme == null)
        {
          LocalizableMessage message = ERR_ENCPW_NO_SUCH_AUTH_SCHEME.get(
                  scheme);
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_ENCPW_NO_SUCH_AUTH_SCHEME.get(scheme));
          return OPERATIONS_ERROR;
        }
@@ -567,21 +537,18 @@
                 DirectoryServer.getPasswordStorageScheme(userPWElements[0]);
            if (storageScheme == null)
            {
              LocalizableMessage message = ERR_ENCPW_NO_SUCH_SCHEME.get(userPWElements[0]);
              err.println(wrapText(message, MAX_LINE_WIDTH));
              printWrappedText(err, ERR_ENCPW_NO_SUCH_SCHEME.get(userPWElements[0]));
              return OPERATIONS_ERROR;
            }
          }
          catch (DirectoryException de)
          {
            LocalizableMessage message = ERR_ENCPW_INVALID_ENCODED_USERPW.get(
                    de.getMessageObject());
            err.println(wrapText(message, MAX_LINE_WIDTH));
            printWrappedText(err, ERR_ENCPW_INVALID_ENCODED_USERPW.get(de.getMessageObject()));
            return OPERATIONS_ERROR;
          }
          catch (Exception e)
          {
            err.println(wrapText(ERR_ENCPW_INVALID_ENCODED_USERPW.get(e), MAX_LINE_WIDTH));
            printWrappedText(err, ERR_ENCPW_INVALID_ENCODED_USERPW.get(e));
            return OPERATIONS_ERROR;
          }
        }
@@ -589,9 +556,7 @@
        {
          if (! schemeName.isPresent())
          {
            LocalizableMessage message = ERR_ENCPW_NO_SCHEME.get(
                    schemeName.getLongIdentifier());
            err.println(wrapText(message, MAX_LINE_WIDTH));
            printWrappedText(err, ERR_ENCPW_NO_SCHEME.get(schemeName.getLongIdentifier()));
            return OPERATIONS_ERROR;
          }
@@ -601,8 +566,7 @@
          storageScheme = DirectoryServer.getPasswordStorageScheme(scheme);
          if (storageScheme == null)
          {
            LocalizableMessage message = ERR_ENCPW_NO_SUCH_SCHEME.get(scheme);
            err.println(wrapText(message, MAX_LINE_WIDTH));
            printWrappedText(err, ERR_ENCPW_NO_SUCH_SCHEME.get(scheme));
            return OPERATIONS_ERROR;
          }
        }
@@ -637,8 +601,7 @@
        storageScheme = DirectoryServer.getAuthPasswordStorageScheme(scheme);
        if (storageScheme == null)
        {
          LocalizableMessage message = ERR_ENCPW_NO_SUCH_AUTH_SCHEME.get(scheme);
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_ENCPW_NO_SUCH_AUTH_SCHEME.get(scheme));
          return OPERATIONS_ERROR;
        }
      }
@@ -648,8 +611,7 @@
        storageScheme = DirectoryServer.getPasswordStorageScheme(scheme);
        if (storageScheme == null)
        {
          LocalizableMessage message = ERR_ENCPW_NO_SUCH_SCHEME.get(scheme);
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_ENCPW_NO_SUCH_SCHEME.get(scheme));
          return OPERATIONS_ERROR;
        }
      }
@@ -674,14 +636,12 @@
        }
        catch (DirectoryException de)
        {
          LocalizableMessage message = ERR_ENCPW_CANNOT_ENCODE.get(de.getMessageObject());
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_ENCPW_CANNOT_ENCODE.get(de.getMessageObject()));
          return OPERATIONS_ERROR;
        }
        catch (Exception e)
        {
          LocalizableMessage message = ERR_ENCPW_CANNOT_ENCODE.get(getExceptionMessage(e));
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_ENCPW_CANNOT_ENCODE.get(getExceptionMessage(e)));
          return OPERATIONS_ERROR;
        }
      }
@@ -704,14 +664,12 @@
        }
        catch (DirectoryException de)
        {
          LocalizableMessage message = ERR_ENCPW_CANNOT_ENCODE.get(de.getMessageObject());
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_ENCPW_CANNOT_ENCODE.get(de.getMessageObject()));
          return OPERATIONS_ERROR;
        }
        catch (Exception e)
        {
          LocalizableMessage message = ERR_ENCPW_CANNOT_ENCODE.get(getExceptionMessage(e));
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_ENCPW_CANNOT_ENCODE.get(getExceptionMessage(e)));
          return OPERATIONS_ERROR;
        }
      }
@@ -726,8 +684,7 @@
  {
    if (storageSchemes.isEmpty())
    {
      LocalizableMessage message = ERR_ENCPW_NO_STORAGE_SCHEMES.get();
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_ENCPW_NO_STORAGE_SCHEMES.get());
    }
    else
    {
@@ -772,14 +729,12 @@
      }
      catch (ConfigException | InitializationException e)
      {
        LocalizableMessage message = ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage()));
        return false;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getExceptionMessage(e)));
        return false;
      }
      //Attempt to bring up enough of the server to process schemes requiring
@@ -794,8 +749,7 @@
          directoryServer.initializeAuthenticatedUsers();
          new CryptoManagerSync();
    } catch (InitializationException | ConfigException e) {
        LocalizableMessage message = ERR_ENCPW_CANNOT_INITIALIZE_SERVER_COMPONENTS.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_ENCPW_CANNOT_INITIALIZE_SERVER_COMPONENTS.get(getExceptionMessage(e)));
        return false;
    }
    return true;
@@ -833,9 +787,8 @@
          backendClass = DirectoryServer.loadClass(className);
          backend = (Backend<BackendCfg>) backendClass.newInstance();
        } catch (Exception e) {
          LocalizableMessage msg = ERR_CONFIG_BACKEND_CANNOT_INSTANTIATE.get(className, backendCfg.dn(),
              stackTraceToSingleLineString(e));
          err.println(wrapText(msg, MAX_LINE_WIDTH));
          printWrappedText(err,
              ERR_CONFIG_BACKEND_CANNOT_INSTANTIATE.get(className, backendCfg.dn(), stackTraceToSingleLineString(e)));
          continue;
        }
        backend.setBackendID(backendID);
@@ -844,17 +797,15 @@
          backend.configureBackend(backendCfg, directoryServer.getServerContext());
          backend.openBackend();
        } catch (Exception e) {
          LocalizableMessage msg = ERR_CONFIG_BACKEND_CANNOT_INITIALIZE.get(className, backendCfg.dn(),
              stackTraceToSingleLineString(e));
          err.println(wrapText(msg, MAX_LINE_WIDTH));
          printWrappedText(err,
              ERR_CONFIG_BACKEND_CANNOT_INITIALIZE.get(className, backendCfg.dn(), stackTraceToSingleLineString(e)));
        }
        try {
          DirectoryServer.registerBackend(backend);
        } catch (Exception e)
        {
          LocalizableMessage msg = WARN_CONFIG_BACKEND_CANNOT_REGISTER_BACKEND.get(backendCfg.getBackendId(),
              getExceptionMessage(e));
          err.println(wrapText(msg, MAX_LINE_WIDTH));
          printWrappedText(
              err, WARN_CONFIG_BACKEND_CANNOT_REGISTER_BACKEND.get(backendCfg.getBackendId(), getExceptionMessage(e)));
        }
      }
    }
@@ -896,24 +847,20 @@
        }
        else
        {
          LocalizableMessage message = ERR_ENCPW_NOT_SAME_PW.get();
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_ENCPW_NOT_SAME_PW.get());
          return null;
        }
      }
      catch (IOException e)
      {
        LocalizableMessage message = ERR_ENCPW_CANNOT_READ_PW.get(e.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_ENCPW_CANNOT_READ_PW.get(e.getMessage()));
        return null;
      }
    }
    else
    {
      LocalizableMessage message = ERR_ENCPW_NO_CLEAR_PW.get(clearPassword
          .getLongIdentifier(), clearPasswordFile.getLongIdentifier(),
          interactivePassword.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_ENCPW_NO_CLEAR_PW.get(clearPassword.getLongIdentifier(),
                            clearPasswordFile.getLongIdentifier(), interactivePassword.getLongIdentifier()));
      err.println(argParser.getUsage());
      return null;
    }
opendj-server-legacy/src/main/java/org/opends/server/tools/ExportLDIF.java
@@ -40,7 +40,6 @@
import java.util.List;
import java.util.Set;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.opends.server.admin.std.server.BackendCfg;
@@ -306,8 +305,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
      return 1;
    }
@@ -330,16 +328,14 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      err.println(argParser.getUsage());
      return 1;
    }
    catch (ClientException ce)
    {
      // No need to display the usage since the problem comes with a provided
      // value.
      err.println(wrapText(ce.getMessageObject(), MAX_LINE_WIDTH));
      // No need to display the usage since the problem comes with a provided value.
      printWrappedText(err, ce.getMessageObject());
      return 1;
    }
@@ -358,7 +354,7 @@
    }
    catch (InitializationException e)
    {
      err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, e.getMessage());
      return 1;
    }
@@ -439,9 +435,7 @@
      }
      catch (Exception e)
      {
        LocalizableMessage message =
                ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e)));
        return 1;
      }
@@ -452,14 +446,12 @@
      }
      catch (InitializationException ie)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e)));
        return 1;
      }
@@ -472,14 +464,12 @@
      }
      catch (ConfigException | InitializationException e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e)));
        return 1;
      }
@@ -492,16 +482,12 @@
      }
      catch (ConfigException | InitializationException e)
      {
        LocalizableMessage message =
                ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message =
                ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getExceptionMessage(e)));
        return 1;
      }
@@ -513,16 +499,12 @@
      }
      catch (ConfigException | InitializationException e)
      {
        LocalizableMessage message =
                ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message =
                ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getExceptionMessage(e)));
        return 1;
      }
@@ -553,16 +535,12 @@
      }
      catch (ConfigException | InitializationException e)
      {
        LocalizableMessage message =
                ERR_LDIFEXPORT_CANNOT_INITIALIZE_PLUGINS.get(e.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_LDIFEXPORT_CANNOT_INITIALIZE_PLUGINS.get(e.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message =
                ERR_LDIFEXPORT_CANNOT_INITIALIZE_PLUGINS.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_LDIFEXPORT_CANNOT_INITIALIZE_PLUGINS.get(getExceptionMessage(e)));
        return 1;
      }
    }
opendj-server-legacy/src/main/java/org/opends/server/tools/ImportLDIF.java
@@ -200,9 +200,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
      return 1;
    }
@@ -224,17 +222,14 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      err.println(argParser.getUsage());
      return 1;
    }
    catch (ClientException ce)
    {
      // No need to display the usage since the problem comes with a provided
      // value.
      err.println(wrapText(ce.getMessageObject(), MAX_LINE_WIDTH));
      // No need to display the usage since the problem comes with a provided value.
      printWrappedText(err, ce.getMessageObject());
      return 1;
    }
@@ -251,19 +246,16 @@
    {
      if (templateFile.isPresent())
      {
        LocalizableMessage message = ERR_LDIFIMPORT_CONFLICTING_OPTIONS.get(
                ldifFiles.getLongIdentifier(),
                templateFile.getLongIdentifier());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err,
            ERR_LDIFIMPORT_CONFLICTING_OPTIONS.get(ldifFiles.getLongIdentifier(), templateFile.getLongIdentifier()));
        return 1;
      }
    }
    else if (! templateFile.isPresent())
    {
      LocalizableMessage message = ERR_LDIFIMPORT_MISSING_REQUIRED_ARGUMENT.get(
              ldifFiles.getLongIdentifier(),
              templateFile.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_LDIFIMPORT_MISSING_REQUIRED_ARGUMENT.get(
          ldifFiles.getLongIdentifier(), templateFile.getLongIdentifier()));
      err.println(argParser.getUsage());
      return 1;
    }
@@ -271,23 +263,19 @@
    // "backendID" argument was provided.
    if(!includeBranchStrings.isPresent() && !backendID.isPresent())
    {
      LocalizableMessage message = ERR_LDIFIMPORT_MISSING_BACKEND_ARGUMENT.get(
              includeBranchStrings.getLongIdentifier(),
              backendID.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_LDIFIMPORT_MISSING_BACKEND_ARGUMENT.get(
          includeBranchStrings.getLongIdentifier(), backendID.getLongIdentifier()));
      err.println(argParser.getUsage());
      return 1;
    }
    // Count rejects option requires the ability to return result codes
    // which are potentially greater than 1. This is not supported by
    // the task framework.
    if (countRejects.isPresent()
        && argParser.connectionArgumentsPresent())
    if (countRejects.isPresent() && argParser.connectionArgumentsPresent())
    {
      LocalizableMessage message =
          ERR_LDIFIMPORT_COUNT_REJECTS_REQUIRES_OFFLINE
              .get(countRejects.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_LDIFIMPORT_COUNT_REJECTS_REQUIRES_OFFLINE.get(countRejects.getLongIdentifier()));
      err.println(argParser.getUsage());
      return 1;
    }
@@ -303,7 +291,7 @@
    }
    catch (InitializationException e)
    {
      err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, e.getMessage());
      return 1;
    }
@@ -598,9 +586,7 @@
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_SERVER_BOOTSTRAP_ERROR.get(
                getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e)));
        return 1;
      }
@@ -611,14 +597,12 @@
      }
      catch (InitializationException ie)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e)));
        return 1;
      }
@@ -631,8 +615,7 @@
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(getMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(getMessage(e)));
        return 1;
      }
@@ -645,8 +628,7 @@
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getMessage(e)));
        return 1;
      }
@@ -658,8 +640,7 @@
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getMessage(e)));
        return 1;
      }
@@ -687,8 +668,7 @@
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_INITIALIZE_ROOTDN_MANAGER.get(getMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_ROOTDN_MANAGER.get(getMessage(e)));
        return 1;
      }
@@ -700,8 +680,7 @@
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_LDIFIMPORT_CANNOT_INITIALIZE_PLUGINS.get(getMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_LDIFIMPORT_CANNOT_INITIALIZE_PLUGINS.get(getMessage(e)));
        return 1;
      }
@@ -712,9 +691,7 @@
      }
      catch (InitializationException ie)
      {
        LocalizableMessage message = ERR_CANNOT_INITIALIZE_SUBENTRY_MANAGER.get(
                ie.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_SUBENTRY_MANAGER.get(ie.getMessage()));
        return 1;
      }
@@ -725,8 +702,7 @@
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_LDIFIMPORT_CANNOT_INITIALIZE_PWPOLICY.get(getMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_LDIFIMPORT_CANNOT_INITIALIZE_PWPOLICY.get(getMessage(e)));
        return 1;
      }
    }
@@ -742,8 +718,7 @@
    }
    catch (Exception e)
    {
      LocalizableMessage message = ERR_LDIFIMPORT_CANNOT_INITIALIZE_PLUGINS.get(getMessage(e));
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_LDIFIMPORT_CANNOT_INITIALIZE_PLUGINS.get(getMessage(e)));
      return 1;
    }
@@ -971,9 +946,7 @@
        !clearBackend.isPresent())
    {
      StringBuilder builder = join(backend.getBaseDNs(), " / ");
      LocalizableMessage message = ERR_LDIFIMPORT_MISSING_CLEAR_BACKEND.get(
              builder, clearBackend.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_LDIFIMPORT_MISSING_CLEAR_BACKEND.get(builder, clearBackend.getLongIdentifier()));
      return 1;
    }
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPCompare.java
@@ -255,9 +255,8 @@
        }
        else
        {
          LocalizableMessage msg = INFO_OPERATION_FAILED.get("COMPARE");
          err.println(wrapText(msg, MAX_LINE_WIDTH));
          err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
          printWrappedText(err, INFO_OPERATION_FAILED.get("COMPARE"));
          printWrappedText(err, ae.getMessage());
          return OPERATIONS_ERROR;
        }
      }
@@ -647,9 +646,7 @@
      argParser.setUsageArgument(showUsage, out);
    } catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -660,9 +657,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      err.println(argParser.getUsage());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -676,10 +671,8 @@
    if(bindPassword.isPresent() && bindPasswordFile.isPresent())
    {
      LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get(
              bindPassword.getLongIdentifier(),
              bindPasswordFile.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(
          err, ERR_TOOL_CONFLICTING_ARGS.get(bindPassword.getLongIdentifier(), bindPasswordFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -687,8 +680,7 @@
    if(attrAndDNStrings.isEmpty())
    {
      LocalizableMessage message = ERR_LDAPCOMPARE_NO_ATTR.get();
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_LDAPCOMPARE_NO_ATTR.get());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -700,7 +692,7 @@
    // If no DNs were provided, then exit with an error.
    if (dnStrings.isEmpty() && !filename.isPresent())
    {
      err.println(wrapText(ERR_LDAPCOMPARE_NO_DNS.get(), MAX_LINE_WIDTH));
      printWrappedText(err, ERR_LDAPCOMPARE_NO_DNS.get());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -708,8 +700,7 @@
    // provided, exit with an error.
    if (!dnStrings.isEmpty() && filename.isPresent())
    {
      err.println(wrapText(ERR_LDAPCOMPARE_FILENAME_AND_DNS.get(),
          MAX_LINE_WIDTH));
      printWrappedText(err, ERR_LDAPCOMPARE_FILENAME_AND_DNS.get());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -717,9 +708,7 @@
    int idx = attributeString.indexOf(":");
    if(idx == -1)
    {
      LocalizableMessage message =
              ERR_LDAPCOMPARE_INVALID_ATTR_STRING.get(attributeString);
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_LDAPCOMPARE_INVALID_ATTR_STRING.get(attributeString));
      return CLIENT_SIDE_PARAM_ERROR;
    }
    attributeType = attributeString.substring(0, idx);
@@ -737,10 +726,8 @@
        }
        catch (ParseException e)
        {
          err.println(wrapText(
                  INFO_COMPARE_CANNOT_BASE64_DECODE_ASSERTION_VALUE.get(),
                  MAX_LINE_WIDTH));
          err.println(wrapText(e.getLocalizedMessage(), MAX_LINE_WIDTH));
          printWrappedText(err, INFO_COMPARE_CANNOT_BASE64_DECODE_ASSERTION_VALUE.get());
          printWrappedText(err, e.getLocalizedMessage());
          return CLIENT_SIDE_PARAM_ERROR;
        }
      } else if(nextChar == '<')
@@ -752,9 +739,7 @@
        }
        catch (Exception e)
        {
          err.println(wrapText(
              INFO_COMPARE_CANNOT_READ_ASSERTION_VALUE_FROM_FILE.get(e),
              MAX_LINE_WIDTH));
          printWrappedText(err, INFO_COMPARE_CANNOT_READ_ASSERTION_VALUE_FROM_FILE.get(e));
          return CLIENT_SIDE_PARAM_ERROR;
        }
      } else
@@ -774,7 +759,7 @@
      portNumber = port.getIntValue();
    } catch (ArgumentException ae)
    {
      err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, ae.getMessage());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -783,13 +768,13 @@
      int versionNumber = version.getIntValue();
      if(versionNumber != 2 && versionNumber != 3)
      {
        err.println(wrapText(ERR_DESCRIPTION_INVALID_VERSION.get(versionNumber), MAX_LINE_WIDTH));
        printWrappedText(err, ERR_DESCRIPTION_INVALID_VERSION.get(versionNumber));
        return CLIENT_SIDE_PARAM_ERROR;
      }
      connectionOptions.setVersionNumber(versionNumber);
    } catch(ArgumentException ae)
    {
      err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, ae.getMessage());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -804,7 +789,7 @@
    }
    catch (ClientException ex)
    {
      err.println(wrapText(ex.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, ex.getMessage());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -843,8 +828,7 @@
        Control ctrl = LDAPToolUtils.getControl(ctrlString, err);
        if(ctrl == null)
        {
          LocalizableMessage message = ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString);
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString));
          err.println(argParser.getUsage());
          return CLIENT_SIDE_PARAM_ERROR;
        }
@@ -866,9 +850,7 @@
      }
      catch (LDAPException le)
      {
        LocalizableMessage message = ERR_LDAP_ASSERTION_INVALID_FILTER.get(
                le.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_LDAP_ASSERTION_INVALID_FILTER.get(le.getMessage()));
        return CLIENT_SIDE_PARAM_ERROR;
      }
    }
@@ -902,14 +884,12 @@
    {
      if(!connectionOptions.useSSL() && !connectionOptions.useStartTLS())
      {
        LocalizableMessage message = ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get();
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get());
        return CLIENT_SIDE_PARAM_ERROR;
      }
      if(keyStorePathValue == null)
      {
        LocalizableMessage message = ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get();
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get());
        return CLIENT_SIDE_PARAM_ERROR;
      }
    }
@@ -971,8 +951,7 @@
          {
            details = t.toString();
          }
          err.println(wrapText(ERR_LDAPCOMPARE_ERROR_READING_FILE.get(
              fileNameValue, details), MAX_LINE_WIDTH));
          printWrappedText(err, ERR_LDAPCOMPARE_ERROR_READING_FILE.get(fileNameValue, details));
          return CLIENT_SIDE_PARAM_ERROR;
        }
      }
@@ -1012,7 +991,7 @@
      return lce.getResultCode();
    } catch(Exception e)
    {
      err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, e.getMessage());
      return OPERATIONS_ERROR;
    } finally
    {
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPDelete.java
@@ -197,9 +197,8 @@
        }
        else
        {
          LocalizableMessage msg = INFO_OPERATION_FAILED.get("DELETE");
          err.println(wrapText(msg, MAX_LINE_WIDTH));
          err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
          printWrappedText(err, INFO_OPERATION_FAILED.get("DELETE"));
          printWrappedText(err, ae.getMessage());
          return;
        }
      }
@@ -549,8 +548,7 @@
      argParser.setUsageArgument(showUsage, out);
    } catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -561,8 +559,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      err.println(argParser.getUsage());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -576,10 +573,8 @@
    if(bindPassword.isPresent() && bindPasswordFile.isPresent())
    {
      LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get(
              bindPassword.getLongIdentifier(),
              bindPasswordFile.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(
          err, ERR_TOOL_CONFLICTING_ARGS.get(bindPassword.getLongIdentifier(), bindPasswordFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -592,7 +587,7 @@
    } catch(ArgumentException ae)
    {
      logger.traceException(ae);
      err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, ae.getMessage());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -601,14 +596,14 @@
      int versionNumber = version.getIntValue();
      if(versionNumber != 2 && versionNumber != 3)
      {
        err.println(wrapText(ERR_DESCRIPTION_INVALID_VERSION.get(versionNumber), MAX_LINE_WIDTH));
        printWrappedText(err, ERR_DESCRIPTION_INVALID_VERSION.get(versionNumber));
        return CLIENT_SIDE_PARAM_ERROR;
      }
      connectionOptions.setVersionNumber(versionNumber);
    } catch(ArgumentException ae)
    {
      logger.traceException(ae);
      err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, ae.getMessage());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -623,7 +618,7 @@
    catch (Exception ex)
    {
      logger.traceException(ex);
      err.println(wrapText(ex.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, ex.getMessage());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -663,8 +658,7 @@
        Control ctrl = LDAPToolUtils.getControl(ctrlString, err);
        if(ctrl == null)
        {
          LocalizableMessage message = ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString);
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString));
          err.println(argParser.getUsage());
          return CLIENT_SIDE_PARAM_ERROR;
        }
@@ -704,14 +698,12 @@
    {
      if(!connectionOptions.useSSL() && !connectionOptions.useStartTLS())
      {
        LocalizableMessage message = ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get();
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get());
        return CLIENT_SIDE_PARAM_ERROR;
      }
      if(keyStorePathValue == null)
      {
        LocalizableMessage message = ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get();
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get());
        return CLIENT_SIDE_PARAM_ERROR;
      }
    }
@@ -789,7 +781,7 @@
    } catch(Exception e)
    {
      logger.traceException(e);
      err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, e.getMessage());
      return 1;
    } finally
    {
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPModify.java
@@ -199,9 +199,7 @@
        }
        else
        {
          LocalizableMessage message = ERR_LDIF_FILE_INVALID_LDIF_ENTRY.get(
              le.getLineNumber(), fileNameValue, le);
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_LDIF_FILE_INVALID_LDIF_ENTRY.get(le.getLineNumber(), fileNameValue, le));
          continue;
        }
      } catch (Exception e)
@@ -224,8 +222,7 @@
        }
        else
        {
          LocalizableMessage message = ERR_LDIF_FILE_READ_ERROR.get(fileNameValue, e);
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_LDIF_FILE_READ_ERROR.get(fileNameValue, e));
          continue;
        }
      }
@@ -313,9 +310,8 @@
        } catch(DecodeException ae)
        {
          logger.traceException(ae);
          LocalizableMessage message = INFO_OPERATION_FAILED.get(operationType);
          err.println(wrapText(message, MAX_LINE_WIDTH));
          err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
          printWrappedText(err, INFO_OPERATION_FAILED.get(operationType));
          printWrappedText(err, ae.getMessage());
          if (!modifyOptions.continueOnError())
          {
            String msg = LDAPToolUtils.getMessageForConnectionException(ae);
@@ -412,7 +408,7 @@
          if (errorMessage != null)
          {
            out.println(wrapText(errorMessage, MAX_LINE_WIDTH));
            printWrappedText(out, errorMessage);
          }
          if (referralURLs != null)
@@ -445,10 +441,7 @@
            }
            catch (DirectoryException de)
            {
              err.println(wrapText(
                  ERR_LDAPMODIFY_PREREAD_CANNOT_DECODE_VALUE.get(
                              de.getMessage()),
                      MAX_LINE_WIDTH));
              printWrappedText(err, ERR_LDAPMODIFY_PREREAD_CANNOT_DECODE_VALUE.get(de.getMessage()));
              continue;
            }
@@ -477,10 +470,7 @@
            }
            catch (DirectoryException de)
            {
              err.println(wrapText(
                      ERR_LDAPMODIFY_POSTREAD_CANNOT_DECODE_VALUE.get(
                              de.getMessage()),
                      MAX_LINE_WIDTH));
              printWrappedText(err, ERR_LDAPMODIFY_POSTREAD_CANNOT_DECODE_VALUE.get(de.getMessage()));
              continue;
            }
@@ -878,9 +868,7 @@
      argParser.setUsageArgument(showUsage, out);
    } catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -891,9 +879,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      err.println(argParser.getUsage());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -907,10 +893,8 @@
    if(bindPassword.isPresent() && bindPasswordFile.isPresent())
    {
      LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get(
              bindPassword.getLongIdentifier(),
              bindPasswordFile.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(
          err, ERR_TOOL_CONFLICTING_ARGS.get(bindPassword.getLongIdentifier(), bindPasswordFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -922,7 +906,7 @@
    } catch(ArgumentException ae)
    {
      logger.traceException(ae);
      err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, ae.getMessage());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -931,14 +915,14 @@
      int versionNumber = version.getIntValue();
      if(versionNumber != 2 && versionNumber != 3)
      {
        err.println(wrapText(ERR_DESCRIPTION_INVALID_VERSION.get(versionNumber), MAX_LINE_WIDTH));
        printWrappedText(err, ERR_DESCRIPTION_INVALID_VERSION.get(versionNumber));
        return CLIENT_SIDE_PARAM_ERROR;
      }
      connectionOptions.setVersionNumber(versionNumber);
    } catch(ArgumentException ae)
    {
      logger.traceException(ae);
      err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, ae.getMessage());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -953,7 +937,7 @@
    catch (Exception ex)
    {
      logger.traceException(ex);
      err.println(wrapText(ex.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, ex.getMessage());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -993,8 +977,7 @@
        Control ctrl = LDAPToolUtils.getControl(ctrlString, err);
        if(ctrl == null)
        {
          LocalizableMessage message = ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString);
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString));
          err.println(argParser.getUsage());
          return CLIENT_SIDE_PARAM_ERROR;
        }
@@ -1024,9 +1007,7 @@
      }
      catch (LDAPException le)
      {
        LocalizableMessage message = ERR_LDAP_ASSERTION_INVALID_FILTER.get(
                le.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_LDAP_ASSERTION_INVALID_FILTER.get(le.getMessage()));
        return CLIENT_SIDE_PARAM_ERROR;
      }
    }
@@ -1085,14 +1066,12 @@
    {
      if(!connectionOptions.useSSL() && !connectionOptions.useStartTLS())
      {
        LocalizableMessage message = ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get();
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get());
        return CLIENT_SIDE_PARAM_ERROR;
      }
      if(keyStorePathValue == null)
      {
        LocalizableMessage message = ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get();
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get());
        return CLIENT_SIDE_PARAM_ERROR;
      }
    }
@@ -1156,12 +1135,12 @@
    } catch (FileNotFoundException fe)
    {
      logger.traceException(fe);
      err.println(wrapText(fe.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, fe.getMessage());
      return CLIENT_SIDE_PARAM_ERROR;
    } catch(Exception e)
    {
      logger.traceException(e);
      err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, e.getMessage());
      return OPERATIONS_ERROR;
    } finally
    {
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPPasswordModify.java
@@ -26,15 +26,15 @@
 */
package org.opends.server.tools;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.extensions.ExtensionsConstants.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
@@ -42,7 +42,9 @@
import java.util.concurrent.atomic.AtomicInteger;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.io.*;
import org.forgerock.opendj.io.ASN1;
import org.forgerock.opendj.io.ASN1Reader;
import org.forgerock.opendj.io.ASN1Writer;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ByteStringBuilder;
import org.opends.server.controls.PasswordPolicyErrorType;
@@ -412,9 +414,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -426,9 +426,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      err.println(argParser.getUsage());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -445,55 +443,43 @@
    // Make sure that the user didn't specify any conflicting arguments.
    if (bindPW.isPresent() && bindPWFile.isPresent())
    {
      LocalizableMessage message = ERR_LDAPPWMOD_CONFLICTING_ARGS.get(
              bindPW.getLongIdentifier(),
              bindPWFile.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(
          err, ERR_LDAPPWMOD_CONFLICTING_ARGS.get(bindPW.getLongIdentifier(), bindPWFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
    if (newPW.isPresent() && newPWFile.isPresent())
    {
      LocalizableMessage message = ERR_LDAPPWMOD_CONFLICTING_ARGS.get(
              newPW.getLongIdentifier(),
              newPWFile.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(
          err, ERR_LDAPPWMOD_CONFLICTING_ARGS.get(newPW.getLongIdentifier(), newPWFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
    if (currentPW.isPresent() && currentPWFile.isPresent())
    {
      LocalizableMessage message = ERR_LDAPPWMOD_CONFLICTING_ARGS.get(
              currentPW.getLongIdentifier(),
              currentPWFile.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err,
          ERR_LDAPPWMOD_CONFLICTING_ARGS.get(currentPW.getLongIdentifier(), currentPWFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
    if (useSSL.isPresent() && useStartTLS.isPresent())
    {
      LocalizableMessage message = ERR_LDAPPWMOD_CONFLICTING_ARGS.get(
              useSSL.getLongIdentifier(),
              useStartTLS.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(
          err, ERR_LDAPPWMOD_CONFLICTING_ARGS.get(useSSL.getLongIdentifier(), useStartTLS.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
    if (sslKeyStorePIN.isPresent() && sslKeyStorePINFile.isPresent())
    {
      LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get(
              sslKeyStorePIN.getLongIdentifier(),
              sslKeyStorePINFile.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err,
          ERR_TOOL_CONFLICTING_ARGS.get(sslKeyStorePIN.getLongIdentifier(), sslKeyStorePINFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
    if (sslTrustStorePIN.isPresent() && sslTrustStorePINFile.isPresent())
    {
      LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get(
              sslTrustStorePIN.getLongIdentifier(),
              sslTrustStorePINFile.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get(sslTrustStorePIN.getLongIdentifier(),
                                                          sslTrustStorePINFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -506,18 +492,14 @@
    {
      if (!bindPW.isPresent() && !bindPWFile.isPresent())
      {
        LocalizableMessage message = ERR_LDAPPWMOD_BIND_DN_AND_PW_MUST_BE_TOGETHER.get();
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_LDAPPWMOD_BIND_DN_AND_PW_MUST_BE_TOGETHER.get());
        err.println(argParser.getUsage());
        return CLIENT_SIDE_PARAM_ERROR;
      }
    }
    else if (bindPW.isPresent() || bindPWFile.isPresent())
    {
      LocalizableMessage message = ERR_LDAPPWMOD_BIND_DN_AND_PW_MUST_BE_TOGETHER.get();
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_LDAPPWMOD_BIND_DN_AND_PW_MUST_BE_TOGETHER.get());
      err.println(argParser.getUsage());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -525,20 +507,15 @@
    {
      if (provideDNForAuthzID.isPresent())
      {
        LocalizableMessage message =
                ERR_LDAPPWMOD_DEPENDENT_ARGS.get(
                        provideDNForAuthzID.getLongIdentifier(),
                        bindDN.getLongIdentifier());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(
            err, ERR_LDAPPWMOD_DEPENDENT_ARGS.get(provideDNForAuthzID.getLongIdentifier(), bindDN.getLongIdentifier()));
        err.println(argParser.getUsage());
        return CLIENT_SIDE_PARAM_ERROR;
      }
      if (!authzID.isPresent() || (!currentPW.isPresent() && !currentPWFile.isPresent()))
      {
        LocalizableMessage message =
                ERR_LDAPPWMOD_ANON_REQUIRES_AUTHZID_AND_CURRENTPW.get();
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_LDAPPWMOD_ANON_REQUIRES_AUTHZID_AND_CURRENTPW.get());
        err.println(argParser.getUsage());
        return CLIENT_SIDE_PARAM_ERROR;
      }
@@ -555,7 +532,7 @@
    catch (Exception e)
    {
      // This should never happen.
      err.println(e);
      printWrappedText(err, e.toString());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -569,8 +546,7 @@
        LDAPControl ctrl = LDAPToolUtils.getControl(ctrlString, err);
        if(ctrl == null)
        {
          LocalizableMessage message = ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString);
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString));
          err.println(argParser.getUsage());
          return CLIENT_SIDE_PARAM_ERROR;
        }
@@ -633,8 +609,7 @@
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_LDAPPWMOD_ERROR_INITIALIZING_SSL.get(e);
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_LDAPPWMOD_ERROR_INITIALIZING_SSL.get(e));
        return CLIENT_SIDE_PARAM_ERROR;
      }
    }
@@ -658,16 +633,14 @@
          //an empty password to the server.
          while(pwChars.length==0)
          {
            err.println(wrapText(
                INFO_LDAPAUTH_NON_EMPTY_PASSWORD.get(),
                MAX_LINE_WIDTH));
            printWrappedText(err, INFO_LDAPAUTH_NON_EMPTY_PASSWORD.get());
            out.print(INFO_LDAPAUTH_PASSWORD_PROMPT.get(dn));
            pwChars = ConsoleApplication.readPassword();
          }
          pw = new String(pwChars);
        } catch(Exception ex)
        {
          err.println(wrapText(ex.getMessage(), MAX_LINE_WIDTH));
          printWrappedText(err, ex.getMessage());
          return CLIENT_SIDE_PARAM_ERROR;
        }
      }
@@ -690,8 +663,7 @@
    }
    catch (LDAPConnectionException lce)
    {
      LocalizableMessage message = ERR_LDAPPWMOD_CANNOT_CONNECT.get(lce.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_LDAPPWMOD_CANNOT_CONNECT.get(lce.getMessage()));
      return lce.getResultCode();
    }
    catch (ArgumentException e)
@@ -771,9 +743,7 @@
    }
    catch (Exception e)
    {
      LocalizableMessage message = ERR_LDAPPWMOD_CANNOT_SEND_PWMOD_REQUEST.get(e);
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_LDAPPWMOD_CANNOT_SEND_PWMOD_REQUEST.get(e));
      unbind(nextMessageID, writer);
      close(reader, writer);
      return 1;
@@ -788,9 +758,7 @@
    }
    catch (Exception e)
    {
      LocalizableMessage message = ERR_LDAPPWMOD_CANNOT_READ_PWMOD_RESPONSE.get(e);
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_LDAPPWMOD_CANNOT_READ_PWMOD_RESPONSE.get(e));
      unbind(nextMessageID, writer);
      close(reader, writer);
      return 1;
@@ -803,21 +771,18 @@
    int resultCode = extendedResponse.getResultCode();
    if (resultCode != LDAPResultCode.SUCCESS)
    {
      LocalizableMessage message = ERR_LDAPPWMOD_FAILED.get(resultCode);
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_LDAPPWMOD_FAILED.get(resultCode));
      LocalizableMessage errorMessage = extendedResponse.getErrorMessage();
      if (errorMessage != null && errorMessage.length() > 0)
      {
        message = ERR_LDAPPWMOD_FAILURE_ERROR_MESSAGE.get(errorMessage);
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_LDAPPWMOD_FAILURE_ERROR_MESSAGE.get(errorMessage));
      }
      DN matchedDN = extendedResponse.getMatchedDN();
      if (matchedDN != null)
      {
        message = ERR_LDAPPWMOD_FAILURE_MATCHED_DN.get(matchedDN);
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_LDAPPWMOD_FAILURE_MATCHED_DN.get(matchedDN));
      }
      unbind(nextMessageID, writer);
@@ -826,14 +791,11 @@
    }
    else
    {
      LocalizableMessage message = INFO_LDAPPWMOD_SUCCESSFUL.get();
      out.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(out, INFO_LDAPPWMOD_SUCCESSFUL.get());
      LocalizableMessage additionalInfo = extendedResponse.getErrorMessage();
      if (additionalInfo != null && additionalInfo.length() > 0)
      {
        message = INFO_LDAPPWMOD_ADDITIONAL_INFO.get(additionalInfo);
        out.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(out, INFO_LDAPPWMOD_ADDITIONAL_INFO.get(additionalInfo));
      }
    }
@@ -857,24 +819,20 @@
                 pwPolicyControl.getWarningType();
            if (pwPolicyWarningType != null)
            {
              LocalizableMessage message = INFO_LDAPPWMOD_PWPOLICY_WARNING.get(
                      pwPolicyWarningType,
                      pwPolicyControl.getWarningValue());
              out.println(wrapText(message, MAX_LINE_WIDTH));
              printWrappedText(
                      out, INFO_LDAPPWMOD_PWPOLICY_WARNING.get(pwPolicyWarningType, pwPolicyControl.getWarningValue()));
            }
            PasswordPolicyErrorType pwPolicyErrorType =
                 pwPolicyControl.getErrorType();
            if (pwPolicyErrorType != null)
            {
              LocalizableMessage message = INFO_LDAPPWMOD_PWPOLICY_ERROR.get(pwPolicyErrorType);
              out.println(wrapText(message, MAX_LINE_WIDTH));
              printWrappedText(out, INFO_LDAPPWMOD_PWPOLICY_ERROR.get(pwPolicyErrorType));
            }
          }
          catch (Exception e)
          {
            LocalizableMessage message = ERR_LDAPPWMOD_CANNOT_DECODE_PWPOLICY_CONTROL.get(e);
            err.println(wrapText(message, MAX_LINE_WIDTH));
            printWrappedText(err, ERR_LDAPPWMOD_CANNOT_DECODE_PWPOLICY_CONTROL.get(e));
          }
        }
      }
@@ -893,24 +851,18 @@
        {
          if (asn1Reader.peekType() == TYPE_PASSWORD_MODIFY_GENERATED_PASSWORD)
          {
            LocalizableMessage message = INFO_LDAPPWMOD_GENERATED_PASSWORD.get(
                    asn1Reader.readOctetStringAsString());
            out.println(wrapText(message, MAX_LINE_WIDTH));
            printWrappedText(out, INFO_LDAPPWMOD_GENERATED_PASSWORD.get(asn1Reader.readOctetStringAsString()));
          }
          else
          {
            LocalizableMessage message = ERR_LDAPPWMOD_UNRECOGNIZED_VALUE_TYPE.get(
                    asn1Reader.readOctetStringAsString());
            err.println(wrapText(message, MAX_LINE_WIDTH));
            printWrappedText(err, ERR_LDAPPWMOD_UNRECOGNIZED_VALUE_TYPE.get(asn1Reader.readOctetStringAsString()));
          }
        }
        asn1Reader.readEndSequence();
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_LDAPPWMOD_COULD_NOT_DECODE_RESPONSE_VALUE.get(e);
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_LDAPPWMOD_COULD_NOT_DECODE_RESPONSE_VALUE.get(e));
        unbind(nextMessageID, writer);
        close(reader, writer);
        return 1;
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPSearch.java
@@ -371,8 +371,7 @@
                  }
                }
                // FIXME - throw exception?
                LocalizableMessage msg = INFO_SEARCH_OPERATION_INVALID_PROTOCOL.get(opType);
                err.println(wrapText(msg, MAX_LINE_WIDTH));
              printWrappedText(err, INFO_SEARCH_OPERATION_INVALID_PROTOCOL.get(opType));
            }
            if(resultCode != SUCCESS)
@@ -384,7 +383,7 @@
            else if (errorMessage != null)
            {
              out.println();
              out.println(wrapText(errorMessage, MAX_LINE_WIDTH));
              printWrappedText(out, errorMessage);
            }
          } while(opType != OP_TYPE_SEARCH_RESULT_DONE);
@@ -1066,9 +1065,7 @@
      argParser.setUsageArgument(showUsage, out);
    } catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -1079,9 +1076,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      err.println(argParser.getUsage());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -1112,7 +1107,7 @@
        } catch (LDAPException le)
        {
          logger.traceException(le);
          err.println(wrapText(le.getMessage(), MAX_LINE_WIDTH));
          printWrappedText(err, le.getMessage());
          return CLIENT_SIDE_PARAM_ERROR;
        }
      }
@@ -1121,38 +1116,28 @@
    if(bindPassword.isPresent() && bindPasswordFile.isPresent())
    {
      LocalizableMessage message =
              ERR_TOOL_CONFLICTING_ARGS.get(
                      bindPassword.getLongIdentifier(),
                      bindPasswordFile.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err,
          ERR_TOOL_CONFLICTING_ARGS.get(bindPassword.getLongIdentifier(), bindPasswordFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
    if (useSSL.isPresent() && startTLS.isPresent())
    {
      LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get(
              useSSL.getLongIdentifier(),
              startTLS.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get(useSSL.getLongIdentifier(), startTLS.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
    if (keyStorePassword.isPresent() && keyStorePasswordFile.isPresent())
    {
      LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get(
              keyStorePassword.getLongIdentifier(),
              keyStorePasswordFile.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get(
          keyStorePassword.getLongIdentifier(), keyStorePasswordFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
    if (trustStorePassword.isPresent() && trustStorePasswordFile.isPresent())
    {
      LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get(
              trustStorePassword.getLongIdentifier(),
              trustStorePasswordFile.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get(
          trustStorePassword.getLongIdentifier(), trustStorePasswordFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -1164,7 +1149,7 @@
    } catch(ArgumentException ae)
    {
      logger.traceException(ae);
      err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, ae.getMessage());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -1174,14 +1159,14 @@
      int versionNumber = version.getIntValue();
      if(versionNumber != 2 && versionNumber != 3)
      {
        err.println(wrapText(ERR_DESCRIPTION_INVALID_VERSION.get(versionNumber), MAX_LINE_WIDTH));
        printWrappedText(err, ERR_DESCRIPTION_INVALID_VERSION.get(versionNumber));
        return CLIENT_SIDE_PARAM_ERROR;
      }
      connectionOptions.setVersionNumber(versionNumber);
    } catch(ArgumentException ae)
    {
      logger.traceException(ae);
      err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, ae.getMessage());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -1205,7 +1190,7 @@
    catch (Exception ex)
    {
      logger.traceException(ex);
      err.println(wrapText(ex.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, ex.getMessage());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -1244,7 +1229,7 @@
      searchOptions.setSizeLimit(sizeLimit.getIntValue());
    } catch(ArgumentException ex1)
    {
      err.println(wrapText(ex1.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, ex1.getMessage());
      return CLIENT_SIDE_PARAM_ERROR;
    }
    if (!searchOptions.setSearchScope(searchScope.getValue(), err)
@@ -1260,8 +1245,7 @@
        Control ctrl = LDAPToolUtils.getControl(ctrlString, err);
        if(ctrl == null)
        {
          LocalizableMessage message = ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString);
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString));
          err.println(argParser.getUsage());
          return CLIENT_SIDE_PARAM_ERROR;
        }
@@ -1272,8 +1256,7 @@
    if(effectiveRightsUser.isPresent()) {
      String authzID=effectiveRightsUser.getValue();
      if (!authzID.startsWith("dn:")) {
        LocalizableMessage message = ERR_EFFECTIVERIGHTS_INVALID_AUTHZID.get(authzID);
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_EFFECTIVERIGHTS_INVALID_AUTHZID.get(authzID));
        err.println(argParser.getUsage());
        return CLIENT_SIDE_PARAM_ERROR;
      }
@@ -1302,8 +1285,7 @@
      if (! tokenizer.hasMoreTokens())
      {
        LocalizableMessage message = ERR_PSEARCH_MISSING_DESCRIPTOR.get();
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_PSEARCH_MISSING_DESCRIPTOR.get());
        return CLIENT_SIDE_PARAM_ERROR;
      }
      else
@@ -1311,8 +1293,7 @@
        String token = tokenizer.nextToken();
        if (! token.equals("ps"))
        {
          LocalizableMessage message = ERR_PSEARCH_DOESNT_START_WITH_PS.get(infoString);
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_PSEARCH_DOESNT_START_WITH_PS.get(infoString));
          return CLIENT_SIDE_PARAM_ERROR;
        }
      }
@@ -1349,8 +1330,7 @@
          }
          else
          {
            LocalizableMessage message = ERR_PSEARCH_INVALID_CHANGE_TYPE.get(token);
            err.println(wrapText(message, MAX_LINE_WIDTH));
            printWrappedText(err, ERR_PSEARCH_INVALID_CHANGE_TYPE.get(token));
            return CLIENT_SIDE_PARAM_ERROR;
          }
        }
@@ -1378,8 +1358,7 @@
        }
        else
        {
          LocalizableMessage message = ERR_PSEARCH_INVALID_CHANGESONLY.get(token);
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_PSEARCH_INVALID_CHANGESONLY.get(token));
          return CLIENT_SIDE_PARAM_ERROR;
        }
      }
@@ -1398,8 +1377,7 @@
        }
        else
        {
          LocalizableMessage message = ERR_PSEARCH_INVALID_RETURN_ECS.get(token);
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_PSEARCH_INVALID_RETURN_ECS.get(token));
          return CLIENT_SIDE_PARAM_ERROR;
        }
      }
@@ -1425,9 +1403,7 @@
      }
      catch (LDAPException le)
      {
        LocalizableMessage message = ERR_LDAP_ASSERTION_INVALID_FILTER.get(
                le.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_LDAP_ASSERTION_INVALID_FILTER.get(le.getMessage()));
        return CLIENT_SIDE_PARAM_ERROR;
      }
    }
@@ -1445,9 +1421,7 @@
        }
        catch (LDAPException le)
        {
          LocalizableMessage message = ERR_LDAP_MATCHEDVALUES_INVALID_FILTER.get(
                  le.getMessage());
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_LDAP_MATCHEDVALUES_INVALID_FILTER.get(le.getMessage()));
          return CLIENT_SIDE_PARAM_ERROR;
        }
      }
@@ -1465,9 +1439,7 @@
      }
      catch (LDAPException le)
      {
        LocalizableMessage message = ERR_LDAP_SORTCONTROL_INVALID_ORDER.get(
                le.getErrorMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_LDAP_SORTCONTROL_INVALID_ORDER.get(le.getErrorMessage()));
        return CLIENT_SIDE_PARAM_ERROR;
      }
    }
@@ -1476,10 +1448,8 @@
    {
      if (! sortOrder.isPresent())
      {
        LocalizableMessage message = ERR_LDAPSEARCH_VLV_REQUIRES_SORT.get(
                vlvDescriptor.getLongIdentifier(),
                sortOrder.getLongIdentifier());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err,
            ERR_LDAPSEARCH_VLV_REQUIRES_SORT.get(vlvDescriptor.getLongIdentifier(), sortOrder.getLongIdentifier()));
        return CLIENT_SIDE_PARAM_ERROR;
      }
@@ -1498,8 +1468,7 @@
        }
        catch (Exception e)
        {
          LocalizableMessage message = ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get();
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get());
          return CLIENT_SIDE_PARAM_ERROR;
        }
      }
@@ -1517,15 +1486,13 @@
        }
        catch (Exception e)
        {
          LocalizableMessage message = ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get();
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get());
          return CLIENT_SIDE_PARAM_ERROR;
        }
      }
      else
      {
        LocalizableMessage message = ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get();
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get());
        return CLIENT_SIDE_PARAM_ERROR;
      }
    }
@@ -1566,14 +1533,12 @@
    {
      if(!connectionOptions.useSSL() && !connectionOptions.useStartTLS())
      {
        LocalizableMessage message = ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get();
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get());
        return CLIENT_SIDE_PARAM_ERROR;
      }
      if(keyStorePathValue == null)
      {
        LocalizableMessage message = ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get();
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get());
        return CLIENT_SIDE_PARAM_ERROR;
      }
    }
@@ -1602,7 +1567,7 @@
      } catch(Exception e)
      {
        logger.traceException(e);
        err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
        printWrappedText(err, e.getMessage());
        return CLIENT_SIDE_PARAM_ERROR;
      }
      finally
@@ -1613,7 +1578,7 @@
    if(filters.isEmpty())
    {
      err.println(wrapText(ERR_SEARCH_NO_FILTERS.get(), MAX_LINE_WIDTH));
      printWrappedText(err, ERR_SEARCH_NO_FILTERS.get());
      err.println(argParser.getUsage());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -1757,7 +1722,7 @@
      if (code == REFERRAL)
      {
        out.println();
        out.println(wrapText(le.getErrorMessage(), MAX_LINE_WIDTH));
        printWrappedText(out, le.getErrorMessage());
      }
      else
      {
@@ -1779,7 +1744,7 @@
    } catch(Exception e)
    {
      logger.traceException(e);
      err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, e.getMessage());
      return 1;
    } finally
    {
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPSearchOptions.java
@@ -26,15 +26,17 @@
 */
package org.opends.server.tools;
import static org.forgerock.opendj.ldap.DereferenceAliasesPolicy.*;
import static org.forgerock.opendj.ldap.SearchScope.*;
import static org.opends.messages.ToolMessages.*;
import static com.forgerock.opendj.cli.Utils.*;
import java.io.PrintStream;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.SearchScope;
import static org.opends.messages.ToolMessages.*;
import static org.forgerock.opendj.ldap.DereferenceAliasesPolicy.*;
import static org.forgerock.opendj.ldap.SearchScope.*;
/**
@@ -131,7 +133,7 @@
        searchScope = SUBORDINATES;
      } else
      {
        err.println(ERR_SEARCH_INVALID_SEARCH_SCOPE.get(scope));
        printWrappedText(err, ERR_SEARCH_INVALID_SEARCH_SCOPE.get(scope));
        return false;
      }
      return true;
@@ -177,7 +179,7 @@
        dereferencePolicy = FINDING_BASE;
      } else
      {
        err.println("Invalid deref alias specified:" + policy);
        printWrappedText(err, ERR_SEARCH_INVALID_DEREFERENCE_POLICY.get(policy));
        return false;
      }
      return true;
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPToolUtils.java
@@ -25,7 +25,11 @@
 *      Portions Copyright 2011-2015 ForgeRock AS
 */
package org.opends.server.tools;
import org.forgerock.i18n.LocalizableMessage;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static com.forgerock.opendj.cli.Utils.*;
import java.io.File;
import java.io.FileInputStream;
@@ -33,15 +37,12 @@
import java.io.PrintStream;
import java.net.SocketTimeoutException;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DecodeException;
import org.opends.server.protocols.ldap.LDAPControl;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.types.DN;
import org.forgerock.opendj.ldap.ByteString;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -143,7 +144,7 @@
        controlCriticality = false;
      } else
      {
        err.println("Invalid format for criticality value:" + remainder);
        printWrappedText(err, "Invalid format for criticality value:" + remainder);
        return null;
      }
      return new LDAPControl(controlOID, controlCriticality);
@@ -158,7 +159,7 @@
      controlCriticality = false;
    } else
    {
      err.println("Invalid format for criticality value:" + critical);
      printWrappedText(err, "Invalid format for criticality value:" + critical);
      return null;
    }
@@ -226,7 +227,7 @@
        // Ensure all the bytes have been read in
        if (offset < val.length)
        {
          err.println("Could not completely read file "+filePath);
          printWrappedText(err, ERR_FILE_NOT_FULLY_READABLE.get(filePath));
          return null;
        }
opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFDiff.java
@@ -71,11 +71,13 @@
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.util.ServerConstants.*;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
import static com.forgerock.opendj.cli.Utils.*;
/**
 * This class provides a program that may be used to determine the differences
@@ -252,8 +254,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
      err.println(message);
      printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
      return OPERATIONS_ERROR;
    }
@@ -265,8 +266,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
      err.println(message);
      printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      err.println(argParser.getUsage());
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -309,7 +309,7 @@
        }
        catch (Exception e)
        {
          err.println(ERR_LDIFDIFF_CANNOT_INITIALIZE_JMX.get(configFile.getValue(), e.getMessage()));
          printWrappedText(err, ERR_LDIFDIFF_CANNOT_INITIALIZE_JMX.get(configFile.getValue(), e.getMessage()));
          return OPERATIONS_ERROR;
        }
@@ -320,7 +320,7 @@
        }
        catch (Exception e)
        {
          err.println(ERR_LDIFDIFF_CANNOT_INITIALIZE_CONFIG.get(configFile.getValue(), e.getMessage()));
          printWrappedText(err, ERR_LDIFDIFF_CANNOT_INITIALIZE_CONFIG.get(configFile.getValue(), e.getMessage()));
          return OPERATIONS_ERROR;
        }
@@ -330,7 +330,7 @@
        }
        catch (Exception e)
        {
          err.println(ERR_LDIFDIFF_CANNOT_INITIALIZE_SCHEMA.get(configFile.getValue(), e.getMessage()));
          printWrappedText(err, ERR_LDIFDIFF_CANNOT_INITIALIZE_SCHEMA.get(configFile.getValue(), e.getMessage()));
          return OPERATIONS_ERROR;
        }
      }
@@ -356,7 +356,7 @@
      }
      catch (Exception e)
      {
        err.println(ERR_LDIFDIFF_CANNOT_READ_FILE_IGNORE_ATTRIBS.get(ignoreAttrsFile.getValue(), e));
        printWrappedText(err, ERR_LDIFDIFF_CANNOT_READ_FILE_IGNORE_ATTRIBS.get(ignoreAttrsFile.getValue(), e));
        return OPERATIONS_ERROR;
      }
      finally
@@ -390,7 +390,7 @@
      }
      catch (Exception e)
      {
        err.println(ERR_LDIFDIFF_CANNOT_READ_FILE_IGNORE_ENTRIES.get(ignoreEntriesFile.getValue(), e));
        printWrappedText(err, ERR_LDIFDIFF_CANNOT_READ_FILE_IGNORE_ENTRIES.get(ignoreEntriesFile.getValue(), e));
        return OPERATIONS_ERROR;
      }
      finally
@@ -408,7 +408,7 @@
    }
    catch (Exception e)
    {
      err.println(ERR_LDIFDIFF_CANNOT_OPEN_SOURCE_LDIF.get(sourceLDIF.getValue(), e));
      printWrappedText(err, ERR_LDIFDIFF_CANNOT_OPEN_SOURCE_LDIF.get(sourceLDIF.getValue(), e));
      return OPERATIONS_ERROR;
    }
@@ -431,7 +431,7 @@
    }
    catch (Exception e)
    {
      err.println(ERR_LDIFDIFF_ERROR_READING_SOURCE_LDIF.get(sourceLDIF.getValue(), e));
      printWrappedText(err, ERR_LDIFDIFF_ERROR_READING_SOURCE_LDIF.get(sourceLDIF.getValue(), e));
      return OPERATIONS_ERROR;
    }
    finally
@@ -448,7 +448,7 @@
    }
    catch (Exception e)
    {
      err.println(ERR_LDIFDIFF_CANNOT_OPEN_TARGET_LDIF.get(targetLDIF.getValue(), e));
      printWrappedText(err, ERR_LDIFDIFF_CANNOT_OPEN_TARGET_LDIF.get(targetLDIF.getValue(), e));
      return OPERATIONS_ERROR;
    }
@@ -471,7 +471,7 @@
    }
    catch (Exception e)
    {
      err.println(ERR_LDIFDIFF_ERROR_READING_TARGET_LDIF.get(targetLDIF.getValue(), e));
      printWrappedText(err, ERR_LDIFDIFF_ERROR_READING_TARGET_LDIF.get(targetLDIF.getValue(), e));
      return OPERATIONS_ERROR;
    }
    finally
@@ -507,7 +507,7 @@
    }
    catch (Exception e)
    {
      err.println(ERR_LDIFDIFF_CANNOT_OPEN_OUTPUT.get(e));
      printWrappedText(err, ERR_LDIFDIFF_CANNOT_OPEN_OUTPUT.get(e));
      return OPERATIONS_ERROR;
    }
@@ -683,7 +683,7 @@
    }
    catch (IOException e)
    {
      err.println(ERR_LDIFDIFF_ERROR_WRITING_OUTPUT.get(e));
      printWrappedText(err, ERR_LDIFDIFF_ERROR_WRITING_OUTPUT.get(e));
      return OPERATIONS_ERROR;
    }
    finally
opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFModify.java
@@ -26,12 +26,13 @@
 */
package org.opends.server.tools;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
import static org.opends.server.util.StaticUtils.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
@@ -49,7 +50,6 @@
import org.opends.server.core.DirectoryServer.DirectoryServerVersionHandler;
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.JDKLogging;
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.DN;
@@ -483,8 +483,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
      err.println(message);
      printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
      return 1;
    }
@@ -496,11 +495,9 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
      err.println(message);
      printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      err.println(argParser.getUsage());
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -518,7 +515,7 @@
    }
    catch (InitializationException e)
    {
      err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, e.getMessage());
      return 1;
    }
@@ -540,7 +537,7 @@
        }
        catch (Exception e)
        {
          err.println(ERR_LDIFMODIFY_CANNOT_INITIALIZE_JMX.get(configFile.getValue(), e.getMessage()));
          printWrappedText(err, ERR_LDIFMODIFY_CANNOT_INITIALIZE_JMX.get(configFile.getValue(), e.getMessage()));
          return 1;
        }
@@ -551,7 +548,7 @@
        }
        catch (Exception e)
        {
          err.println(ERR_LDIFMODIFY_CANNOT_INITIALIZE_CONFIG.get(configFile.getValue(), e.getMessage()));
          printWrappedText(err, ERR_LDIFMODIFY_CANNOT_INITIALIZE_CONFIG.get(configFile.getValue(), e.getMessage()));
          return 1;
        }
@@ -561,7 +558,7 @@
        }
        catch (Exception e)
        {
          err.println(ERR_LDIFMODIFY_CANNOT_INITIALIZE_SCHEMA.get(configFile.getValue(), e.getMessage()));
          printWrappedText(err, ERR_LDIFMODIFY_CANNOT_INITIALIZE_SCHEMA.get(configFile.getValue(), e.getMessage()));
          return 1;
        }
      }
@@ -572,10 +569,8 @@
    File source = new File(sourceFile.getValue());
    if (! source.exists())
    {
      LocalizableMessage message = ERR_LDIFMODIFY_SOURCE_DOES_NOT_EXIST.get(
              sourceFile.getValue());
      err.println(message);
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
      printWrappedText(err, ERR_LDIFMODIFY_SOURCE_DOES_NOT_EXIST.get(sourceFile.getValue()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
    LDIFImportConfig importConfig = new LDIFImportConfig(sourceFile.getValue());
@@ -586,16 +581,16 @@
    }
    catch (IOException ioe)
    {
      err.println(ERR_LDIFMODIFY_CANNOT_OPEN_SOURCE.get(sourceFile.getValue(), ioe));
      return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR;
      printWrappedText(err, ERR_LDIFMODIFY_CANNOT_OPEN_SOURCE.get(sourceFile.getValue(), ioe));
      return CLIENT_SIDE_LOCAL_ERROR;
    }
    File changes = new File(changesFile.getValue());
    if (! changes.exists())
    {
      err.println(ERR_LDIFMODIFY_CHANGES_DOES_NOT_EXIST.get(changesFile.getValue()));
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
      printWrappedText(err, ERR_LDIFMODIFY_CHANGES_DOES_NOT_EXIST.get(changesFile.getValue()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
    importConfig = new LDIFImportConfig(changesFile.getValue());
@@ -606,10 +601,8 @@
    }
    catch (IOException ioe)
    {
      LocalizableMessage message = ERR_LDIFMODIFY_CANNOT_OPEN_CHANGES.get(
              sourceFile.getValue(), ioe.getMessage());
      err.println(message);
      return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR;
      printWrappedText(err, ERR_LDIFMODIFY_CANNOT_OPEN_CHANGES.get(sourceFile.getValue(), ioe.getMessage()));
      return CLIENT_SIDE_LOCAL_ERROR;
    }
@@ -623,10 +616,8 @@
    }
    catch (IOException ioe)
    {
      LocalizableMessage message = ERR_LDIFMODIFY_CANNOT_OPEN_TARGET.get(
              sourceFile.getValue(), ioe.getMessage());
      err.println(message);
      return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR;
      printWrappedText(err, ERR_LDIFMODIFY_CANNOT_OPEN_TARGET.get(sourceFile.getValue(), ioe.getMessage()));
      return CLIENT_SIDE_LOCAL_ERROR;
    }
opendj-server-legacy/src/main/java/org/opends/server/tools/LDIFSearch.java
@@ -31,6 +31,7 @@
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.BufferedReader;
@@ -227,8 +228,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
      err.println(message);
      printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
      return 1;
    }
@@ -240,11 +240,9 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
      err.println(message);
      printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      err.println(argParser.getUsage());
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -262,7 +260,7 @@
    }
    catch (InitializationException e)
    {
      err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, e.getMessage());
      return 1;
    }
@@ -297,7 +295,7 @@
        }
      } catch(Exception e)
      {
        err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
        printWrappedText(err, e.getMessage());
        return 1;
      }
      finally
@@ -335,8 +333,8 @@
      ArrayList<String> trailingArguments = argParser.getTrailingArguments();
      if (trailingArguments == null || trailingArguments.isEmpty())
      {
        LocalizableMessage message = ERR_LDIFSEARCH_NO_FILTER.get();
        err.println(message);
        printWrappedText(err, ERR_LDIFSEARCH_NO_FILTER.get());
        err.println(argParser.getUsage());
        return 1;
      }
@@ -400,7 +398,8 @@
    // schema.
    boolean checkSchema = configFile.isPresent();
    if(initializeServer) {
    if (initializeServer)
    {
     DirectoryServer.bootstrapClient();
    if (checkSchema)
@@ -411,18 +410,17 @@
      }
      catch (Exception e)
      {
        err.println(ERR_LDIFSEARCH_CANNOT_INITIALIZE_JMX.get(configFile.getValue(), e.getMessage()));
          printWrappedText(err, ERR_LDIFSEARCH_CANNOT_INITIALIZE_JMX.get(configFile.getValue(), e.getMessage()));
        return 1;
      }
      try
      {
        directoryServer.initializeConfiguration(configClass.getValue(),
                                                configFile.getValue());
          directoryServer.initializeConfiguration(configClass.getValue(), configFile.getValue());
      }
      catch (Exception e)
      {
        err.println(ERR_LDIFSEARCH_CANNOT_INITIALIZE_CONFIG.get(configFile.getValue(), e.getMessage()));
          printWrappedText(err, ERR_LDIFSEARCH_CANNOT_INITIALIZE_CONFIG.get(configFile.getValue(), e.getMessage()));
        return 1;
      }
@@ -432,7 +430,7 @@
      }
      catch (Exception e)
      {
        err.println(ERR_LDIFSEARCH_CANNOT_INITIALIZE_SCHEMA.get(configFile.getValue(), e.getMessage()));
          printWrappedText(err, ERR_LDIFSEARCH_CANNOT_INITIALIZE_SCHEMA.get(configFile.getValue(), e.getMessage()));
        return 1;
      }
    }
@@ -476,9 +474,7 @@
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_LDIFSEARCH_CANNOT_PARSE_FILTER.get(
                filterString, e.getMessage());
        err.println(message);
        printWrappedText(err, ERR_LDIFSEARCH_CANNOT_PARSE_FILTER.get(filterString, e.getMessage()));
        return 1;
      }
    }
@@ -541,9 +537,7 @@
        }
        catch (Exception e)
        {
          LocalizableMessage message = ERR_LDIFSEARCH_CANNOT_PARSE_BASE_DN.get(
                  dnString, e.getMessage());
          err.println(message);
          printWrappedText(err, ERR_LDIFSEARCH_CANNOT_PARSE_BASE_DN.get(dnString, e.getMessage()));
          return 1;
        }
      }
@@ -569,7 +563,7 @@
    }
    catch (Exception e)
    {
      err.println(ERR_LDIFSEARCH_CANNOT_PARSE_TIME_LIMIT.get(e));
      printWrappedText(err, ERR_LDIFSEARCH_CANNOT_PARSE_TIME_LIMIT.get(e));
      return 1;
    }
@@ -589,7 +583,7 @@
    }
    catch (Exception e)
    {
      err.println(ERR_LDIFSEARCH_CANNOT_PARSE_SIZE_LIMIT.get(e));
      printWrappedText(err, ERR_LDIFSEARCH_CANNOT_PARSE_SIZE_LIMIT.get(e));
      return 1;
    }
@@ -648,7 +642,7 @@
    }
    catch (Exception e)
    {
      err.println(ERR_LDIFSEARCH_CANNOT_CREATE_READER.get(e));
      printWrappedText(err, ERR_LDIFSEARCH_CANNOT_CREATE_READER.get(e));
      return 1;
    }
@@ -659,7 +653,7 @@
    catch (Exception e)
    {
      close(reader);
      err.println(ERR_LDIFSEARCH_CANNOT_CREATE_WRITER.get(e));
      printWrappedText(err, ERR_LDIFSEARCH_CANNOT_CREATE_WRITER.get(e));
      return 1;
    }
opendj-server-legacy/src/main/java/org/opends/server/tools/ListBackends.java
@@ -186,9 +186,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
      return 1;
    }
@@ -200,9 +198,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      err.println(argParser.getUsage());
      return 1;
    }
@@ -220,10 +216,7 @@
    // arguments.
    if (backendID.isPresent() && baseDN.isPresent())
    {
      LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get(
              backendID.getLongIdentifier(),
              baseDN.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get(backendID.getLongIdentifier(), baseDN.getLongIdentifier()));
      return 1;
    }
@@ -234,7 +227,7 @@
    }
    catch (InitializationException e)
    {
      err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, e.getMessage());
      return 1;
    }
@@ -251,9 +244,7 @@
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_SERVER_BOOTSTRAP_ERROR.get(
                getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e)));
        return 1;
      }
@@ -264,14 +255,12 @@
      }
      catch (InitializationException ie)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e)));
        return 1;
      }
@@ -284,14 +273,12 @@
      }
      catch (ConfigException | InitializationException e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e)));
        return 1;
      }
    }
@@ -305,16 +292,12 @@
    }
    catch (ConfigException ce)
    {
      LocalizableMessage message = ERR_LISTBACKENDS_CANNOT_GET_BACKENDS.get(
              ce.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_LISTBACKENDS_CANNOT_GET_BACKENDS.get(ce.getMessage()));
      return 1;
    }
    catch (Exception e)
    {
      LocalizableMessage message = ERR_LISTBACKENDS_CANNOT_GET_BACKENDS.get(
              getExceptionMessage(e));
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_LISTBACKENDS_CANNOT_GET_BACKENDS.get(getExceptionMessage(e)));
      return 1;
    }
@@ -350,16 +333,12 @@
        }
        catch (DirectoryException de)
        {
          LocalizableMessage message = ERR_LISTBACKENDS_INVALID_DN.get(
                  dnStr, de.getMessage());
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_LISTBACKENDS_INVALID_DN.get(dnStr, de.getMessage()));
          return 1;
        }
        catch (Exception e)
        {
          LocalizableMessage message = ERR_LISTBACKENDS_INVALID_DN.get(
                  dnStr, getExceptionMessage(e));
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_LISTBACKENDS_INVALID_DN.get(dnStr, getExceptionMessage(e)));
          return 1;
        }
@@ -423,8 +402,7 @@
        TreeSet<DN> baseDNs = backends.get(id);
        if (baseDNs == null)
        {
          LocalizableMessage message = ERR_LISTBACKENDS_NO_SUCH_BACKEND.get(id);
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_LISTBACKENDS_NO_SUCH_BACKEND.get(id));
          iterator.remove();
        }
        else
@@ -439,8 +417,7 @@
      if (backendIDs.isEmpty())
      {
        LocalizableMessage message = ERR_LISTBACKENDS_NO_VALID_BACKENDS.get();
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_LISTBACKENDS_NO_VALID_BACKENDS.get());
        return 1;
      }
opendj-server-legacy/src/main/java/org/opends/server/tools/ManageAccount.java
@@ -32,6 +32,7 @@
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.extensions.PasswordPolicyStateExtendedOperation.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -596,10 +597,8 @@
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_PWPSTATE_CANNOT_SEND_REQUEST_EXTOP.get(
                getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return LDAPResultCode.CLIENT_SIDE_SERVER_DOWN;
        printWrappedText(err, ERR_PWPSTATE_CANNOT_SEND_REQUEST_EXTOP.get(getExceptionMessage(e)));
        return CLIENT_SIDE_SERVER_DOWN;
      }
@@ -609,10 +608,8 @@
        LDAPMessage responseMessage = ldapReader.readMessage();
        if (responseMessage == null)
        {
          LocalizableMessage message =
                  ERR_PWPSTATE_CONNECTION_CLOSED_READING_RESPONSE.get();
          err.println(wrapText(message, MAX_LINE_WIDTH));
          return LDAPResultCode.CLIENT_SIDE_SERVER_DOWN;
          printWrappedText(err, ERR_PWPSTATE_CONNECTION_CLOSED_READING_RESPONSE.get());
          return CLIENT_SIDE_SERVER_DOWN;
        }
        ExtendedResponseProtocolOp extendedResponse =
@@ -621,11 +618,8 @@
        int resultCode = extendedResponse.getResultCode();
        if (resultCode != LDAPResultCode.SUCCESS)
        {
          LocalizableMessage message =
               ERR_PWPSTATE_REQUEST_FAILED.get(resultCode,
                          LDAPResultCode.toString(resultCode),
                          extendedResponse.getErrorMessage());
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_PWPSTATE_REQUEST_FAILED.get(
              resultCode, LDAPResultCode.toString(resultCode), extendedResponse.getErrorMessage()));
          return resultCode;
        }
@@ -660,9 +654,7 @@
          }
          catch (Exception e)
          {
            LocalizableMessage message = ERR_PWPSTATE_CANNOT_DECODE_RESPONSE_OP.get(
                getExceptionMessage(e));
            err.println(wrapText(message, MAX_LINE_WIDTH));
            printWrappedText(err, ERR_PWPSTATE_CANNOT_DECODE_RESPONSE_OP.get(getExceptionMessage(e)));
            continue;
          }
@@ -781,7 +773,7 @@
            default:
              message = ERR_PWPSTATE_INVALID_RESPONSE_OP_TYPE.get(opType);
              err.println(wrapText(message, MAX_LINE_WIDTH));
              printWrappedText(err, message);
              break;
          }
        }
@@ -790,10 +782,8 @@
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_PWPSTATE_CANNOT_DECODE_RESPONSE_MESSAGE.get(
            getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return LDAPResultCode.CLIENT_SIDE_SERVER_DOWN;
        printWrappedText(err, ERR_PWPSTATE_CANNOT_DECODE_RESPONSE_MESSAGE.get(getExceptionMessage(e)));
        return CLIENT_SIDE_SERVER_DOWN;
      }
      // If we've gotten here, then everything completed successfully.
@@ -1197,10 +1187,8 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR;
      printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
      return CLIENT_SIDE_LOCAL_ERROR;
    }
    try
@@ -1209,11 +1197,9 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      err.println(argParser.getUsage());
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -1244,22 +1230,18 @@
    // return an error.
    if (bindPW.isPresent() && bindPWFile.isPresent())
    {
      LocalizableMessage message = ERR_PWPSTATE_MUTUALLY_EXCLUSIVE_ARGUMENTS.get(
              bindPW.getLongIdentifier(),
              bindPWFile.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
      printWrappedText(err,
          ERR_PWPSTATE_MUTUALLY_EXCLUSIVE_ARGUMENTS.get(bindPW.getLongIdentifier(), bindPWFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
    // If both a key store password and key store password file were provided,
    // then return an error.
    if (keyStorePW.isPresent() && keyStorePWFile.isPresent())
    {
      LocalizableMessage message = ERR_PWPSTATE_MUTUALLY_EXCLUSIVE_ARGUMENTS.get(
              keyStorePW.getLongIdentifier(),
              keyStorePWFile.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
      printWrappedText(err, ERR_PWPSTATE_MUTUALLY_EXCLUSIVE_ARGUMENTS.get(
          keyStorePW.getLongIdentifier(), keyStorePWFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -1267,11 +1249,9 @@
    // provided, then return an error.
    if (trustStorePW.isPresent() && trustStorePWFile.isPresent())
    {
      LocalizableMessage message = ERR_PWPSTATE_MUTUALLY_EXCLUSIVE_ARGUMENTS.get(
              trustStorePW.getLongIdentifier(),
              trustStorePWFile.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
      printWrappedText(err, ERR_PWPSTATE_MUTUALLY_EXCLUSIVE_ARGUMENTS.get(
          trustStorePW.getLongIdentifier(), trustStorePWFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -1293,10 +1273,8 @@
      connectionOptions.setSSLConnectionFactory(sslConnectionFactory);
    } catch (SSLConnectionException sce) {
      LocalizableMessage message = ERR_PWPSTATE_CANNOT_INITIALIZE_SSL.get(
        sce.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR;
      printWrappedText(err, ERR_PWPSTATE_CANNOT_INITIALIZE_SSL.get(sce.getMessage()));
      return CLIENT_SIDE_LOCAL_ERROR;
    }
@@ -1312,9 +1290,8 @@
        int equalPos = s.indexOf('=');
        if (equalPos <= 0)
        {
          LocalizableMessage message = ERR_PWPSTATE_CANNOT_PARSE_SASL_OPTION.get(s);
          err.println(wrapText(message, MAX_LINE_WIDTH));
          return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
          printWrappedText(err, ERR_PWPSTATE_CANNOT_PARSE_SASL_OPTION.get(s));
          return CLIENT_SIDE_PARAM_ERROR;
        }
        else
        {
@@ -1333,9 +1310,8 @@
      if (mechanism == null)
      {
        LocalizableMessage message = ERR_PWPSTATE_NO_SASL_MECHANISM.get();
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
        printWrappedText(err, ERR_PWPSTATE_NO_SASL_MECHANISM.get());
        return CLIENT_SIDE_PARAM_ERROR;
      }
      connectionOptions.setSASLMechanism(mechanism);
@@ -1360,11 +1336,8 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_PWPSTATE_CANNOT_DETERMINE_PORT.get(
              port.getLongIdentifier(),
              ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
      printWrappedText(err, ERR_PWPSTATE_CANNOT_DETERMINE_PORT.get(port.getLongIdentifier(), ae.getMessage()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
    catch (LDAPConnectionException lce)
    {
@@ -1378,14 +1351,14 @@
        message = ERR_PWPSTATE_CANNOT_CONNECT.get(hostPort,
          lce.getMessage());
      }
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR;
      printWrappedText(err, message);
      return CLIENT_SIDE_CONNECT_ERROR;
    }
    ldapReader = connection.getLDAPReader();
    ldapWriter = connection.getLDAPWriter();
    return LDAPResultCode.SUCCESS;
    return SUCCESS;
  }
@@ -1403,10 +1376,9 @@
    SubCommand subCommand = argParser.getSubCommand();
    if (subCommand == null)
    {
      LocalizableMessage message = ERR_PWPSTATE_NO_SUBCOMMAND.get();
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_PWPSTATE_NO_SUBCOMMAND.get());
      err.println(argParser.getUsage());
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
      return CLIENT_SIDE_PARAM_ERROR;
    }
    String subCommandName = subCommand.getName();
@@ -1438,16 +1410,14 @@
        }
        else
        {
          LocalizableMessage message = ERR_PWPSTATE_INVALID_BOOLEAN_VALUE.get(valueStr);
          err.println(wrapText(message, MAX_LINE_WIDTH));
          return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
          printWrappedText(err, ERR_PWPSTATE_INVALID_BOOLEAN_VALUE.get(valueStr));
          return CLIENT_SIDE_PARAM_ERROR;
        }
      }
      else
      {
        LocalizableMessage message = ERR_PWPSTATE_NO_BOOLEAN_VALUE.get();
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
        printWrappedText(err, ERR_PWPSTATE_NO_BOOLEAN_VALUE.get());
        return CLIENT_SIDE_PARAM_ERROR;
      }
    }
    else if (subCommandName.equals(SC_CLEAR_ACCOUNT_DISABLED_STATE))
@@ -1625,16 +1595,14 @@
        }
        else
        {
          LocalizableMessage message = ERR_PWPSTATE_INVALID_BOOLEAN_VALUE.get(valueStr);
          err.println(wrapText(message, MAX_LINE_WIDTH));
          return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
          printWrappedText(err, ERR_PWPSTATE_INVALID_BOOLEAN_VALUE.get(valueStr));
          return CLIENT_SIDE_PARAM_ERROR;
        }
      }
      else
      {
        LocalizableMessage message = ERR_PWPSTATE_NO_BOOLEAN_VALUE.get();
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
        printWrappedText(err, ERR_PWPSTATE_NO_BOOLEAN_VALUE.get());
        return CLIENT_SIDE_PARAM_ERROR;
      }
    }
    else if(subCommandName.equals(SC_CLEAR_PASSWORD_RESET_STATE))
@@ -1725,13 +1693,12 @@
    }
    else
    {
      LocalizableMessage message = ERR_PWPSTATE_INVALID_SUBCOMMAND.get(subCommandName);
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_PWPSTATE_INVALID_SUBCOMMAND.get(subCommandName));
      err.println(argParser.getUsage());
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
      return CLIENT_SIDE_PARAM_ERROR;
    }
    return LDAPResultCode.SUCCESS;
    return SUCCESS;
  }
opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java
@@ -153,9 +153,7 @@
    }
    catch (ArgumentException ae)
    {
      final LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
      return 1;
    }
@@ -166,9 +164,7 @@
    }
    catch (ArgumentException ae)
    {
      final LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      err.println(argParser.getUsage());
      return 1;
    }
@@ -192,53 +188,42 @@
        && !rebuildAll.isPresent()
        && !rebuildDegraded.isPresent())
    {
      final LocalizableMessage message =
          ERR_REBUILDINDEX_REQUIRES_AT_LEAST_ONE_INDEX.get();
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_REBUILDINDEX_REQUIRES_AT_LEAST_ONE_INDEX.get());
      err.println(argParser.getUsage());
      return 1;
    }
    if (rebuildAll.isPresent() && indexList.isPresent())
    {
      final LocalizableMessage msg = ERR_REBUILDINDEX_REBUILD_ALL_ERROR.get();
      err.println(wrapText(msg, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_REBUILDINDEX_REBUILD_ALL_ERROR.get());
      err.println(argParser.getUsage());
      return 1;
    }
    if (rebuildDegraded.isPresent() && indexList.isPresent())
    {
      final LocalizableMessage msg = ERR_REBUILDINDEX_REBUILD_DEGRADED_ERROR.get("index");
      err.println(wrapText(msg, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_REBUILDINDEX_REBUILD_DEGRADED_ERROR.get("index"));
      err.println(argParser.getUsage());
      return 1;
    }
    if (rebuildDegraded.isPresent() && clearDegradedState.isPresent())
    {
      final LocalizableMessage msg =
          ERR_REBUILDINDEX_REBUILD_DEGRADED_ERROR.get("clearDegradedState");
      err.println(wrapText(msg, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_REBUILDINDEX_REBUILD_DEGRADED_ERROR.get("clearDegradedState"));
      err.println(argParser.getUsage());
      return 1;
    }
    if (rebuildAll.isPresent() && rebuildDegraded.isPresent())
    {
      final LocalizableMessage msg =
          ERR_REBUILDINDEX_REBUILD_ALL_DEGRADED_ERROR.get("rebuildDegraded");
      err.println(wrapText(msg, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_REBUILDINDEX_REBUILD_ALL_DEGRADED_ERROR.get("rebuildDegraded"));
      err.println(argParser.getUsage());
      return 1;
    }
    if (rebuildAll.isPresent() && clearDegradedState.isPresent())
    {
      final LocalizableMessage msg =
          ERR_REBUILDINDEX_REBUILD_ALL_DEGRADED_ERROR.get("clearDegradedState");
      err.println(wrapText(msg, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_REBUILDINDEX_REBUILD_ALL_DEGRADED_ERROR.get("clearDegradedState"));
      err.println(argParser.getUsage());
      return 1;
    }
@@ -250,7 +235,7 @@
    }
    catch (InitializationException e)
    {
      err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, e.getMessage());
      return 1;
    }
    return process(argParser, initializeServer, out, err);
@@ -445,9 +430,7 @@
    }
    catch (Exception e)
    {
      final LocalizableMessage message =
          ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e));
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e)));
      return 1;
    }
@@ -458,7 +441,7 @@
    }
    catch (Exception ex)
    {
      err.println(toErrorMsg(ERR_CANNOT_LOAD_CONFIG, ex));
      printWrappedText(err, toErrorMsg(ERR_CANNOT_LOAD_CONFIG, ex));
      return 1;
    }
@@ -469,7 +452,7 @@
    }
    catch (Exception e)
    {
      err.println(toErrorMsg(ERR_CANNOT_LOAD_SCHEMA, e));
      printWrappedText(err, toErrorMsg(ERR_CANNOT_LOAD_SCHEMA, e));
      return 1;
    }
@@ -481,7 +464,7 @@
    }
    catch (Exception ex)
    {
      err.println(toErrorMsg(ERR_CANNOT_INITIALIZE_CORE_CONFIG, ex));
      printWrappedText(err, toErrorMsg(ERR_CANNOT_INITIALIZE_CORE_CONFIG, ex));
      return 1;
    }
@@ -492,7 +475,7 @@
    }
    catch (Exception ex)
    {
      err.println(toErrorMsg(ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER, ex));
      printWrappedText(err, toErrorMsg(ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER, ex));
      return 1;
    }
@@ -698,8 +681,7 @@
      }
      catch (ArgumentException ae)
      {
        final LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
        out.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(out, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
        return 1;
      }
@@ -709,8 +691,7 @@
      }
      catch (ArgumentException ae)
      {
        final LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
        out.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(out, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
        return 1;
      }
opendj-server-legacy/src/main/java/org/opends/server/tools/RestoreDB.java
@@ -219,9 +219,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
      return 1;
    }
@@ -243,17 +241,14 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      err.println(argParser.getUsage());
      return 1;
    }
    catch (ClientException ce)
    {
      // No need to display the usage since the problem comes with a provided
      // value.
      err.println(wrapText(ce.getMessageObject(), MAX_LINE_WIDTH));
      // No need to display the usage since the problem comes with a provided value.
      printWrappedText(err, ce.getMessageObject());
      return 1;
    }
@@ -267,9 +262,7 @@
    if (listBackups.isPresent() && argParser.connectionArgumentsPresent()) {
      LocalizableMessage message = ERR_LDAP_CONN_INCOMPATIBLE_ARGS.get(
              listBackups.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_LDAP_CONN_INCOMPATIBLE_ARGS.get(listBackups.getLongIdentifier()));
      return 1;
    }
@@ -280,7 +273,7 @@
    }
    catch (InitializationException e)
    {
      err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, e.getMessage());
      return 1;
    }
@@ -336,9 +329,7 @@
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_SERVER_BOOTSTRAP_ERROR.get(
                getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e)));
        return 1;
      }
@@ -349,14 +340,12 @@
      }
      catch (InitializationException ie)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e)));
        return 1;
      }
@@ -369,14 +358,12 @@
      }
      catch (ConfigException | InitializationException e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e)));
        return 1;
      }
@@ -389,14 +376,12 @@
      }
      catch (ConfigException | InitializationException e)
      {
        LocalizableMessage message = ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getExceptionMessage(e)));
        return 1;
      }
@@ -408,14 +393,12 @@
      }
      catch (ConfigException | InitializationException e)
      {
        LocalizableMessage message = ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getExceptionMessage(e)));
        return 1;
      }
opendj-server-legacy/src/main/java/org/opends/server/tools/StartWindowsService.java
@@ -25,7 +25,10 @@
 *      Portions Copyright 2013-2015 ForgeRock AS.
 */
package org.opends.server.tools;
import org.forgerock.i18n.LocalizableMessage;
import static org.opends.messages.ToolMessages.*;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.util.OperatingSystem.*;
import java.io.OutputStream;
import java.io.PrintStream;
@@ -33,10 +36,6 @@
import org.opends.server.loggers.JDKLogging;
import org.opends.server.types.NullOutputStream;
import static org.opends.messages.ToolMessages.*;
import static com.forgerock.opendj.util.OperatingSystem.hasUAC;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
/**
  * This class is used to start the Windows service associated with this
  * instance on this machine.
@@ -85,8 +84,7 @@
    String serviceName = ConfigureWindowsService.getServiceName();
    if (serviceName == null)
    {
      LocalizableMessage message = ERR_WINDOWS_SERVICE_NOT_FOUND.get();
      err.println(message);
      printWrappedText(err, ERR_WINDOWS_SERVICE_NOT_FOUND.get());
      return SERVICE_NOT_FOUND;
    }
@@ -118,9 +116,8 @@
    }
    catch (Throwable t)
    {
      LocalizableMessage message = ERR_WINDOWS_SERVICE_START_ERROR.get();
      err.println(message);
      err.println("Exception:" + t);
      printWrappedText(err, ERR_WINDOWS_SERVICE_START_ERROR.get());
      printWrappedText(err, "Exception:" + t);
      return SERVICE_START_ERROR;
    }
  }
opendj-server-legacy/src/main/java/org/opends/server/tools/StopDS.java
@@ -32,6 +32,7 @@
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.util.CollectionUtils.*;
import static org.opends.server.protocols.ldap.LDAPResultCode.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -390,10 +391,8 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
      printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -404,11 +403,9 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      err.println(argParser.getUsage());
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -433,11 +430,9 @@
    // an error.
    if (bindPW.isPresent() && bindPWFile.isPresent())
    {
      LocalizableMessage message = ERR_STOPDS_MUTUALLY_EXCLUSIVE_ARGUMENTS.get(
              bindPW.getLongIdentifier(),
              bindPWFile.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
      printWrappedText(err,
          ERR_STOPDS_MUTUALLY_EXCLUSIVE_ARGUMENTS.get(bindPW.getLongIdentifier(), bindPWFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -445,11 +440,9 @@
    // then return an error.
    if (keyStorePW.isPresent() && keyStorePWFile.isPresent())
    {
      LocalizableMessage message = ERR_STOPDS_MUTUALLY_EXCLUSIVE_ARGUMENTS.get(
              keyStorePW.getLongIdentifier(),
              keyStorePWFile.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
      printWrappedText(err, ERR_STOPDS_MUTUALLY_EXCLUSIVE_ARGUMENTS.get(
              keyStorePW.getLongIdentifier(), keyStorePWFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -457,11 +450,9 @@
    // provided, then return an error.
    if (trustStorePW.isPresent() && trustStorePWFile.isPresent())
    {
      LocalizableMessage message = ERR_STOPDS_MUTUALLY_EXCLUSIVE_ARGUMENTS.get(
              trustStorePW.getLongIdentifier(),
              trustStorePWFile.getLongIdentifier());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
      printWrappedText(err, ERR_STOPDS_MUTUALLY_EXCLUSIVE_ARGUMENTS.get(
              trustStorePW.getLongIdentifier(), trustStorePWFile.getLongIdentifier()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
@@ -478,18 +469,15 @@
        }
        catch (Exception e)
        {
          LocalizableMessage message = ERR_STOPDS_CANNOT_DECODE_STOP_TIME.get();
          err.println(wrapText(message, MAX_LINE_WIDTH));
          return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
          printWrappedText(err, ERR_STOPDS_CANNOT_DECODE_STOP_TIME.get());
          return CLIENT_SIDE_PARAM_ERROR;
        }
        // Check that the provided date is not previous to the current date.
        Date currentDate = new Date(System.currentTimeMillis());
        if (currentDate.after(stopTime))
        {
          LocalizableMessage message = ERR_STOPDS_DATETIME_ALREADY_PASSED.get(
              timeStr);
          err.println(wrapText(message, MAX_LINE_WIDTH));
          return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
          printWrappedText(err, ERR_STOPDS_DATETIME_ALREADY_PASSED.get(timeStr));
          return CLIENT_SIDE_PARAM_ERROR;
        }
      }
    }
@@ -518,10 +506,8 @@
      connectionOptions.setSSLConnectionFactory(sslConnectionFactory);
    } catch (SSLConnectionException sce) {
      LocalizableMessage message =
        ERR_STOPDS_CANNOT_INITIALIZE_SSL.get(sce.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR;
      printWrappedText(err, ERR_STOPDS_CANNOT_INITIALIZE_SSL.get(sce.getMessage()));
      return CLIENT_SIDE_LOCAL_ERROR;
    }
@@ -537,9 +523,8 @@
        int equalPos = s.indexOf('=');
        if (equalPos <= 0)
        {
          LocalizableMessage message = ERR_STOPDS_CANNOT_PARSE_SASL_OPTION.get(s);
          err.println(wrapText(message, MAX_LINE_WIDTH));
          return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
          printWrappedText(err, ERR_STOPDS_CANNOT_PARSE_SASL_OPTION.get(s));
          return CLIENT_SIDE_PARAM_ERROR;
        }
        else
        {
@@ -558,9 +543,8 @@
      if (mechanism == null)
      {
        LocalizableMessage message = ERR_STOPDS_NO_SASL_MECHANISM.get();
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
        printWrappedText(err, ERR_STOPDS_NO_SASL_MECHANISM.get());
        return CLIENT_SIDE_PARAM_ERROR;
      }
      connectionOptions.setSASLMechanism(mechanism);
@@ -586,11 +570,8 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_STOPDS_CANNOT_DETERMINE_PORT.get(
              port.getLongIdentifier(),
              ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return LDAPResultCode.CLIENT_SIDE_PARAM_ERROR;
      printWrappedText(err, ERR_STOPDS_CANNOT_DETERMINE_PORT.get(port.getLongIdentifier(), ae.getMessage()));
      return CLIENT_SIDE_PARAM_ERROR;
    }
    catch (LDAPConnectionException lce)
    {
@@ -604,8 +585,8 @@
        message = ERR_STOPDS_CANNOT_CONNECT.get(hostPort,
          lce.getMessage());
      }
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR;
      printWrappedText(err, message);
      return CLIENT_SIDE_CONNECT_ERROR;
    }
    LDAPReader reader = connection.getLDAPReader();
@@ -660,20 +641,18 @@
      responseMessage = reader.readMessage();
      if (responseMessage == null)
      {
        LocalizableMessage message = ERR_STOPDS_UNEXPECTED_CONNECTION_CLOSURE.get();
        err.println(wrapText(message, MAX_LINE_WIDTH));
        return LDAPResultCode.CLIENT_SIDE_SERVER_DOWN;
        printWrappedText(err, ERR_STOPDS_UNEXPECTED_CONNECTION_CLOSURE.get());
        return CLIENT_SIDE_SERVER_DOWN;
      }
    }
    catch (DecodeException | LDAPException e)
    {
      LocalizableMessage message = ERR_STOPDS_DECODE_ERROR.get(e.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return LDAPResultCode.CLIENT_SIDE_DECODING_ERROR;
      printWrappedText(err, ERR_STOPDS_DECODE_ERROR.get(e.getMessage()));
      return CLIENT_SIDE_DECODING_ERROR;
    }
    catch (IOException ioe)
    {
      err.println(wrapText(ERR_STOPDS_IO_ERROR.get(ioe), MAX_LINE_WIDTH));
      printWrappedText(err, ERR_STOPDS_IO_ERROR.get(ioe));
      return LDAPResultCode.CLIENT_SIDE_SERVER_DOWN;
    }
@@ -691,32 +670,21 @@
        String responseOID = extendedResponse.getOID();
        if (LDAPConstants.OID_NOTICE_OF_DISCONNECTION.equals(responseOID))
        {
          LocalizableMessage message = extendedResponse.getErrorMessage();
          if (message != null)
          {
            err.println(wrapText(message, MAX_LINE_WIDTH));
          }
          printWrappedText(err, extendedResponse.getErrorMessage());
          return extendedResponse.getResultCode();
        }
      }
      LocalizableMessage message = ERR_STOPDS_INVALID_RESPONSE_TYPE.get(
              responseMessage.getProtocolOpName());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      return LDAPResultCode.CLIENT_SIDE_LOCAL_ERROR;
      printWrappedText(err, ERR_STOPDS_INVALID_RESPONSE_TYPE.get(responseMessage.getProtocolOpName()));
      return CLIENT_SIDE_LOCAL_ERROR;
    }
    AddResponseProtocolOp addResponse =
         responseMessage.getAddResponseProtocolOp();
    LocalizableMessage errorMessage = addResponse.getErrorMessage();
    if (errorMessage != null)
    {
      err.println(wrapText(errorMessage, MAX_LINE_WIDTH));
    }
    AddResponseProtocolOp addResponse = responseMessage.getAddResponseProtocolOp();
    printWrappedText(err, addResponse.getErrorMessage());
    return addResponse.getResultCode();
  }
opendj-server-legacy/src/main/java/org/opends/server/tools/StopWindowsService.java
@@ -25,7 +25,10 @@
 *      Portions Copyright 2012-2014 ForgeRock AS
 */
package org.opends.server.tools;
import org.forgerock.i18n.LocalizableMessage;
import static org.opends.messages.ToolMessages.*;
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.util.OperatingSystem.*;
import java.io.OutputStream;
import java.io.PrintStream;
@@ -33,10 +36,6 @@
import org.opends.server.loggers.JDKLogging;
import org.opends.server.types.NullOutputStream;
import static org.opends.messages.ToolMessages.*;
import static com.forgerock.opendj.util.OperatingSystem.hasUAC;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
/**
  * This class is used to stop the Windows service associated with this
  * instance on this machine.
@@ -82,8 +81,7 @@
    String serviceName = ConfigureWindowsService.getServiceName();
    if (serviceName == null)
    {
      LocalizableMessage message = ERR_WINDOWS_SERVICE_NOT_FOUND.get();
      err.println(message);
      printWrappedText(err, ERR_WINDOWS_SERVICE_NOT_FOUND.get());
      return SERVICE_NOT_FOUND;
    }
    String[] cmd;
@@ -122,9 +120,8 @@
    }
    catch (Throwable t)
    {
      LocalizableMessage message = ERR_WINDOWS_SERVICE_STOP_ERROR.get();
      err.println(message);
      err.println("Exception:" + t);
      printWrappedText(err, ERR_WINDOWS_SERVICE_STOP_ERROR.get());
      printWrappedText(err, "Exception:" + t);
      return SERVICE_STOP_ERROR;
    }
  }
opendj-server-legacy/src/main/java/org/opends/server/tools/VerifyIndex.java
@@ -178,9 +178,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
      return 1;
    }
@@ -192,9 +190,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      err.println(argParser.getUsage());
      return 1;
    }
@@ -217,10 +213,7 @@
    if (cleanMode.isPresent() && indexList.getValues().size() != 1)
    {
      LocalizableMessage message =
              ERR_VERIFYINDEX_VERIFY_CLEAN_REQUIRES_SINGLE_INDEX.get();
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_VERIFYINDEX_VERIFY_CLEAN_REQUIRES_SINGLE_INDEX.get());
      err.println(argParser.getUsage());
      return 1;
    }
@@ -232,7 +225,7 @@
    }
    catch (InitializationException e)
    {
      err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, e.getMessage());
      return 1;
    }
@@ -249,9 +242,7 @@
      }
      catch (Exception e)
      {
        LocalizableMessage message =
                ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e)));
        return 1;
      }
@@ -262,15 +253,12 @@
      }
      catch (InitializationException ie)
      {
        LocalizableMessage message =
                ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(ie.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_CONFIG.get(getExceptionMessage(e)));
        return 1;
      }
@@ -283,14 +271,12 @@
      }
      catch (ConfigException | InitializationException e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(e.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_LOAD_SCHEMA.get(getExceptionMessage(e)));
        return 1;
      }
@@ -303,16 +289,12 @@
      }
      catch (ConfigException | InitializationException e)
      {
        LocalizableMessage message =
                ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(e.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message =
                ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CORE_CONFIG.get(getExceptionMessage(e)));
        return 1;
      }
@@ -324,17 +306,12 @@
      }
      catch (ConfigException | InitializationException e)
      {
        LocalizableMessage message =
                ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(e.getMessage()));
        return 1;
      }
      catch (Exception e)
      {
        LocalizableMessage message =
                ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(
                        getExceptionMessage(e));
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_CANNOT_INITIALIZE_CRYPTO_MANAGER.get(getExceptionMessage(e)));
        return 1;
      }
    }
@@ -347,14 +324,12 @@
    }
    catch (DirectoryException de)
    {
      err.println(wrapText(ERR_CANNOT_DECODE_BASE_DN.get(baseDNString.getValue(),
          de.getMessageObject()), MAX_LINE_WIDTH));
      printWrappedText(err, ERR_CANNOT_DECODE_BASE_DN.get(baseDNString.getValue(), de.getMessageObject()));
      return 1;
    }
    catch (Exception e)
    {
      err.println(wrapText(ERR_CANNOT_DECODE_BASE_DN.get(baseDNString.getValue(),
          getExceptionMessage(e)), MAX_LINE_WIDTH));
      printWrappedText(err, ERR_CANNOT_DECODE_BASE_DN.get(baseDNString.getValue(), getExceptionMessage(e)));
      return 1;
    }
@@ -384,7 +359,7 @@
          }
          else
          {
            err.println(wrapText(ERR_MULTIPLE_BACKENDS_FOR_BASE.get(baseDNString.getValue()), MAX_LINE_WIDTH));
            printWrappedText(err, ERR_MULTIPLE_BACKENDS_FOR_BASE.get(baseDNString.getValue()));
            return 1;
          }
          break;
@@ -394,13 +369,13 @@
    if (backend == null)
    {
      err.println(wrapText(ERR_NO_BACKENDS_FOR_BASE.get(baseDNString.getValue()), MAX_LINE_WIDTH));
      printWrappedText(err, ERR_NO_BACKENDS_FOR_BASE.get(baseDNString.getValue()));
      return 1;
    }
    if (!backend.supports(BackendOperation.INDEXING))
    {
      err.println(wrapText(ERR_BACKEND_NO_INDEXING_SUPPORT.get(), MAX_LINE_WIDTH));
      printWrappedText(err, ERR_BACKEND_NO_INDEXING_SUPPORT.get());
      return 1;
    }
@@ -430,15 +405,13 @@
      StringBuilder failureReason = new StringBuilder();
      if (! LockFileManager.acquireSharedLock(lockFile, failureReason))
      {
        err.println(wrapText(ERR_VERIFYINDEX_CANNOT_LOCK_BACKEND.get(backend.getBackendID(),
            failureReason), MAX_LINE_WIDTH));
        printWrappedText(err, ERR_VERIFYINDEX_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), failureReason));
        return 1;
      }
    }
    catch (Exception e)
    {
      err.println(wrapText(ERR_VERIFYINDEX_CANNOT_LOCK_BACKEND.get(backend.getBackendID(),
          getExceptionMessage(e)), MAX_LINE_WIDTH));
      printWrappedText(err, ERR_VERIFYINDEX_CANNOT_LOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e)));
      return 1;
    }
@@ -462,14 +435,12 @@
    }
    catch (InitializationException e)
    {
      err.println(wrapText(ERR_VERIFYINDEX_ERROR_DURING_VERIFY.get(e.getMessage()),
          MAX_LINE_WIDTH));
      printWrappedText(err, ERR_VERIFYINDEX_ERROR_DURING_VERIFY.get(e.getMessage()));
      returnCode = 1;
    }
    catch (Exception e)
    {
      err.println(wrapText(ERR_VERIFYINDEX_ERROR_DURING_VERIFY.get(stackTraceToSingleLineString(e)),
          MAX_LINE_WIDTH));
      printWrappedText(err, ERR_VERIFYINDEX_ERROR_DURING_VERIFY.get(stackTraceToSingleLineString(e)));
      returnCode = 1;
    }
@@ -481,16 +452,13 @@
      StringBuilder failureReason = new StringBuilder();
      if (! LockFileManager.releaseLock(lockFile, failureReason))
      {
        err.println(wrapText(WARN_VERIFYINDEX_CANNOT_UNLOCK_BACKEND.get(backend.getBackendID(),
            failureReason), MAX_LINE_WIDTH));
        printWrappedText(err, WARN_VERIFYINDEX_CANNOT_UNLOCK_BACKEND.get(backend.getBackendID(), failureReason));
      }
    }
    catch (Exception e)
    {
      err.println(wrapText(WARN_VERIFYINDEX_CANNOT_UNLOCK_BACKEND.get(backend.getBackendID(),
          getExceptionMessage(e)), MAX_LINE_WIDTH));
      printWrappedText(err, WARN_VERIFYINDEX_CANNOT_UNLOCK_BACKEND.get(backend.getBackendID(), getExceptionMessage(e)));
    }
    return returnCode;
  }
}
opendj-server-legacy/src/main/java/org/opends/server/tools/makeldif/MakeLDIF.java
@@ -205,8 +205,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
      return 1;
    }
@@ -218,8 +217,7 @@
    }
    catch (ArgumentException ae)
    {
      LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
      err.println(argParser.getUsage());
      return 1;
    }
@@ -239,7 +237,7 @@
    }
    catch (InitializationException e)
    {
      err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, e.getMessage());
      return 1;
    }
@@ -256,8 +254,7 @@
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_MAKELDIF_CANNOT_INITIALIZE_JMX.get(configFile.getValue(), e.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_MAKELDIF_CANNOT_INITIALIZE_JMX.get(configFile.getValue(), e.getMessage()));
        return 1;
      }
@@ -268,8 +265,7 @@
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_MAKELDIF_CANNOT_INITIALIZE_CONFIG.get(configFile.getValue(), e.getMessage());
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_MAKELDIF_CANNOT_INITIALIZE_CONFIG.get(configFile.getValue(), e.getMessage()));
        return 1;
      }
    }
@@ -282,8 +278,7 @@
      }
      catch (Exception e)
      {
        LocalizableMessage message = ERR_MAKELDIF_CANNOT_INITIALIZE_SCHEMA.get(configFile.getValue(), e.getMessage());
        System.err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_MAKELDIF_CANNOT_INITIALIZE_SCHEMA.get(configFile.getValue(), e.getMessage()));
        return 1;
      }
    }
@@ -313,9 +308,7 @@
    File resourceDir = new File(resourcePath.getValue());
    if (! resourceDir.exists())
    {
      LocalizableMessage message = ERR_MAKELDIF_NO_SUCH_RESOURCE_DIRECTORY.get(
              resourcePath.getValue());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_MAKELDIF_NO_SUCH_RESOURCE_DIRECTORY.get(resourcePath.getValue()));
      return 1;
    }
@@ -329,14 +322,12 @@
    }
    catch (IOException ioe)
    {
      LocalizableMessage message = ERR_MAKELDIF_IOEXCEPTION_DURING_PARSE.get(ioe.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_MAKELDIF_IOEXCEPTION_DURING_PARSE.get(ioe.getMessage()));
      return 1;
    }
    catch (Exception e)
    {
      LocalizableMessage message = ERR_MAKELDIF_EXCEPTION_DURING_PARSE.get(e.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_MAKELDIF_EXCEPTION_DURING_PARSE.get(e.getMessage()));
      return 1;
    }
@@ -346,7 +337,7 @@
    {
      for (LocalizableMessage s : warnings)
      {
        err.println(wrapText(s, MAX_LINE_WIDTH));
        printWrappedText(err, s);
      }
    }
@@ -361,8 +352,7 @@
    }
    catch (IOException ioe)
    {
      LocalizableMessage message = ERR_MAKELDIF_UNABLE_TO_CREATE_LDIF.get(ldifFile.getValue(), ioe);
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_MAKELDIF_UNABLE_TO_CREATE_LDIF.get(ldifFile.getValue(), ioe));
      return 1;
    }
@@ -374,9 +364,7 @@
    }
    catch (Exception e)
    {
      LocalizableMessage message = ERR_MAKELDIF_ERROR_WRITING_LDIF.get(
              ldifFile.getValue(), stackTraceToSingleLineString(e));
      err.println(wrapText(message, MAX_LINE_WIDTH));
      printWrappedText(err, ERR_MAKELDIF_ERROR_WRITING_LDIF.get(ldifFile.getValue(), stackTraceToSingleLineString(e)));
      return 1;
    }
    finally
@@ -431,9 +419,7 @@
        if ((++entriesWritten % 1000) == 0)
        {
          LocalizableMessage message =
            INFO_MAKELDIF_PROCESSED_N_ENTRIES.get(entriesWritten);
          out.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(out, INFO_MAKELDIF_PROCESSED_N_ENTRIES.get(entriesWritten));
        }
      }
      else
@@ -448,9 +434,7 @@
            break ;
          }
        }
        LocalizableMessage message =
          ERR_MAKELDIF_CANNOT_WRITE_ENTRY_WITHOUT_DN.get(nullRdn);
        err.println(wrapText(message, MAX_LINE_WIDTH));
        printWrappedText(err, ERR_MAKELDIF_CANNOT_WRITE_ENTRY_WITHOUT_DN.get(nullRdn));
        return true;
      }
@@ -477,8 +461,7 @@
  @Override
  public void closeEntryWriter()
  {
    LocalizableMessage message = INFO_MAKELDIF_PROCESSING_COMPLETE.get(entriesWritten);
    out.println(wrapText(message, MAX_LINE_WIDTH));
    printWrappedText(out, INFO_MAKELDIF_PROCESSING_COMPLETE.get(entriesWritten));
  }
}
opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskTool.java
@@ -267,9 +267,7 @@
        }
        catch (Exception e)
        {
          LocalizableMessage message = ERR_SERVER_BOOTSTRAP_ERROR.get(
                  getExceptionMessage(e));
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_SERVER_BOOTSTRAP_ERROR.get(getExceptionMessage(e)));
          return 1;
        }
      }
@@ -281,24 +279,12 @@
        TaskEntry taskEntry = tc.schedule(this);
        LocalizableMessage startTime = taskEntry.getScheduledStartTime();
        if (taskEntry.getTaskState() == TaskState.RECURRING) {
          out.println(
                  wrapText(INFO_TASK_TOOL_RECURRING_TASK_SCHEDULED.get(
                          taskEntry.getType(),
                          taskEntry.getId()),
                  MAX_LINE_WIDTH));
          printWrappedText(out, INFO_TASK_TOOL_RECURRING_TASK_SCHEDULED.get(taskEntry.getType(), taskEntry.getId()));
        } else if (startTime == null || startTime.length() == 0) {
          out.println(
                  wrapText(INFO_TASK_TOOL_TASK_SCHEDULED_NOW.get(
                          taskEntry.getType(),
                          taskEntry.getId()),
                  MAX_LINE_WIDTH));
          printWrappedText(out, INFO_TASK_TOOL_TASK_SCHEDULED_NOW.get(taskEntry.getType(), taskEntry.getId()));
        } else {
          out.println(
                  wrapText(INFO_TASK_TOOL_TASK_SCHEDULED_FUTURE.get(
                          taskEntry.getType(),
                          taskEntry.getId(),
                          taskEntry.getScheduledStartTime()),
                  MAX_LINE_WIDTH));
          printWrappedText(out, INFO_TASK_TOOL_TASK_SCHEDULED_FUTURE.get(
              taskEntry.getType(), taskEntry.getId(), taskEntry.getScheduledStartTime()));
        }
        if (!taskScheduleArgs.startArg.isPresent()) {
@@ -323,66 +309,36 @@
          } while (!taskEntry.isDone());
          if (TaskState.isSuccessful(taskEntry.getTaskState())) {
            if (taskEntry.getTaskState() != TaskState.RECURRING) {
              out.println(
                  wrapText(INFO_TASK_TOOL_TASK_SUCESSFULL.get(
                          taskEntry.getType(),
                          taskEntry.getId()),
                  MAX_LINE_WIDTH));
              printWrappedText(out, INFO_TASK_TOOL_TASK_SUCESSFULL.get(taskEntry.getType(), taskEntry.getId()));
            }
            return 0;
          } else {
            out.println(
                wrapText(INFO_TASK_TOOL_TASK_NOT_SUCESSFULL.get(
                        taskEntry.getType(),
                        taskEntry.getId()),
                MAX_LINE_WIDTH));
            printWrappedText(out, INFO_TASK_TOOL_TASK_NOT_SUCESSFULL.get(taskEntry.getType(), taskEntry.getId()));
            return 1;
          }
        }
        ret = 0;
      } catch (LDAPConnectionException e) {
        LocalizableMessage message;
        if (isWrongPortException(e,
            Integer.valueOf(argParser.getArguments().getPort())))
        {
          message = ERR_TASK_LDAP_FAILED_TO_CONNECT_WRONG_PORT.get(
            argParser.getArguments().getHostName(),
            argParser.getArguments().getPort());
          printWrappedText(err, ERR_TASK_LDAP_FAILED_TO_CONNECT_WRONG_PORT.get(
              argParser.getArguments().getHostName(), argParser.getArguments().getPort()));
        } else {
          message = ERR_TASK_TOOL_START_TIME_NO_LDAP.get(e.getMessage());
        }
        if (err != null)
        {
          err.println(wrapText(message, MAX_LINE_WIDTH));
          printWrappedText(err, ERR_TASK_TOOL_START_TIME_NO_LDAP.get(e.getMessage()));
        }
        ret = 1;
      } catch (DecodeException ae) {
        LocalizableMessage message = ERR_TASK_TOOL_DECODE_ERROR.get(ae.getMessage());
        if (err != null)
        {
          err.println(wrapText(message, MAX_LINE_WIDTH));
        }
        printWrappedText(err, ERR_TASK_TOOL_DECODE_ERROR.get(ae.getMessage()));
        ret = 1;
      } catch (IOException ioe) {
        LocalizableMessage message = ERR_TASK_TOOL_IO_ERROR.get(ioe);
        if (err != null)
        {
          err.println(wrapText(message, MAX_LINE_WIDTH));
        }
        printWrappedText(err, ERR_TASK_TOOL_IO_ERROR.get(ioe));
        ret = 1;
      } catch (LDAPException le) {
        LocalizableMessage message = ERR_TASK_TOOL_LDAP_ERROR.get(le.getMessage());
        if (err != null)
        {
          err.println(wrapText(message, MAX_LINE_WIDTH));
        }
        printWrappedText(err, ERR_TASK_TOOL_LDAP_ERROR.get(le.getMessage()));
        ret = 1;
      } catch (ArgumentException | OpenDsException e) {
        LocalizableMessage message = e.getMessageObject();
        if (err != null)
        {
          err.println(wrapText(message, MAX_LINE_WIDTH));
        }
        printWrappedText(err, e.getMessageObject());
        ret = 1;
      } finally
      {
opendj-server-legacy/src/main/java/org/opends/server/util/args/LDAPConnectionArgumentParser.java
@@ -222,7 +222,7 @@
      }
      catch (SSLConnectionException sce)
      {
        err.println(wrapText(ERR_LDAP_CONN_CANNOT_INITIALIZE_SSL.get(sce.getMessage()), MAX_LINE_WIDTH));
        printWrappedText(err, ERR_LDAP_CONN_CANNOT_INITIALIZE_SSL.get(sce.getMessage()));
      }
    }
@@ -280,7 +280,7 @@
  private void printAndThrowException(PrintStream err, LocalizableMessage message) throws ArgumentException
  {
    err.println(wrapText(message, MAX_LINE_WIDTH));
    printWrappedText(err, message);
    throw new ArgumentException(message);
  }
@@ -425,7 +425,7 @@
    }
    catch (Exception ex)
    {
      err.println(wrapText(ex.getMessage(), MAX_LINE_WIDTH));
      printWrappedText(err, ex.getMessage());
      return null;
    }
  }
@@ -464,7 +464,7 @@
      // an empty password to the server.
      while (pwChars.length == 0)
      {
        err.println(wrapText(INFO_LDAPAUTH_NON_EMPTY_PASSWORD.get(), MAX_LINE_WIDTH));
        printWrappedText(err, INFO_LDAPAUTH_NON_EMPTY_PASSWORD.get());
        out.print(INFO_LDAPAUTH_PASSWORD_PROMPT.get(bindDNValue));
        pwChars = ConsoleApplication.readPassword();
      }
opendj-server-legacy/src/messages/org/opends/messages/tool.properties
@@ -2672,3 +2672,5 @@
 by this version of the tool
ERR_INSTANCE_NOT_CONFIGURED_20013=The local instance is not configured or you do not \
 have permissions to access it.
ERR_SEARCH_INVALID_DEREFERENCE_POLICY_20014=Invalid deref alias specified: %s
ERR_FILE_NOT_FULLY_READABLE_20015=Could not completely read file '%s'