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

Gaetan Boismal
17.32.2014 a70b2bcac49f3c36b89ae6fd7e2e9b4dd052326f
OPENDJ-1656 (CR-5711) start-ds -V displays no information
1 files added
1 files modified
56 ■■■■■ changed files
opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java 19 ●●●● patch | view | raw | blame | history
opendj-cli/src/main/java/com/forgerock/opendj/cli/VersionHandler.java 37 ●●●●● patch | view | raw | blame | history
opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentParser.java
@@ -130,6 +130,9 @@
    /** Indicates whether the version argument was provided. */
    private boolean versionPresent;
    /** The handler to call to print the product version. */
    private VersionHandler versionHandler;
    /**
     * The set of arguments defined for this parser, referenced by short ID.
     */
@@ -958,11 +961,12 @@
                        // usage information.
                        writeUsageToOutputStream();
                        return;
                    } else if (OPTION_LONG_PRODUCT_VERSION.equals(argName)) {
                    } else if (versionHandler != null && OPTION_LONG_PRODUCT_VERSION.equals(argName)) {
                        // "--version" will always be interpreted as requesting
                        // version information.
                        usageOrVersionDisplayed = true;
                        versionPresent = true;
                        versionHandler.printVersion();
                        return;
                    } else {
                        // There is no such argument registered.
@@ -1035,13 +1039,14 @@
                    if (argCharacter == '?') {
                        writeUsageToOutputStream();
                        return;
                    } else if (argCharacter == OPTION_SHORT_PRODUCT_VERSION
                    } else if (versionHandler != null && argCharacter == OPTION_SHORT_PRODUCT_VERSION
                            && !shortIDMap.containsKey(OPTION_SHORT_PRODUCT_VERSION)) {
                        // "-V" will always be interpreted as requesting
                        // version information except if it's already defined
                        // (e.g in ldap tools).
                        usageOrVersionDisplayed = true;
                        versionPresent = true;
                        versionHandler.printVersion();
                        return;
                    } else {
                        // There is no such argument registered.
@@ -1313,6 +1318,16 @@
    }
    /**
     * Sets the version handler which will be used to display the product version.
     *
     * @param handler
     *            The version handler.
     */
    public void setVersionHandler(final VersionHandler handler) {
        versionHandler = handler;
    }
    /**
     * Indicates whether the version or the usage information has been displayed
     * to the end user either by an explicit argument like "-H" or "--help", or
     * by a built-in argument like "-?".
opendj-cli/src/main/java/com/forgerock/opendj/cli/VersionHandler.java
New file
@@ -0,0 +1,37 @@
/*
 * 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 2014 ForgeRock AS
 */
package com.forgerock.opendj.cli;
/**
 * A handler for printing product version.
 */
//@FunctionalInterface
public interface VersionHandler {
    /** Invoked when the version of the product should be printed. */
    void printVersion();
}