From 2173aa3140a1a35176921dfb8f2f9278b6973d73 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Mon, 12 Nov 2007 04:26:49 +0000
Subject: [PATCH] Update the dsreplication command-line to be consistent with dsconfig in the use of menus and in the order that questions to connect to the servers. Update the upgrade to use the same menus as the other command-lines. Do some minor changes in the uninstall command-line in order to be more consistent with dsconfig in the order where the connection parameters are provided. Fix a bug in ApplicationTrustManager related to the accepted certificates when there is a mismatch between the certificate and the host name. Do some refactorization of the code and remove the CliApplicationHelper class so that we use ConsoleApplication everywhere.

---
 opends/src/quicksetup/org/opends/quicksetup/upgrader/BuildExtractorCliHelper.java |   55 ++++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 46 insertions(+), 9 deletions(-)

diff --git a/opends/src/quicksetup/org/opends/quicksetup/upgrader/BuildExtractorCliHelper.java b/opends/src/quicksetup/org/opends/quicksetup/upgrader/BuildExtractorCliHelper.java
index ec58cdd..31c53cc 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/upgrader/BuildExtractorCliHelper.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/upgrader/BuildExtractorCliHelper.java
@@ -31,6 +31,10 @@
 import org.opends.messages.Message;
 
 import org.opends.quicksetup.UserDataException;
+import org.opends.server.util.cli.CLIException;
+import org.opends.server.util.cli.Menu;
+import org.opends.server.util.cli.MenuBuilder;
+import org.opends.server.util.cli.MenuResult;
 
 import java.util.logging.Logger;
 import java.util.logging.Level;
@@ -65,19 +69,52 @@
     if (launcher.isInteractive()) {
       if (!launcher.isNoPrompt()) {
         LOG.log(Level.INFO, "obtaining file information interactively");
+        final int UPGRADE = 1;
+        final int REVERT = 2;
+        int[] indexes = {UPGRADE, REVERT};
         Message[] options = new Message[] {
-                INFO_UPGRADE_OPERATION_UPGRADE.get(),
-                INFO_UPGRADE_OPERATION_REVERSION.get()
+            INFO_UPGRADE_OPERATION_UPGRADE.get(),
+            INFO_UPGRADE_OPERATION_REVERSION.get()
         };
-        int response = promptOptions(
-                INFO_UPGRADE_OPERATION_PROMPT.get(),
-                options[0],
-                options);
-        if (response == 0) {
+
+        MenuBuilder<Integer> builder = new MenuBuilder<Integer>(this);
+
+        builder.setPrompt(INFO_UPGRADE_OPERATION_PROMPT.get());
+
+        for (int i=0; i<indexes.length; i++)
+        {
+          builder.addNumberedOption(options[i], MenuResult.success(indexes[i]));
+        }
+
+        builder.setDefault(Message.raw(String.valueOf(UPGRADE)),
+            MenuResult.success(UPGRADE));
+
+        Menu<Integer> menu = builder.toMenu();
+        int choice;
+        try
+        {
+          MenuResult<Integer> m = menu.run();
+          if (m.isSuccess())
+          {
+            choice = m.getValue();
+          }
+          else
+          {
+            // Should never happen.
+            throw new RuntimeException();
+          }
+        }
+        catch (CLIException ce)
+        {
+          choice = UPGRADE;
+          LOG.log(Level.WARNING, "Error reading input: "+ce, ce);
+        }
+
+        if (choice == UPGRADE) {
           uud.setOperation(UpgradeUserData.Operation.UPGRADE);
           while(true) {
-            String fileName = promptForString(
-                    INFO_UPGRADE_FILE_PROMPT.get(), null);
+            String fileName = readInput(
+                    INFO_UPGRADE_FILE_PROMPT.get(), null, LOG);
             try {
               uud.setInstallPackage(validateInstallPackFile(fileName));
               LOG.log(Level.INFO, "file specified interactively: " +

--
Gitblit v1.10.0