From 0190fa66bcab9f911f23bf954eaa45f9af4aaa76 Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Tue, 25 Jun 2013 15:06:39 +0000
Subject: [PATCH] OPENDJ-1010 "upgrade --force" should not automatically accept the license

---
 opends/src/server/org/opends/server/tools/upgrade/Upgrade.java |   29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)

diff --git a/opends/src/server/org/opends/server/tools/upgrade/Upgrade.java b/opends/src/server/org/opends/server/tools/upgrade/Upgrade.java
index 86eca24..830f4a5 100644
--- a/opends/src/server/org/opends/server/tools/upgrade/Upgrade.java
+++ b/opends/src/server/org/opends/server/tools/upgrade/Upgrade.java
@@ -631,18 +631,26 @@
       if (LicenseFile.exists())
       {
         context.notify(Message.raw("\n" + LicenseFile.getText()));
-
-        // If the user asks for no-prompt. We just display the license text.
-        // User doesn't asks for no-prompt. We just display the license text
-        // and force to accept it.
         context.notify(INFO_LICENSE_DETAILS_CLI_LABEL.get());
-
         if (!context.isAcceptLicenseMode())
         {
+          final int answer;
 
-          final int answer =
-              context.confirmYN(INFO_LICENSE_ACCEPT.get(),
-                  ConfirmationCallback.NO);
+          // The force cannot answer yes to the license's question,
+          // which is not a task even if it requires a user interaction OR
+          // -an accept license mode to continue the process.
+          if (context.isForceUpgradeMode())
+          {
+            answer = ConfirmationCallback.NO;
+            context.notify(Message.raw(INFO_LICENSE_ACCEPT.get() + " "
+                + INFO_PROMPT_NO_COMPLETE_ANSWER.get()));
+          }
+          else
+          {
+            answer =
+                context.confirmYN(INFO_LICENSE_ACCEPT.get(),
+                    ConfirmationCallback.NO);
+          }
 
           if (answer == ConfirmationCallback.NO)
           {
@@ -655,8 +663,9 @@
         }
         else
         {
-          context.notify(INFO_LICENSE_ACCEPT.get());
-          context.notify(INFO_PROMPT_YES_COMPLETE_ANSWER.get());
+          // We automatically accept the license with this option.
+          context.notify(Message.raw(INFO_LICENSE_ACCEPT.get() + " "
+              + INFO_PROMPT_YES_COMPLETE_ANSWER.get()));
           LicenseFile.setApproval(true);
         }
       }

--
Gitblit v1.10.0