From 18bef688bddb3ed5cef3b7ee54eb278ffe5d56c5 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Fri, 05 Oct 2007 15:13:51 +0000
Subject: [PATCH] Fix for issue 2422.
---
opendj-sdk/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliArgumentParser.java | 146 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 145 insertions(+), 1 deletions(-)
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliArgumentParser.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliArgumentParser.java
index 118a07e..ee27939 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliArgumentParser.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliArgumentParser.java
@@ -59,6 +59,7 @@
private SubCommand enableReplicationSubCmd;
private SubCommand disableReplicationSubCmd;
private SubCommand initializeReplicationSubCmd;
+ private SubCommand initializeAllReplicationSubCmd;
private SubCommand statusReplicationSubCmd;
private BooleanArgument noPromptArg;
@@ -249,6 +250,12 @@
public static final String INITIALIZE_REPLICATION_SUBCMD_NAME = "initialize";
/**
+ * The text of the initialize all replication subcommand.
+ */
+ public static final String INITIALIZE_ALL_REPLICATION_SUBCMD_NAME =
+ "initialize-all";
+
+ /**
* The text of the status replication subcommand.
*/
public static final String STATUS_REPLICATION_SUBCMD_NAME = "status";
@@ -286,6 +293,7 @@
createEnableReplicationSubCommand();
createDisableReplicationSubCommand();
createInitializeReplicationSubCommand();
+ createInitializeAllReplicationSubCommand();
createStatusReplicationSubCommand();
}
@@ -616,7 +624,8 @@
initializeReplicationSubCmd = new SubCommand(this,
INITIALIZE_REPLICATION_SUBCMD_NAME,
- INFO_DESCRIPTION_SUBCMD_INITIALIZE_REPLICATION.get());
+ INFO_DESCRIPTION_SUBCMD_INITIALIZE_REPLICATION.get(
+ INITIALIZE_ALL_REPLICATION_SUBCMD_NAME));
Argument[] argsToAdd = {
hostNameSourceArg, portSourceArg, useSSLSourceArg, useStartTLSSourceArg,
@@ -630,6 +639,28 @@
}
/**
+ * Creates the initialize all replication subcommand and all the specific
+ * options for the subcommand. Note: this method assumes that
+ * initializeGlobalArguments has already been called and that hostNameArg,
+ * portArg, startTLSArg and useSSLArg have been created.
+ */
+ private void createInitializeAllReplicationSubCommand()
+ throws ArgumentException
+ {
+ initializeAllReplicationSubCmd = new SubCommand(this,
+ INITIALIZE_ALL_REPLICATION_SUBCMD_NAME,
+ INFO_DESCRIPTION_SUBCMD_INITIALIZE_ALL_REPLICATION.get(
+ INITIALIZE_REPLICATION_SUBCMD_NAME));
+ Argument[] argsToAdd = { secureArgsList.hostNameArg,
+ secureArgsList.portArg, secureArgsList.useSSLArg,
+ secureArgsList.useStartTLSArg };
+ for (int i=0; i<argsToAdd.length; i++)
+ {
+ initializeAllReplicationSubCmd.addArgument(argsToAdd[i]);
+ }
+ }
+
+ /**
* Creates the status replication subcommand and all the specific options
* for the subcommand. Note: this method assumes that
* initializeGlobalArguments has already been called and that hostNameArg,
@@ -920,6 +951,30 @@
}
/**
+ * Indicate if the SSL mode is required for the server in the initialize all
+ * replication subcommand.
+ *
+ * @return <CODE>true</CODE> if SSL mode is required for the server in the
+ * initialize all replication subcommand and <CODE>false</CODE> otherwise.
+ */
+ public boolean useSSLToInitializeAll()
+ {
+ return secureArgsList.useSSLArg.isPresent();
+ }
+
+ /**
+ * Indicate if the SSL mode is required for the server in the initialize all
+ * replication subcommand.
+ *
+ * @return <CODE>true</CODE> if StartTLS mode is required for the server in
+ * the initialize all replication subcommand and <CODE>false</CODE> otherwise.
+ */
+ public boolean useStartTLSToInitializeAll()
+ {
+ return secureArgsList.useStartTLSArg.isPresent();
+ }
+
+ /**
* Indicate if the SSL mode is required for the server in the status
* replication subcommand.
*
@@ -1246,6 +1301,28 @@
}
/**
+ * Returns the host name explicitly provided in the initialize all replication
+ * subcommand.
+ * @return the host name explicitly provided in the initialize all replication
+ * subcommand.
+ */
+ public String getHostNameToInitializeAll()
+ {
+ return getValue(secureArgsList.hostNameArg);
+ }
+
+ /**
+ * Returns the host name default value in the initialize all replication
+ * subcommand.
+ * @return the host name default value in the initialize all replication
+ * subcommand.
+ */
+ public String getDefaultHostNameToInitializeAll()
+ {
+ return getDefaultValue(secureArgsList.hostNameArg);
+ }
+
+ /**
* Returns the source host name explicitly provided in the initialize
* replication subcommand.
* @return the source host name explicitly provided in the initialize
@@ -1356,6 +1433,28 @@
}
/**
+ * Returns the server port explicitly provided in the initialize all
+ * replication subcommand.
+ * @return the server port explicitly provided in the initialize all
+ * replication subcommand. Returns -1 if no port was explicitly provided.
+ */
+ public int getPortToInitializeAll()
+ {
+ return getValue(secureArgsList.portArg);
+ }
+
+ /**
+ * Returns the server port default value in the initialize all replication
+ * subcommand.
+ * @return the server port default value in the initialize all replication
+ * subcommand.
+ */
+ public int getDefaultPortToInitializeAll()
+ {
+ return getDefaultValue(secureArgsList.portArg);
+ }
+
+ /**
* Returns the server port explicitly provided in the status replication
* subcommand.
* @return the server port explicitly provided in the status replication
@@ -1483,6 +1582,10 @@
{
validateInitializeReplicationOptions(buf);
}
+ else if (isInitializeAllReplicationSubcommand())
+ {
+ validateInitializeAllReplicationOptions(buf);
+ }
else
{
@@ -1526,6 +1629,17 @@
}
/**
+ * Returns whether the user provided subcommand is the initialize all
+ * replication or not.
+ * @return <CODE>true</CODE> if the user provided subcommand is the
+ * initialize all replication and <CODE>false</CODE> otherwise.
+ */
+ public boolean isInitializeAllReplicationSubcommand()
+ {
+ return isSubcommand(INITIALIZE_ALL_REPLICATION_SUBCMD_NAME);
+ }
+
+ /**
* Returns whether the user provided subcommand is the initialize replication
* or not.
* @return <CODE>true</CODE> if the user provided subcommand is the
@@ -1630,6 +1744,36 @@
}
/**
+ * Checks the initialize all replication subcommand options and updates the
+ * provided MessageBuilder with the errors that were encountered with the
+ * subcommand options.
+ *
+ * This method assumes that the method parseArguments for the parser has
+ * already been called.
+ * @param buf the MessageBuilder object where we add the error messages
+ * describing the errors encountered.
+ */
+ private void validateInitializeAllReplicationOptions(MessageBuilder buf)
+ {
+ Argument[][] conflictingPairs =
+ {
+ {secureArgsList.useStartTLSArg, secureArgsList.useSSLArg}
+ };
+
+ for (int i=0; i< conflictingPairs.length; i++)
+ {
+ Argument arg1 = conflictingPairs[i][0];
+ Argument arg2 = conflictingPairs[i][1];
+ if (arg1.isPresent() && arg2.isPresent())
+ {
+ Message message = ERR_TOOL_CONFLICTING_ARGS.get(
+ arg1.getLongIdentifier(), arg2.getLongIdentifier());
+ addMessage(buf, message);
+ }
+ }
+ }
+
+ /**
* Checks the status replication subcommand options and updates the provided
* MessageBuilder with the errors that were encountered with the subcommand
* options.
--
Gitblit v1.10.0