From 76873cf7ce1d9160d018688cbe806ad7e67bbd1d Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Thu, 24 Jan 2008 09:02:14 +0000
Subject: [PATCH] There was a flag day when the new security framework was added in build 1.0.0 build 6.  The following changes address the issue.  The main thing that has been updated are the changes at the end of VersionCompatibilityIssue.  The problem is that the code relied only on the fact that a flag day was known (we register the flag days).  However it can happen (as it is the case) that a flag day is registered in the code way after the changes occurred.  So when we registered a flag day, systematically we could not upgrade from previous builds.

---
 opends/src/quicksetup/org/opends/quicksetup/upgrader/VersionIssueNotifier.java |    4 +-
 opends/src/messages/messages/version.properties                                |    8 +++-
 opends/src/server/org/opends/server/util/VersionCompatibilityIssue.java        |   53 +++++++++++++++++++++++++-
 opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java              |    4 +-
 4 files changed, 60 insertions(+), 9 deletions(-)

diff --git a/opends/src/messages/messages/version.properties b/opends/src/messages/messages/version.properties
index c40c240..778265b 100644
--- a/opends/src/messages/messages/version.properties
+++ b/opends/src/messages/messages/version.properties
@@ -20,7 +20,7 @@
 #
 # CDDL HEADER END
 #
-#      Portions Copyright 2006-2007 Sun Microsystems, Inc.
+#      Portions Copyright 2006-2008 Sun Microsystems, Inc.
 
 
 
@@ -84,4 +84,8 @@
  because the default password storage scheme and deprecated password storage \
  scheme references in the password policy have been converted from names to \
  DNs, and it is not possible to revert from the DN back to the scheme name
-
+INFO_3294_UPGRADE_9=This upgrade introduces a new security framework that is \
+ not backwards compatible.  Upgrade is not possible.
+INFO_3294_REVERSION_10=The revision 3294 introduces a new security framework.  \
+ Revert is not possible.
+ 
diff --git a/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java b/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java
index 1b4b777..b5fa7af 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/BuildInformation.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
+ *      Portions Copyright 2006-2008 Sun Microsystems, Inc.
  */
 
 package org.opends.quicksetup;
@@ -291,7 +291,7 @@
         try {
           ids.add(Integer.parseInt(s));
         } catch (NumberFormatException nfe) {
-          LOG.log(Level.INFO, "invalid upgrade incompatability ID " + s);
+          LOG.log(Level.INFO, "invalid upgrade incompatibility ID " + s);
         }
       }
     }
diff --git a/opends/src/quicksetup/org/opends/quicksetup/upgrader/VersionIssueNotifier.java b/opends/src/quicksetup/org/opends/quicksetup/upgrader/VersionIssueNotifier.java
index ea3871f..0cd2831 100644
--- a/opends/src/quicksetup/org/opends/quicksetup/upgrader/VersionIssueNotifier.java
+++ b/opends/src/quicksetup/org/opends/quicksetup/upgrader/VersionIssueNotifier.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Portions Copyright 2007 Sun Microsystems, Inc.
+ *      Portions Copyright 2007-2008 Sun Microsystems, Inc.
  */
 
 package org.opends.quicksetup.upgrader;
@@ -150,7 +150,7 @@
     List<VersionCompatibilityIssue> compatibilityIssues;
     Set<Integer> excludeIds = current.getIncompatibilityEventIds();
     if (excludeIds != null) {
-      compatibilityIssues = getEvents(excludeIds);
+      compatibilityIssues = getEvents(excludeIds, current, neu);
     } else {
       // This method is only used as a fallback for pre 1.0.0 servers which
       // do not advertise incompatible version events.
diff --git a/opends/src/server/org/opends/server/util/VersionCompatibilityIssue.java b/opends/src/server/org/opends/server/util/VersionCompatibilityIssue.java
index 77ec145..e467eb0 100644
--- a/opends/src/server/org/opends/server/util/VersionCompatibilityIssue.java
+++ b/opends/src/server/org/opends/server/util/VersionCompatibilityIssue.java
@@ -22,11 +22,12 @@
  * CDDL HEADER END
  *
  *
- *      Portions Copyright 2007 Sun Microsystems, Inc.
+ *      Portions Copyright 2007-2008 Sun Microsystems, Inc.
  */
 
 package org.opends.server.util;
 import org.opends.messages.Message;
+import org.opends.quicksetup.BuildInformation;
 
 import static org.opends.messages.VersionMessages.*;
 
@@ -216,6 +217,18 @@
    * or more versions of the OpenDS codebase.
    */
   public enum Cause {
+    /**
+     * Incompatible changes in the cryptomanager and specially in the way
+     * replication works.  These changes were committed on several revisions
+     * and the flagday that has been chosen corresponds to revision 3294
+     * (opends 1.0.0 build 6 of 16/10/2007)
+     */
+    REPLICATION_SECURITY_CHANGE_1(
+            5, // Unique ID.  See javadoc for more information.
+            INFO_3294_UPGRADE.get(),
+            INFO_3294_REVERSION.get(),
+            Effect.REVERSION_NOT_POSSIBLE,
+            Effect.UPGRADE_NOT_POSSIBLE),
 
     /**
      * Incompatible property name change committed on 09/05/2007
@@ -424,6 +437,9 @@
   //***************************************************
 
   static {
+    //
+    register(Cause.REPLICATION_SECURITY_CHANGE_1,
+        new BuildVersion(1, 0, 0, 3294));
     register(Cause.PROPERTY_CHANGE_1, new BuildVersion(1, 0, 0, 3053));
     register(Cause.DB_FORMAT_CHANGE_2, new BuildVersion(0, 9, 0, 2049));
     register(Cause.DB_FORMAT_CHANGE_1, new BuildVersion(0, 1, 0, 1582));
@@ -456,19 +472,50 @@
    *
    * @param excludeIds collection of IDs representing issues
    *        that will not be returned in the list
+   * @param current build version
+   * @param neu build version
    *
    * @return list of issues sorted by build version in which
    *         they appear
    */
   static public List<VersionCompatibilityIssue> getEvents(
-          Collection<Integer> excludeIds)
+          Collection<Integer> excludeIds, BuildInformation current,
+          BuildInformation neu)
   {
     if (excludeIds == null) excludeIds = Collections.emptySet();
     List<VersionCompatibilityIssue> issueList =
             new ArrayList<VersionCompatibilityIssue>();
     for (VersionCompatibilityIssue evt : VERSION_COMPATIBILITY_ISSUES) {
       if (!excludeIds.contains(evt.getCause().getId())) {
-        issueList.add(evt);
+        boolean isUpgrade = neu.compareTo(current) >= 0;
+        BuildVersion newVersion = new BuildVersion(neu.getMajorVersion(),
+            neu.getMinorVersion(), neu.getPointVersion(),
+            neu.getRevisionNumber());
+        BuildVersion currentVersion = new BuildVersion(
+            current.getMajorVersion(), current.getMinorVersion(),
+            current.getPointVersion(), current.getRevisionNumber());
+        if (isUpgrade)
+        {
+          // If the currentVersion is newer than the issue described, then there
+          // is no problem.  This can occur for instance when we discovered a
+          // flag day too late (and we added the flag day description to the
+          // code way after the revision).
+          if (currentVersion.compareTo(evt.getVersion()) < 0)
+          {
+            issueList.add(evt);
+          }
+        }
+        else
+        {
+          // If the newVersion in the reversion is newer than the issue
+          // described, then there is no problem.  This can occur for instance
+          // when we discovered a flag day too late (and we added the flag day
+          // description to the code way after the revision).
+          if (currentVersion.compareTo(evt.getVersion()) < 0)
+          {
+            issueList.add(evt);
+          }
+        }
       }
     }
     Collections.sort(issueList, VERSION_COMPARATOR);

--
Gitblit v1.10.0