From 2e83705627546bbf34e6f1fe6922c51bcbf5d0a0 Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Mon, 02 Dec 2013 09:34:32 +0000
Subject: [PATCH] CR-2635 Second fix for OpenDJ-1196. As an issue was find by Christophe when template 02-config was deleted, added a check on template existence before copying it. - Added i18n/path in messages. - Added message ouput for post upgrade task. - Moved temp file creation as it leaves .temp files in schema folder when upgrade fails.
---
opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/UpgradeUtils.java | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/UpgradeUtils.java b/opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/UpgradeUtils.java
index acbddac..810ec28 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/UpgradeUtils.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/upgrade/UpgradeUtils.java
@@ -53,6 +53,7 @@
import static org.opends.messages.ConfigMessages.INFO_CONFIG_FILE_HEADER;
import static org.opends.messages.ToolMessages.ERR_UPGRADE_UNKNOWN_OC_ATT;
+import static org.opends.messages.ToolMessages.ERR_UPGRADE_CORRUPTED_TEMPLATE;
import static org.opends.server.tools.upgrade.FileManager.deleteRecursively;
import static org.opends.server.tools.upgrade.FileManager.rename;
import static org.opends.server.tools.upgrade.Installation.*;
@@ -579,9 +580,7 @@
LDIFEntryReader reader = null;
BufferedReader br = null;
FileWriter fw = null;
- final File copy =
- File.createTempFile("copySchema", ".tmp",
- destination.getParentFile());
+ File copy = null;
try
{
reader = new LDIFEntryReader(new FileInputStream(templateFile));
@@ -589,8 +588,8 @@
if (!reader.hasNext())
{
// Unless template are corrupted, this should not happen.
- throw new IOException(String.format(
- "'%s' file is empty. Template corrupted.", templateFile.getName()));
+ throw new IOException(ERR_UPGRADE_CORRUPTED_TEMPLATE.get(
+ templateFile.getPath()).toString());
}
final LinkedList<String> definitionsList = new LinkedList<String>();
@@ -640,7 +639,9 @@
}
// Then, open the destination file and write the new attribute
// or objectClass definitions
-
+ copy =
+ File.createTempFile("copySchema", ".tmp",
+ destination.getParentFile());
br = new BufferedReader(new FileReader(destination));
fw = new FileWriter(copy);
String line = br.readLine();
@@ -743,7 +744,7 @@
File parentDirectory = destination.getParentFile();
if (!parentDirectory.exists())
{
- LOG.log(Level.INFO, String.format("File %s's parent doesn't exist",
+ LOG.log(Level.INFO, String.format("Parent file of %s doesn't exist",
destination.getPath()));
parentDirectory.mkdirs();
@@ -763,7 +764,7 @@
writer.writeEntry(theNewSchemaEntry);
LOG.log(Level.INFO, String.format(
- "%s file created and completed successfully.", destination
+ "%s created and completed successfully.", destination
.getAbsolutePath()));
}
}
--
Gitblit v1.10.0