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

Jean-Noël Rouvignac
15.28.2015 3ea043ecdcf10a6c808bc01de235b9c27a1fb160
Code cleanup
6 files modified
240 ■■■■ changed files
opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java 65 ●●●● patch | view | raw | blame | history
opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java 4 ●●●● patch | view | raw | blame | history
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPCompare.java 28 ●●●● patch | view | raw | blame | history
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java 34 ●●●●● patch | view | raw | blame | history
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java 14 ●●●● patch | view | raw | blame | history
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java 95 ●●●● patch | view | raw | blame | history
opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java
@@ -85,23 +85,11 @@
    /** The argument that will be used to indicate the file properties. */
    private StringArgument filePropertiesPathArgument;
    /**
     * The argument that will be used to indicate that we'll not look for
     * default properties file.
     */
    /** The argument that will be used to indicate that we'll not look for default properties file. */
    private BooleanArgument noPropertiesFileArgument;
    /**
     * The argument that will be used to trigger the display of usage
     * information.
     */
    /** The argument that will be used to trigger the display of usage information. */
    private Argument usageArgument;
    /**
     * The argument that will be used to trigger the display of the OpenDJ
     * version.
     */
    /** The argument that will be used to trigger the display of the OpenDJ version. */
    private Argument versionArgument;
    /** The set of unnamed trailing arguments that were provided for this parser. */
@@ -112,17 +100,13 @@
     * the end of the list.
     */
    private final boolean allowsTrailingArguments;
    /**
     * Indicates whether long arguments should be treated in a case-sensitive
     * manner.
     */
    /** Indicates whether long arguments should be treated in a case-sensitive manner. */
    private final boolean longArgumentsCaseSensitive;
    /** Indicates whether the usage or version information has been displayed. */
    private boolean usageOrVersionDisplayed;
    /** Indicates whether the version argument was provided. */
    private boolean versionPresent;
    /** The handler to call to print the product version. */
    private VersionHandler versionHandler = new VersionHandler() {
        @Override
@@ -164,11 +148,10 @@
     * displaying usage information.
     */
    private final LocalizableMessage toolDescription;
    /** A short description for this tool, suitable in a man page summary line. */
    private LocalizableMessage shortToolDescription;
    /**
     * The display name that will be used for the trailing arguments in the
     * usage information.
     */
    /** The display name that will be used for the trailing arguments in the usage information. */
    private final String trailingArgsDisplayName;
    /** The raw set of command-line arguments that were provided. */
@@ -623,18 +606,11 @@
        return toolDescription;
    }
    /**
     * A short description for this tool, suitable in a man page summary line.
     */
    private LocalizableMessage shortToolDescription;
    /** {@inheritDoc} */
    @Override
    public LocalizableMessage getShortToolDescription() {
        return shortToolDescription != null ? shortToolDescription : LocalizableMessage.EMPTY;
    }
    /** {@inheritDoc} */
    @Override
    public void setShortToolDescription(final LocalizableMessage shortDescription) {
        this.shortToolDescription = shortDescription;
@@ -646,7 +622,6 @@
     */
    private DocDescriptionSupplement docToolDescriptionSupplement;
    /** {@inheritDoc} */
    @Override
    public LocalizableMessage getDocToolDescriptionSupplement() {
        this.docToolDescriptionSupplement =
@@ -654,7 +629,6 @@
        return this.docToolDescriptionSupplement.getDocDescriptionSupplement();
    }
    /** {@inheritDoc} */
    @Override
    public void setDocToolDescriptionSupplement(final LocalizableMessage supplement) {
        this.docToolDescriptionSupplement =
@@ -667,17 +641,15 @@
     * intended for use in generated reference documentation.
     */
    private class DocSubcommandsDescriptionSupplement implements DocDescriptionSupplement {
        /**
         * A supplement to the description intended for use in generated reference documentation.
         */
        /** A supplement to the description intended for use in generated reference documentation. */
        private LocalizableMessage docDescriptionSupplement;
        /** {@inheritDoc} */
        @Override
        public LocalizableMessage getDocDescriptionSupplement() {
            return docDescriptionSupplement != null ? docDescriptionSupplement : LocalizableMessage.EMPTY;
        }
        /** {@inheritDoc} */
        @Override
        public void setDocDescriptionSupplement(final LocalizableMessage docDescriptionSupplement) {
            this.docDescriptionSupplement = docDescriptionSupplement;
        }
@@ -685,7 +657,6 @@
    private DocDescriptionSupplement docSubcommandsDescriptionSupplement;
    /** {@inheritDoc} */
    @Override
    public LocalizableMessage getDocSubcommandsDescriptionSupplement() {
        this.docSubcommandsDescriptionSupplement =
@@ -693,7 +664,6 @@
        return this.docSubcommandsDescriptionSupplement.getDocDescriptionSupplement();
    }
    /** {@inheritDoc} */
    @Override
    public void setDocSubcommandsDescriptionSupplement(final LocalizableMessage supplement) {
        this.docSubcommandsDescriptionSupplement =
@@ -979,7 +949,6 @@
    SortedSet<Argument> sortArguments(final List<Argument> arguments) {
        final SortedSet<Argument> result = new TreeSet<>(new Comparator<Argument>() {
            /** {@inheritDoc} */
            @Override
            public int compare(final Argument o1, final Argument o2) {
                final String s1 = getIdentifier(o1);
@@ -1182,20 +1151,17 @@
                String argValue = null;
                final int equalPos = argName.indexOf('=');
                if (equalPos < 0) {
                    // This is fine. The value is not part of the argument name
                    // token.
                    // This is fine. The value is not part of the argument name token.
                } else if (equalPos == 0) {
                    // The argument starts with "--=", which is not acceptable.
                    throw new ArgumentException(ERR_ARGPARSER_LONG_ARG_WITHOUT_NAME.get(arg));
                } else {
                    // The argument is in the form --name=value, so parse them
                    // both out.
                    // The argument is in the form --name=value, so parse them both out.
                    argValue = argName.substring(equalPos + 1);
                    argName = argName.substring(0, equalPos);
                }
                // If we're not case-sensitive, then convert the name to
                // lowercase.
                // If we're not case-sensitive, then convert the name to lowercase.
                final String origArgName = argName;
                if (!longArgumentsCaseSensitive) {
                    argName = toLowerCase(argName);
@@ -1205,8 +1171,7 @@
                final Argument a = longIDMap.get(argName);
                if (a == null) {
                    if (OPTION_LONG_HELP.equals(argName)) {
                        // "--help" will always be interpreted as requesting
                        // usage information.
                        // "--help" will always be interpreted as requesting usage information.
                        writeToUsageOutputStream(getUsage());
                        return;
                    } else if (OPTION_LONG_PRODUCT_VERSION.equals(argName)) {
opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/SubCommandArgumentParser.java
@@ -47,10 +47,11 @@
import java.util.SortedMap;
import java.util.TreeMap;
import com.forgerock.opendj.util.OperatingSystem;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageBuilder;
import com.forgerock.opendj.util.OperatingSystem;
/**
 * This class defines a variant of the argument parser that can be used with applications that use subcommands to
 * customize their behavior and that have a different set of options per subcommand (e.g, "cvs checkout" takes different
@@ -1095,7 +1096,6 @@
        toRefEntry(builder, subCommands);
    }
    /** {@inheritDoc} */
    @Override
    String getSynopsisArgs() {
        if (subCommands.isEmpty()) {
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPCompare.java
@@ -48,8 +48,8 @@
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.ConnectionFactory;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.LdapException;
import org.forgerock.opendj.ldap.Filter;
import org.forgerock.opendj.ldap.LdapException;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.controls.AssertionRequestControl;
import org.forgerock.opendj.ldap.controls.Control;
@@ -68,9 +68,7 @@
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.
 */
/** A tool that can be used to issue Compare requests to the Directory Server. */
public final class LDAPCompare extends ConsoleApplication {
    /**
     * The main method for LDAPModify tool.
@@ -78,7 +76,6 @@
     * @param args
     *            The command-line arguments provided to this program.
     */
    public static void main(final String[] args) {
        final int retCode = new LDAPCompare().run(args);
        System.exit(filterExitCode(retCode));
@@ -100,13 +97,11 @@
      super(out, err);
    }
    /** {@inheritDoc} */
    @Override
    public boolean isInteractive() {
        return false;
    }
    /** {@inheritDoc} */
    @Override
    public boolean isVerbose() {
        return verbose.isPresent();
@@ -121,7 +116,6 @@
                if (result.getResultCode() == ResultCode.COMPARE_FALSE) {
                    println(INFO_COMPARE_OPERATION_RESULT_FALSE.get(request.getName().toString()));
                } else {
                    println(INFO_COMPARE_OPERATION_RESULT_TRUE.get(request.getName().toString()));
                }
            } catch (final LdapException ere) {
@@ -210,10 +204,8 @@
            showUsage = CommonArguments.getShowUsage();
            argParser.addArgument(showUsage);
            argParser.setUsageArgument(showUsage, getOutputStream());
        } catch (final ArgumentException ae) {
            final LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
            errPrintln(message);
            errPrintln(ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
            return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
        }
@@ -221,8 +213,7 @@
        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;
            }
@@ -243,7 +234,7 @@
            }
        } catch (final ArgumentException ae) {
            argParser.displayMessageAndUsageReference(
                getErrStream(), ERR_DESCRIPTION_INVALID_VERSION.get(String.valueOf(version.getValue())));
                getErrStream(), ERR_DESCRIPTION_INVALID_VERSION.get(version.getValue()));
            return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
        }
@@ -317,9 +308,7 @@
                    final Control ctrl = Utils.getControl(ctrlString);
                    compare.addControl(ctrl);
                } catch (final DecodeException de) {
                    final LocalizableMessage message =
                            ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString);
                    errPrintln(message);
                    errPrintln(ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString));
                    return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
                }
            }
@@ -342,9 +331,7 @@
                final Control assertionControl = AssertionRequestControl.newControl(true, filter);
                compare.addControl(assertionControl);
            } catch (final LocalizedIllegalArgumentException le) {
                final LocalizableMessage message =
                        ERR_LDAP_ASSERTION_INVALID_FILTER.get(le.getMessage());
                errPrintln(message);
                errPrintln(ERR_LDAP_ASSERTION_INVALID_FILTER.get(le.getMessage()));
                return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
            }
        }
@@ -406,5 +393,4 @@
        return 0;
    }
}
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java
@@ -46,8 +46,8 @@
import org.forgerock.opendj.ldap.ConnectionFactory;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.DecodeOptions;
import org.forgerock.opendj.ldap.LdapException;
import org.forgerock.opendj.ldap.Filter;
import org.forgerock.opendj.ldap.LdapException;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.controls.AssertionRequestControl;
import org.forgerock.opendj.ldap.controls.Control;
@@ -84,6 +84,7 @@
 */
public final class LDAPModify extends ConsoleApplication {
    private class VisitorImpl implements ChangeRecordVisitor<Integer, java.lang.Void> {
        @Override
        public Integer visitChangeRecord(final Void aVoid, final AddRequest change) {
            for (final Control control : controls) {
                change.addControl(control);
@@ -102,6 +103,7 @@
            return ResultCode.SUCCESS.intValue();
        }
        @Override
        public Integer visitChangeRecord(final Void aVoid, final DeleteRequest change) {
            for (final Control control : controls) {
                change.addControl(control);
@@ -120,6 +122,7 @@
            return ResultCode.SUCCESS.intValue();
        }
        @Override
        public Integer visitChangeRecord(final Void aVoid, final ModifyDNRequest change) {
            for (final Control control : controls) {
                change.addControl(control);
@@ -138,6 +141,7 @@
            return ResultCode.SUCCESS.intValue();
        }
        @Override
        public Integer visitChangeRecord(final Void aVoid, final ModifyRequest change) {
            for (final Control control : controls) {
                change.addControl(control);
@@ -232,13 +236,11 @@
        // Nothing to do.
    }
    /** {@inheritDoc} */
    @Override
    public boolean isInteractive() {
        return false;
    }
    /** {@inheritDoc} */
    @Override
    public boolean isVerbose() {
        return verbose.isPresent();
@@ -354,8 +356,7 @@
            argParser.addArgument(showUsage);
            argParser.setUsageArgument(showUsage, getOutputStream());
        } catch (final ArgumentException ae) {
            final LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
            errPrintln(message);
            errPrintln(ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
            return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
        }
@@ -363,8 +364,7 @@
        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;
            }
@@ -383,7 +383,7 @@
                return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
            }
        } catch (final ArgumentException ae) {
            errPrintln(ERR_DESCRIPTION_INVALID_VERSION.get(String.valueOf(version.getValue())));
            errPrintln(ERR_DESCRIPTION_INVALID_VERSION.get(version.getValue()));
            return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
        }
@@ -394,9 +394,7 @@
                    final Control ctrl = Utils.getControl(ctrlString);
                    controls.add(ctrl);
                } catch (final DecodeException de) {
                    final LocalizableMessage message =
                            ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString);
                    errPrintln(message);
                    errPrintln(ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString));
                    ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
                }
            }
@@ -419,9 +417,7 @@
                final Control assertionControl = AssertionRequestControl.newControl(true, filter);
                controls.add(assertionControl);
            } catch (final LocalizedIllegalArgumentException le) {
                final LocalizableMessage message =
                        ERR_LDAP_ASSERTION_INVALID_FILTER.get(le.getMessage());
                errPrintln(message);
                errPrintln(ERR_LDAP_ASSERTION_INVALID_FILTER.get(le.getMessage()));
                return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
            }
        }
@@ -433,9 +429,7 @@
            while (tokenizer.hasMoreTokens()) {
                attributes.add(tokenizer.nextToken());
            }
            final PreReadRequestControl control =
                    PreReadRequestControl.newControl(true, attributes);
            controls.add(control);
            controls.add(PreReadRequestControl.newControl(true, attributes));
        }
        if (postReadAttributes.isPresent()) {
@@ -450,7 +444,6 @@
            controls.add(control);
        }
        writer = new LDIFEntryWriter(getOutputStream());
        final VisitorImpl visitor = new VisitorImpl();
        ChangeRecordReader reader = null;
@@ -489,10 +482,7 @@
                    }
                }
            } catch (final IOException ioe) {
                final LocalizableMessage message =
                        ERR_LDIF_FILE_READ_ERROR
                                .get(filename.getValue(), ioe.getLocalizedMessage());
                errPrintln(message);
                errPrintln(ERR_LDIF_FILE_READ_ERROR.get(filename.getValue(), ioe.getLocalizedMessage()));
                return ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue();
            }
        } finally {
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java
@@ -83,13 +83,11 @@
        // Nothing to do.
    }
    /** {@inheritDoc} */
    @Override
    public boolean isInteractive() {
        return false;
    }
    /** {@inheritDoc} */
    @Override
    public boolean isVerbose() {
        return verbose.isPresent();
@@ -180,8 +178,7 @@
            argParser.addArgument(showUsage);
            argParser.setUsageArgument(showUsage, getOutputStream());
        } catch (final ArgumentException ae) {
            final LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
            errPrintln(message);
            errPrintln(ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
            return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
        }
@@ -189,8 +186,7 @@
        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;
            }
@@ -209,7 +205,7 @@
                return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
            }
        } catch (final ArgumentException ae) {
            errPrintln(ERR_DESCRIPTION_INVALID_VERSION.get(String.valueOf(version.getValue())));
            errPrintln(ERR_DESCRIPTION_INVALID_VERSION.get(version.getValue()));
            return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
        }
@@ -219,9 +215,7 @@
                    final Control ctrl = Utils.getControl(ctrlString);
                    request.addControl(ctrl);
                } catch (final DecodeException de) {
                    final LocalizableMessage message =
                            ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString);
                    errPrintln(message);
                    errPrintln(ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString));
                    ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
                }
            }
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java
@@ -45,8 +45,8 @@
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.DecodeOptions;
import org.forgerock.opendj.ldap.DereferenceAliasesPolicy;
import org.forgerock.opendj.ldap.LdapException;
import org.forgerock.opendj.ldap.Filter;
import org.forgerock.opendj.ldap.LdapException;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchResultHandler;
import org.forgerock.opendj.ldap.SearchScope;
@@ -92,15 +92,11 @@
import static com.forgerock.opendj.cli.Utils.*;
import static com.forgerock.opendj.ldap.tools.ToolsMessages.*;
/**
 * A tool that can be used to issue Search requests to the Directory Server.
 */
/** A tool that can be used to issue Search requests to the Directory Server. */
public final class LDAPSearch extends ConsoleApplication {
    private class LDAPSearchResultHandler implements SearchResultHandler {
        private int entryCount;
        /** {@inheritDoc} */
        @Override
        public boolean handleEntry(final SearchResultEntry entry) {
            entryCount++;
@@ -129,7 +125,6 @@
                if (control != null) {
                    println(INFO_LDAPSEARCH_ACCTUSABLE_HEADER.get());
                    if (control.isUsable()) {
                        println(INFO_LDAPSEARCH_ACCTUSABLE_IS_USABLE.get());
                        if (control.getSecondsBeforeExpiration() > 0) {
                            final int timeToExp = control.getSecondsBeforeExpiration();
@@ -140,7 +135,6 @@
                                    .get(timeToExpStr));
                        }
                    } else {
                        println(INFO_LDAPSEARCH_ACCTUSABLE_NOT_USABLE.get());
                        if (control.isInactive()) {
                            println(INFO_LDAPSEARCH_ACCTUSABLE_ACCT_INACTIVE.get());
@@ -183,7 +177,6 @@
            return true;
        }
        /** {@inheritDoc} */
        @Override
        public boolean handleReference(final SearchResultReference reference) {
            println(LocalizableMessage.raw(reference.toString()));
@@ -221,22 +214,19 @@
        super(out, err);
    }
    /** {@inheritDoc} */
    @Override
    public boolean isInteractive() {
        return false;
    }
    /** {@inheritDoc} */
    @Override
    public boolean isVerbose() {
        return verbose.isPresent();
    }
    /** Run ldapsearch with provided command-line arguments. **/
    /** Run ldapsearch with provided command-line arguments. */
    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,
@@ -435,8 +425,7 @@
            argParser.addArgument(showUsage);
            argParser.setUsageArgument(showUsage, getOutputStream());
        } catch (final ArgumentException ae) {
            final LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
            errPrintln(message);
            errPrintln(ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
            return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
        }
@@ -460,7 +449,7 @@
        final List<Filter> filters = new LinkedList<>();
        final List<String> attributes = new LinkedList<>();
        final ArrayList<String> filterAndAttributeStrings = argParser.getTrailingArguments();
        if (filterAndAttributeStrings.size() > 0) {
        if (!filterAndAttributeStrings.isEmpty()) {
            /* The list of trailing arguments should be structured as follow:
             - If a filter file is present, trailing arguments are
             considered as attributes
@@ -543,7 +532,7 @@
                return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
            }
        } catch (final ArgumentException ae) {
            errPrintln(ERR_DESCRIPTION_INVALID_VERSION.get(String.valueOf(version.getValue())));
            errPrintln(ERR_DESCRIPTION_INVALID_VERSION.get(version.getValue()));
            return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
        }
@@ -573,9 +562,7 @@
                    final Control ctrl = Utils.getControl(ctrlString);
                    search.addControl(ctrl);
                } catch (final DecodeException de) {
                    final LocalizableMessage message =
                            ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString);
                    errPrintln(message);
                    errPrintln(ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString));
                    ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
                }
            }
@@ -584,8 +571,7 @@
        if (effectiveRightsUser.isPresent()) {
            final String authzID = effectiveRightsUser.getValue();
            if (!authzID.startsWith("dn:")) {
                final LocalizableMessage message = ERR_EFFECTIVERIGHTS_INVALID_AUTHZID.get(authzID);
                errPrintln(message);
                errPrintln(ERR_EFFECTIVERIGHTS_INVALID_AUTHZID.get(authzID));
                return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
            }
            final Control effectiveRightsControl =
@@ -609,15 +595,12 @@
            final StringTokenizer tokenizer = new StringTokenizer(infoString, ":");
            if (!tokenizer.hasMoreTokens()) {
                final LocalizableMessage message = ERR_PSEARCH_MISSING_DESCRIPTOR.get();
                errPrintln(message);
                errPrintln(ERR_PSEARCH_MISSING_DESCRIPTOR.get());
                return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
            } else {
                final String token = tokenizer.nextToken();
                if (!"ps".equals(token)) {
                    final LocalizableMessage message =
                            ERR_PSEARCH_DOESNT_START_WITH_PS.get(String.valueOf(infoString));
                    errPrintln(message);
                    errPrintln(ERR_PSEARCH_DOESNT_START_WITH_PS.get(infoString));
                    return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
                }
            }
@@ -648,9 +631,7 @@
                            ct.add(PersistentSearchChangeType.MODIFY);
                            ct.add(PersistentSearchChangeType.MODIFY_DN);
                        } else {
                            final LocalizableMessage message =
                                    ERR_PSEARCH_INVALID_CHANGE_TYPE.get(String.valueOf(token));
                            errPrintln(message);
                            errPrintln(ERR_PSEARCH_INVALID_CHANGE_TYPE.get(token));
                            return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
                        }
                    } while (st.hasMoreTokens());
@@ -664,9 +645,7 @@
                } else if ("0".equals(token) || "false".equals(token) || "no".equals(token)) {
                    changesOnly = false;
                } else {
                    final LocalizableMessage message =
                            ERR_PSEARCH_INVALID_CHANGESONLY.get(String.valueOf(token));
                    errPrintln(message);
                    errPrintln(ERR_PSEARCH_INVALID_CHANGESONLY.get(token));
                    return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
                }
            }
@@ -678,9 +657,7 @@
                } else if ("0".equals(token) || "false".equals(token) || "no".equals(token)) {
                    returnECs = false;
                } else {
                    final LocalizableMessage message =
                            ERR_PSEARCH_INVALID_RETURN_ECS.get(String.valueOf(token));
                    errPrintln(message);
                    errPrintln(ERR_PSEARCH_INVALID_RETURN_ECS.get(token));
                    return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
                }
            }
@@ -702,9 +679,7 @@
                final Control assertionControl = AssertionRequestControl.newControl(true, filter);
                search.addControl(assertionControl);
            } catch (final LocalizedIllegalArgumentException le) {
                final LocalizableMessage message =
                        ERR_LDAP_ASSERTION_INVALID_FILTER.get(le.getMessage());
                errPrintln(message);
                errPrintln(ERR_LDAP_ASSERTION_INVALID_FILTER.get(le.getMessage()));
                return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
            }
        }
@@ -717,9 +692,7 @@
                    final Filter f = Filter.valueOf(s);
                    mvFilters.add(f);
                } catch (final LocalizedIllegalArgumentException le) {
                    final LocalizableMessage message =
                            ERR_LDAP_MATCHEDVALUES_INVALID_FILTER.get(le.getMessage());
                    errPrintln(message);
                    errPrintln(ERR_LDAP_MATCHEDVALUES_INVALID_FILTER.get(le.getMessage()));
                    return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
                }
            }
@@ -734,9 +707,7 @@
                search.addControl(ServerSideSortRequestControl.newControl(false, sortOrder
                        .getValue()));
            } catch (final LocalizedIllegalArgumentException le) {
                final LocalizableMessage message =
                        ERR_LDAP_SORTCONTROL_INVALID_ORDER.get(le.getMessageObject());
                errPrintln(message);
                errPrintln(ERR_LDAP_SORTCONTROL_INVALID_ORDER.get(le.getMessageObject()));
                return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
            }
        }
@@ -760,8 +731,7 @@
                    search.addControl(VirtualListViewRequestControl.newAssertionControl(true,
                            assertionValue, beforeCount, afterCount, null));
                } catch (final Exception e) {
                    final LocalizableMessage message = ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get();
                    errPrintln(message);
                    errPrintln(ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get());
                    return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
                }
            } else if (numTokens == 4) {
@@ -773,13 +743,11 @@
                    search.addControl(VirtualListViewRequestControl.newOffsetControl(true, offset,
                            contentCount, beforeCount, afterCount, null));
                } catch (final Exception e) {
                    final LocalizableMessage message = ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get();
                    errPrintln(message);
                    errPrintln(ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get());
                    return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
                }
            } else {
                final LocalizableMessage message = ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get();
                errPrintln(message);
                errPrintln(ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get());
                return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
            }
        }
@@ -787,8 +755,7 @@
        int pageSize = 0;
        if (simplePageSize.isPresent()) {
            if (filters.size() > 1) {
                final LocalizableMessage message = ERR_PAGED_RESULTS_REQUIRES_SINGLE_FILTER.get();
                errPrintln(message);
                errPrintln(ERR_PAGED_RESULTS_REQUIRES_SINGLE_FILTER.get());
                return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
            }
@@ -797,24 +764,10 @@
                search.addControl(SimplePagedResultsControl.newControl(true, pageSize, ByteString
                        .empty()));
            } catch (final ArgumentException ae) {
                final LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
                errPrintln(message);
                errPrintln(ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
                return ResultCode.CLIENT_SIDE_PARAM_ERROR.intValue();
            }
        }
        /*
         * if(connectionOptions.useSASLExternal()) {
         * if(!connectionOptions.useSSL() && !connectionOptions.useStartTLS()) {
         * LocalizableMessage message =
         * ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get();
         * errPrintln(wrapText(message, MAX_LINE_WIDTH)); return
         * CLIENT_SIDE_PARAM_ERROR; } if(keyStorePathValue == null) {
         * LocalizableMessage message =
         * ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get();
         * errPrintln(wrapText(message, MAX_LINE_WIDTH)); return
         * CLIENT_SIDE_PARAM_ERROR; } }
         * connectionOptions.setVerbose(verbose.isPresent());
         */
        int wrapColumn = 80;
        if (dontWrap.isPresent()) {
@@ -918,9 +871,7 @@
                }
            }
            if (countEntries.isPresent() && !isQuiet()) {
                final LocalizableMessage message =
                        INFO_LDAPSEARCH_MATCHING_ENTRY_COUNT.get(resultHandler.entryCount);
                println(message);
                println(INFO_LDAPSEARCH_MATCHING_ENTRY_COUNT.get(resultHandler.entryCount));
                println();
            }
        } catch (final LdapException ere) {