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

kenneth_suter
11.26.2007 9b5052233376c10b3623782e473cfbbf7f8f17a8
- Corrected prefetching of build ID information which was broken and consolidated in the Installation class.

- Add current build ID string to choose version panel
6 files modified
255 ■■■■ changed files
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Installation.java 36 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties 2 ●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java 50 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/ChooseVersionPanel.java 101 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/UpgraderReviewPanel.java 34 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java 32 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Installation.java
@@ -29,6 +29,11 @@
import java.io.*;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.concurrent.FutureTask;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import org.opends.quicksetup.util.Utils;
@@ -236,6 +241,9 @@
    }
  }
  static private final Logger LOG =
          Logger.getLogger(Installation.class.getName());
  private File rootDirectory;
  private Status status;
@@ -284,8 +292,19 @@
    // Hold off on doing validation of rootDirectory since
    // some applications (like the Installer) create an Installation
    // before the actual bits have been laid down on the filesyste.
    this.rootDirectory = rootDirectory;
    // Obtaining build information is a fairly time consuming operation.
    // Try to get a head start if possible.
    if (isValid()) {
      try {
        BuildInformation bi = getBuildInformation();
        LOG.log(Level.INFO, "build info for " + rootDirectory.getName() +
                ": " + bi);
      } catch (ApplicationException e) {
        LOG.log(Level.INFO, "error determining build information", e);
      }
    }
  }
  /**
@@ -682,7 +701,20 @@
   */
  public BuildInformation getBuildInformation() throws ApplicationException {
    if (buildInformation == null) {
      buildInformation = BuildInformation.create(this);
      FutureTask<BuildInformation> ft = new FutureTask<BuildInformation>(
              new Callable<BuildInformation>() {
                public BuildInformation call() throws ApplicationException {
                  return BuildInformation.create(Installation.this);
                }
              });
      new Thread(ft).start();
      try {
        buildInformation = ft.get();
      } catch (InterruptedException e) {
        LOG.log(Level.INFO, "interrupted trying to get build information", e);
      } catch (ExecutionException e) {
        throw (ApplicationException)e.getCause();
      }
    }
    return buildInformation;
  }
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
@@ -1016,7 +1016,7 @@
are correct.
upgrade-review-panel-server-label=Server to Upgrade:
upgrade-review-panel-server-tooltip=File system location of the build that will be upgraded
upgrade-review-panel-old-version-label=Old Version:
upgrade-review-panel-old-version-label=Current Version:
upgrade-review-panel-old-version-tooltip=The current version of the server
upgrade-review-panel-new-version-label=New Version:
upgrade-review-panel-new-version-tooltip=The target version of the server
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
@@ -186,6 +186,14 @@
  static private final Logger LOG = Logger.getLogger(Upgrader.class.getName());
  /**
   * Passed in from the shell script if the root is known at the time
   * of invocation.
   */
  static private final String SYS_PROP_INSTALL_ROOT =
          "org.opends.quicksetup.upgrader.Root";
  /**
   * If set to true, an error is introduced during the
   * upgrade process for testing.
   */
@@ -265,6 +273,8 @@
   * Creates a default instance.
   */
  public Upgrader() {
    // Initialize the logs if necessary
    try {
      if (!QuickSetupLog.isInitialized())
        QuickSetupLog.initLogFileHandler(
@@ -274,9 +284,18 @@
    } catch (IOException e) {
      System.err.println("Failed to initialize log");
    }
    // Get started on downloading the web start jars
    if (Utils.isWebStart()) {
      initLoader();
    }
    final String instanceRootFromSystem =
            System.getProperty(SYS_PROP_INSTALL_ROOT);
    if (instanceRootFromSystem != null) {
      setInstallation(new Installation(instanceRootFromSystem));
    }
  }
  /**
@@ -587,22 +606,20 @@
            File serverLocation = new File(serverLocationString);
            Installation.validateRootDirectory(serverLocation);
            // If we get here the value is acceptable
            final Installation installation = new Installation(serverLocation);
            setInstallation(installation);
            // If we get here the value is acceptable and not null
            // The build ID is needed on the review panel and it is
            // fairly time consuming to get.  So prime this cached
            // value in a separate thread.
            new Thread(new Runnable() {
              public void run() {
                try {
                  installation.getBuildInformation().getBuildId();
                } catch (ApplicationException e) {
                  LOG.log(Level.INFO, "error", e);
                }
              }
            }).start();
            Installation currentInstallation = getInstallation();
            if (currentInstallation == null ||
                !serverLocation.equals(getInstallation().getRootDirectory())) {
              LOG.log(Level.INFO,
                      "user changed server root from " +
                      (currentInstallation == null ?
                              "'null'" :
                              currentInstallation.getRootDirectory()) +
                      " to " + serverLocation);
              Installation installation = new Installation(serverLocation);
              setInstallation(installation);
            }
            uud.setServerLocation(serverLocationString);
@@ -1640,8 +1657,7 @@
   */
  public UserData createUserData() {
    UpgradeUserData uud = new UpgradeUserData();
    String instanceRootFromSystem =
            System.getProperty("org.opends.quicksetup.upgrader.Root");
    String instanceRootFromSystem = System.getProperty(SYS_PROP_INSTALL_ROOT);
    if (instanceRootFromSystem != null) {
      uud.setServerLocation(instanceRootFromSystem);
    }
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/ChooseVersionPanel.java
@@ -34,11 +34,12 @@
import org.opends.quicksetup.upgrader.RemoteBuildManager;
import org.opends.quicksetup.upgrader.Upgrader;
import org.opends.quicksetup.util.BackgroundTask;
import org.opends.quicksetup.util.Utils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -55,6 +56,7 @@
  static private final long serialVersionUID = -6941309163077121917L;
  private JLabel lblCurrentVersion = null;
  private JRadioButton rbRemote = null;
  private JRadioButton rbLocal = null;
  private ButtonGroup grpRemoteLocal = null;
@@ -78,8 +80,7 @@
  /**
   * {@inheritDoc}
   */
  public boolean blockingBeginDisplay()
  {
  public boolean blockingBeginDisplay() {
    return true;
  }
@@ -88,6 +89,7 @@
   */
  public void beginDisplay(UserData data) {
    super.beginDisplay(data);
    if (!loadBuildListAttempted) {
      // Begin display is called outside the UI
@@ -116,6 +118,10 @@
      t.setRepeats(false);
      t.start();
    }
    lblCurrentVersion.setText(
            Utils.getBuildString(getApplication().getInstallation()));
  }
  /**
@@ -144,6 +150,18 @@
    JPanel p = UIFactory.makeJPanel();
    LabelFieldDescriptor currentVersionDescriptor = new LabelFieldDescriptor(
      getMsg("upgrade-review-panel-old-version-label"),
      getMsg("upgrade-review-panel-old-version-tooltip"),
      LabelFieldDescriptor.FieldType.READ_ONLY,
      LabelFieldDescriptor.LabelType.PRIMARY,
      0
    );
    lblCurrentVersion = UIFactory.makeJLabel(
            UIFactory.IconType.NO_ICON,
            "", UIFactory.TextStyle.SECONDARY_FIELD_VALID);
    rbRemote = UIFactory.makeJRadioButton(
            getMsg("upgrade-choose-version-remote-label"),
            getMsg("upgrade-choose-version-remote-tooltip"),
@@ -197,50 +215,72 @@
    p.setLayout(new GridBagLayout());
    // p.setBorder(BorderFactory.createLineBorder(Color.RED));
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.FIRST_LINE_START;
    gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD;
    gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
    p.add(UIFactory.makeJLabel(currentVersionDescriptor), gbc);
    gbc.gridx = 1;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.insets = UIFactory.getEmptyInsets();
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = UIFactory.getEmptyInsets();
    gbc.insets.top = 15; // non-standard but looks better
    gbc.anchor = GridBagConstraints.FIRST_LINE_START;
    gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD;
    gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
    p.add(lblCurrentVersion, gbc);
    gbc.gridx = 0;
    gbc.gridy++;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets.top = UIFactory.TOP_INSET_RADIOBUTTON + 15;
    gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD;
    gbc.anchor = GridBagConstraints.FIRST_LINE_START;
    p.add(rbRemote, gbc);
    gbc.gridy = 1;
    gbc.gridwidth = 1;
    gbc.insets = UIFactory.getEmptyInsets();
    gbc.gridy++;
    gbc.gridwidth = 2;
    gbc.insets.top = UIFactory.TOP_INSET_RADIO_SUBORDINATE;
    gbc.insets.left = UIFactory.LEFT_INSET_RADIO_SUBORDINATE;
    gbc.insets.left = UIFactory.LEFT_INSET_RADIO_SUBORDINATE +
            UIFactory.LEFT_INSET_PRIMARY_FIELD;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 2;
    p.add(cboBuild, gbc);
    gbc.gridy = 1;
    gbc.gridx = 1;
    gbc.weightx = 1.5;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = UIFactory.getEmptyInsets();
    JPanel fill = UIFactory.makeJPanel();
    // fill.setBorder(BorderFactory.createLineBorder(Color.BLUE));
    p.add(fill, gbc);
    gbc.gridy = 2;
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.insets = UIFactory.getEmptyInsets();
    gbc.insets.top = 15; // UIFactory.TOP_INSET_RADIOBUTTON;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
    gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD;
    p.add(rbLocal, gbc);
    gbc.gridy = 3;
    gbc.gridy++;
    gbc.insets = UIFactory.getEmptyInsets();
    gbc.insets.top = UIFactory.TOP_INSET_RADIO_SUBORDINATE;
    gbc.insets.left = UIFactory.LEFT_INSET_RADIO_SUBORDINATE;
    gbc.insets.left = UIFactory.LEFT_INSET_RADIO_SUBORDINATE +
            UIFactory.LEFT_INSET_PRIMARY_FIELD;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 2;
    gbc.fill = GridBagConstraints.BOTH;
    // pnlBrowse.setBorder(BorderFactory.createLineBorder(Color.BLUE));
    p.add(pnlBrowse, gbc);
    gbc.gridy = 4;
    gbc.gridy++;
    gbc.weighty = 1.0;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
@@ -473,4 +513,29 @@
    tfFile.setEnabled(rbLocal.isSelected());
    butBrowse.setEnabled((rbLocal.isSelected()));
  }
//  public static void main(String[] args) {
//    final UserData ud = new UpgradeUserData();
//    ud.setServerLocation("XXX/XXXXX/XX/XXXXXXXXXXXX/XXXX");
//    Upgrader app = new Upgrader();
//    app.setUserData(ud);
//    final ChooseVersionPanel p = new ChooseVersionPanel(app);
//    p.initialize();
//    JFrame frame = new JFrame();
//    frame.getContentPane().add(p);
//    frame.addComponentListener(new ComponentAdapter() {
//      public void componentHidden(ComponentEvent componentEvent) {
//        System.exit(0);
//      }
//    });
//    frame.pack();
//    frame.setVisible(true);
//    new Thread(new Runnable() {
//      public void run() {
//        p.beginDisplay(ud);
//      }
//    }).start();
//
//  }
}
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ui/UpgraderReviewPanel.java
@@ -27,20 +27,18 @@
package org.opends.quicksetup.upgrader.ui;
import org.opends.quicksetup.UserData;
import org.opends.quicksetup.ui.FieldName;
import org.opends.quicksetup.ui.LabelFieldDescriptor;
import org.opends.quicksetup.ui.ReviewPanel;
import org.opends.quicksetup.ui.UIFactory;
import org.opends.quicksetup.ui.LabelFieldDescriptor;
import org.opends.quicksetup.ui.FieldName;
import org.opends.quicksetup.upgrader.Upgrader;
import org.opends.quicksetup.upgrader.UpgradeUserData;
import org.opends.quicksetup.upgrader.Build;
import org.opends.quicksetup.ApplicationException;
import org.opends.quicksetup.UserData;
import org.opends.quicksetup.BuildInformation;
import org.opends.quicksetup.upgrader.UpgradeUserData;
import org.opends.quicksetup.upgrader.Upgrader;
import org.opends.quicksetup.util.Utils;
import javax.swing.*;
import java.awt.*;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
@@ -73,9 +71,8 @@
  public void beginDisplay(UserData data) {
    tcServerLocation.setText(getServerToUpgrade());
    // Unfortunately these string are different.  The
    // old build string is the build ID (14 digit number)
    // and the new build is the build display name that
    // Unfortunately these string are different.
    // The new build is the build display name that
    // appears in the available builds information page.
    // It is currently not feasible to correlate these.
    tcOldBuild.setText(getOldBuildString());
@@ -203,20 +200,7 @@
  }
  private String getOldBuildString() {
    String oldVersion = null;
    try {
      BuildInformation bi = getApplication().getInstallation().
              getBuildInformation();
      if (bi != null) {
        oldVersion = bi.toString();
      }
    } catch (ApplicationException e) {
      LOG.log(Level.INFO, "error", e);
    }
    if (oldVersion == null) {
      oldVersion = getMsg("upgrade-build-id-unknown");
    }
    return oldVersion;
    return Utils.getBuildString(getApplication().getInstallation());
  }
  /**
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -40,6 +40,8 @@
import java.io.RandomAccessFile;
import java.net.ConnectException;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.CommunicationException;
import javax.naming.Context;
@@ -50,8 +52,7 @@
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import org.opends.quicksetup.CurrentInstallStatus;
import org.opends.quicksetup.Installation;
import org.opends.quicksetup.*;
import org.opends.quicksetup.webstart.JnlpProperties;
import org.opends.quicksetup.i18n.ResourceProvider;
import org.opends.server.util.SetupUtils;
@@ -63,6 +64,9 @@
 */
public class Utils
{
  private static final Logger LOG =
          Logger.getLogger(Utils.class.getName());
  private static final int DEFAULT_LDAP_CONNECT_TIMEOUT = 3000;
  private static final int BUFFER_SIZE = 1024;
@@ -1337,4 +1341,28 @@
    return perm;
  }
  /**
   * Returns a string representing the installation's current build information
   * useful for presenting to the user.  If the build string could not be
   * determined for any reason a localized String 'unknown' is returned.
   * @param installation whose build information is sought
   * @return String representing the application's build.
   */
  static public String getBuildString(Installation installation) {
    String b = null;
    try {
      BuildInformation bi = installation.getBuildInformation();
      if (bi != null) {
        b = bi.toString();
      }
    } catch (ApplicationException e) {
      LOG.log(Level.INFO, "error trying to determine current build string", e);
    }
    if (b == null) {
      b = ResourceProvider.getInstance().
              getMsg("upgrade-build-id-unknown");
    }
    return b;
  }
}