From 6df6635f1250c399a2f39d87d0534301ce4c22d7 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Fri, 31 Aug 2007 15:43:58 +0000
Subject: [PATCH] Exposes the reversion functionality of the upgrader (issue 2169).  Originally it was intended to be exposed as a new script but in order to avoid the negativity of having a command devoted to undoing the upgrade and to avoid more scripts in the top-level directory, I've exposed the functionality as 2 new options in the existing upgrade script.  I will update the Wiki with documentation for these new options soon.

---
 opends/src/quicksetup/org/opends/quicksetup/upgrader/ReversionLauncher.java |  147 +-----------------------------------------------
 1 files changed, 5 insertions(+), 142 deletions(-)

diff --git a/opends/src/quicksetup/org/opends/quicksetup/upgrader/ReversionLauncher.java b/opends/src/quicksetup/org/opends/quicksetup/upgrader/ReversionLauncher.java
index 5e778c4..bc2d911 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/upgrader/ReversionLauncher.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/upgrader/ReversionLauncher.java
@@ -27,42 +27,19 @@
 
 package org.opends.quicksetup.upgrader;
 
-import org.opends.messages.Message;
 import static org.opends.messages.QuickSetupMessages.*;
 
-import org.opends.quicksetup.Launcher;
 import org.opends.quicksetup.CliApplication;
 import org.opends.quicksetup.QuickSetupLog;
-import org.opends.quicksetup.Installation;
-import org.opends.quicksetup.util.Utils;
-
-import org.opends.server.util.args.ArgumentParser;
-import org.opends.server.util.args.BooleanArgument;
-import org.opends.server.util.args.FileBasedArgument;
-import org.opends.server.util.ServerConstants;
-import static org.opends.messages.ToolMessages.*;
-import static org.opends.server.tools.ToolConstants.*;
 
 import java.io.File;
 
 /**
- * Launches a reversion operation.
+ * Launches a reversion operation.  This class just extends UpgradeLauncher
+ * which really contains all the smarts for launching reversion/upgrade
+ * operations.
  */
-public class ReversionLauncher extends Launcher {
-
-  /** Short form of the option for specifying the reversion files directory. */
-  static public final Character DIRECTORY_OPTION_SHORT = 'd';
-
-  /** Long form of the option for specifying the reversion files directory. */
-  static public final String DIRECTORY_OPTION_LONG = "directory";
-
-  /** Short form of the option for specifying the 'most recent' option. */
-  static public final Character MOST_RECENT_OPTION_SHORT = 'm';
-
-  /** Long form of the option for specifying the 'most recent' option. */
-  static public final String MOST_RECENT_OPTION_LONG = "mostRecent";
-
-  static private final String LOG_FILE_PREFIX = "opends-revert-";
+public class ReversionLauncher extends UpgradeLauncher {
 
   /**
    * Creates and launches a reversion operation.
@@ -80,140 +57,26 @@
     new ReversionLauncher(args).launch();
   }
 
-  private ArgumentParser argParser;
-
-  private BooleanArgument showUsage;
-  private FileBasedArgument dir;
-  private BooleanArgument mostRecent;
-  private BooleanArgument quiet;
-  private BooleanArgument interactive;
-
-  /**
-   * Gets the file's directory if specified on the command line.
-   * @return File representing the directory where the reversion files are
-   * stored.
-   */
-  public File getFilesDirectory() {
-    File f = null;
-    String s = dir.getValue();
-    if (s != null) {
-      f = new File(s);
-    }
-    return f;
-  }
-
-  /**
-   * Indicates whether the user has specified the 'mostRecent' option.
-   * @return boolean where true indicates use the most recent upgrade backup
-   */
-  public boolean useMostRecentUpgrade() {
-    return mostRecent.isPresent();
-  }
-
   /**
    * {@inheritDoc}
    */
-  protected boolean isCli() {
-    // for now only CLI is supported via command line
+  public boolean isReversion() {
     return true;
   }
 
   /**
    * {@inheritDoc}
    */
-  protected Message getFrameTitle() {
-    return null;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
   protected CliApplication createCliApplication() {
     return new Reverter();
   }
 
   /**
-   * {@inheritDoc}
-   */
-  protected void willLaunchGui() {
-    // not supported;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  protected void guiLaunchFailed(String logFileName) {
-    // not supported;
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public ArgumentParser getArgumentParser() {
-    return argParser;
-  }
-
-  /**
    * Creates a new launcher.
    * @param args from the command line
    */
   protected  ReversionLauncher(String[] args) {
     super(args);
-
-    String scriptName;
-    if (Utils.isWindows()) {
-      scriptName = Installation.WINDOWS_REVERT_FILE_NAME;
-    } else {
-      scriptName = Installation.UNIX_REVERT_FILE_NAME;
-    }
-    System.setProperty(ServerConstants.PROPERTY_SCRIPT_NAME, scriptName);
-
-    argParser = new ArgumentParser(getClass().getName(),
-        INFO_REVERT_LAUNCHER_USAGE_DESCRIPTION.get(), false);
-    try
-    {
-      dir = new FileBasedArgument("directory",
-              DIRECTORY_OPTION_SHORT,
-              DIRECTORY_OPTION_LONG,
-              false, false,
-              "{directory}",
-              null, null, INFO_REVERT_DESCRIPTION_DIRECTORY.get());
-      argParser.addArgument(dir);
-
-      mostRecent = new BooleanArgument("mostRecent",
-              MOST_RECENT_OPTION_SHORT,
-              MOST_RECENT_OPTION_LONG,
-              INFO_REVERT_DESCRIPTION_RECENT.get());
-      argParser.addArgument(mostRecent);
-
-      interactive = new BooleanArgument("interactive", 'i', "interactive",
-          INFO_REVERT_DESCRIPTION_INTERACTIVE.get());
-      argParser.addArgument(interactive);
-
-      quiet = new BooleanArgument("quiet",
-              OPTION_SHORT_QUIET,
-              OPTION_LONG_QUIET,
-              INFO_REVERT_DESCRIPTION_SILENT.get());
-      argParser.addArgument(quiet);
-
-      showUsage = new BooleanArgument("showusage", OPTION_SHORT_HELP,
-        OPTION_LONG_HELP,
-        INFO_DESCRIPTION_USAGE.get());
-      argParser.addArgument(showUsage);
-      argParser.setUsageArgument(showUsage);
-
-      argParser.parseArguments(args);
-    }
-    catch (Throwable t)
-    {
-      System.out.println("ERROR: "+t);
-      t.printStackTrace();
-    }
-
-  }
-
-  private void validate(ArgumentParser argParser) {
-
   }
 
 }

--
Gitblit v1.10.0