From 7a6f3dd0c046db02a9cebddd7e635c2189e378ff Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Sat, 21 Jul 2012 20:43:37 +0000
Subject: [PATCH] Fix OPENDJ-522: Add capability to force the upgrade to complete if errors occur during non-interactive mode
---
opends/src/quicksetup/org/opends/quicksetup/CliUserInteraction.java | 39 ++++++++++++++++++++-------------------
1 files changed, 20 insertions(+), 19 deletions(-)
diff --git a/opends/src/quicksetup/org/opends/quicksetup/CliUserInteraction.java b/opends/src/quicksetup/org/opends/quicksetup/CliUserInteraction.java
index 67668a7..95de7fd 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/CliUserInteraction.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/CliUserInteraction.java
@@ -23,6 +23,7 @@
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
+ * Portions copyright 2012 ForgeRock AS.
*/
package org.opends.quicksetup;
@@ -43,8 +44,6 @@
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
-import java.io.PrintStream;
-import java.io.InputStream;
/**
* Supports user interactions for a command line driven application.
@@ -54,21 +53,25 @@
static private final Logger LOG =
Logger.getLogger(CliUserInteraction.class.getName());
+ private final boolean isInteractive;
+ private final boolean isForceOnError;
+
/**
* Creates an instance that will use standard streams for interaction.
*/
public CliUserInteraction() {
- super(System.in, System.out, System.err);
+ this(null);
}
/**
- * Creates an instance using specific streams.
- * @param out OutputStream where prompts will be written
- * @param err OutputStream where errors will be written
- * @param in InputStream from which information will be read
+ * Creates an instance that will use standard streams for interaction and with
+ * the provided CLI arguments.
+ * @param ud The CLI arguments.
*/
- public CliUserInteraction(PrintStream out, PrintStream err, InputStream in) {
- super(in, out, err);
+ public CliUserInteraction(UserData ud) {
+ super(System.in, System.out, System.err);
+ isInteractive = ud != null ? ud.isInteractive() : true;
+ isForceOnError = ud != null ? ud.isForceOnError() : false;
}
/**
@@ -174,15 +177,6 @@
return sb.toString();
}
- /**
- * {@inheritDoc}
- */
- public String promptForString(Message prompt, Message title,
- String defaultValue) {
-
- return readInput(prompt, defaultValue, LOG);
- }
-
private void println(String text) {
text = Utils.convertHtmlBreakToLineSeparator(text);
text = Utils.stripHtml(text);
@@ -203,7 +197,7 @@
* {@inheritDoc}
*/
public boolean isInteractive() {
- return true;
+ return isInteractive;
}
@@ -250,4 +244,11 @@
{
return true;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isForceOnError() {
+ return isForceOnError;
+ }
}
--
Gitblit v1.10.0