From 0af0c6ab9fdb449bdd468afecdeb5adc3ef426ea Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Fri, 24 Jul 2009 09:46:24 +0000
Subject: [PATCH] Refactor the code of dsreplication and extract some of its commodity methods and move them to the classes they apply to.
---
opendj-sdk/opends/src/server/org/opends/server/util/cli/ConsoleApplication.java | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/util/cli/ConsoleApplication.java b/opendj-sdk/opends/src/server/org/opends/server/util/cli/ConsoleApplication.java
index 720ed8f..1d149d9 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/util/cli/ConsoleApplication.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/util/cli/ConsoleApplication.java
@@ -648,6 +648,55 @@
}
/**
+ * Returns a message object for the given NamingException.
+ * @param ne the NamingException.
+ * @param hostPort the hostPort representation of the server we were
+ * contacting when the NamingException occurred.
+ * @return a message object for the given NamingException.
+ */
+ protected Message getMessageForException(NamingException ne, String hostPort)
+ {
+ Message msg;
+ if (Utils.isCertificateException(ne))
+ {
+ msg = INFO_ERROR_READING_CONFIG_LDAP_CERTIFICATE_SERVER.get(
+ hostPort, ne.toString(true));
+ }
+ else
+ {
+ msg = INFO_CANNOT_CONNECT_TO_REMOTE_GENERIC.get(
+ hostPort, ne.toString(true));
+ }
+ return msg;
+ }
+
+ /**
+ * Commodity method used to repeatidly ask the user to provide a port value.
+ * @param prompt the prompt message.
+ * @param defaultValue the default value of the port to be proposed to the
+ * user.
+ * @param logger the logger where the errors will be written.
+ * @return the port value provided by the user.
+ */
+ protected int askPort(Message prompt, int defaultValue, Logger logger)
+ {
+ int port = -1;
+ while (port == -1)
+ {
+ try
+ {
+ port = readPort(prompt, defaultValue);
+ }
+ catch (CLIException ce)
+ {
+ port = -1;
+ logger.log(Level.WARNING, "Error reading input: "+ce, ce);
+ }
+ }
+ return port;
+ }
+
+ /**
* Interactively prompts for user input and continues until valid
* input is provided.
*
--
Gitblit v1.10.0