From 532463a23dac7820a1804985595a18aac58711e1 Mon Sep 17 00:00:00 2001
From: chebrard <chebrard@localhost>
Date: Mon, 04 May 2009 12:52:53 +0000
Subject: [PATCH] Fix for issue #3958: Upgrade should support products built on top of OpenDS

---
 opends/src/server/org/opends/server/tools/configurator/CheckInstance.java |   29 +++++++++++++++++++++--------
 opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java        |   18 +++++++++++++-----
 2 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java b/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
index 98b060d..fa80cbd 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
+++ b/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);
diff --git a/opends/src/server/org/opends/server/tools/configurator/CheckInstance.java b/opends/src/server/org/opends/server/tools/configurator/CheckInstance.java
index 060a626..06eb2db 100644
--- a/opends/src/server/org/opends/server/tools/configurator/CheckInstance.java
+++ b/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);
 
   }
-}
+}
\ No newline at end of file

--
Gitblit v1.10.0