From 882e51b3ada821426c91aabc085d21e3fe2e0b03 Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Tue, 04 Mar 2014 09:55:16 +0000
Subject: [PATCH] Backport CR-3127 OPENDJ-1098 – Upgrading must disable old patches
---
opends/resource/upgrade | 10 +++++++++-
opends/src/messages/messages/tools.properties | 2 ++
opends/resource/upgrade.bat | 16 +++++++++++++++-
opends/src/server/org/opends/server/tools/upgrade/Upgrade.java | 27 +++++++++++++++++++++++++++
4 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/opends/resource/upgrade b/opends/resource/upgrade
index f45bd0d..b8f9040 100644
--- a/opends/resource/upgrade
+++ b/opends/resource/upgrade
@@ -22,7 +22,7 @@
# CDDL HEADER END
#
#
-# Copyright 2013 ForgeRock AS
+# Copyright 2013-2014 ForgeRock AS
# This script may be used to perform a backup of a Directory Server backend.
@@ -32,5 +32,13 @@
SCRIPT_NAME="upgrade"
export SCRIPT_NAME
+DIR_CLASSES="./classes"
+# The upgrade is not compatible with patches. If the folder is not empty
+# we renamed it as "classes.disabled", and the upgrade process should be launched properly.
+if [ "`(ls -A ${DIR_CLASSES})`" ]; then
+ mv -f ${DIR_CLASSES} "./classes.disabled"
+ mkdir ${DIR_CLASSES}
+fi
+
SCRIPT_DIR=`dirname "${0}"`
"${SCRIPT_DIR}/lib/_server-script.sh" "${@}"
diff --git a/opends/resource/upgrade.bat b/opends/resource/upgrade.bat
index 8bb51e8..72e019d 100644
--- a/opends/resource/upgrade.bat
+++ b/opends/resource/upgrade.bat
@@ -22,11 +22,25 @@
rem CDDL HEADER END
rem
rem
-rem Copyright 2013 ForgeRock AS
+rem Copyright 2013-2014 ForgeRock AS
setlocal
set OPENDJ_INVOKE_CLASS="org.opends.server.tools.upgrade.UpgradeCli"
set SCRIPT_NAME=upgrade
+
+set DIR_CLASSES="classes"
+rem The upgrade is not compatible with patches. If the folder is not empty
+rem we renamed it as "classes.disabled", and the upgrade process should be launched properly.
+IF EXIST "%DIR_CLASSES%" (
+ for /F %%i in ('dir /b %DIR_CLASSES%\*.*') do goto renamePatchesFolder
+)
+goto end
+
+:renamePatchesFolder
+rename %DIR_CLASSES% "classes.disabled"
+mkdir %DIR_CLASSES%
+
+:end
for %%i in (%~sf0) do call "%%~dPsi\lib\_server-script.bat" %*
diff --git a/opends/src/messages/messages/tools.properties b/opends/src/messages/messages/tools.properties
index 7f2d49d..6d9be6d 100644
--- a/opends/src/messages/messages/tools.properties
+++ b/opends/src/messages/messages/tools.properties
@@ -2553,6 +2553,8 @@
SEVERE_ERR_UPGRADE_CORRUPTED_TEMPLATE_1850='%s' is missing or empty, it is probably corrupted
INFO_UPGRADE_REBUILD_INDEX_NO_BACKEND_FOUND_1851=No backend found. The rebuild index task \
stops
+INFO_UPGRADE_CLASSES_FOLDER_RENAMED_1852=The classes folder has been renamed to \
+'%s' to avoid compatibility issues
# Upgrade tasks
INFO_UPGRADE_TASK_6869_SUMMARY_10000=Fixing de-DE collation matching rule OID
diff --git a/opends/src/server/org/opends/server/tools/upgrade/Upgrade.java b/opends/src/server/org/opends/server/tools/upgrade/Upgrade.java
index 03dbafa..0535e26 100644
--- a/opends/src/server/org/opends/server/tools/upgrade/Upgrade.java
+++ b/opends/src/server/org/opends/server/tools/upgrade/Upgrade.java
@@ -381,6 +381,8 @@
// Checks License.
checkLicence(context);
+ logWarnAboutPatchesFolder();
+
/*
* Get the list of required upgrade tasks.
*/
@@ -676,6 +678,31 @@
}
/**
+ * The classes folder is renamed by the script launcher to avoid
+ * incompatibility between patches and upgrade process. If a folder
+ * "classes.disabled" is found, this function just displays a warning in the
+ * log file, meaning the "classes" folder has been renamed. See upgrade.sh /
+ * upgrade.bat scripts which hold the renaming process. (OPENDJ-1098)
+ */
+ private static void logWarnAboutPatchesFolder()
+ {
+ try
+ {
+ final File backup =
+ new File(UpgradeUtils.getInstancePath(), "classes.disabled");
+ if (backup.exists() && backup.listFiles() != null
+ && backup.listFiles().length > 0)
+ {
+ LOG.log(Level.WARNING, INFO_UPGRADE_CLASSES_FOLDER_RENAMED.get(backup
+ .getAbsoluteFile().toString()).toString());
+ }
+ }
+ catch (SecurityException se)
+ {
+ LOG.log(Level.SEVERE, se.getMessage());
+ }
+ }
+ /**
* Returns {@code true} if the current upgrade contains post upgrade tasks.
*
* @return {@code true} if the current upgrade contains post upgrade tasks.
--
Gitblit v1.10.0