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

kenneth_suter
17.49.2007 28820aea2e89c5e7d046ff4049db7af383a92721
The upgrader writes a log in the history directory that contains information about attempts to upgrade and contains references to the current and upgrade build.  Formerly these were SVN revision numbers which is not very informative to humans.  This commit writes the build's major, minor, point and revision numbers in the historical log.
4 files modified
152 ■■■■ changed files
opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java 68 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/upgrader/HistoricalLog.java 5 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/upgrader/HistoricalRecord.java 41 ●●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java 38 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java
@@ -35,6 +35,8 @@
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.io.InputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
@@ -56,6 +58,7 @@
  static private final String MINOR_VERSION = "Minor Version";
  static private final String POINT_VERSION = "Point Version";
  static private final String REVISION_NUMBER = "Revision Number";
  static private final String VERSION_QUALIFIER = "Version Qualifier";
  static private final String FIX_IDS = "Fix IDs";
  static private final String DEBUG_BUILD = "Debug Build";
  static private final String BUILD_OS = "Build OS";
@@ -122,6 +125,39 @@
  }
  /**
   * Creates an instance from a string representing a build number
   * of the for MAJOR.MINOR.POINT.REVISION where MAJOR, MINOR, POINT,
   * and REVISION are integers.
   * @param bn String representation of a build number
   * @return a BuildInformation object populated with the information
   * provided in <code>bn</code>
   * @throws IllegalArgumentException if <code>bn</code> is not a build
   * number
   */
  static public BuildInformation fromBuildString(String bn) throws
    IllegalArgumentException
  {
    // -------------------------------------------------------
    // NOTE:  if you change this be sure to change getBuildString()
    // -------------------------------------------------------
    Pattern p = Pattern.compile("((\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+))");
    Matcher m = p.matcher(bn);
    if (!m.matches()) {
      throw new IllegalArgumentException("'" + bn + "' is not a build string");
    }
    BuildInformation bi = new BuildInformation();
    try {
      bi.values.put(MAJOR_VERSION, m.group(2));
      bi.values.put(MINOR_VERSION, m.group(3));
      bi.values.put(POINT_VERSION, m.group(4));
      bi.values.put(REVISION_NUMBER, m.group(5));
    } catch (Exception e) {
      throw new IllegalArgumentException("Error parsing build number " + bn);
    }
    return bi;
  }
  /**
   * Creates an instance from constants present in the current build.
   * @return BuildInformation created from current constant values
   * @throws ApplicationException if all or some important information could
@@ -137,6 +173,8 @@
            String.valueOf(DynamicConstants.MINOR_VERSION));
    bi.values.put(POINT_VERSION,
            String.valueOf(DynamicConstants.POINT_VERSION));
    bi.values.put(VERSION_QUALIFIER,
            String.valueOf(DynamicConstants.VERSION_QUALIFIER));
    bi.values.put(REVISION_NUMBER,
            String.valueOf(DynamicConstants.REVISION_NUMBER));
    bi.values.put(FIX_IDS, DynamicConstants.FIX_IDS);
@@ -208,6 +246,15 @@
  }
  /**
   * Gets the version qualifier.
   *
   * @return String reprenting the version qualifier
   */
  public String getVersionQualifier() {
    return values.get(VERSION_QUALIFIER);
  }
  /**
   * Gets the SVN revision number.
   *
   * @return Integer representing the SVN revision number
@@ -217,6 +264,27 @@
  }
  /**
   * Returns a build string representation of this object.  A build
   * number is a string formatted MAJOR.MINOR.POINT.REVISION where
   * MAJOR, MINOR, POINT and REVISION are integers.
   * @return String representation of a build number
   */
  public String getBuildString() {
    // -------------------------------------------------------
    // NOTE:  if you change this be sure to change fromBuildString()
    // -------------------------------------------------------
    StringBuilder sb = new StringBuilder();
    sb.append(getMajorVersion());
    sb.append(".");
    sb.append(getMinorVersion());
    sb.append(".");
    sb.append(getPointVersion());
    sb.append(".");
    sb.append(getRevisionNumber());
    return sb.toString();
  }
  /**
   * {@inheritDoc}
   */
  public String toString() {
opends/src/quicksetup/org/opends/quicksetup/upgrader/HistoricalLog.java
@@ -28,6 +28,7 @@
package org.opends.quicksetup.upgrader;
import org.opends.quicksetup.util.Utils;
import org.opends.quicksetup.BuildInformation;
import java.util.List;
import java.util.ArrayList;
@@ -82,7 +83,7 @@
   * @return Long operation ID that can be used in writing future logs
   * @throws IOException if there is a problem appending the log to the file
   */
  public Long append(Integer from, Integer to,
  public Long append(BuildInformation from, BuildInformation to,
                     HistoricalRecord.Status status, String note)
          throws IOException
  {
@@ -105,7 +106,7 @@
   * @param note optional string with additional information
   * @throws IOException if there is a problem appending the log to the file
   */
  public void append(Long id, Integer from, Integer to,
  public void append(Long id, BuildInformation from, BuildInformation to,
                     HistoricalRecord.Status status, String note)
          throws IOException
  {
opends/src/quicksetup/org/opends/quicksetup/upgrader/HistoricalRecord.java
@@ -27,6 +27,8 @@
package org.opends.quicksetup.upgrader;
import org.opends.quicksetup.BuildInformation;
import java.util.StringTokenizer;
import java.util.EnumSet;
import java.util.Set;
@@ -110,8 +112,8 @@
  static public HistoricalRecord fromString(String s)
          throws IllegalArgumentException {
    Long operationid = null;
    Integer fromInt = null;
    Integer toInt = null;
    BuildInformation from = null;
    BuildInformation to = null;
    Status outcome = null;
    Date date = null;
    String note = null;
@@ -129,11 +131,11 @@
      token = st.nextToken();
      String fromString = token.substring(FROM.length());
      fromInt = new Integer(fromString);
      from = BuildInformation.fromBuildString(fromString);
      token = st.nextToken();
      String toString = token.substring(TO.length());
      toInt = new Integer(toString);
      to = BuildInformation.fromBuildString(fromString);
      token = st.nextToken();
      String outcomeString = token.substring(STATUS.length());
@@ -151,15 +153,15 @@
      LOG.log(Level.INFO, "error creating historical log record", e);
      creationError = e;
    }
    return new HistoricalRecord(operationid, date, fromInt,
            toInt, outcome, note, creationError);
    return new HistoricalRecord(operationid, date, from,
            to, outcome, note, creationError);
  }
  private Long operationId;
  private Integer from;
  private BuildInformation from;
  private Integer to;
  private BuildInformation to;
  private Status status;
@@ -178,8 +180,9 @@
   * @param status of the upgrade
   * @param note containing details of status; can be null
   */
  public HistoricalRecord(Integer from,
                          Integer to, Status status, String note) {
  public HistoricalRecord(BuildInformation from,
                          BuildInformation to,
                          Status status, String note) {
    this.from = from;
    this.to = to;
    this.status = status;
@@ -196,8 +199,10 @@
   * @param status of the upgrade
   * @param note containing details of status; can be null
   */
  public HistoricalRecord(Long operationId, Integer from,
                          Integer to, Status status, String note) {
  public HistoricalRecord(Long operationId,
                          BuildInformation from,
                          BuildInformation to,
                          Status status, String note) {
    this.from = from;
    this.to = to;
    this.status = status;
@@ -216,8 +221,8 @@
   * @param creationError Exception that occurred while this record was
   * being created
   */
  private HistoricalRecord(Long operationId, Date date, Integer from,
                          Integer to, Status status, String note,
  private HistoricalRecord(Long operationId, Date date, BuildInformation from,
                          BuildInformation to, Status status, String note,
                          Exception creationError) {
    this.operationId = operationId;
    this.from = from;
@@ -248,7 +253,7 @@
   * Gets the Integer representing the SVN rev ID of the current installation.
   * @return Integer version ID
   */
  public Integer getFromVersion() {
  public BuildInformation getFromVersion() {
    return this.from;
  }
@@ -257,7 +262,7 @@
   * upgraded to.
   * @return Integer version ID
   */
  public Integer getToVersion() {
  public BuildInformation getToVersion() {
    return this.to;
  }
@@ -273,10 +278,10 @@
    .append(new SimpleDateFormat(DATE_FORMAT).format(date))
    .append(SEPARATOR)
    .append(FROM)
    .append(from)
    .append(from.getBuildString())
    .append(SEPARATOR)
    .append(TO)
    .append(to)
    .append(to.getBuildString())
    .append(SEPARATOR)
    .append(STATUS)
    .append(status);
opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
@@ -277,20 +277,20 @@
  private Long historicalOperationId;
  /**
   * SVN rev number of the current build.
   * Information on the current build.
   */
  private Integer currentVersion = null;
  private BuildInformation currentVersion = null;
  /**
   * Information on the staged build.
   */
  private BuildInformation stagedVersion = null;
  /**
   * New OpenDS bits.
   */
  private Installation stagedInstallation = null;
  /**
   * SVN rev number of the build in the stage directory.
   */
  private Integer stagedVersion = null;
  private RemoteBuildManager remoteBuildManager = null;
  /** Set to true if the user decides to close the window while running. */
@@ -1033,8 +1033,8 @@
        LOG.log(Level.INFO, "recording upgrade history");
        setCurrentProgressStep(UpgradeProgressStep.RECORDING_HISTORY);
        writeHistoricalRecord(historicalOperationId,
                getCurrentVersion(),
                getStagedVersion(),
                getCurrentBuildInformation(),
                getStagedBuildInformation(),
                status,
                note);
        notifyListeners(formatter.getFormattedDone() +
@@ -1262,8 +1262,8 @@
  }
  private Long writeInitialHistoricalRecord(
          Integer fromVersion,
          Integer toVersion)
          BuildInformation fromVersion,
          BuildInformation toVersion)
          throws ApplicationException {
    Long id;
    try {
@@ -1281,8 +1281,8 @@
  private void writeHistoricalRecord(
          Long id,
          Integer from,
          Integer to,
          BuildInformation from,
          BuildInformation to,
          HistoricalRecord.Status status,
          String note)
          throws ApplicationException {
@@ -1457,8 +1457,8 @@
  private void initialize() throws ApplicationException {
    try {
      Integer fromVersion = getCurrentVersion();
      Integer toVersion = getStagedVersion();
      BuildInformation fromVersion = getCurrentBuildInformation();
      BuildInformation toVersion = getStagedBuildInformation();
      this.historicalOperationId =
              writeInitialHistoricalRecord(fromVersion, toVersion);
@@ -1649,10 +1649,10 @@
    return new File(getUpgradeBackupDirectory(), "schema.custom.diff");
  }
  private Integer getCurrentVersion() {
  private BuildInformation getCurrentBuildInformation() {
    if (this.currentVersion == null) {
      try {
        currentVersion = getInstallation().getSvnRev();
        currentVersion = getInstallation().getBuildInformation();
      } catch (ApplicationException e) {
        LOG.log(Level.INFO, "error trying to determine current version", e);
      }
@@ -1660,10 +1660,10 @@
    return currentVersion;
  }
  private Integer getStagedVersion() {
  private BuildInformation getStagedBuildInformation() {
    if (stagedVersion == null) {
      try {
        stagedVersion = getStagedInstallation().getSvnRev();
        stagedVersion = getStagedInstallation().getBuildInformation();
      } catch (Exception e) {
        LOG.log(Level.INFO, "error", e);
      }