From 26cba063b15bd0d0925e2290800d9a661961530b Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Thu, 09 Apr 2009 08:27:35 +0000
Subject: [PATCH] Fix for issue 2017 (tools usage should disclose default value for options)

---
 opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java b/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java
index f21b7f2..ce30d54 100644
--- a/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java
+++ b/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java
@@ -67,6 +67,8 @@
   private SubCommand preExternalInitializationSubCmd;
   private SubCommand statusReplicationSubCmd;
 
+  int defaultAdminPort = 4444;
+
   /**
    * No-prompt argument.
    */
@@ -293,6 +295,14 @@
       throws ArgumentException
   {
     initializeGlobalArguments(outStream);
+    try
+    {
+      defaultAdminPort = secureArgsList.getAdminPortFromConfig();
+    }
+    catch (Throwable t)
+    {
+      // Ignore
+    }
     createEnableReplicationSubCommand();
     createDisableReplicationSubCommand();
     createInitializeReplicationSubCommand();
@@ -529,7 +539,8 @@
         null, INFO_DESCRIPTION_ENABLE_REPLICATION_HOST1.get());
 
     port1Arg = new IntegerArgument("port1", OPTION_SHORT_PORT, "port1",
-        false, false, true, INFO_PORT_PLACEHOLDER.get(), 4444, null,
+        false, false, true, INFO_PORT_PLACEHOLDER.get(),
+        defaultAdminPort, null,
         INFO_DESCRIPTION_ENABLE_REPLICATION_SERVER_PORT1.get());
 
     bindDn1Arg = new StringArgument("bindDN1", OPTION_SHORT_BINDDN,
@@ -562,7 +573,7 @@
         null, INFO_DESCRIPTION_ENABLE_REPLICATION_HOST2.get());
 
     port2Arg = new IntegerArgument("port2", null, "port2",
-        false, false, true, INFO_PORT_PLACEHOLDER.get(), 4444, null,
+        false, false, true, INFO_PORT_PLACEHOLDER.get(), defaultAdminPort, null,
         INFO_DESCRIPTION_ENABLE_REPLICATION_SERVER_PORT2.get());
 
     bindDn2Arg = new StringArgument("bindDN2", null,
@@ -659,8 +670,8 @@
         INFO_DESCRIPTION_INITIALIZE_REPLICATION_HOST_SOURCE.get());
 
     portSourceArg = new IntegerArgument("portSource", OPTION_SHORT_PORT,
-        "portSource", false, false, true, INFO_PORT_PLACEHOLDER.get(), 4444,
-        null,
+        "portSource", false, false, true, INFO_PORT_PLACEHOLDER.get(),
+        defaultAdminPort, null,
         INFO_DESCRIPTION_INITIALIZE_REPLICATION_SERVER_PORT_SOURCE.get());
 
     hostNameDestinationArg = new StringArgument("hostDestination", 'O',
@@ -670,7 +681,7 @@
 
     portDestinationArg = new IntegerArgument("portDestination", null,
         "portDestination", false, false, true, INFO_PORT_PLACEHOLDER.get(),
-        4444,
+        defaultAdminPort,
         null,
         INFO_DESCRIPTION_INITIALIZE_REPLICATION_SERVER_PORT_DESTINATION.get());
 

--
Gitblit v1.10.0