From 7799753ee3631b6ac9f3ade5205da789455bc4fd Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Thu, 01 Aug 2013 15:38:23 +0000
Subject: [PATCH] More minor enhancements to the upgrader so that it can be used for embedded upgrades.

---
 opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/UpgradeContext.java |   60 ++++++++++++++++++++++++++++++------------------------------
 1 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/UpgradeContext.java b/opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/UpgradeContext.java
index 4c76d24..ad01a0e 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/UpgradeContext.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/UpgradeContext.java
@@ -39,6 +39,7 @@
 
 import org.opends.messages.Message;
 import org.opends.server.tools.ClientException;
+import org.opends.server.types.InitializationException;
 import org.opends.server.util.BuildVersion;
 
 
@@ -88,6 +89,23 @@
 
 
   /**
+   * Creates a new upgrade context for upgrading from the instance version (as
+   * obtained from config/buildinfo) to the binary version.
+   *
+   * @param handler
+   *          The call-back handler for interacting with the upgrade
+   *          application.
+   * @throws InitializationException
+   *           If an error occurred while reading or parsing the version.
+   */
+  public UpgradeContext(CallbackHandler handler) throws InitializationException
+  {
+    this(BuildVersion.instanceVersion(), BuildVersion.binaryVersion(), handler);
+  }
+
+
+
+  /**
    * Constructor for the upgrade context.
    *
    * @param fromVersion
@@ -149,10 +167,12 @@
    *
    * @param isIgnoreErrorsMode
    *          {@code true} if ignore error mode is activated.
+   * @return This upgrade context.
    */
-  public void setIgnoreErrorsMode(boolean isIgnoreErrorsMode)
+  public UpgradeContext setIgnoreErrorsMode(boolean isIgnoreErrorsMode)
   {
     this.isIgnoreErrorsMode = isIgnoreErrorsMode;
+    return this;
   }
 
 
@@ -174,10 +194,12 @@
    *
    * @param isAcceptLicenseMode
    *          {@code true} if the accept license mode is activated.
+   * @return This upgrade context.
    */
-  public void setAcceptLicenseMode(boolean isAcceptLicenseMode)
+  public UpgradeContext setAcceptLicenseMode(boolean isAcceptLicenseMode)
   {
     this.isAcceptLicenseMode = isAcceptLicenseMode;
+    return this;
   }
 
 
@@ -211,10 +233,12 @@
    *
    * @param isInteractiveMode
    *          {@code true} if the interactive mode is activated.
+   * @return This upgrade context.
    */
-  public void setInteractiveMode(boolean isInteractiveMode)
+  public UpgradeContext setInteractiveMode(boolean isInteractiveMode)
   {
     this.isInteractiveMode = isInteractiveMode;
+    return this;
   }
 
 
@@ -236,10 +260,12 @@
    *
    * @param isForceUpgradeMode
    *          {@code true} if the force upgrade mode is activated.
+   * @return This upgrade context.
    */
-  public void setForceUpgradeMode(boolean isForceUpgradeMode)
+  public UpgradeContext setForceUpgradeMode(boolean isForceUpgradeMode)
   {
     this.isForceUpgradeMode = isForceUpgradeMode;
+    return this;
   }
 
 
@@ -347,30 +373,4 @@
     }
     return confirmYNCallback.getSelectedIndex();
   }
-
-
-
-  /**
-   * Returns the default option string.
-   *
-   * @param defaultOption
-   *          The default option int value.
-   * @return The default option string.
-   */
-  public static String getDefaultOption(final int defaultOption)
-  {
-    if (defaultOption == ConfirmationCallback.YES)
-    {
-      return INFO_PROMPT_YES_COMPLETE_ANSWER.get().toString();
-    }
-    else if (defaultOption == ConfirmationCallback.NO)
-    {
-      return INFO_PROMPT_NO_COMPLETE_ANSWER.get().toString();
-    }
-    else if (defaultOption == ConfirmationCallback.CANCEL)
-    {
-      return INFO_TASKINFO_CMD_CANCEL_CHAR.get().toString();
-    }
-    return null;
-  }
 }

--
Gitblit v1.10.0