From 728eb3e9368b641832819b7c8687864a938dee4b Mon Sep 17 00:00:00 2001
From: Tim "Docteur" Caillot <tim.caillot@gmail.com>
Date: Wed, 26 Jun 2019 07:12:09 +0000
Subject: [PATCH] Added backwards compatibility with -a (#73)
---
opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentConstants.java | 7 ++++++-
opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java | 16 ++++++++++++++++
opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java | 7 +++++++
opendj-cli/src/main/resources/com/forgerock/opendj/cli/cli.properties | 1 +
opendj-server-legacy/src/messages/org/opends/messages/tool.properties | 4 ++--
5 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentConstants.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentConstants.java
index de1ed2b..bbf9253 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentConstants.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/ArgumentConstants.java
@@ -205,7 +205,12 @@
/** The value for the long option certNickname . */
public static final String OPTION_LONG_CERT_NICKNAME = "certNickname";
- /** The value for the short option continueOnError . */
+ /** The value for the short option defaultAdd . */
+ public static final char OPTION_SHORT_DEFAULT_ADD = 'a';
+ /** The value for the long option defaultAdd . */
+ public static final String OPTION_LONG_DEFAULT_ADD = "defaultAdd";
+
+ /** The value for the short option continueOnError . */
public static final char OPTION_SHORT_CONTINUE_ON_ERROR = 'c';
/** The value for the long option continueOnError . */
public static final String OPTION_LONG_CONTINUE_ON_ERROR = "continueOnError";
diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java
index 4ea1669..5cd5b86 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java
@@ -143,6 +143,22 @@
}
/**
+ * Returns the "Default Add" boolean argument. <br>
+ * This is a legacy argument and exists for backwards compatibility.
+ *
+ * <br><i> N.B : the 'a' short option is also used by backupall, addBaseEntry.</i>
+ * @return The "defaultAdd" argument.
+ * @throws ArgumentException
+ * If there is a problem with any of the parameters used to create this argument.
+ */
+ public static BooleanArgument defaultAddArgument() throws ArgumentException {
+ return BooleanArgument.builder(OPTION_LONG_DEFAULT_ADD)
+ .shortIdentifier(OPTION_SHORT_DEFAULT_ADD)
+ .description(INFO_DESCRIPTION_DEFAULT_ADD.get())
+ .buildArgument();
+ }
+
+ /**
* Returns the "control" string argument.
*
* @return The "control" argument.
diff --git a/opendj-cli/src/main/resources/com/forgerock/opendj/cli/cli.properties b/opendj-cli/src/main/resources/com/forgerock/opendj/cli/cli.properties
index f87dd96..b469dbb 100644
--- a/opendj-cli/src/main/resources/com/forgerock/opendj/cli/cli.properties
+++ b/opendj-cli/src/main/resources/com/forgerock/opendj/cli/cli.properties
@@ -134,6 +134,7 @@
information
INFO_DESCRIPTION_CONTINUE_ON_ERROR=Continue processing even if there are \
errors
+INFO_DESCRIPTION_DEFAULT_ADD=Legacy argument for ForgeRock OpenDJ compatibility.
INFO_DESCRIPTION_USE_SSL=Use SSL for secure communication with the server
INFO_DESCRIPTION_START_TLS=Use StartTLS to secure communication with the \
server
diff --git a/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java b/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java
index bd08ee8..3e98df5 100644
--- a/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java
+++ b/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java
@@ -263,6 +263,7 @@
BooleanArgument continueOnError;
BooleanArgument noop;
BooleanArgument showUsage;
+ BooleanArgument defaultAdd;
StringArgument assertionFilter;
StringArgument controlStr;
StringArgument filename;
@@ -319,6 +320,12 @@
continueOnError = continueOnErrorArgument();
argParser.addArgument(continueOnError);
+ /* Legacy argument in ForgeRock's OpenDJ to avoid failing when running older scripts.
+ The current behaviour is the opposite of Forgerock (defaultAdd false),
+ as we treat records with no changetype as add operations by default. */
+ defaultAdd = defaultAddArgument();
+ argParser.addArgument(defaultAdd);
+
noop = noOpArgument();
argParser.addArgument(noop);
diff --git a/opendj-server-legacy/src/messages/org/opends/messages/tool.properties b/opendj-server-legacy/src/messages/org/opends/messages/tool.properties
index 3fc6f7e..05ff5d2 100644
--- a/opendj-server-legacy/src/messages/org/opends/messages/tool.properties
+++ b/opendj-server-legacy/src/messages/org/opends/messages/tool.properties
@@ -2592,7 +2592,7 @@
ERR_FILE_NOT_FULLY_READABLE_20015=Could not completely read file '%s'
SUPPLEMENT_DESCRIPTION_BACKEND_TOOL_SUBCMD_LIST_INDEX_STATUS_20016=\
<xinclude:include href="variablelist-backendstat-index-status.xml" />
-
+INFO_DESCRIPTION_DEFAULT_ADD_20017=Legacy argument for ForgeRock OpenDJ compatibility.
INFO_LDAP_CONN_PROMPT_SECURITY_LDAP=LDAP
INFO_LDAP_CONN_PROMPT_SECURITY_USE_SSL=LDAP with SSL
INFO_LDAP_CONN_PROMPT_SECURITY_USE_START_TLS=LDAP with StartTLS
@@ -2689,4 +2689,4 @@
INFO_UPGRADE_TASK_DELETE_SUBORDINATE_BASE_DN_FROM_ROOT_DSE=Removing subordinate-base-dn attribute from \
Root DSE configuration
INFO_UPGRADE_TASK_ADD_SUBORDINATE_BASE_DN_TO_GLOBAL_CONFIG=Adding subordinate-base-dn attribute to \
- Global configuration
\ No newline at end of file
+ Global configuration
--
Gitblit v1.10.0