| opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/CliConstants.java | ●●●●● patch | view | raw | blame | history | |
| opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java | ●●●●● patch | view | raw | blame | history | |
| opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/ReturnCode.java | ●●●●● patch | view | raw | blame | history | |
| opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java | ●●●●● patch | view | raw | blame | history | |
| opendj-sdk/opendj-cli/src/main/resources/com/forgerock/opendj/cli/cli.properties | ●●●●● patch | view | raw | blame | history | |
| opendj-sdk/opendj-cli/src/test/java/com/forgerock/opendj/cli/CliTestCase.java | ●●●●● patch | view | raw | blame | history | |
| opendj-sdk/opendj-cli/src/test/java/com/forgerock/opendj/cli/UtilsTestCase.java | ●●●●● patch | view | raw | blame | history |
opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/CliConstants.java
@@ -633,6 +633,11 @@ */ public static final String OPTION_LONG_ROOT_USER_DN = "rootUserDN"; /** * The value for the long option connect timeout attribute. */ public static final String OPTION_LONG_CONNECT_TIMEOUT = "connectTimeout"; // Prevent instantiation. private CliConstants() { opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java
@@ -69,7 +69,7 @@ * @throws ArgumentException * If there is a problem with any of the parameters used to create this argument. */ public static final StringArgument getPropertiesFileArgument() throws ArgumentException { public static final StringArgument getPropertiesFile() throws ArgumentException { return 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()); } @@ -77,23 +77,23 @@ /** * Returns the "No properties file" boolean argument. * * @return The "No properties file" argument. * @return The "noPropertiesFile" argument. * @throws ArgumentException * If there is a problem with any of the parameters used to create this argument. */ public static final BooleanArgument getNoPropertiesFileArgument() throws ArgumentException { return new BooleanArgument("noPropertiesFileArgument", null, OPTION_LONG_NO_PROP_FILE, public static final BooleanArgument getNoPropertiesFile() throws ArgumentException { return new BooleanArgument("noPropertiesFile", null, OPTION_LONG_NO_PROP_FILE, INFO_DESCRIPTION_NO_PROP_FILE.get()); } /** * Returns the "Continue On Error" boolean argument. * * @return The "Continue On Error" argument. * @return The "continueOnError" argument. * @throws ArgumentException * If there is a problem with any of the parameters used to create this argument. */ public static final BooleanArgument getContinueOnErrorArgument() throws ArgumentException { public static final BooleanArgument getContinueOnError() throws ArgumentException { final BooleanArgument continueOnError = new BooleanArgument("continueOnError", 'c', "continueOnError", INFO_DESCRIPTION_CONTINUE_ON_ERROR.get()); continueOnError.setPropertyName("continueOnError"); @@ -107,7 +107,7 @@ * @throws ArgumentException * If there is a problem with any of the parameters used to create this argument. */ public static final IntegerArgument getVersionArgument() throws ArgumentException { public static final IntegerArgument getVersion() throws ArgumentException { final IntegerArgument 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()); @@ -167,6 +167,24 @@ } /** * Returns the "connection timeout" boolean argument. * * @param defaultTimeout * The default timeout. * @return The "connectTimeout" argument. * @throws ArgumentException * If there is a problem with any of the parameters used to create this argument. */ public static final IntegerArgument getConnectTimeOut(final int defaultTimeout) throws ArgumentException { final IntegerArgument connectTimeout = new IntegerArgument(OPTION_LONG_CONNECT_TIMEOUT, null, OPTION_LONG_CONNECT_TIMEOUT, false, false, true, INFO_TIMEOUT_PLACEHOLDER.get(), defaultTimeout, null, true, 1, true, 65535, INFO_DESCRIPTION_CONNECTION_TIMEOUT.get()); connectTimeout.setPropertyName(OPTION_LONG_CONNECT_TIMEOUT); connectTimeout.setHidden(true); return connectTimeout; } /** * Returns the "CLI" boolean argument. * * @return The "CLI" argument. opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/ReturnCode.java
New file @@ -0,0 +1,117 @@ /* * 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; /** * List of return codes used by CLIs. */ public enum ReturnCode { /** * Successful setup. * <PRE> * Code value of 0. * </PRE> */ SUCCESS(0), /** * Unexpected error (potential bug). * <PRE> * Code value of 1. * </PRE> */ ERROR_UNEXPECTED(1), /** * Cannot parse arguments or data provided by user is not valid. * <PRE> * Code value of 2. * </PRE> */ ERROR_USER_DATA(2), /** * Error server already installed. * <PRE> * Code value of 3. * </PRE> */ ERROR_SERVER_ALREADY_INSTALLED(3), /** * Error initializing server. * <PRE> * Code value of 4. * </PRE> */ ERROR_INITIALIZING_SERVER(4), /** * The user failed providing password (for the key store for instance). * <PRE> * Code value of 5. * </PRE> */ ERROR_PASSWORD_LIMIT(5), /** * The user cancelled the setup. * <PRE> * Code value of 6. * </PRE> */ ERROR_USER_CANCELLED(6), /** * The user doesn't accept the license. * <PRE> * Code value of 7. * </PRE> */ ERROR_LICENSE_NOT_ACCEPTED(7), /** * Incompatible java version. * <PRE> * Code value of 8. * </PRE> */ JAVA_VERSION_INCOMPATIBLE(8), /** * The client-side result code that indicates that there was a problem with one or more of the parameters provided * by the user. * <PRE> * Code value of 89. * </PRE> */ CLIENT_SIDE_PARAM_ERROR(89); private int returnCode; private ReturnCode(int returnCode) { this.returnCode = returnCode; } /** * Get the corresponding return code value. * * @return The corresponding return code value. */ public int get() { return returnCode; } } opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/Utils.java
@@ -332,6 +332,20 @@ return buffer.toString(); } /** * Checks that the java version. * * @throws CLIException * If the java version we are running on is not compatible. */ public static void checkJavaVersion() throws CLIException { final String version = System.getProperty("java.specification.version"); if (!(Float.valueOf(version) >= 1.6)) { final String javaBin = System.getProperty("java.home") + File.separator + "bin" + File.separator + "java"; throw new CLIException(ERR_INCOMPATIBLE_JAVA_VERSION.get("1.6", version, javaBin), null); } } // Prevent instantiation. private Utils() { // Do nothing. opendj-sdk/opendj-cli/src/main/resources/com/forgerock/opendj/cli/cli.properties
@@ -544,6 +544,7 @@ INFO_ROOT_USER_PWD_PLACEHOLDER={rootUserPassword} INFO_ROOT_USER_PWD_FILE_PLACEHOLDER={rootUserPasswordFile} INFO_HOST_PLACEHOLDER={host} INFO_TIMEOUT_PLACEHOLDER={timeout} INFO_GENERAL_DESCRIPTION_REJECTED_FILE=Write rejected entries to the \ specified file INFO_GENERAL_DESCRIPTION_SKIPPED_FILE=Write skipped entries to the \ @@ -699,4 +700,18 @@ INFO_BACKUPDB_DESCRIPTION_BACKEND_ID=Backend ID for the backend to \ archive INFO_BACKUPDB_DESCRIPTION_BACKUP_ALL=Back up all backends in the server INFO_SETUP_SUBCOMMAND_CREATE_DIRECTORY_SERVER=Can be used with global arguments \ to setup a directory server INFO_SETUP_SUBCOMMAND_CREATE_PROXY=Can be used with global arguments \ to setup a proxy ERR_INCOMPATIBLE_JAVA_VERSION=The minimum Java version required is %s.%n%n\ The detected version is %s.%nThe binary detected is %s%n%nPlease set \ OPENDJ_JAVA_HOME to the root of a compatible Java installation or edit the \ java.properties file and then run the dsjavaproperties script to specify the \ java version to be used. INFO_INSTANCE_DIRECTORY=Instance Directory: %s INFO_INSTALLATION_DIRECTORY=Installation Directory: %s ERR_INVALID_LOG_FILE=Invalid log file %s INFO_DESCRIPTION_CONNECTION_TIMEOUT=Maximum length of time (in \ milliseconds) that can be taken to establish a connection. Use '0' to \ specify no time out opendj-sdk/opendj-cli/src/test/java/com/forgerock/opendj/cli/CliTestCase.java
@@ -30,9 +30,9 @@ import org.testng.annotations.Test; /** * An abstract class that all cli unit tests should extend. * An abstract class that all CLI unit tests should extend. */ @Test(groups = { "precommit", "cli", "sdk" }) public abstract class CliTestCase extends ForgeRockTestCase { } opendj-sdk/opendj-cli/src/test/java/com/forgerock/opendj/cli/UtilsTestCase.java
New file @@ -0,0 +1,47 @@ /* * 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; import org.testng.annotations.Test; public class UtilsTestCase extends CliTestCase { @Test(expectedExceptions = CLIException.class) public void testInvalidJavaVersion() throws CLIException { final String original = System.getProperty("java.specification.version"); System.setProperty("java.specification.version", "1.5"); try { Utils.checkJavaVersion(); } finally { System.setProperty("java.specification.version", original); } } @Test() public void testValidJavaVersion() throws CLIException { Utils.checkJavaVersion(); } }