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

Jean-Noël Rouvignac
15.54.2015 6c5a0862f30d13a27da02ea812e08e29d1512883
OPENDJ-2311 Option -V/--version don't work for SDK tools

Implemented "--version" for all sdk tools.
Here is an example output:

$ modrate --version
3.0.0.SNAPSHOT (revision 1bf0c1a7b33e936f1161dc9cd5c505fd341e52cc)

SdkVersionHandler.java: ADDED
Always read the version from opendj-core's MANIFEST.MF file
1 files added
13 files modified
255 ■■■■■ changed files
opendj-sdk/opendj-core/pom.xml 20 ●●●●● patch | view | raw | blame | history
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AddRate.java 6 ●●●●● patch | view | raw | blame | history
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthRate.java 19 ●●●● patch | view | raw | blame | history
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPCompare.java 11 ●●●● patch | view | raw | blame | history
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java 9 ●●●●● patch | view | raw | blame | history
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java 5 ●●●●● patch | view | raw | blame | history
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java 2 ●●●●● patch | view | raw | blame | history
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFDiff.java 17 ●●●●● patch | view | raw | blame | history
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFModify.java 15 ●●●●● patch | view | raw | blame | history
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFSearch.java 20 ●●●●● patch | view | raw | blame | history
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/MakeLDIF.java 35 ●●●● patch | view | raw | blame | history
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ModRate.java 17 ●●●● patch | view | raw | blame | history
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/SdkVersionHandler.java 66 ●●●●● patch | view | raw | blame | history
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/SearchRate.java 13 ●●●●● patch | view | raw | blame | history
opendj-sdk/opendj-core/pom.xml
@@ -77,6 +77,7 @@
        <opendj.osgi.import.additional>
            com.sun.security.auth*;resolution:=optional
        </opendj.osgi.import.additional>
        <maven.build.timestamp.format>yyyy-MM-dd'T'HH:mm:ss'Z'</maven.build.timestamp.format>
    </properties>
@@ -100,6 +101,20 @@
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>buildnumber-maven-plugin</artifactId>
                <version>1.4</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>create</goal>
                        </goals>
                     </execution>
                </executions>
            </plugin>
            <!-- Creates opendj-core bundle -->
            <plugin>
                <groupId>org.apache.felix</groupId>
@@ -112,6 +127,11 @@
                            org.forgerock.opendj.ldap*,
                            org.forgerock.opendj.ldif
                        </Export-Package>
                        <Build-Maven>Apache Maven ${maven.version}</Build-Maven>
                        <SCM-Revision>${buildNumber}</SCM-Revision>
                        <SCM-Branch>${scmBranch}</SCM-Branch>
                        <Build-Time>${maven.build.timestamp}</Build-Time>
                        <Build-Java>${java.version}</Build-Java>
                    </instructions>
                </configuration>
            </plugin>
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AddRate.java
@@ -52,8 +52,8 @@
import org.forgerock.opendj.ldap.ConnectionFactory;
import org.forgerock.opendj.ldap.Entry;
import org.forgerock.opendj.ldap.LdapException;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.LdapResultHandler;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.responses.Responses;
import org.forgerock.opendj.ldap.responses.Result;
import org.forgerock.opendj.ldif.EntryGenerator;
@@ -395,19 +395,16 @@
        super(out, err);
    }
    /** {@inheritDoc} */
    @Override
    public boolean isInteractive() {
        return false;
    }
    /** {@inheritDoc} */
    @Override
    public boolean isScriptFriendly() {
        return scriptFriendly.isPresent();
    }
    /** {@inheritDoc} */
    @Override
    public boolean isVerbose() {
        return verbose.isPresent();
@@ -418,6 +415,7 @@
        final LocalizableMessage toolDescription = INFO_ADDRATE_TOOL_DESCRIPTION.get();
        final ArgumentParser argParser =
            new ArgumentParser(AddRate.class.getName(), toolDescription, false, true, 1, 1, "template-file-path");
        argParser.setVersionHandler(new SdkVersionHandler());
        argParser.setShortToolDescription(REF_SHORT_DESC_ADDRATE.get());
        argParser.setDocToolDescriptionSupplement(SUPPLEMENT_DESCRIPTION_RATE_TOOLS.get());
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthRate.java
@@ -96,8 +96,7 @@
            }
        }
        private final class BindUpdateStatsResultHandler extends
                UpdateStatsResultHandler<BindResult> {
        private final class BindUpdateStatsResultHandler extends UpdateStatsResultHandler<BindResult> {
            private BindUpdateStatsResultHandler(final long startTime) {
                super(startTime);
            }
@@ -119,16 +118,13 @@
            private final char[] invalidPassword = "invalid-password".toCharArray();
            private final ThreadLocal<Random> rng = new ThreadLocal<Random>() {
                @Override
                protected Random initialValue() {
                    return new Random();
                }
            };
            private BindWorkerThread(final Connection connection,
                    final ConnectionFactory connectionFactory) {
            private BindWorkerThread(final Connection connection, final ConnectionFactory connectionFactory) {
                super(connection, connectionFactory);
            }
@@ -347,7 +343,6 @@
     * @param args
     *            The command-line arguments provided to this program.
     */
    public static void main(final String[] args) {
        final int retCode = new AuthRate().run(args);
        System.exit(filterExitCode(retCode));
@@ -372,19 +367,16 @@
        super(out, err);
    }
    /** {@inheritDoc} */
    @Override
    public boolean isInteractive() {
        return false;
    }
    /** {@inheritDoc} */
    @Override
    public boolean isScriptFriendly() {
        return scriptFriendly.isPresent();
    }
    /** {@inheritDoc} */
    @Override
    public boolean isVerbose() {
        return verbose.isPresent();
@@ -396,6 +388,7 @@
        final ArgumentParser argParser =
                new ArgumentParser(AuthRate.class.getName(), toolDescription, false, true, 0, 0,
                        "[filter format string] [attributes ...]");
        argParser.setVersionHandler(new SdkVersionHandler());
        argParser.setShortToolDescription(REF_SHORT_DESC_AUTHRATE.get());
        argParser.setDocToolDescriptionSupplement(SUPPLEMENT_DESCRIPTION_RATE_TOOLS.get());
@@ -410,7 +403,6 @@
        StringArgument propertiesFileArgument;
        BooleanArgument noPropertiesFileArgument;
        IntegerArgument invalidCredPercent;
        try {
            setDefaultPerfToolProperties();
            PerformanceRunnerOptions options = new PerformanceRunnerOptions(argParser, this);
@@ -479,8 +471,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;
            }
@@ -499,7 +490,7 @@
        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:
             the first trailing argument is considered the filter, the other
             as attributes.*/
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPCompare.java
@@ -143,13 +143,13 @@
    }
    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_LDAPCOMPARE_TOOL_DESCRIPTION.get();
        final ArgumentParser argParser =
                new ArgumentParser(LDAPCompare.class.getName(), toolDescription, false, true, 1, 0,
                        "attribute:value [DN ...]");
        final ArgumentParser argParser = new ArgumentParser(
            LDAPCompare.class.getName(), toolDescription, false, true, 1, 0, "attribute:value [DN ...]");
        argParser.setVersionHandler(new SdkVersionHandler());
        argParser.setShortToolDescription(REF_SHORT_DESC_LDAPCOMPARE.get());
        ConnectionFactoryProvider connectionFactoryProvider;
        ConnectionFactory connectionFactory;
        BindRequest bindRequest;
@@ -165,7 +165,6 @@
        StringArgument proxyAuthzID;
        StringArgument propertiesFileArgument;
        BooleanArgument noPropertiesFileArgument;
        try {
            connectionFactoryProvider = new ConnectionFactoryProvider(argParser, this);
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java
@@ -160,8 +160,7 @@
            if (r.getResultCode() != ResultCode.SUCCESS && r.getResultCode() != ResultCode.REFERRAL) {
                final LocalizableMessage msg = INFO_OPERATION_FAILED.get(operationType);
                errPrintln(msg);
                errPrintln(ERR_TOOL_RESULT_CODE.get(r.getResultCode().intValue(), r.getResultCode()
                        .toString()));
                errPrintln(ERR_TOOL_RESULT_CODE.get(r.getResultCode().intValue(), r.getResultCode()));
                if (r.getDiagnosticMessage() != null && r.getDiagnosticMessage().length() > 0) {
                    errPrintln(LocalizableMessage.raw(r.getDiagnosticMessage()));
                }
@@ -169,8 +168,7 @@
                    errPrintln(ERR_TOOL_MATCHED_DN.get(r.getMatchedDN()));
                }
            } else {
                final LocalizableMessage msg = INFO_OPERATION_SUCCESSFUL.get(operationType, name);
                println(msg);
                println(INFO_OPERATION_SUCCESSFUL.get(operationType, name));
                if (r.getDiagnosticMessage() != null && r.getDiagnosticMessage().length() > 0) {
                    errPrintln(LocalizableMessage.raw(r.getDiagnosticMessage()));
                }
@@ -217,7 +215,6 @@
     * @param args
     *            The command-line arguments provided to this program.
     */
    public static void main(final String[] args) {
        final int retCode = new LDAPModify().run(args);
        System.exit(filterExitCode(retCode));
@@ -252,7 +249,9 @@
        final LocalizableMessage toolDescription = INFO_LDAPMODIFY_TOOL_DESCRIPTION.get();
        final ArgumentParser argParser =
                new ArgumentParser(LDAPModify.class.getName(), toolDescription, false);
        argParser.setVersionHandler(new SdkVersionHandler());
        argParser.setShortToolDescription(REF_SHORT_DESC_LDAPMODIFY.get());
        ConnectionFactoryProvider connectionFactoryProvider;
        ConnectionFactory connectionFactory;
        BindRequest bindRequest;
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java
@@ -96,12 +96,13 @@
    }
    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_LDAPPWMOD_TOOL_DESCRIPTION.get();
        final ArgumentParser argParser =
                new ArgumentParser(LDAPPasswordModify.class.getName(), toolDescription, false);
        argParser.setVersionHandler(new SdkVersionHandler());
        argParser.setShortToolDescription(REF_SHORT_DESC_LDAPPASSWORDMODIFY.get());
        ConnectionFactoryProvider connectionFactoryProvider;
        ConnectionFactory connectionFactory;
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java
@@ -241,7 +241,9 @@
        final ArgumentParser argParser =
                new ArgumentParser(LDAPSearch.class.getName(), toolDescription, false, true, 0, 0,
                        "[filter] [attributes ...]");
        argParser.setVersionHandler(new SdkVersionHandler());
        argParser.setShortToolDescription(REF_SHORT_DESC_LDAPSEARCH.get());
        ConnectionFactoryProvider connectionFactoryProvider;
        ConnectionFactory connectionFactory;
        BindRequest bindRequest;
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFDiff.java
@@ -76,18 +76,15 @@
    }
    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_LDIFDIFF_TOOL_DESCRIPTION.get();
        final ArgumentParser argParser =
                new ArgumentParser(LDIFDiff.class.getName(), toolDescription, false, true, 2, 2,
                        "source target");
        final ArgumentParser argParser = new ArgumentParser(
            LDIFDiff.class.getName(), toolDescription, false, true, 2, 2, "source target");
        argParser.setVersionHandler(new SdkVersionHandler());
        argParser.setShortToolDescription(REF_SHORT_DESC_LDIFDIFF.get());
        final BooleanArgument showUsage;
        final StringArgument outputFilename;
        try {
            outputFilename =
                    new StringArgument("outputFilename", OPTION_SHORT_OUTPUT_LDIF_FILENAME,
@@ -110,8 +107,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 ResultCode.SUCCESS.intValue();
            }
@@ -182,8 +178,7 @@
                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();
                errPrintln(message);
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFModify.java
@@ -66,7 +66,6 @@
 * to a set of entries contained in an LDIF file.
 */
public final class LDIFModify extends ConsoleApplication {
    /**
     * The main method for LDIFModify tool.
     *
@@ -83,19 +82,16 @@
    }
    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_LDIFMODIFY_TOOL_DESCRIPTION.get();
        final ArgumentParser argParser =
                new ArgumentParser(LDIFModify.class.getName(), toolDescription, false, true, 1, 2,
                        "source [changes]");
        final ArgumentParser argParser = new ArgumentParser(
            LDIFModify.class.getName(), toolDescription, false, true, 1, 2, "source [changes]");
        argParser.setVersionHandler(new SdkVersionHandler());
        argParser.setShortToolDescription(REF_SHORT_DESC_LDIFMODIFY.get());
        final BooleanArgument continueOnError;
        final BooleanArgument showUsage;
        final StringArgument outputFilename;
        try {
            outputFilename =
                    new StringArgument("outputFilename", OPTION_SHORT_OUTPUT_LDIF_FILENAME,
@@ -193,8 +189,7 @@
                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();
                errPrintln(message);
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDIFSearch.java
@@ -63,12 +63,8 @@
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.
 */
/** This utility can be used to perform search operations against data in an LDIF file. */
public final class LDIFSearch extends ConsoleApplication {
    /**
     * The main method for LDIFSearch tool.
     *
@@ -85,13 +81,11 @@
    }
    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 =
                new ArgumentParser(LDIFSearch.class.getName(), toolDescription, false, true, 1, 0,
                        "source [filter] [attributes ...]");
        final ArgumentParser argParser = new ArgumentParser(
            LDIFSearch.class.getName(), toolDescription, false, true, 1, 0, "source [filter] [attributes ...]");
        argParser.setVersionHandler(new SdkVersionHandler());
        argParser.setShortToolDescription(REF_SHORT_DESC_LDIFSEARCH.get());
        final BooleanArgument showUsage;
@@ -102,7 +96,6 @@
        final StringArgument baseDN;
        final MultiChoiceArgument<SearchScope> searchScope;
        final IntegerArgument sizeLimit;
        try {
            outputFilename =
                    new StringArgument("outputFilename", OPTION_SHORT_OUTPUT_LDIF_FILENAME,
@@ -162,8 +155,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 ResultCode.SUCCESS.intValue();
            }
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/MakeLDIF.java
@@ -50,19 +50,12 @@
import org.forgerock.opendj.ldif.EntryGenerator;
import org.forgerock.opendj.ldif.LDIFEntryWriter;
/**
 * Program that generate LDIF content based on a template.
 */
/** Program that generate LDIF content based on a template. */
public final class MakeLDIF extends ConsoleApplication {
    /**
     * The value for the constant option in LDIF generator tools.
     */
    /** The value for the constant option in LDIF generator tools. */
    public static final String OPTION_LONG_CONSTANT = "constant";
    /**
     * The value for the path to look for LDIF resources (e.g data files).
     */
    /** The value for the path to look for LDIF resources (e.g data files). */
    public static final String OPTION_LONG_RESOURCE_PATH = "resourcePath";
    private static final int EXIT_CODE_SUCCESS = 0;
@@ -87,6 +80,7 @@
        final LocalizableMessage toolDescription = INFO_MAKELDIF_TOOL_DESCRIPTION.get();
        final ArgumentParser argParser = new ArgumentParser(MakeLDIF.class.getName(), toolDescription,
                false, true, 1, 1, "template-file-path");
        argParser.setVersionHandler(new SdkVersionHandler());
        argParser.setShortToolDescription(REF_SHORT_DESC_MAKELDIF.get());
        argParser.setDocToolDescriptionSupplement(SUPPLEMENT_DESCRIPTION_MAKELDIF.get());
@@ -142,10 +136,8 @@
    /** Run Make LDIF with provided arguments. */
    private int run(final String templatePath, final StringArgument resourcePath,
            final StringArgument ldifFile, final IntegerArgument randomSeedArg, final StringArgument constants) {
        EntryGenerator generator = null;
        LDIFEntryWriter writer = null;
        try {
            generator = createGenerator(templatePath, resourcePath, randomSeedArg, constants);
        try (EntryGenerator generator = createGenerator(templatePath, resourcePath, randomSeedArg, constants)) {
            if (generator == null) {
                return EXIT_CODE_FAILURE;
            }
@@ -173,11 +165,10 @@
            errPrintln(INFO_MAKELDIF_PROCESSING_COMPLETE.get(numberOfEntriesWritten));
        } finally {
            closeSilently(generator, writer);
        }
        return EXIT_CODE_SUCCESS;
        } finally {
            closeSilently(writer);
        }
    }
    static EntryGenerator createGenerator(final String templatePath, final StringArgument resourcePath,
@@ -223,9 +214,7 @@
        return generator;
    }
    /**
     * Returns true if all constants are added to generator, false otherwise.
     */
    /** Returns true if all constants are added to generator, false otherwise. */
    private static boolean addConstantsToGenerator(StringArgument constants, EntryGenerator generator,
                                                       final ConsoleApplication app) {
        for (final String constant : constants.getValues()) {
@@ -239,15 +228,12 @@
        return true;
    }
    private EntryGenerator createGenerator(final String templatePath, final StringArgument resourcePath,
            final IntegerArgument randomSeedArg, final StringArgument constants) {
        return createGenerator(templatePath, resourcePath, randomSeedArg, constants, true, this);
    }
    /**
     * Returns true if generation is successful, false otherwise.
     */
    /** Returns true if generation is successful, false otherwise. */
    private boolean generateEntries(final EntryGenerator generator, final LDIFEntryWriter writer,
            final StringArgument ldifFile) {
        try {
@@ -278,5 +264,4 @@
    MakeLDIF(PrintStream out, PrintStream err) {
        super(out, err);
    }
}
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/ModRate.java
@@ -129,7 +129,6 @@
     * @param args
     *            The command-line arguments provided to this program.
     */
    public static void main(final String[] args) {
        final int retCode = new ModRate().run(args);
        System.exit(filterExitCode(retCode));
@@ -142,33 +141,31 @@
        // Nothing to do.
    }
    /** {@inheritDoc} */
    @Override
    public boolean isInteractive() {
        return false;
    }
    /** {@inheritDoc} */
    @Override
    public boolean isScriptFriendly() {
        return scriptFriendly.isPresent();
    }
    /** {@inheritDoc} */
    @Override
    public boolean isVerbose() {
        return verbose.isPresent();
    }
    private int run(final String[] args) {
        /* Creates 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,
                        "[(attribute:value format string) ...]");
        argParser.setVersionHandler(new SdkVersionHandler());
        argParser.setShortToolDescription(REF_SHORT_DESC_MODRATE.get());
        argParser.setDocToolDescriptionSupplement(SUPPLEMENT_DESCRIPTION_RATE_TOOLS.get());
        ConnectionFactoryProvider connectionFactoryProvider;
        ConnectionFactory connectionFactory;
        ModifyPerformanceRunner runner;
@@ -177,7 +174,6 @@
        StringArgument propertiesFileArgument;
        BooleanArgument noPropertiesFileArgument;
        StringArgument baseDN;
        try {
            Utils.setDefaultPerfToolProperties();
@@ -221,8 +217,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;
            }
@@ -241,9 +236,7 @@
        runner.baseDN = baseDN.getValue();
        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-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/SdkVersionHandler.java
New file
@@ -0,0 +1,66 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *      Copyright 2015 ForgeRock AS
 */
package com.forgerock.opendj.ldap.tools;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Enumeration;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import com.forgerock.opendj.cli.VersionHandler;
/** Class that prints the version of the SDK to System.out. */
public class SdkVersionHandler implements VersionHandler {
    @Override
    public void printVersion() {
        System.out.println(getVersion());
    }
    @Override
    public String toString() {
        return getClass().getSimpleName() + "(" + getVersion() + ")";
    }
    private String getVersion() {
        try {
            final Enumeration<URL> manifests = getClass().getClassLoader().getResources("META-INF/MANIFEST.MF");
            while (manifests.hasMoreElements()) {
                final URL manifestUrl = manifests.nextElement();
                if (manifestUrl.toString().contains("/opendj-core-")) {
                    try (InputStream manifestStream = manifestUrl.openStream()) {
                        final Attributes attrs = new Manifest(manifestStream).getMainAttributes();
                        return attrs.getValue("Bundle-Version") + " (revision " + attrs.getValue("SCM-Revision") + ")";
                    }
                }
            }
            return null;
        } catch (IOException e) {
            throw new RuntimeException("IOException while determining SDK version", e);
        }
    }
}
opendj-sdk/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/SearchRate.java
@@ -183,31 +183,28 @@
        // Nothing to do.
    }
    /** {@inheritDoc} */
    @Override
    public boolean isInteractive() {
        return false;
    }
    /** {@inheritDoc} */
    @Override
    public boolean isScriptFriendly() {
        return scriptFriendly.isPresent();
    }
    /** {@inheritDoc} */
    @Override
    public boolean isVerbose() {
        return verbose.isPresent();
    }
    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_SEARCHRATE_TOOL_DESCRIPTION.get();
        final ArgumentParser argParser =
                new ArgumentParser(SearchRate.class.getName(), toolDescription, false, true, 1, 0,
                        "[filter format string] [attributes ...]");
        argParser.setVersionHandler(new SdkVersionHandler());
        argParser.setShortToolDescription(REF_SHORT_DESC_SEARCHRATE.get());
        argParser.setDocToolDescriptionSupplement(SUPPLEMENT_DESCRIPTION_RATE_TOOLS.get());
@@ -221,7 +218,6 @@
        BooleanArgument showUsage;
        StringArgument propertiesFileArgument;
        BooleanArgument noPropertiesFileArgument;
        try {
            Utils.setDefaultPerfToolProperties();
@@ -293,7 +289,7 @@
        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:
             the first trailing argument is considered the filter, the other as attributes.*/
            runner.filter = filterAndAttributeStrings.remove(0);
@@ -311,8 +307,7 @@
        }
        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);