mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

kenneth_suter
24.07.2007 cb3a76a157589591106fdc50895a1d987ca25483
enough code to get the upgrader to perform a successful upgrade in graphical UI mode on a sunny day
1 files added
11 files modified
420 ■■■■■ changed files
opends/resource/upgrade 5 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties 4 ●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/ui/ButtonsPanel.java 13 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupPanel.java 6 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/upgrader/Build.java 10 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/upgrader/RemoteBuildManager.java 39 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java 53 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/BuildListDownloadErrorPanel.java 123 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/ChooseVersionPanel.java 98 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/util/FileManager.java 11 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/util/Utils.java 44 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/util/ZipExtractor.java 14 ●●●● patch | view | raw | blame | history
opends/resource/upgrade
@@ -165,8 +165,9 @@
  else
    # URL FOR TESTING ONLY
    # JAVAWS_VM_ARGS="-Dorg.opends.quicksetup.upgrader.Root=$INSTANCE_ROOT -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"
    JAVAWS_VM_ARGS="-Xclearcache -Dorg.opends.quicksetup.upgrader.Root=$INSTANCE_ROOT"
    JAVAWS_VM_ARGS="-Dorg.opends.quicksetup.upgrader.Root=$INSTANCE_ROOT"
    export JAVAWS_VM_ARGS
    "${JAVAWS_BIN}" "http://localhost:8080/install/QuickUpgrade.jnlp"
    "${JAVAWS_BIN}" "http://localhost:8080/install/QuickUpgrade.jnlp"
    echo "Started Java Web Start upgrade"
  fi
fi
opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
@@ -702,7 +702,9 @@
summary-upgrade-history=Recording Upgrade History...
summary-upgrade-cleanup=Cleaning Up...
summary-upgrade-abort=Aborting Upgrade Due to Error...
summary-upgrade-finished-successfully=Upgrade Finished Successfully
summary-upgrade-finished-successfully=<b>OpenDS QuickSetup Completed \
  Successfully.</b><br>The OpenDS installation at {0} has now been upgraded \
  to version {1}.
summary-upgrade-finished-with-errors=Upgrade Finished with Errors
#
opends/src/quicksetup/org/opends/quicksetup/ui/ButtonsPanel.java
@@ -29,6 +29,7 @@
import org.opends.quicksetup.ButtonName;
import org.opends.quicksetup.WizardStep;
import org.opends.quicksetup.upgrader.Upgrader;
import org.opends.quicksetup.event.ButtonActionListener;
import org.opends.quicksetup.event.ButtonEvent;
import org.opends.quicksetup.installer.Installer;
@@ -106,8 +107,13 @@
  {
    GuiApplication application = getApplication();
    previousButton.setVisible(application.canGoBack(step));
    nextButton.setVisible(application.canGoForward(step));
    finishButton.setVisible(application.canFinish(step));
    if (application.canFinish(step)) {
      finishButton.setVisible(true);
      nextButton.setVisible(false);
    } else {
      finishButton.setVisible(false);
      nextButton.setVisible(application.canGoForward(step));
    }
    quitButton.setVisible(application.canQuit(step));
    closeButton.setVisible(application.canClose(step));
    cancelButton.setVisible(application.canCancel(step));
@@ -224,7 +230,8 @@
    nextFinishPanel.add(nextButton, gbcAux);
    // TODO: remove this hack
    if (getApplication() instanceof Installer) {
    if (getApplication() instanceof Installer ||
            getApplication() instanceof Upgrader) {
      nextFinishPanel.add(finishButton, gbcAux);
    }
    width =
opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupPanel.java
@@ -110,7 +110,7 @@
   * @return the value associated to the key in the properties file.
   * properties file.
   */
  protected String getMsg(String key)
  public String getMsg(String key)
  {
    return getI18n().getMsg(key);
  }
@@ -130,7 +130,7 @@
   * @param args the arguments to be passed to generate the resulting value.
   * @return the value associated to the key in the properties file.
   */
  protected String getMsg(String key, String[] args)
  public String getMsg(String key, String[] args)
  {
    return getI18n().getMsg(key, args);
  }
@@ -139,7 +139,7 @@
   * Returns a ResourceProvider instance.
   * @return a ResourceProvider instance.
   */
  private ResourceProvider getI18n()
  public ResourceProvider getI18n()
  {
    return ResourceProvider.getInstance();
  }
opends/src/quicksetup/org/opends/quicksetup/upgrader/Build.java
@@ -32,7 +32,7 @@
/**
   * Representation of an OpenDS build package.
 */
public class Build {
public class Build implements Comparable {
  private URL url;
  private String id;
@@ -78,4 +78,12 @@
  public String toString() {
    return getDisplayName();
  }
  /**
   * {@inheritDoc}
   */
  public int compareTo(Object o) {
    return getDisplayName().compareTo(((Build)o).getDisplayName());
  }
}
opends/src/quicksetup/org/opends/quicksetup/upgrader/RemoteBuildManager.java
@@ -28,6 +28,8 @@
package org.opends.quicksetup.upgrader;
import org.opends.quicksetup.Application;
import org.opends.quicksetup.util.Utils;
import org.opends.server.util.DynamicConstants;
import javax.swing.*;
import java.net.URL;
@@ -123,9 +125,29 @@
    while (m.find()) {
      buildIds.add(dailyBuildsPage.substring(m.start(), m.end()));
    }
    for (String buildId : buildIds) {
      buildList.add(new Build(url, buildId));
    }
//    for (String buildId : buildIds) {
//      // TODO:  this needs to be changed
//      URL buildUrl =
//              new URL(url, "daily-builds/" +
//                      buildId +
//                      "/OpenDS/build/package/OpenDS-0.1.zip");
//      buildList.add(new Build(url, buildId));
//    }
    // This is encoded in build.xml.  We might need a more dynamic
    // way of getting this information.
    StringBuilder latestContextSb = new StringBuilder()
            .append("daily-builds/latest/OpenDS/build/package/OpenDS-")
            .append(DynamicConstants.MAJOR_VERSION)
            .append(".")
            .append(DynamicConstants.MINOR_VERSION)
            .append(DynamicConstants.VERSION_QUALIFIER)
            .append(".zip");
    Build latest = new Build(new URL(url, latestContextSb.toString()),
                            "Latest");
    buildList.add(latest);
    Collections.sort(buildList);
    return buildList;
  }
@@ -188,6 +210,17 @@
    }
    InputStream is = null;
    FileOutputStream fos = null;
    // If the destination already exists blow it away, then
    // create the new file.
    if (destination.exists()) {
      if (!destination.delete()) {
        throw new IOException("Could not overwrite existing file " +
                Utils.getPath(destination));
      }
    }
    Utils.createFile(destination);
    try {
      is = conn.getInputStream();
      fos = new FileOutputStream(destination);
opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
@@ -300,7 +300,28 @@
   * {@inheritDoc}
   */
  public String getSummary(ProgressStep step) {
    return getMsg(((UpgradeProgressStep) step).getSummaryMesssageKey());
    String txt = null;
    if (step == UpgradeProgressStep.FINISHED) {
      String installPath = Utils.getPath(getInstallation().getRootDirectory());
      String newVersion = null;
      try {
        newVersion = getInstallation().getBuildId();
      } catch (QuickSetupException e) {
        newVersion = getMsg("upgrade-build-id-unknown");
      }
      String[] args = {
              formatter.getFormattedText(installPath),
              newVersion };
      txt = getFormattedSuccess(
              getMsg("summary-upgrade-finished-successfully",
              args));
    } else if (step == UpgradeProgressStep.FINISHED_WITH_ERRORS) {
      txt = getFormattedError(
              getMsg("summary-upgrade-finished-with-errors"));
    } else {
      txt = getMsg(((UpgradeProgressStep) step).getSummaryMesssageKey());
    }
    return txt;
  }
  /**
@@ -458,6 +479,8 @@
   * {@inheritDoc}
   */
  public void finishClicked(final WizardStep cStep, final QuickSetup qs) {
    qs.launch();
    qs.setCurrentStep(UpgradeWizardStep.PROGRESS);
  }
  /**
@@ -470,6 +493,8 @@
   * {@inheritDoc}
   */
  public void closeClicked(WizardStep cStep, QuickSetup qs) {
    // TODO: prompt
    qs.quit();
  }
  /**
@@ -484,7 +509,22 @@
   * {@inheritDoc}
   */
  public boolean canFinish(WizardStep step) {
    return UpgradeWizardStep.REVIEW.equals(step);
    boolean cf = UpgradeWizardStep.REVIEW.equals(step);
    return cf;
  }
  /**
   * {@inheritDoc}
   */
  public boolean canGoBack(WizardStep step) {
    return super.canGoBack(step) && !step.equals(UpgradeWizardStep.PROGRESS);
  }
  /**
   * {@inheritDoc}
   */
  public boolean canClose(WizardStep step) {
    return step.equals(UpgradeWizardStep.PROGRESS);
  }
  /**
@@ -704,8 +744,7 @@
      setCurrentProgressStep(UpgradeProgressStep.FINISHED);
    } else {
      setCurrentProgressStep(UpgradeProgressStep.FINISHED_WITH_ERRORS);
      notifyListeners(runException.getLocalizedMessage() +
              formatter.getLineBreak());
      notifyListeners(formatter.getFormattedError(runException, true));
    }
  }
@@ -720,7 +759,7 @@
  private void abort(ProgressStep lastStep) throws ApplicationException {
    UpgradeProgressStep lastUpgradeStep = (UpgradeProgressStep) lastStep;
    EnumSet<UpgradeProgressStep> stepsStarted =
            EnumSet.range(UpgradeProgressStep.INITIALIZING, lastUpgradeStep);
            EnumSet.range(UpgradeProgressStep.NOT_STARTED, lastUpgradeStep);
    if (stepsStarted.contains(UpgradeProgressStep.BACKING_UP_FILESYSTEM)) {
@@ -1116,7 +1155,9 @@
      // old delete.  Note that on Windows there are file
      // locking issues to we mark files for deletion after
      // this JVM exits
      fm.deleteRecursively(stagingDir, null, /*onExit=*/true);
      if (stagingDir.exists()) {
        fm.deleteRecursively(stagingDir, null, /*onExit=*/true);
      }
    } catch (IOException e) {
      // TODO i18n
opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/BuildListDownloadErrorPanel.java
New file
@@ -0,0 +1,123 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Portions Copyright 2007 Sun Microsystems, Inc.
 */
package org.opends.quicksetup.upgrader.ui;
import org.opends.quicksetup.upgrader.RemoteBuildManager;
import org.opends.quicksetup.ui.CustomHTMLEditorKit;
import org.opends.quicksetup.ui.UIFactory;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.net.Proxy;
import java.net.SocketAddress;
import java.net.URL;
/**
   * This panel represents the big error message the pops up when the
 * panel can't download the build information.
 */
class BuildListDownloadErrorPanel extends JPanel {
  private RemoteBuildManager rbm = null;
  private Throwable reason = null;
  private ChooseVersionPanel chooseVersionPanel;
  private static final long serialVersionUID = 4614415561629811272L;
  /**
   * Creates an instance.
   * @param rbm RemoteBuildManager that is having trouble.
   * @param reason Throwable indicating the error when downloading
   * @param chooseVersionPanel ChooseVersionPanel where the error occurred
   */
  public BuildListDownloadErrorPanel(ChooseVersionPanel chooseVersionPanel,
                                     RemoteBuildManager rbm,
                                     Throwable reason) {
    this.chooseVersionPanel = chooseVersionPanel;
    this.rbm = rbm;
    this.reason = reason;
    layoutPanel();
  }
  private void layoutPanel() {
    setLayout(new GridBagLayout());
    String proxyString = "None";
    Proxy proxy = rbm.getProxy();
    if (proxy != null) {
      SocketAddress addr = proxy.address();
      proxyString = addr.toString();
    }
    String baseContext = "Unspecified";
    URL url = rbm.getBaseContext();
    if (url != null) {
      baseContext = url.toString();
    }
    String html =
            chooseVersionPanel.getMsg("upgrade-choose-version-build-list-error",
            new String[]{
                    baseContext,
                    reason.getLocalizedMessage(),
                    proxyString});
    /* This helps with debugger the HTML rendering
    StringBuffer content = new StringBuffer();
    try {
      FileInputStream fis = new FileInputStream("/tmp/error-html");
      BufferedReader reader = new BufferedReader(new InputStreamReader(fis));
      String line = null;
      while (null != (line = reader.readLine())) {
        content.append(line);
      }
      html = content.toString();
    } catch (IOException e) {
      e.printStackTrace();
    }
    */
    CustomHTMLEditorKit ek = new CustomHTMLEditorKit();
    ek.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent ev) {
        chooseVersionPanel.specifyProxy(getParent());
        // Since the proxy info may change we need
        // to regenerate the text
        removeAll();
        layoutPanel();
        repaint();
        validate();
      }
    });
    add(UIFactory.makeHtmlPane(html, ek, UIFactory.INSTRUCTIONS_FONT));
  }
}
opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/ChooseVersionPanel.java
@@ -28,7 +28,6 @@
package org.opends.quicksetup.upgrader.ui;
import org.opends.quicksetup.UserData;
import org.opends.quicksetup.ui.CustomHTMLEditorKit;
import org.opends.quicksetup.ui.FieldName;
import org.opends.quicksetup.ui.GuiApplication;
import org.opends.quicksetup.ui.QuickSetupStepPanel;
@@ -42,14 +41,11 @@
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.SocketAddress;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -221,7 +217,13 @@
    bld.startBackgroundTask();
  }
  private void specifyProxy(final Component parent) {
  /**
   * Displays a dialog prompting the user for proxy information
   * after which applys the new proxy information to the available
   * RemoteBuildManager.
   * @param parent Component that will server as parent to the dialog
   */
  void specifyProxy(final Component parent) {
    Runnable proxySpecifier = new Runnable() {
      public void run() {
        String host = null;
@@ -311,89 +313,6 @@
  }
  /**
   * This panel represents the big error message the pops up when the
   * panel can't download the build information.
   */
  private class BuildListDownloadErrorPanel extends JPanel {
    private RemoteBuildManager rbm = null;
    private Throwable reason = null;
    /**
     * The serial version identifier required to satisfy the compiler because
     * this * class extends a class that implements the
     * {@code java.io.Serializable} interface.  This value was generated using
     * the {@code serialver} command-line utility included with the Java SDK.
     */
    private static final long serialVersionUID = -5606673656068527646L;
    /**
     * Creates an instance.
     * @param rbm RemoteBuildManager that is having trouble.
     */
    public BuildListDownloadErrorPanel(RemoteBuildManager rbm,
                                       Throwable reason) {
      this.rbm = rbm;
      this.reason = reason;
      layoutPanel();
    }
    private void layoutPanel() {
      setLayout(new GridBagLayout());
      String proxyString = "None";
      Proxy proxy = rbm.getProxy();
      if (proxy != null) {
        SocketAddress addr = proxy.address();
        proxyString = addr.toString();
      }
      String baseContext = "Unspecified";
      URL url = rbm.getBaseContext();
      if (url != null) {
        baseContext = url.toString();
      }
      String html = getMsg("upgrade-choose-version-build-list-error",
              new String[]{
                      baseContext,
                      reason.getLocalizedMessage(),
                      proxyString});
      /* This helps with debugger the HTML rendering
      StringBuffer content = new StringBuffer();
      try {
        FileInputStream fis = new FileInputStream("/tmp/error-html");
        BufferedReader reader = new BufferedReader(new InputStreamReader(fis));
        String line = null;
        while (null != (line = reader.readLine())) {
          content.append(line);
        }
        html = content.toString();
      } catch (IOException e) {
        e.printStackTrace();
      }
      */
      CustomHTMLEditorKit ek = new CustomHTMLEditorKit();
      ek.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
          specifyProxy(getParent());
          // Since the proxy info may change we need
          // to regenerate the text
          removeAll();
          layoutPanel();
          repaint();
          validate();
        }
      });
      add(UIFactory.makeHtmlPane(html, ek, UIFactory.INSTRUCTIONS_FONT));
    }
  }
  /**
   * Uses the remote build manager is a separate thread to create
   * and populate the combo box model with build information.  Contains
   * the loop and dialog prompting that happens if there is a problem
@@ -424,7 +343,8 @@
        try {
        String[] options = { "Retry", "Close" };
        int i = JOptionPane.showOptionDialog(getMainWindow(),
                new BuildListDownloadErrorPanel(rbm, throwable),
                new BuildListDownloadErrorPanel(ChooseVersionPanel.this, rbm,
                        throwable),
                "Network Error",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.ERROR_MESSAGE,
opends/src/quicksetup/org/opends/quicksetup/util/FileManager.java
@@ -298,7 +298,7 @@
        }
        if (!destination.exists()) {
          if (insureParentsExist(destination)) {
          if (Utils.insureParentsExist(destination)) {
            application.notifyListeners(application.getFormattedWithPoints(
                    getMsg("progress-copying-file", args)));
@@ -468,15 +468,6 @@
    }
  }
  private boolean insureParentsExist(File f) {
    File parent = f.getParentFile();
    boolean b = parent.exists();
    if (!b) {
      b = parent.mkdirs();
    }
    return b;
  }
  private String getMsg(String key) {
    return ResourceProvider.getInstance().getMsg(key);
  }
opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -430,6 +430,21 @@
  }
  /**
   * Creates the parent directory if it does not already exist.
   * @param f File for which parentage will be insured
   * @return boolean indicating whether or not the input <code>f</code>
   * has a parent after this method is invoked.
   */
  static public boolean insureParentsExist(File f) {
    File parent = f.getParentFile();
    boolean b = parent.exists();
    if (!b) {
      b = parent.mkdirs();
    }
    return b;
  }
  /**
   * Returns <CODE>true</CODE> if we can write on the provided path and
   * <CODE>false</CODE> otherwise.
   * @param path the path.
@@ -464,10 +479,20 @@
   * was a directory) and <CODE>false</CODE> otherwise.
   * @throws IOException if something goes wrong.
   */
  public static boolean createDirectory(String path) throws IOException
  public static boolean createDirectory(String path) throws IOException {
    return createDirectory(new File(path));
  }
  /**
   * Creates the a directory in the provided path.
   * @param f the path.
   * @return <CODE>true</CODE> if the path was created or already existed (and
   * was a directory) and <CODE>false</CODE> otherwise.
   * @throws IOException if something goes wrong.
   */
  public static boolean createDirectory(File f) throws IOException
  {
    boolean directoryCreated;
    File f = new File(path);
    if (!f.exists())
    {
      directoryCreated = f.mkdirs();
@@ -485,7 +510,20 @@
   * @param is the InputStream with the contents of the file.
   * @throws IOException if something goes wrong.
   */
  public static void createFile(String path, InputStream is) throws IOException
  public static void createFile(String path, InputStream is)
          throws IOException
  {
    createFile(new File(path), is);
  }
  /**
   * Creates a file on the specified path with the contents of the provided
   * stream.
   * @param path the path where the file will be created.
   * @param is the InputStream with the contents of the file.
   * @throws IOException if something goes wrong.
   */
  public static void createFile(File path, InputStream is) throws IOException
  {
    FileOutputStream out;
    BufferedOutputStream dest;
opends/src/quicksetup/org/opends/quicksetup/util/ZipExtractor.java
@@ -234,13 +234,12 @@
    {
      entryName = entryName.substring(zipFirstPath.length());
    }
    String path = Utils.getPath(new File(basePath, entryName));
    File path = new File(basePath, entryName);
    String progressSummary =
            ResourceProvider.getInstance().getMsg("progress-extracting",
                    new String[]{ path });
                    new String[]{ Utils.getPath(path) });
    app.notifyListeners(ratioBeforeCompleted, progressSummary);
    if (Utils.createParentPath(path))
    if (Utils.insureParentsExist(path))
    {
      if (entry.isDirectory())
      {
@@ -250,7 +249,7 @@
        {
          list = new ArrayList<String>();
        }
        list.add(path);
        list.add(Utils.getPath(path));
        permissions.put(perm, list);
        if (!Utils.createDirectory(path))
@@ -265,7 +264,8 @@
        {
          list = new ArrayList<String>();
        }
        list.add(path);
        list.add(Utils.getPath(path));
        permissions.put(perm, list);
        Utils.createFile(path, is);
      }
    } else
@@ -280,7 +280,7 @@
   * @param path the directory for which we want the file permissions.
   * @return the file system permissions for the directory.
   */
  private String getDirectoryFileSystemPermissions(String path)
  private String getDirectoryFileSystemPermissions(File path)
  {
    // TODO We should get this dynamically during build?
    return "755";