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

Violette Roche-Montane
29.57.2014 8f434776744e26ae11fe4d7e395837f62461dc59
OPENDJ-1303 Split out CLI support from opendj-ldap-toolkit into a separate Maven module, "opendj-cli"
- Add dependency to opendj-cli module.
- Classes modified in order to take into account this change.
- Fixed comments.

13 files deleted
19 files modified
6092 ■■■■■ changed files
opendj-ldap-toolkit/pom.xml 5 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/Argument.java 650 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ArgumentException.java 72 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ArgumentGroup.java 171 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ArgumentParser.java 1598 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthRate.java 53 ●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/BooleanArgument.java 110 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/CLIException.java 84 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ConnectionFactoryProvider.java 31 ●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ConsoleApplication.java 324 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/DataSource.java 5 ●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/FileBasedArgument.java 243 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/IntegerArgument.java 485 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPCompare.java 57 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java 58 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java 44 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java 75 ●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFDiff.java 29 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFModify.java 32 ●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFSearch.java 38 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/MakeLDIF.java 15 ●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ModRate.java 44 ●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/MultiChoiceArgument.java 238 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/MultiColumnPrinter.java 475 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/PerformanceRunner.java 12 ●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/PromptingTrustManager.java 3 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/SearchRate.java 41 ●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/StringArgument.java 135 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ToolConstants.java 625 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/Utils.java 329 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/test/java/com/forgerock/opendj/ldap/tools/ConnectionFactoryProviderTest.java 5 ●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/src/test/java/com/forgerock/opendj/ldap/tools/MakeLDIFTestCase.java 6 ●●●●● patch | view | raw | blame | history
opendj-ldap-toolkit/pom.xml
@@ -57,6 +57,11 @@
      <artifactId>i18n-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.forgerock.opendj</groupId>
      <artifactId>opendj-cli</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.forgerock</groupId>
      <artifactId>forgerock-build-tools</artifactId>
      <version>${forgerockBuildToolsVersion}</version>
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/Argument.java
File was deleted
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ArgumentException.java
File was deleted
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ArgumentGroup.java
File was deleted
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ArgumentParser.java
File was deleted
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthRate.java
@@ -22,14 +22,14 @@
 *
 *
 *      Copyright 2010 Sun Microsystems, Inc.
 *      Portions copyright 2011 ForgeRock AS
 *      Portions copyright 2011-2014 ForgeRock AS
 */
package com.forgerock.opendj.ldap.tools;
import static com.forgerock.opendj.ldap.tools.ToolConstants.*;
import static com.forgerock.opendj.cli.CliConstants.*;
import static com.forgerock.opendj.ldap.tools.ToolsMessages.*;
import static com.forgerock.opendj.ldap.tools.Utils.filterExitCode;
import static com.forgerock.opendj.ldap.tools.Utils.setDefaultPerfToolProperties;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
import java.util.ArrayList;
import java.util.LinkedList;
@@ -39,6 +39,16 @@
import java.util.concurrent.atomic.AtomicLong;
import org.forgerock.i18n.LocalizableMessage;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.CommonArguments;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.ArgumentParser;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.MultiChoiceArgument;
import com.forgerock.opendj.cli.StringArgument;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.ConnectionFactory;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
@@ -362,8 +372,7 @@
    }
    private int run(final String[] args) {
        // Create the command-line argument parser for use with this
        // program.
        // Create the command-line argument parser for use with this program.
        final LocalizableMessage toolDescription = INFO_AUTHRATE_TOOL_DESCRIPTION.get();
        final ArgumentParser argParser =
                new ArgumentParser(AuthRate.class.getName(), toolDescription, false, true, 0, 0,
@@ -382,27 +391,20 @@
        IntegerArgument invalidCredPercent;
        try {
            Utils.setDefaultPerfToolProperties();
            setDefaultPerfToolProperties();
            connectionFactoryProvider = new ConnectionFactoryProvider(argParser, this);
            runner = new BindPerformanceRunner(argParser, this);
            propertiesFileArgument =
                    new StringArgument("propertiesFilePath", null, OPTION_LONG_PROP_FILE_PATH,
                            false, false, true, INFO_PROP_FILE_PATH_PLACEHOLDER.get(), null, null,
                            INFO_DESCRIPTION_PROP_FILE_PATH.get());
            propertiesFileArgument = CommonArguments.getPropertiesFileArgument();
            argParser.addArgument(propertiesFileArgument);
            argParser.setFilePropertiesArgument(propertiesFileArgument);
            noPropertiesFileArgument =
                    new BooleanArgument("noPropertiesFileArgument", null, OPTION_LONG_NO_PROP_FILE,
                            INFO_DESCRIPTION_NO_PROP_FILE.get());
            noPropertiesFileArgument = CommonArguments.getNoPropertiesFileArgument();
            argParser.addArgument(noPropertiesFileArgument);
            argParser.setNoPropertiesFileArgument(noPropertiesFileArgument);
            showUsage =
                    new BooleanArgument("showUsage", OPTION_SHORT_HELP, OPTION_LONG_HELP,
                            INFO_DESCRIPTION_SHOWUSAGE.get());
            showUsage = CommonArguments.getShowUsage();
            argParser.addArgument(showUsage);
            argParser.setUsageArgument(showUsage, getOutputStream());
@@ -439,9 +441,7 @@
            invalidCredPercent.setPropertyName("invalidPassword");
            argParser.addArgument(invalidCredPercent);
            verbose =
                    new BooleanArgument("verbose", 'v', "verbose", INFO_DESCRIPTION_VERBOSE.get());
            verbose.setPropertyName("verbose");
            verbose = CommonArguments.getVerbose();
            argParser.addArgument(verbose);
            scriptFriendly =
@@ -459,8 +459,8 @@
        try {
            argParser.parseArguments(args);
            // If we should just display usage or version information,
            // then print it and exit.
            /* If we should just display usage or version information,
             then print it and exit.*/
            if (argParser.usageOrVersionDisplayed()) {
                return 0;
            }
@@ -482,9 +482,9 @@
        final List<String> attributes = new LinkedList<String>();
        final ArrayList<String> filterAndAttributeStrings = argParser.getTrailingArguments();
        if (filterAndAttributeStrings.size() > 0) {
            // the list of trailing arguments should be structured as follow:
            // the first trailing argument is considered the filter, the other
            // as attributes.
             /*The list of trailing arguments should be structured as follow:
             the first trailing argument is considered the filter, the other
             as attributes.*/
            runner.filter = filterAndAttributeStrings.remove(0);
            // The rest are attributes
@@ -503,8 +503,7 @@
            return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
        }
        // Try it out to make sure the format string and data sources
        // match.
        // Try it out to make sure the format string and data sources match.
        final Object[] data = DataSource.generateData(runner.getDataSources(), null);
        try {
            if (runner.baseDN != null && runner.filter != null) {
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/BooleanArgument.java
File was deleted
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/CLIException.java
File was deleted
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ConnectionFactoryProvider.java
@@ -22,12 +22,11 @@
 *
 *
 *      Copyright 2010 Sun Microsystems, Inc.
 *      Portions copyright 2011-2013 ForgeRock AS
 *      Portions copyright 2011-2014 ForgeRock AS
 */
package com.forgerock.opendj.ldap.tools;
import static com.forgerock.opendj.ldap.tools.ToolConstants.*;
import static com.forgerock.opendj.cli.CliConstants.*;
import static com.forgerock.opendj.ldap.tools.ToolsMessages.*;
import java.io.File;
@@ -47,6 +46,16 @@
import javax.net.ssl.X509TrustManager;
import org.forgerock.i18n.LocalizableMessage;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.ArgumentParser;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.CLIException;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.FileBasedArgument;
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.StringArgument;
import org.forgerock.opendj.ldap.ConnectionFactory;
import org.forgerock.opendj.ldap.KeyManagers;
import org.forgerock.opendj.ldap.LDAPConnectionFactory;
@@ -68,11 +77,6 @@
 */
final class ConnectionFactoryProvider {
    /**
     * End Of Line.
     */
    static final String EOL = System.getProperty("line.separator");
    /**
     * The Logger.
     */
    static final Logger LOG = Logger.getLogger(ConnectionFactoryProvider.class.getName());
@@ -353,8 +357,8 @@
                throw new ArgumentException(message);
            }
            // Couldn't have at the same time trustAll and
            // trustStore related arg
            /* Couldn't have at the same time trustAll and
             trustStore related arg*/
            if (trustAllArg.isPresent() && trustStorePathArg.isPresent()) {
                final LocalizableMessage message =
                        ERR_TOOL_CONFLICTING_ARGS.get(trustAllArg.getLongIdentifier(),
@@ -374,8 +378,8 @@
                throw new ArgumentException(message);
            }
            // Couldn't have at the same time trustStorePasswordArg and
            // trustStorePasswordFileArg
            /* Couldn't have at the same time trustStorePasswordArg and
             trustStorePasswordFileArg*/
            if (trustStorePasswordArg.isPresent() && trustStorePasswordFileArg.isPresent()) {
                final LocalizableMessage message =
                        ERR_TOOL_CONFLICTING_ARGS.get(trustStorePasswordArg.getLongIdentifier(),
@@ -401,8 +405,7 @@
                }
            }
            // Couldn't have at the same time startTLSArg and
            // useSSLArg
            // Couldn't have at the same time startTLSArg and useSSLArg
            if (useStartTLSArg.isPresent() && useSSLArg.isPresent()) {
                final LocalizableMessage message =
                        ERR_TOOL_CONFLICTING_ARGS.get(useStartTLSArg.getLongIdentifier(), useSSLArg
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ConsoleApplication.java
File was deleted
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/DataSource.java
@@ -22,6 +22,7 @@
 *
 *
 *      Copyright 2009-2010 Sun Microsystems, Inc.
 *      Portions copyright 2014 ForgeRock AS
 */
package com.forgerock.opendj.ldap.tools;
@@ -37,7 +38,9 @@
import org.forgerock.i18n.LocalizableMessage;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.util.StaticUtils;
import org.forgerock.util.Reject;
/**
@@ -249,7 +252,7 @@
     *            Data sources that will generate arguments referenced by the
     *            format specifiers in the format string.
     * @param data
     *            The array where genereated data will be placed to format the
     *            The array where generated data will be placed to format the
     *            string.
     * @return A formatted string
     */
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/FileBasedArgument.java
File was deleted
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/IntegerArgument.java
File was deleted
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPCompare.java
@@ -22,14 +22,14 @@
 *
 *
 *      Copyright 2010 Sun Microsystems, Inc.
 *      Portions copyright 2011-2012 ForgeRock AS
 *      Portions copyright 2011-2014 ForgeRock AS
 */
package com.forgerock.opendj.ldap.tools;
import static com.forgerock.opendj.ldap.tools.ToolConstants.*;
import static com.forgerock.opendj.cli.CliConstants.*;
import static com.forgerock.opendj.ldap.tools.ToolsMessages.*;
import static com.forgerock.opendj.ldap.tools.Utils.filterExitCode;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
import static com.forgerock.opendj.cli.Utils.readBytesFromFile;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
@@ -54,6 +54,14 @@
import org.forgerock.opendj.ldap.requests.Requests;
import org.forgerock.opendj.ldap.responses.Result;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.ArgumentParser;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.CommonArguments;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.StringArgument;
/**
 * A tool that can be used to issue Compare requests to the Directory Server.
 */
@@ -138,16 +146,12 @@
        try {
            connectionFactoryProvider = new ConnectionFactoryProvider(argParser, this);
            propertiesFileArgument =
                    new StringArgument("propertiesFilePath", null, OPTION_LONG_PROP_FILE_PATH,
                            false, false, true, INFO_PROP_FILE_PATH_PLACEHOLDER.get(), null, null,
                            INFO_DESCRIPTION_PROP_FILE_PATH.get());
            propertiesFileArgument = CommonArguments.getPropertiesFileArgument();
            argParser.addArgument(propertiesFileArgument);
            argParser.setFilePropertiesArgument(propertiesFileArgument);
            noPropertiesFileArgument =
                    new BooleanArgument("noPropertiesFileArgument", null, OPTION_LONG_NO_PROP_FILE,
                            INFO_DESCRIPTION_NO_PROP_FILE.get());
            noPropertiesFileArgument = CommonArguments.getNoPropertiesFileArgument();
            argParser.addArgument(noPropertiesFileArgument);
            argParser.setNoPropertiesFileArgument(noPropertiesFileArgument);
@@ -180,12 +184,7 @@
            controlStr.setPropertyName("control");
            argParser.addArgument(controlStr);
            version =
                    new IntegerArgument("version", OPTION_SHORT_PROTOCOL_VERSION,
                            OPTION_LONG_PROTOCOL_VERSION, false, false, true,
                            INFO_PROTOCOL_VERSION_PLACEHOLDER.get(), 3, null,
                            INFO_DESCRIPTION_VERSION.get());
            version.setPropertyName(OPTION_LONG_PROTOCOL_VERSION);
            version = CommonArguments.getVersionArgument();
            argParser.addArgument(version);
            encodingStr =
@@ -195,10 +194,7 @@
            encodingStr.setPropertyName("encoding");
            argParser.addArgument(encodingStr);
            continueOnError =
                    new BooleanArgument("continueOnError", 'c', "continueOnError",
                            INFO_DESCRIPTION_CONTINUE_ON_ERROR.get());
            continueOnError.setPropertyName("continueOnError");
            continueOnError = CommonArguments.getContinueOnErrorArgument();
            argParser.addArgument(continueOnError);
            noop =
@@ -207,16 +203,13 @@
            noop.setPropertyName(OPTION_LONG_DRYRUN);
            argParser.addArgument(noop);
            verbose =
                    new BooleanArgument("verbose", 'v', "verbose", INFO_DESCRIPTION_VERBOSE.get());
            verbose.setPropertyName("verbose");
            verbose = CommonArguments.getVerbose();
            argParser.addArgument(verbose);
            showUsage =
                    new BooleanArgument("showUsage", OPTION_SHORT_HELP, OPTION_LONG_HELP,
                            INFO_DESCRIPTION_SHOWUSAGE.get());
            showUsage = CommonArguments.getShowUsage();
            argParser.addArgument(showUsage);
            argParser.setUsageArgument(showUsage, getOutputStream());
        } catch (final ArgumentException ae) {
            final LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
            println(message);
@@ -227,8 +220,8 @@
        try {
            argParser.parseArguments(args);
            // If we should just display usage or version information,
            // then print it and exit.
            /* If we should just display usage or version information,
             then print it and exit.*/
            if (argParser.usageOrVersionDisplayed()) {
                return 0;
            }
@@ -274,8 +267,8 @@
            return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
        }
        // If trailing DNs were provided and the filename argument was also
        // provided, exit with an error.
        /* If trailing DNs were provided and the filename argument was also
         provided, exit with an error.*/
        if (!dnStrings.isEmpty() && filename.isPresent()) {
            println(ERR_LDAPCOMPARE_FILENAME_AND_DNS.get());
            return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
@@ -305,7 +298,7 @@
            } else if (nextChar == '<') {
                try {
                    final String filePath = remainder.substring(1, remainder.length());
                    attributeVal = ByteString.wrap(Utils.readBytesFromFile(filePath));
                    attributeVal = ByteString.wrap(readBytesFromFile(filePath));
                } catch (final Exception e) {
                    println(INFO_COMPARE_CANNOT_READ_ASSERTION_VALUE_FROM_FILE.get(String
                            .valueOf(e)));
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java
@@ -22,14 +22,15 @@
 *
 *
 *      Copyright 2010 Sun Microsystems, Inc.
 *      Portions copyright 2011-2012 ForgeRock AS
 *      Portions copyright 2011-2014 ForgeRock AS
 */
package com.forgerock.opendj.ldap.tools;
import static com.forgerock.opendj.ldap.tools.ToolConstants.*;
import static com.forgerock.opendj.cli.CliConstants.*;
import static com.forgerock.opendj.ldap.tools.ToolsMessages.*;
import static com.forgerock.opendj.ldap.tools.Utils.filterExitCode;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
import static com.forgerock.opendj.ldap.tools.Utils.printErrorMessage;
import static org.forgerock.util.Utils.closeSilently;
import java.io.FileInputStream;
import java.io.IOException;
@@ -66,6 +67,14 @@
import org.forgerock.opendj.ldif.LDIFChangeRecordReader;
import org.forgerock.opendj.ldif.LDIFEntryWriter;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.ArgumentParser;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.CommonArguments;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.StringArgument;
/**
 * A tool that can be used to issue update (Add/Delete/Modify/ModifyDN) requests
 * to the Directory Server.
@@ -102,7 +111,7 @@
                    printResult(opType, change.getName().toString(), r);
                    return r.getResultCode().intValue();
                } catch (final ErrorResultException ere) {
                    return Utils.printErrorMessage(LDAPModify.this, ere);
                    return printErrorMessage(LDAPModify.this, ere);
                }
            }
            return ResultCode.SUCCESS.intValue();
@@ -232,8 +241,7 @@
    }
    private int run(final String[] args) {
        // Create the command-line argument parser for use with this
        // program.
        // Create the command-line argument parser for use with this program.
        final LocalizableMessage toolDescription = INFO_LDAPMODIFY_TOOL_DESCRIPTION.get();
        final ArgumentParser argParser =
                new ArgumentParser(LDAPModify.class.getName(), toolDescription, false);
@@ -258,16 +266,12 @@
        try {
            connectionFactoryProvider = new ConnectionFactoryProvider(argParser, this);
            propertiesFileArgument =
                    new StringArgument("propertiesFilePath", null, OPTION_LONG_PROP_FILE_PATH,
                            false, false, true, INFO_PROP_FILE_PATH_PLACEHOLDER.get(), null, null,
                            INFO_DESCRIPTION_PROP_FILE_PATH.get());
            propertiesFileArgument = CommonArguments.getPropertiesFileArgument();
            argParser.addArgument(propertiesFileArgument);
            argParser.setFilePropertiesArgument(propertiesFileArgument);
            noPropertiesFileArgument =
                    new BooleanArgument("noPropertiesFileArgument", null, OPTION_LONG_NO_PROP_FILE,
                            INFO_DESCRIPTION_NO_PROP_FILE.get());
            noPropertiesFileArgument = CommonArguments.getNoPropertiesFileArgument();
            argParser.addArgument(noPropertiesFileArgument);
            argParser.setNoPropertiesFileArgument(noPropertiesFileArgument);
@@ -319,12 +323,7 @@
            controlStr.setPropertyName("control");
            argParser.addArgument(controlStr);
            version =
                    new IntegerArgument("version", OPTION_SHORT_PROTOCOL_VERSION,
                            OPTION_LONG_PROTOCOL_VERSION, false, false, true,
                            INFO_PROTOCOL_VERSION_PLACEHOLDER.get(), 3, null,
                            INFO_DESCRIPTION_VERSION.get());
            version.setPropertyName(OPTION_LONG_PROTOCOL_VERSION);
            version = CommonArguments.getVersionArgument();
            argParser.addArgument(version);
            encodingStr =
@@ -334,10 +333,7 @@
            encodingStr.setPropertyName("encoding");
            argParser.addArgument(encodingStr);
            continueOnError =
                    new BooleanArgument("continueOnError", 'c', "continueOnError",
                            INFO_DESCRIPTION_CONTINUE_ON_ERROR.get());
            continueOnError.setPropertyName("continueOnError");
            continueOnError = CommonArguments.getContinueOnErrorArgument();
            argParser.addArgument(continueOnError);
            noop =
@@ -346,14 +342,10 @@
            noop.setPropertyName(OPTION_LONG_DRYRUN);
            argParser.addArgument(noop);
            verbose =
                    new BooleanArgument("verbose", 'v', "verbose", INFO_DESCRIPTION_VERBOSE.get());
            verbose.setPropertyName("verbose");
            verbose = CommonArguments.getVerbose();
            argParser.addArgument(verbose);
            showUsage =
                    new BooleanArgument("showUsage", OPTION_SHORT_HELP, OPTION_LONG_HELP,
                            INFO_DESCRIPTION_SHOWUSAGE.get());
            showUsage = CommonArguments.getShowUsage();
            argParser.addArgument(showUsage);
            argParser.setUsageArgument(showUsage, getOutputStream());
        } catch (final ArgumentException ae) {
@@ -366,8 +358,8 @@
        try {
            argParser.parseArguments(args);
            // If we should just display usage or version information,
            // then print it and exit.
            /* If we should just display usage or version information,
             then print it and exit.*/
            if (argParser.usageOrVersionDisplayed()) {
                return 0;
            }
@@ -503,7 +495,7 @@
                return ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue();
            }
        } finally {
            org.forgerock.util.Utils.closeSilently(reader, connection);
            closeSilently(reader, connection);
        }
        return ResultCode.SUCCESS.intValue();
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java
@@ -22,14 +22,12 @@
 *
 *
 *      Copyright 2010 Sun Microsystems, Inc.
 *      Portions copyright 2011-2013 ForgeRock AS
 *      Portions copyright 2011-2014 ForgeRock AS
 */
package com.forgerock.opendj.ldap.tools;
import static com.forgerock.opendj.ldap.tools.ToolConstants.*;
import static com.forgerock.opendj.ldap.tools.ToolsMessages.*;
import static com.forgerock.opendj.ldap.tools.Utils.filterExitCode;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
@@ -43,6 +41,15 @@
import org.forgerock.opendj.ldap.requests.Requests;
import org.forgerock.opendj.ldap.responses.PasswordModifyExtendedResult;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.ArgumentParser;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.CommonArguments;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.FileBasedArgument;
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.StringArgument;
/**
 * A tool that can be used to issue LDAP password modify extended requests to
 * the Directory Server. It exposes the three primary options available for this
@@ -105,16 +112,12 @@
        try {
            connectionFactoryProvider = new ConnectionFactoryProvider(argParser, this);
            propertiesFileArgument =
                    new StringArgument("propertiesFilePath", null, OPTION_LONG_PROP_FILE_PATH,
                            false, false, true, INFO_PROP_FILE_PATH_PLACEHOLDER.get(), null, null,
                            INFO_DESCRIPTION_PROP_FILE_PATH.get());
            propertiesFileArgument = CommonArguments.getPropertiesFileArgument();
            argParser.addArgument(propertiesFileArgument);
            argParser.setFilePropertiesArgument(propertiesFileArgument);
            noPropertiesFileArgument =
                    new BooleanArgument("noPropertiesFileArgument", null, OPTION_LONG_NO_PROP_FILE,
                            INFO_DESCRIPTION_NO_PROP_FILE.get());
            noPropertiesFileArgument = CommonArguments.getNoPropertiesFileArgument();
            argParser.addArgument(noPropertiesFileArgument);
            argParser.setNoPropertiesFileArgument(noPropertiesFileArgument);
@@ -160,22 +163,13 @@
            controlStr.setPropertyName("control");
            argParser.addArgument(controlStr);
            version =
                    new IntegerArgument("version", OPTION_SHORT_PROTOCOL_VERSION,
                            OPTION_LONG_PROTOCOL_VERSION, false, false, true,
                            INFO_PROTOCOL_VERSION_PLACEHOLDER.get(), 3, null,
                            INFO_DESCRIPTION_VERSION.get());
            version.setPropertyName(OPTION_LONG_PROTOCOL_VERSION);
            version = CommonArguments.getVersionArgument();
            argParser.addArgument(version);
            verbose =
                    new BooleanArgument("verbose", 'v', "verbose", INFO_DESCRIPTION_VERBOSE.get());
            verbose.setPropertyName("verbose");
            verbose = CommonArguments.getVerbose();
            argParser.addArgument(verbose);
            showUsage =
                    new BooleanArgument("showUsage", OPTION_SHORT_HELP, OPTION_LONG_HELP,
                            INFO_DESCRIPTION_SHOWUSAGE.get());
            showUsage = CommonArguments.getShowUsage();
            argParser.addArgument(showUsage);
            argParser.setUsageArgument(showUsage, getOutputStream());
        } catch (final ArgumentException ae) {
@@ -188,8 +182,8 @@
        try {
            argParser.parseArguments(args);
            // If we should just display usage or version information,
            // then print it and exit.
            /* If we should just display usage or version information,
             then print it and exit.*/
            if (argParser.usageOrVersionDisplayed()) {
                return 0;
            }
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java
@@ -22,14 +22,15 @@
 *
 *
 *      Copyright 2010 Sun Microsystems, Inc.
 *      Portions copyright 2011-2012 ForgeRock AS
 *      Portions copyright 2011-2014 ForgeRock AS
 */
package com.forgerock.opendj.ldap.tools;
import static com.forgerock.opendj.ldap.tools.ToolConstants.*;
import static com.forgerock.opendj.cli.CliConstants.*;
import static com.forgerock.opendj.ldap.tools.ToolsMessages.*;
import static com.forgerock.opendj.ldap.tools.Utils.filterExitCode;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
import static com.forgerock.opendj.cli.Utils.secondsToTimeString;
import static org.forgerock.util.Utils.closeSilently;
import java.io.BufferedReader;
import java.io.FileReader;
@@ -75,6 +76,14 @@
import org.forgerock.opendj.ldif.EntryWriter;
import org.forgerock.opendj.ldif.LDIFEntryWriter;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.ArgumentParser;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.CommonArguments;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.MultiChoiceArgument;
import com.forgerock.opendj.cli.StringArgument;
import com.forgerock.opendj.ldap.controls.AccountUsabilityResponseControl;
import com.forgerock.opendj.util.StaticUtils;
@@ -120,7 +129,7 @@
                        if (control.getSecondsBeforeExpiration() > 0) {
                            final int timeToExp = control.getSecondsBeforeExpiration();
                            final LocalizableMessage timeToExpStr =
                                    Utils.secondsToTimeString(timeToExp);
                                    secondsToTimeString(timeToExp);
                            println(INFO_LDAPSEARCH_ACCTUSABLE_TIME_UNTIL_EXPIRATION
                                    .get(timeToExpStr));
@@ -147,7 +156,7 @@
                            if (control.getSecondsBeforeUnlock() > 0) {
                                final int timeToUnlock = control.getSecondsBeforeUnlock();
                                final LocalizableMessage timeToUnlockStr =
                                        Utils.secondsToTimeString(timeToUnlock);
                                        secondsToTimeString(timeToUnlock);
                                println(INFO_LDAPSEARCH_ACCTUSABLE_TIME_UNTIL_UNLOCK
                                        .get(timeToUnlockStr));
@@ -221,8 +230,8 @@
    }
    private int run(final String[] args, final boolean returnMatchingEntries) {
        // Create the command-line argument parser for use with this
        // program.
        /* Create the command-line argument parser for use with this
         program.*/
        final LocalizableMessage toolDescription = INFO_LDAPSEARCH_TOOL_DESCRIPTION.get();
        final ArgumentParser argParser =
                new ArgumentParser(LDAPSearch.class.getName(), toolDescription, false, true, 0, 0,
@@ -254,15 +263,11 @@
        try {
            connectionFactoryProvider = new ConnectionFactoryProvider(argParser, this);
            final StringArgument propertiesFileArgument =
                    new StringArgument("propertiesFilePath", null, OPTION_LONG_PROP_FILE_PATH,
                            false, false, true, INFO_PROP_FILE_PATH_PLACEHOLDER.get(), null, null,
                            INFO_DESCRIPTION_PROP_FILE_PATH.get());
                CommonArguments.getPropertiesFileArgument();
            argParser.addArgument(propertiesFileArgument);
            argParser.setFilePropertiesArgument(propertiesFileArgument);
            final BooleanArgument noPropertiesFileArgument =
                    new BooleanArgument("noPropertiesFileArgument", null, OPTION_LONG_NO_PROP_FILE,
                            INFO_DESCRIPTION_NO_PROP_FILE.get());
            final BooleanArgument noPropertiesFileArgument = CommonArguments.getNoPropertiesFileArgument();
            argParser.addArgument(noPropertiesFileArgument);
            argParser.setNoPropertiesFileArgument(noPropertiesFileArgument);
@@ -360,12 +365,7 @@
            effectiveRightsAttrs.setPropertyName(OPTION_LONG_EFFECTIVERIGHTSATTR);
            argParser.addArgument(effectiveRightsAttrs);
            version =
                    new IntegerArgument("version", OPTION_SHORT_PROTOCOL_VERSION,
                            OPTION_LONG_PROTOCOL_VERSION, false, false, true,
                            INFO_PROTOCOL_VERSION_PLACEHOLDER.get(), 3, null,
                            INFO_DESCRIPTION_VERSION.get());
            version.setPropertyName(OPTION_LONG_PROTOCOL_VERSION);
            version = CommonArguments.getVersionArgument();
            argParser.addArgument(version);
            final StringArgument encodingStr =
@@ -416,10 +416,7 @@
            countEntries.setPropertyName("countEntries");
            argParser.addArgument(countEntries);
            final BooleanArgument continueOnError =
                    new BooleanArgument("continueOnError", 'c', "continueOnError",
                            INFO_DESCRIPTION_CONTINUE_ON_ERROR.get());
            continueOnError.setPropertyName("continueOnError");
            final BooleanArgument continueOnError = CommonArguments.getContinueOnErrorArgument();
            argParser.addArgument(continueOnError);
            noop =
@@ -428,14 +425,10 @@
            noop.setPropertyName(OPTION_LONG_DRYRUN);
            argParser.addArgument(noop);
            verbose =
                    new BooleanArgument("verbose", 'v', "verbose", INFO_DESCRIPTION_VERBOSE.get());
            verbose.setPropertyName("verbose");
            verbose = CommonArguments.getVerbose();
            argParser.addArgument(verbose);
            final BooleanArgument showUsage =
                    new BooleanArgument("showUsage", OPTION_SHORT_HELP, OPTION_LONG_HELP,
                            INFO_DESCRIPTION_SHOWUSAGE.get());
            final BooleanArgument showUsage = CommonArguments.getShowUsage();
            argParser.addArgument(showUsage);
            argParser.setUsageArgument(showUsage, getOutputStream());
        } catch (final ArgumentException ae) {
@@ -465,11 +458,11 @@
        final List<String> attributes = new LinkedList<String>();
        final ArrayList<String> filterAndAttributeStrings = argParser.getTrailingArguments();
        if (filterAndAttributeStrings.size() > 0) {
            // the list of trailing arguments should be structured as follow:
            // - If a filter file is present, trailing arguments are
            // considered as attributes
            // - If filter file is not present, the first trailing argument is
            // considered the filter, the other as attributes.
            /* The list of trailing arguments should be structured as follow:
             - If a filter file is present, trailing arguments are
             considered as attributes
             - If filter file is not present, the first trailing argument is
             considered the filter, the other as attributes.*/
            if (!filename.isPresent()) {
                final String filterString = filterAndAttributeStrings.remove(0);
@@ -830,11 +823,11 @@
        }
        if (noop.isPresent()) {
            // We don't actually need to open a connection or perform the
            // search, so we're done. We should return 0 to either mean that the
            // processing was successful or that there were no matching entries,
            // based on countEntries.isPresent() (but in either case the return value
            // should be zero).
            /* We don't actually need to open a connection or perform the
             search, so we're done. We should return 0 to either mean that the
             processing was successful or that there were no matching entries,
             based on countEntries.isPresent() (but in either case the return value
             should be zero).*/
            return 0;
        }
@@ -944,7 +937,7 @@
        } catch (final ErrorResultException ere) {
            return Utils.printErrorMessage(this, ere);
        } finally {
            org.forgerock.util.Utils.closeSilently(ldifWriter, connection);
            closeSilently(ldifWriter, connection);
        }
        return 0;
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFDiff.java
@@ -22,16 +22,14 @@
 *
 *
 *      Copyright 2012-2013 ForgeRock AS
 *      Portions copyright 2014 ForgeRock AS
 */
package com.forgerock.opendj.ldap.tools;
import static com.forgerock.opendj.ldap.tools.ToolConstants.OPTION_LONG_HELP;
import static com.forgerock.opendj.ldap.tools.ToolConstants.OPTION_LONG_OUTPUT_LDIF_FILENAME;
import static com.forgerock.opendj.ldap.tools.ToolConstants.OPTION_SHORT_HELP;
import static com.forgerock.opendj.ldap.tools.ToolConstants.OPTION_SHORT_OUTPUT_LDIF_FILENAME;
import static com.forgerock.opendj.cli.CliConstants.OPTION_LONG_OUTPUT_LDIF_FILENAME;
import static com.forgerock.opendj.cli.CliConstants.OPTION_SHORT_OUTPUT_LDIF_FILENAME;
import static com.forgerock.opendj.ldap.tools.ToolsMessages.*;
import static com.forgerock.opendj.ldap.tools.Utils.filterExitCode;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -48,6 +46,13 @@
import org.forgerock.opendj.ldif.LDIFChangeRecordWriter;
import org.forgerock.opendj.ldif.LDIFEntryReader;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.ArgumentParser;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.CommonArguments;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.StringArgument;
/**
 * This utility can be used to compare two LDIF files and report the differences
 * in LDIF format.
@@ -90,9 +95,7 @@
                                    .get(INFO_OUTPUT_LDIF_FILE_PLACEHOLDER.get()));
            argParser.addArgument(outputFilename);
            showUsage =
                    new BooleanArgument("showUsage", OPTION_SHORT_HELP, OPTION_LONG_HELP,
                            INFO_DESCRIPTION_SHOWUSAGE.get());
            showUsage = CommonArguments.getShowUsage();
            argParser.addArgument(showUsage);
            argParser.setUsageArgument(showUsage, getOutputStream());
        } catch (final ArgumentException ae) {
@@ -105,8 +108,8 @@
        try {
            argParser.parseArguments(args);
            // If we should just display usage or version information,
            // then print it and exit.
            /* If we should just display usage or version information,
             then print it and exit.*/
            if (argParser.usageOrVersionDisplayed()) {
                return ResultCode.SUCCESS.intValue();
            }
@@ -178,8 +181,8 @@
                outputStream = System.out;
            }
            // Check that we are not attempting to read both the source and
            // target from stdin.
            /* Check that we are not attempting to read both the source and
             target from stdin.*/
            if (sourceInputStream == targetInputStream) {
                final LocalizableMessage message = ERR_LDIFDIFF_MULTIPLE_USES_OF_STDIN.get();
                println(message);
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFModify.java
@@ -21,17 +21,14 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2012-2013 ForgeRock AS
 *      Copyright 2012-2014 ForgeRock AS
 */
package com.forgerock.opendj.ldap.tools;
import static com.forgerock.opendj.ldap.tools.ToolConstants.OPTION_LONG_HELP;
import static com.forgerock.opendj.ldap.tools.ToolConstants.OPTION_LONG_OUTPUT_LDIF_FILENAME;
import static com.forgerock.opendj.ldap.tools.ToolConstants.OPTION_SHORT_HELP;
import static com.forgerock.opendj.ldap.tools.ToolConstants.OPTION_SHORT_OUTPUT_LDIF_FILENAME;
import static com.forgerock.opendj.cli.CliConstants.OPTION_LONG_OUTPUT_LDIF_FILENAME;
import static com.forgerock.opendj.cli.CliConstants.OPTION_SHORT_OUTPUT_LDIF_FILENAME;
import static com.forgerock.opendj.ldap.tools.ToolsMessages.*;
import static com.forgerock.opendj.ldap.tools.Utils.filterExitCode;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -56,6 +53,13 @@
import org.forgerock.opendj.ldif.LDIFEntryWriter;
import org.forgerock.opendj.ldif.RejectedChangeRecordListener;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.ArgumentParser;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.CommonArguments;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.StringArgument;
/**
 * A tool that can be used to issue update (Add/Delete/Modify/ModifyDN) requests
 * to a set of entries contained in an LDIF file.
@@ -99,15 +103,10 @@
                                    .get(INFO_OUTPUT_LDIF_FILE_PLACEHOLDER.get()));
            argParser.addArgument(outputFilename);
            continueOnError =
                    new BooleanArgument("continueOnError", 'c', "continueOnError",
                            INFO_DESCRIPTION_CONTINUE_ON_ERROR.get());
            continueOnError.setPropertyName("continueOnError");
            continueOnError = CommonArguments.getContinueOnErrorArgument();
            argParser.addArgument(continueOnError);
            showUsage =
                    new BooleanArgument("showUsage", OPTION_SHORT_HELP, OPTION_LONG_HELP,
                            INFO_DESCRIPTION_SHOWUSAGE.get());
            showUsage = CommonArguments.getShowUsage();
            argParser.addArgument(showUsage);
            argParser.setUsageArgument(showUsage, getOutputStream());
        } catch (final ArgumentException ae) {
@@ -193,9 +192,8 @@
                outputStream = System.out;
            }
            // Check that we are not attempting to read both the source and
            // changes
            // from stdin.
            /* Check that we are not attempting to read both the source and
             changes from stdin.*/
            if (sourceInputStream == changesInputStream) {
                final LocalizableMessage message = ERR_LDIFMODIFY_MULTIPLE_USES_OF_STDIN.get();
                println(message);
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFSearch.java
@@ -21,14 +21,13 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2012-2013 ForgeRock AS
 *      Copyright 2012-2014 ForgeRock AS
 */
package com.forgerock.opendj.ldap.tools;
import static com.forgerock.opendj.ldap.tools.ToolConstants.*;
import static com.forgerock.opendj.cli.CliConstants.*;
import static com.forgerock.opendj.ldap.tools.ToolsMessages.*;
import static com.forgerock.opendj.ldap.tools.Utils.filterExitCode;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
import java.io.BufferedReader;
import java.io.FileInputStream;
@@ -54,6 +53,15 @@
import org.forgerock.opendj.ldif.LDIFEntryReader;
import org.forgerock.opendj.ldif.LDIFEntryWriter;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.ArgumentParser;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.CommonArguments;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.MultiChoiceArgument;
import com.forgerock.opendj.cli.StringArgument;
/**
 * This utility can be used to perform search operations against data in an LDIF
 * file.
@@ -76,8 +84,8 @@
    }
    private int run(final String[] args) {
        // Create the command-line argument parser for use with this
        // program.
        /* Create the command-line argument parser for use with this
         program.*/
        final LocalizableMessage toolDescription = INFO_LDIFSEARCH_TOOL_DESCRIPTION.get();
        final ArgumentParser argParser =
@@ -144,9 +152,7 @@
            timeLimit.setPropertyName("timeLimit");
            argParser.addArgument(timeLimit);
            showUsage =
                    new BooleanArgument("showUsage", OPTION_SHORT_HELP, OPTION_LONG_HELP,
                            INFO_DESCRIPTION_SHOWUSAGE.get());
            showUsage = CommonArguments.getShowUsage();
            argParser.addArgument(showUsage);
            argParser.setUsageArgument(showUsage, getOutputStream());
        } catch (final ArgumentException ae) {
@@ -159,8 +165,8 @@
        try {
            argParser.parseArguments(args);
            // If we should just display usage or version information,
            // then print it and exit.
            /* If we should just display usage or version information,
             then print it and exit.*/
            if (argParser.usageOrVersionDisplayed()) {
                return ResultCode.SUCCESS.intValue();
            }
@@ -177,11 +183,11 @@
            final List<String> filterAndAttributeStrings =
                    trailingArguments.subList(1, trailingArguments.size());
            // the list of trailing arguments should be structured as follow:
            // - If a filter file is present, trailing arguments are
            // considered as attributes
            // - If filter file is not present, the first trailing argument is
            // considered the filter, the other as attributes.
            /* The list of trailing arguments should be structured as follow:
             - If a filter file is present, trailing arguments are
             considered as attributes
             - If filter file is not present, the first trailing argument is
             considered the filter, the other as attributes.*/
            if (!filename.isPresent()) {
                final String filterString = filterAndAttributeStrings.remove(0);
                try {
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/MakeLDIF.java
@@ -22,20 +22,29 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2013 ForgeRock AS
 *      Portions Copyright 2013-2014 ForgeRock AS
 */
package com.forgerock.opendj.ldap.tools;
import static com.forgerock.opendj.ldap.tools.ToolConstants.*;
import static com.forgerock.opendj.cli.CliConstants.*;
import static com.forgerock.opendj.ldap.tools.ToolsMessages.*;
import static com.forgerock.opendj.ldap.tools.Utils.*;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import org.forgerock.i18n.LocalizableMessage;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.ArgumentParser;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.StringArgument;
import org.forgerock.opendj.ldap.Entry;
import org.forgerock.opendj.ldif.EntryGenerator;
import org.forgerock.opendj.ldif.LDIFEntryWriter;
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ModRate.java
@@ -22,14 +22,13 @@
 *
 *
 *      Copyright 2010 Sun Microsystems, Inc.
 *      Portions copyright 2011 ForgeRock AS
 *      Portions copyright 2011-2014 ForgeRock AS
 */
package com.forgerock.opendj.ldap.tools;
import static com.forgerock.opendj.ldap.tools.ToolConstants.*;
import static com.forgerock.opendj.cli.CliConstants.*;
import static com.forgerock.opendj.ldap.tools.ToolsMessages.*;
import static com.forgerock.opendj.ldap.tools.Utils.filterExitCode;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.Connection;
@@ -41,6 +40,13 @@
import org.forgerock.opendj.ldap.requests.Requests;
import org.forgerock.opendj.ldap.responses.Result;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.ArgumentParser;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.CommonArguments;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.StringArgument;
/**
 * A load generation tool that can be used to load a Directory Server with
 * Modify requests using one or more LDAP connections.
@@ -148,8 +154,8 @@
    }
    private int run(final String[] args) {
        // Create the command-line argument parser for use with this
        // program.
        /* Creates the command-line argument parser for use with this
         program*/
        final LocalizableMessage toolDescription = INFO_MODRATE_TOOL_DESCRIPTION.get();
        final ArgumentParser argParser =
                new ArgumentParser(ModRate.class.getName(), toolDescription, false, true, 1, 0,
@@ -168,16 +174,12 @@
            connectionFactoryProvider = new ConnectionFactoryProvider(argParser, this);
            runner = new ModifyPerformanceRunner(argParser, this);
            propertiesFileArgument =
                    new StringArgument("propertiesFilePath", null, OPTION_LONG_PROP_FILE_PATH,
                            false, false, true, INFO_PROP_FILE_PATH_PLACEHOLDER.get(), null, null,
                            INFO_DESCRIPTION_PROP_FILE_PATH.get());
            propertiesFileArgument = CommonArguments.getPropertiesFileArgument();
            argParser.addArgument(propertiesFileArgument);
            argParser.setFilePropertiesArgument(propertiesFileArgument);
            noPropertiesFileArgument =
                    new BooleanArgument("noPropertiesFileArgument", null, OPTION_LONG_NO_PROP_FILE,
                            INFO_DESCRIPTION_NO_PROP_FILE.get());
            noPropertiesFileArgument = CommonArguments.getNoPropertiesFileArgument();
            argParser.addArgument(noPropertiesFileArgument);
            argParser.setNoPropertiesFileArgument(noPropertiesFileArgument);
@@ -188,14 +190,10 @@
            baseDN.setPropertyName(OPTION_LONG_BASEDN);
            argParser.addArgument(baseDN);
            verbose =
                    new BooleanArgument("verbose", 'v', "verbose", INFO_DESCRIPTION_VERBOSE.get());
            verbose.setPropertyName("verbose");
            verbose = CommonArguments.getVerbose();
            argParser.addArgument(verbose);
            showUsage =
                    new BooleanArgument("showUsage", OPTION_SHORT_HELP, OPTION_LONG_HELP,
                            INFO_DESCRIPTION_SHOWUSAGE.get());
            showUsage = CommonArguments.getShowUsage();
            argParser.addArgument(showUsage);
            argParser.setUsageArgument(showUsage, getOutputStream());
@@ -214,8 +212,8 @@
        try {
            argParser.parseArguments(args);
            // If we should just display usage or version information,
            // then print it and exit.
            /* If we should just display usage or version information,
             then print it and exit.*/
            if (argParser.usageOrVersionDisplayed()) {
                return 0;
            }
@@ -235,8 +233,8 @@
        try {
            // Try it out to make sure the format string and data sources
            // match.
            /* Try it out to make sure the format string and data sources
             match.*/
            final Object[] data = DataSource.generateData(runner.getDataSources(), null);
            for (final String modString : runner.modStrings) {
                String.format(modString, data);
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/MultiChoiceArgument.java
File was deleted
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/MultiColumnPrinter.java
File was deleted
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/PerformanceRunner.java
@@ -27,6 +27,8 @@
package com.forgerock.opendj.ldap.tools;
import static org.forgerock.util.Utils.closeSilently;
import java.io.IOException;
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
@@ -48,8 +50,14 @@
import org.forgerock.opendj.ldap.ResultHandler;
import org.forgerock.opendj.ldap.responses.ExtendedResult;
import org.forgerock.opendj.ldap.responses.Result;
import org.forgerock.util.Utils;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.ArgumentParser;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.IntegerArgument;
import com.forgerock.opendj.cli.MultiColumnPrinter;
import com.forgerock.opendj.cli.StringArgument;
import com.forgerock.opendj.ldap.tools.AuthenticatedConnectionFactory.AuthenticatedConnection;
import com.forgerock.opendj.util.StaticUtils;
@@ -859,7 +867,7 @@
            stopRequested = true;
            app.println(LocalizableMessage.raw(e.getResult().getDiagnosticMessage()));
        } finally {
            Utils.closeSilently(connections);
            closeSilently(connections);
        }
        return 0;
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/PromptingTrustManager.java
@@ -50,6 +50,9 @@
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.util.Reject;
import com.forgerock.opendj.cli.CLIException;
import com.forgerock.opendj.cli.ConsoleApplication;
/**
 * A trust manager which prompts the user for the length of time that they would
 * like to trust a server certificate.
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/SearchRate.java
@@ -22,14 +22,13 @@
 *
 *
 *      Copyright 2010 Sun Microsystems, Inc.
 *      Portions copyright 2011 ForgeRock AS
 *      Portions copyright 2011-2014 ForgeRock AS
 */
package com.forgerock.opendj.ldap.tools;
import static com.forgerock.opendj.ldap.tools.ToolConstants.*;
import static com.forgerock.opendj.cli.CliConstants.*;
import static com.forgerock.opendj.ldap.tools.ToolsMessages.*;
import static com.forgerock.opendj.ldap.tools.Utils.filterExitCode;
import static com.forgerock.opendj.cli.Utils.filterExitCode;
import java.util.ArrayList;
import java.util.LinkedList;
@@ -50,6 +49,14 @@
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
import org.forgerock.opendj.ldap.responses.SearchResultReference;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.ArgumentParser;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.CommonArguments;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.cli.MultiChoiceArgument;
import com.forgerock.opendj.cli.StringArgument;
/**
 * A load generation tool that can be used to load a Directory Server with
 * Search requests using one or more LDAP connections.
@@ -211,22 +218,15 @@
            connectionFactoryProvider = new ConnectionFactoryProvider(argParser, this);
            runner = new SearchPerformanceRunner(argParser, this);
            propertiesFileArgument =
                    new StringArgument("propertiesFilePath", null, OPTION_LONG_PROP_FILE_PATH,
                            false, false, true, INFO_PROP_FILE_PATH_PLACEHOLDER.get(), null, null,
                            INFO_DESCRIPTION_PROP_FILE_PATH.get());
            propertiesFileArgument = CommonArguments.getPropertiesFileArgument();
            argParser.addArgument(propertiesFileArgument);
            argParser.setFilePropertiesArgument(propertiesFileArgument);
            noPropertiesFileArgument =
                    new BooleanArgument("noPropertiesFileArgument", null, OPTION_LONG_NO_PROP_FILE,
                            INFO_DESCRIPTION_NO_PROP_FILE.get());
            noPropertiesFileArgument = CommonArguments.getNoPropertiesFileArgument();
            argParser.addArgument(noPropertiesFileArgument);
            argParser.setNoPropertiesFileArgument(noPropertiesFileArgument);
            showUsage =
                    new BooleanArgument("showUsage", OPTION_SHORT_HELP, OPTION_LONG_HELP,
                            INFO_DESCRIPTION_SHOWUSAGE.get());
            showUsage = CommonArguments.getShowUsage();
            argParser.addArgument(showUsage);
            argParser.setUsageArgument(showUsage, getOutputStream());
@@ -254,9 +254,7 @@
            dereferencePolicy.setDefaultValue(DereferenceAliasesPolicy.NEVER);
            argParser.addArgument(dereferencePolicy);
            verbose =
                    new BooleanArgument("verbose", 'v', "verbose", INFO_DESCRIPTION_VERBOSE.get());
            verbose.setPropertyName("verbose");
            verbose = CommonArguments.getVerbose();
            argParser.addArgument(verbose);
            scriptFriendly =
@@ -291,9 +289,8 @@
        final List<String> attributes = new LinkedList<String>();
        final ArrayList<String> filterAndAttributeStrings = argParser.getTrailingArguments();
        if (filterAndAttributeStrings.size() > 0) {
            // the list of trailing arguments should be structured as follow:
            // the first trailing argument is
            // considered the filter, the other as attributes.
            /* The list of trailing arguments should be structured as follow:
             the first trailing argument is considered the filter, the other as attributes.*/
            runner.filter = filterAndAttributeStrings.remove(0);
            // The rest are attributes
            for (final String s : filterAndAttributeStrings) {
@@ -311,8 +308,8 @@
        }
        try {
            // Try it out to make sure the format string and data sources
            // match.
            /* Try it out to make sure the format string and data sources
             match.*/
            final Object[] data = DataSource.generateData(runner.getDataSources(), null);
            String.format(runner.filter, data);
            String.format(runner.baseDN, data);
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/StringArgument.java
File was deleted
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ToolConstants.java
File was deleted
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/Utils.java
@@ -22,16 +22,13 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions copyright 2014 ForgeRock AS
 */
package com.forgerock.opendj.ldap.tools;
import static com.forgerock.opendj.ldap.tools.ToolsMessages.*;
import static com.forgerock.opendj.util.StaticUtils.EOL;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.StringTokenizer;
import static com.forgerock.opendj.cli.Utils.readBytesFromFile;
import static com.forgerock.opendj.cli.Utils.secondsToTimeString;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
@@ -52,6 +49,7 @@
import org.forgerock.opendj.ldap.controls.SubtreeDeleteRequestControl;
import org.forgerock.opendj.ldap.responses.BindResult;
import com.forgerock.opendj.cli.ConsoleApplication;
import com.forgerock.opendj.ldap.controls.AccountUsabilityRequestControl;
import com.forgerock.opendj.ldap.tools.AuthenticatedConnectionFactory.AuthenticatedConnection;
import com.forgerock.opendj.util.StaticUtils;
@@ -60,52 +58,6 @@
 * This class provides utility functions for all the client side tools.
 */
final class Utils {
    /**
     * The name of a command-line script used to launch a tool.
     */
    static final String PROPERTY_SCRIPT_NAME = "com.forgerock.opendj.ldap.tools.scriptName";
    /**
     * The column at which to wrap long lines of output in the command-line
     * tools.
     */
    static final int MAX_LINE_WIDTH;
    static {
        int columns = 80;
        try {
            final String s = System.getenv("COLUMNS");
            if (s != null) {
                columns = Integer.parseInt(s);
            }
        } catch (final Exception e) {
            // Do nothing.
        }
        MAX_LINE_WIDTH = columns - 1;
    }
    /**
     * Filters the provided value to ensure that it is appropriate for use as an
     * exit code. Exit code values are generally only allowed to be between 0
     * and 255, so any value outside of this range will be converted to 255,
     * which is the typical exit code used to indicate an overflow value.
     *
     * @param exitCode
     *            The exit code value to be processed.
     * @return An integer value between 0 and 255, inclusive. If the provided
     *         exit code was already between 0 and 255, then the original value
     *         will be returned. If the provided value was out of this range,
     *         then 255 will be returned.
     */
    static int filterExitCode(final int exitCode) {
        if (exitCode < 0) {
            return 255;
        } else if (exitCode > 255) {
            return 255;
        } else {
            return exitCode;
        }
    }
    /**
     * Parse the specified command line argument to create the appropriate
@@ -219,11 +171,9 @@
     * @return The error code.
     */
    static int printErrorMessage(final ConsoleApplication app, final ErrorResultException ere) {
        // if ((ere.getMessage() != null) && (ere.getMessage().length() >
        // 0))
        // {
        // app.println(LocalizableMessage.raw(ere.getMessage()));
        // }
         /* if ((ere.getMessage() != null) && (ere.getMessage().length() > 0)) {
             app.println(LocalizableMessage.raw(ere.getMessage()));
         }*/
        if (ere.getResult().getResultCode().intValue() >= 0) {
            app.println(ERR_TOOL_RESULT_CODE.get(ere.getResult().getResultCode().intValue(), ere
@@ -282,7 +232,7 @@
                                new DecodeOptions());
                if (control != null) {
                    final LocalizableMessage timeString =
                            Utils.secondsToTimeString(control.getSecondsUntilExpiration());
                            secondsToTimeString(control.getSecondsUntilExpiration());
                    final LocalizableMessage message = INFO_BIND_PASSWORD_EXPIRING.get(timeString);
                    app.println(message);
                }
@@ -311,7 +261,7 @@
                    final PasswordPolicyWarningType warningType = control.getWarningType();
                    if (warningType == PasswordPolicyWarningType.TIME_BEFORE_EXPIRATION) {
                        final LocalizableMessage timeString =
                                Utils.secondsToTimeString(control.getWarningValue());
                                secondsToTimeString(control.getWarningValue());
                        final LocalizableMessage message =
                                INFO_BIND_PASSWORD_EXPIRING.get(timeString);
                        app.println(message);
@@ -328,79 +278,6 @@
    }
    /**
     * Read the data from the specified file and return it in a byte array.
     *
     * @param filePath
     *            The path to the file that should be read.
     * @return A byte array containing the contents of the requested file.
     * @throws IOException
     *             If a problem occurs while trying to read the specified file.
     */
    static byte[] readBytesFromFile(final String filePath) throws IOException {
        byte[] val = null;
        FileInputStream fis = null;
        try {
            final File file = new File(filePath);
            fis = new FileInputStream(file);
            final long length = file.length();
            val = new byte[(int) length];
            // Read in the bytes
            int offset = 0;
            int numRead = 0;
            while (offset < val.length
                    && (numRead = fis.read(val, offset, val.length - offset)) >= 0) {
                offset += numRead;
            }
            // Ensure all the bytes have been read in
            if (offset < val.length) {
                throw new IOException("Could not completely read file " + filePath);
            }
            return val;
        } finally {
            if (fis != null) {
                fis.close();
            }
        }
    }
    /**
     * Retrieves a user-friendly string that indicates the length of time (in
     * days, hours, minutes, and seconds) in the specified number of seconds.
     *
     * @param numSeconds
     *            The number of seconds to be converted to a more user-friendly
     *            value.
     * @return The user-friendly representation of the specified number of
     *         seconds.
     */
    static LocalizableMessage secondsToTimeString(final int numSeconds) {
        if (numSeconds < 60) {
            // We can express it in seconds.
            return INFO_TIME_IN_SECONDS.get(numSeconds);
        } else if (numSeconds < 3600) {
            // We can express it in minutes and seconds.
            final int m = numSeconds / 60;
            final int s = numSeconds % 60;
            return INFO_TIME_IN_MINUTES_SECONDS.get(m, s);
        } else if (numSeconds < 86400) {
            // We can express it in hours, minutes, and seconds.
            final int h = numSeconds / 3600;
            final int m = (numSeconds % 3600) / 60;
            final int s = numSeconds % 3600 % 60;
            return INFO_TIME_IN_HOURS_MINUTES_SECONDS.get(h, m, s);
        } else {
            // We can express it in days, hours, minutes, and seconds.
            final int d = numSeconds / 86400;
            final int h = (numSeconds % 86400) / 3600;
            final int m = (numSeconds % 86400 % 3600) / 60;
            final int s = numSeconds % 86400 % 3600 % 60;
            return INFO_TIME_IN_DAYS_HOURS_MINUTES_SECONDS.get(d, h, m, s);
        }
    }
    /**
     * Sets default system property settings for the xxxrate performance tools.
     */
    static void setDefaultPerfToolProperties() {
@@ -409,196 +286,14 @@
            System.setProperty("org.forgerock.opendj.transport.useWorkerThreads", "false");
        }
        // Configure connections to be terminate immediately after closing (this
        // prevents port exhaustion in xxxrate tools when
        // connecting/disconnecting).
        /* Configure connections to be terminate immediately after closing (this
         prevents port exhaustion in xxxrate tools when
         connecting/disconnecting).*/
        if (System.getProperty("org.forgerock.opendj.transport.linger") == null) {
            System.setProperty("org.forgerock.opendj.transport.linger", "0");
        }
    }
    /**
     * Inserts line breaks into the provided buffer to wrap text at no more than
     * the specified column width. Wrapping will only be done at space
     * boundaries and if there are no spaces within the specified width, then
     * wrapping will be performed at the first space after the specified column.
     *
     * @param message
     *            The message to be wrapped.
     * @param width
     *            The maximum number of characters to allow on a line if there
     *            is a suitable breaking point.
     * @return The wrapped text.
     */
    static String wrapText(final LocalizableMessage message, final int width) {
        return wrapText(message.toString(), width, 0);
    }
    /**
     * Inserts line breaks into the provided buffer to wrap text at no more than
     * the specified column width. Wrapping will only be done at space
     * boundaries and if there are no spaces within the specified width, then
     * wrapping will be performed at the first space after the specified column.
     * In addition each line will be indented by the specified amount.
     *
     * @param message
     *            The message to be wrapped.
     * @param width
     *            The maximum number of characters to allow on a line if there
     *            is a suitable breaking point (including any indentation).
     * @param indent
     *            The number of columns to indent each line.
     * @return The wrapped text.
     */
    static String wrapText(final LocalizableMessage message, final int width, final int indent) {
        return wrapText(message.toString(), width, indent);
    }
    /**
     * Inserts line breaks into the provided buffer to wrap text at no more than
     * the specified column width. Wrapping will only be done at space
     * boundaries and if there are no spaces within the specified width, then
     * wrapping will be performed at the first space after the specified column.
     *
     * @param text
     *            The text to be wrapped.
     * @param width
     *            The maximum number of characters to allow on a line if there
     *            is a suitable breaking point.
     * @return The wrapped text.
     */
    static String wrapText(final String text, final int width) {
        return wrapText(text, width, 0);
    }
    /**
     * Inserts line breaks into the provided buffer to wrap text at no more than
     * the specified column width. Wrapping will only be done at space
     * boundaries and if there are no spaces within the specified width, then
     * wrapping will be performed at the first space after the specified column.
     * In addition each line will be indented by the specified amount.
     *
     * @param text
     *            The text to be wrapped.
     * @param width
     *            The maximum number of characters to allow on a line if there
     *            is a suitable breaking point (including any indentation).
     * @param indent
     *            The number of columns to indent each line.
     * @return The wrapped text.
     */
    static String wrapText(final String text, int width, final int indent) {
        // Calculate the real width and indentation padding.
        width -= indent;
        final StringBuilder pb = new StringBuilder();
        for (int i = 0; i < indent; i++) {
            pb.append(' ');
        }
        final String padding = pb.toString();
        final StringBuilder buffer = new StringBuilder();
        if (text != null) {
            final StringTokenizer lineTokenizer = new StringTokenizer(text, "\r\n", true);
            while (lineTokenizer.hasMoreTokens()) {
                final String line = lineTokenizer.nextToken();
                if (line.equals("\r") || line.equals("\n")) {
                    // It's an end-of-line character, so append it as-is.
                    buffer.append(line);
                } else if (line.length() <= width) {
                    // The line fits in the specified width, so append it as-is.
                    buffer.append(padding);
                    buffer.append(line);
                } else {
                    // The line doesn't fit in the specified width, so it needs
                    // to
                    // be
                    // wrapped. Do so at space boundaries.
                    StringBuilder lineBuffer = new StringBuilder();
                    StringBuilder delimBuffer = new StringBuilder();
                    final StringTokenizer wordTokenizer = new StringTokenizer(line, " ", true);
                    while (wordTokenizer.hasMoreTokens()) {
                        final String word = wordTokenizer.nextToken();
                        if (word.equals(" ")) {
                            // It's a space, so add it to the delim buffer only
                            // if the
                            // line
                            // buffer is not empty.
                            if (lineBuffer.length() > 0) {
                                delimBuffer.append(word);
                            }
                        } else if (word.length() > width) {
                            // This is a long word that can't be wrapped, so
                            // we'll
                            // just have
                            // to make do.
                            if (lineBuffer.length() > 0) {
                                buffer.append(padding);
                                buffer.append(lineBuffer);
                                buffer.append(EOL);
                                lineBuffer = new StringBuilder();
                            }
                            buffer.append(padding);
                            buffer.append(word);
                            if (wordTokenizer.hasMoreTokens()) {
                                // The next token must be a space, so remove it.
                                // If
                                // there are
                                // still more tokens after that, then append an
                                // EOL.
                                wordTokenizer.nextToken();
                                if (wordTokenizer.hasMoreTokens()) {
                                    buffer.append(EOL);
                                }
                            }
                            if (delimBuffer.length() > 0) {
                                delimBuffer = new StringBuilder();
                            }
                        } else {
                            // It's not a space, so see if we can fit it on the
                            // curent
                            // line.
                            final int newLineLength =
                                    lineBuffer.length() + delimBuffer.length() + word.length();
                            if (newLineLength < width) {
                                // It does fit on the line, so add it.
                                lineBuffer.append(delimBuffer).append(word);
                                if (delimBuffer.length() > 0) {
                                    delimBuffer = new StringBuilder();
                                }
                            } else {
                                // It doesn't fit on the line, so end the
                                // current line
                                // and start
                                // a new one.
                                buffer.append(padding);
                                buffer.append(lineBuffer);
                                buffer.append(EOL);
                                lineBuffer = new StringBuilder();
                                lineBuffer.append(word);
                                if (delimBuffer.length() > 0) {
                                    delimBuffer = new StringBuilder();
                                }
                            }
                        }
                    }
                    // If there's anything left in the line buffer, then add it
                    // to
                    // the
                    // final buffer.
                    buffer.append(padding);
                    buffer.append(lineBuffer);
                }
            }
        }
        return buffer.toString();
    }
    // Prevent instantiation.
    private Utils() {
        // Do nothing.
opendj-ldap-toolkit/src/test/java/com/forgerock/opendj/ldap/tools/ConnectionFactoryProviderTest.java
@@ -21,7 +21,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2013 ForgeRock AS.
 *      Copyright 2013-2014 ForgeRock AS.
 */
package com.forgerock.opendj.ldap.tools;
@@ -36,6 +36,9 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.forgerock.opendj.cli.ArgumentParser;
import com.forgerock.opendj.cli.ConsoleApplication;
@SuppressWarnings("javadoc")
public class ConnectionFactoryProviderTest extends ToolsTestCase {
opendj-ldap-toolkit/src/test/java/com/forgerock/opendj/ldap/tools/MakeLDIFTestCase.java
@@ -21,12 +21,14 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2013 ForgeRock AS.
 *      Copyright 2013-2014 ForgeRock AS.
 */
package com.forgerock.opendj.ldap.tools;
import static org.fest.assertions.Assertions.*;
import static com.forgerock.opendj.ldap.tools.ToolsMessages.*;
import static com.forgerock.opendj.cli.Utils.MAX_LINE_WIDTH;
import static com.forgerock.opendj.cli.Utils.wrapText;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
@@ -107,7 +109,7 @@
                assertThat(out.size()).isEqualTo(0);
            }
            assertThat(err.toString("UTF-8")).contains(Utils.wrapText(expectedErrOutput, Utils.MAX_LINE_WIDTH));
            assertThat(err.toString("UTF-8")).contains(wrapText(expectedErrOutput, MAX_LINE_WIDTH));
        } finally {
            org.forgerock.util.Utils.closeSilently(outStream, errStream);
        }