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

chebrard
04.52.2009 532463a23dac7820a1804985595a18aac58711e1
Fix for issue #3958: Upgrade should support products built on top of OpenDS

OpenDS can be customized: quicksetup splashscreen / product name ... But upgrade CLI fails as soon as current version and target version are the same. This change allows upgrade to a same version as soon as the product names are different so allows upgrading from an OpenDS to a customized OpenDS.

This also fixes issue #3959 (Add a way to have the version of the instance) for Unix platform. For that, we add a file in the instance files (config/buildinfo) that contains the version number of the instance. This file were already created in SVR4 and pkg(5) deliveries context. This change creates the file in ZIP delivery context.
For Windows platform, some changes are required in the .bat files to solve issue #3959 (Add a way to have the version of the instance). These changes will be handled by another commit.

2 files modified
47 ■■■■ changed files
opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java 18 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/configurator/CheckInstance.java 29 ●●●● patch | view | raw | blame | history
opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
@@ -1869,11 +1869,19 @@
    try {
      BuildInformation fromVersion = getCurrentInstanceBuildInformation();
      BuildInformation toVersion = getStagedBuildInformation();
      if (fromVersion.equals(toVersion))
      {
        throw new ApplicationException(ReturnCode.APPLICATION_ERROR,
            INFO_UPGRADE_ORACLE_SAME_VERSION.get(
                toVersion.toString()), null);
      if (fromVersion.equals(toVersion)) {
        // Only possible if product differs
        String fromProductName = getCurrentBuildInformation().getName();
        String toProductName = toVersion.getName();
        LOG.log(Level.FINEST, "fromProductName=" + fromProductName);
        LOG.log(Level.FINEST, "toProductName=" + toProductName);
        if ((fromProductName != null) &&
                (toProductName != null) &&
                fromProductName.equals(toProductName)) {
          throw new ApplicationException(ReturnCode.APPLICATION_ERROR,
                  INFO_UPGRADE_ORACLE_SAME_VERSION.get(
                  toVersion.toString()), null);
        }
      }
      if (getInstallation().getStatus().isServerRunning()) {
        new ServerController(getInstallation()).stopServer(true);
opends/src/server/org/opends/server/tools/configurator/CheckInstance.java
@@ -277,19 +277,32 @@
      System.exit(USER_ERROR);
    }
    // Initialize buildinfo in not already done (ZIP delivery)
    BuildInformation installBi =
            BuildInformation.fromBuildString(MAJOR_VERSION +
            "." + MINOR_VERSION +
            "." + POINT_VERSION +
            "." + REVISION_NUMBER);
    File bif = new File(confDir, Installation.BUILDINFO_RELATIVE_PATH);
    if (!bif.exists()) {
      FileWriter fwriter = null;
      try {
        fwriter = new FileWriter(bif, true);
        fwriter.append(installBi.getBuildString());
      } catch (Exception e) {
      } finally {
        try {
          fwriter.close();
        } catch (Exception e) {
        }
      }
    }
    // Check version
    if (checkVersionArg.isPresent()) {
        BuildInformation installBi =
                  BuildInformation.fromBuildString(MAJOR_VERSION +
                                                   "." + MINOR_VERSION +
                                                   "." + POINT_VERSION +
                                                   "." + REVISION_NUMBER);
      BuildInformation instanceBi = installBi;
      try {
        File bif = new File(confDir, Installation.BUILDINFO_RELATIVE_PATH);
        if (bif.exists()) {
          BufferedReader breader = new BufferedReader(new FileReader(bif));
@@ -365,4 +378,4 @@
    System.exit(SUCCESS);
  }
}
}