From 2c18c7eda8c978ea6c0b7f6facd631e828a15533 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Wed, 11 Jul 2007 21:14:32 +0000
Subject: [PATCH] This commit addresses issue 1973 "exclude some config subdirectories from copy during upgrade". During an upgrade, the contents of the old config directory are recursively copied to the new config directory in order to retain things like the keystore and other SSL related artifacts and tasks.ldif. There are however some files that should not be copied over, namely the contents of the upgrade and schema subdirectories. This commit excludes those subdirectories.
---
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java | 14 +++++++++++++-
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/FileManager.java | 26 ++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 1 deletions(-)
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
index a15654c..2aa9b35 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java
@@ -1378,7 +1378,19 @@
File newConfigDir =
getInstallation().getConfigurationDirectory();
FileManager fm = new FileManager();
- fm.synchronize(oldConfigDir, newConfigDir);
+
+ // Define a filter for files that we don't want to copy over
+ // from the old config directory.
+ final File oldConfigUpgradeDir = new File(oldConfigDir, "upgrade");
+ final File oldConfigSchemaDir = new File(oldConfigDir, "schema");
+ FileFilter filter = new FileFilter() {
+ public boolean accept(File f) {
+ return !Utils.isDescendant(f, oldConfigUpgradeDir) &&
+ !Utils.isDescendant(f, oldConfigSchemaDir);
+ }
+ };
+
+ fm.synchronize(oldConfigDir, newConfigDir, filter);
}
private boolean calculateConfigCustomizations() throws ApplicationException {
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/FileManager.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/FileManager.java
index f8e572e..f3a9181 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/FileManager.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/FileManager.java
@@ -112,6 +112,32 @@
}
/**
+ * Recursively copies any files or directories appearing in
+ * <code>source</code> or a subdirectory of <code>source</code>
+ * to the corresponding directory under <code>target</code>. Files
+ * in under <code>source</code> are not copied to <code>target</code>
+ * if a file by the same name already exists in <code>target</code>.
+ *
+ * @param source source directory
+ * @param target target directory
+ * @param filter for specifying particular files to synchronize
+ * @throws ApplicationException if there is a problem copying files
+ */
+ public void synchronize(File source, File target, FileFilter filter)
+ throws ApplicationException
+ {
+ if (source != null && target != null) {
+ String[] sourceFileNames = source.list();
+ if (sourceFileNames != null) {
+ for (String sourceFileName : sourceFileNames) {
+ File sourceFile = new File(source, sourceFileName);
+ copyRecursively(sourceFile, target, filter, false);
+ }
+ }
+ }
+ }
+
+ /**
* Renames the source file to the target file. If the target file exists
* it is first deleted. The rename and delete operation return values
* are checked for success and if unsuccessful, this method throws an
--
Gitblit v1.10.0