From 0fb9b879350996a40a419dbbc8c3ed3068553e16 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Mon, 07 Apr 2008 11:56:09 +0000
Subject: [PATCH] Fix for issue 3121 (Bad management of upgrade -r on a already reverted installation)
---
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/GuiUserInteraction.java | 8 ++
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/VersionIssueNotifier.java | 9 ++
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/CliUserInteraction.java | 10 +++
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgradeIssueNotifier.java | 19 +++--
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java | 27 +++++++++
opendj-sdk/opends/src/messages/messages/quicksetup.properties | 5 +
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserInteraction.java | 7 ++
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ReversionIssueNotifier.java | 18 +++--
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Reverter.java | 21 ++++++
9 files changed, 106 insertions(+), 18 deletions(-)
diff --git a/opendj-sdk/opends/src/messages/messages/quicksetup.properties b/opendj-sdk/opends/src/messages/messages/quicksetup.properties
index aa3bf94..d09d0ee 100644
--- a/opendj-sdk/opends/src/messages/messages/quicksetup.properties
+++ b/opendj-sdk/opends/src/messages/messages/quicksetup.properties
@@ -663,6 +663,9 @@
INFO_ORACLE_EI_ACTION_STEP1=Before starting the operation you should export \
the entire data set for this server to LDIF format. <b>If you have not \
completed this step you should cancel this operation now</b>.
+INFO_ORACLE_EI_ACTION_STEP1_CLI=Before starting the operation you should \
+ export the entire data set for this server to LDIF format. If you have not \
+ completed this step you should cancel this operation now.
INFO_ORACLE_EI_ACTION_STEP2=Continue with this operation until this tool has \
finished.
INFO_ORACLE_EI_ACTION_STEP3=When this operation is complete, manually delete \
@@ -829,6 +832,8 @@
supported.
INFO_REVERT_ERROR_EMPTY_HISTORY_DIR=There are no existing backup locations \
from prior upgrades. The 'history' directory is empty.
+INFO_REVERT_ERROR_INVALID_HISTORY_DIR=There are no valid existing backup \
+ locations from prior upgrades.
INFO_REVERT_ERROR_INVALID_FILES_DIR=The specified reversion archive directory \
does not appear to contain files backed up from an invocation of the upgrade \
tool.
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/CliUserInteraction.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/CliUserInteraction.java
index 586ee28..efa5f9d 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/CliUserInteraction.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/CliUserInteraction.java
@@ -166,7 +166,7 @@
StringBuilder sb = new StringBuilder();
if (list != null) {
for (Object o : list) {
- sb.append(/*bullet=*/"\u2022 ");
+ sb.append(/*bullet=*/"* ");
sb.append(o.toString());
sb.append(Constants.LINE_SEPARATOR);
}
@@ -242,4 +242,12 @@
public boolean isVerbose() {
return true;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isCLI()
+ {
+ return true;
+ }
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserInteraction.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserInteraction.java
index 4a79150..9ea771b 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserInteraction.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserInteraction.java
@@ -115,4 +115,11 @@
*/
String promptForString(Message prompt, Message title, String defaultValue);
+ /**
+ * Tells whether the interaction is command-line based.
+ * @return <CODE>true</CODE> if the user interaction is command-line based and
+ * <CODE>false</CODE> otherwise.
+ */
+ boolean isCLI();
+
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/GuiUserInteraction.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/GuiUserInteraction.java
index 3a3f56e..a8e436f 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/GuiUserInteraction.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/GuiUserInteraction.java
@@ -162,6 +162,14 @@
}
/**
+ * {@inheritDoc}
+ */
+ public boolean isCLI()
+ {
+ return false;
+ }
+
+ /**
* JOptionPane that controls the number of characters that are allowed
* to appear on a single line in the input area of the dialog.
*/
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ReversionIssueNotifier.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ReversionIssueNotifier.java
index 3b2f5e4..1f90df5 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ReversionIssueNotifier.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/ReversionIssueNotifier.java
@@ -98,13 +98,15 @@
Message details;
Message defaultAction;
UserInteraction.MessageType msgType;
+ String lineBreak = ui.isCLI() ?
+ Constants.LINE_SEPARATOR : Constants.HTML_LINE_BREAK;
switch (directive.getType()) {
case ACTION:
title = INFO_GENERAL_ACTION_REQUIRED.get();
summary = INFO_REVERSION_ORACLE_ACTION.get();
details = new MessageBuilder(directive.getMessage())
- .append(Constants.HTML_LINE_BREAK)
- .append(Constants.HTML_LINE_BREAK)
+ .append(lineBreak)
+ .append(lineBreak)
.append(INFO_ORACLE_ACTION_PROMPT.get())
.toMessage();
msgType = UserInteraction.MessageType.WARNING;
@@ -114,8 +116,8 @@
title = INFO_GENERAL_INFO.get();
summary = INFO_REVERSION_ORACLE_INFO.get();
details = new MessageBuilder(directive.getMessage())
- .append(Constants.HTML_LINE_BREAK)
- .append(Constants.HTML_LINE_BREAK)
+ .append(lineBreak)
+ .append(lineBreak)
.append(INFO_ORACLE_INFO_PROMPT.get())
.toMessage();
msgType = UserInteraction.MessageType.INFORMATION;
@@ -125,8 +127,8 @@
title = INFO_GENERAL_WARNING.get();
summary = INFO_REVERSION_ORACLE_WARNING.get();
details = new MessageBuilder(directive.getMessage())
- .append(Constants.HTML_LINE_BREAK)
- .append(Constants.HTML_LINE_BREAK)
+ .append(lineBreak)
+ .append(lineBreak)
.append(INFO_ORACLE_INFO_PROMPT.get())
.toMessage();
msgType = UserInteraction.MessageType.WARNING;
@@ -176,8 +178,10 @@
// If the import/export effect is present, append the detailed
// instructions.
if (effects.contains(Effect.REVERSION_DATA_EXPORT_AND_REIMPORT_REQUIRED)) {
+ String lineBreak = ui.isCLI() ?
+ Constants.LINE_SEPARATOR : Constants.HTML_LINE_BREAK;
msg = new MessageBuilder(msg)
- .append(Constants.HTML_LINE_BREAK)
+ .append(lineBreak)
.append(ui.createUnorderedList(getExportImportInstructions()))
.toMessage();
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Reverter.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Reverter.java
index 89da102..52b622d 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Reverter.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Reverter.java
@@ -260,6 +260,7 @@
}
};
String[] childNames = historyDir.list(filter);
+ boolean found = false;
if (childNames != null && childNames.length > 0) {
// The directories beneath 'history' are named according
@@ -272,11 +273,16 @@
File b = new File(historyDir, childName);
File d = new File(b, HISTORY_BACKUP_FILES_DIR_NAME);
if (isReversionFilesDirectory(d)) {
+ found = true;
ud.setReversionArchiveDirectory(d);
break;
}
}
-
+ if (!found)
+ {
+ throw new UserDataException(null,
+ INFO_REVERT_ERROR_INVALID_HISTORY_DIR.get());
+ }
} else {
throw new UserDataException(null,
INFO_REVERT_ERROR_EMPTY_HISTORY_DIR.get());
@@ -499,6 +505,12 @@
if (toBi != null) {
toBuildString = toBi.toString();
} else {
+ if (getReversionFilesDirectory() == null)
+ {
+ throw new ApplicationException(
+ ReturnCode.APPLICATION_ERROR,
+ INFO_REVERT_ERROR_INVALID_HISTORY_DIR.get(), null);
+ }
toBuildString = INFO_UPGRADE_BUILD_ID_UNKNOWN.get().toString();
}
if (cancel.equals(ui.confirm(
@@ -896,8 +908,14 @@
FileManager fm = new FileManager();
try {
fm.deleteRecursively(getReversionFilesDirectory());
+ File parent = getReversionFilesDirectory().getParentFile();
+ if (Utils.directoryExistsAndIsEmpty(parent.getAbsolutePath()))
+ {
+ fm.deleteRecursively(parent);
+ }
} catch (Exception e) {
// ignore; this is best effort
+ LOG.log(Level.WARNING, "Error: "+e, e);
}
}
@@ -910,6 +928,7 @@
fm.deleteRecursively(getTempBackupDirectory());
} catch (Exception e) {
// ignore; this is best effort
+ LOG.log(Level.WARNING, "Error: "+e, e);
}
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgradeIssueNotifier.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgradeIssueNotifier.java
index 8becdc1..526cb64 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgradeIssueNotifier.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/UpgradeIssueNotifier.java
@@ -70,7 +70,6 @@
* {@inheritDoc}
*/
public void notifyUser() throws ApplicationException {
- String[] args = { currentBuildInfo.toString(), newBuildInfo.toString() };
Message cont = INFO_ORACLE_ACTION_PROMPT_CONTINUE.get();
Message cancel = INFO_ORACLE_ACTION_PROMPT_CANCEL.get();
if (hasIssues()) {
@@ -94,6 +93,8 @@
null);
} else {
if (ui != null) {
+ String lineBreak = ui.isCLI() ?
+ Constants.LINE_SEPARATOR : Constants.HTML_LINE_BREAK;
for (VersionIssueNotifier.Directive directive : issues) {
Message title;
Message summary;
@@ -105,8 +106,8 @@
title = INFO_GENERAL_ACTION_REQUIRED.get();
summary = INFO_UPGRADE_ORACLE_ACTION.get();
details = new MessageBuilder(directive.getMessage())
- .append(Constants.HTML_LINE_BREAK)
- .append(Constants.HTML_LINE_BREAK)
+ .append(lineBreak)
+ .append(lineBreak)
.append(INFO_ORACLE_ACTION_PROMPT.get())
.toMessage();
msgType = UserInteraction.MessageType.WARNING;
@@ -116,8 +117,8 @@
title = INFO_GENERAL_INFO.get();
summary = INFO_UPGRADE_ORACLE_INFO.get();
details = new MessageBuilder(directive.getMessage())
- .append(Constants.HTML_LINE_BREAK)
- .append(Constants.HTML_LINE_BREAK)
+ .append(lineBreak)
+ .append(lineBreak)
.append(INFO_ORACLE_INFO_PROMPT.get())
.toMessage();
msgType = UserInteraction.MessageType.INFORMATION;
@@ -127,8 +128,8 @@
title = INFO_GENERAL_WARNING.get();
summary = INFO_UPGRADE_ORACLE_WARNING.get();
details = new MessageBuilder(directive.getMessage())
- .append(Constants.HTML_LINE_BREAK)
- .append(Constants.HTML_LINE_BREAK)
+ .append(lineBreak)
+ .append(lineBreak)
.append(INFO_ORACLE_INFO_PROMPT.get())
.toMessage();
msgType = UserInteraction.MessageType.WARNING;
@@ -178,8 +179,10 @@
// If the import/export effect is present, append the detailed
// instructions.
if (effects.contains(Effect.UPGRADE_DATA_EXPORT_AND_REIMPORT_REQUIRED)) {
+ String lineBreak = ui.isCLI() ?
+ Constants.LINE_SEPARATOR : Constants.HTML_LINE_BREAK;
msg = new MessageBuilder(msg)
- .append(Constants.HTML_LINE_BREAK)
+ .append(lineBreak)
.append(ui.createUnorderedList(getExportImportInstructions()))
.toMessage();
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/VersionIssueNotifier.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/VersionIssueNotifier.java
index acd71dd..f884663 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/VersionIssueNotifier.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/VersionIssueNotifier.java
@@ -300,7 +300,14 @@
*/
protected List<Message> getExportImportInstructions() {
List<Message> instructions = new ArrayList<Message>();
- instructions.add(INFO_ORACLE_EI_ACTION_STEP1.get());
+ if (ui.isCLI())
+ {
+ instructions.add(INFO_ORACLE_EI_ACTION_STEP1_CLI.get());
+ }
+ else
+ {
+ instructions.add(INFO_ORACLE_EI_ACTION_STEP1.get());
+ }
instructions.add(INFO_ORACLE_EI_ACTION_STEP2.get());
instructions.add(INFO_ORACLE_EI_ACTION_STEP3.get());
instructions.add(INFO_ORACLE_EI_ACTION_STEP4.get());
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
index 581b16a..06aeadd 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java
@@ -307,6 +307,33 @@
}
/**
+ * Returns <CODE>true</CODE> if the the provided path is a directory, exists
+ * and is empty <CODE>false</CODE> otherwise.
+ * @param path the path that we are analyzing.
+ * @return <CODE>true</CODE> if the the provided path is a directory, exists
+ * and is empty <CODE>false</CODE> otherwise.
+ */
+ public static boolean directoryExistsAndIsEmpty(String path)
+ {
+ boolean directoryExistsAndIsEmpty = false;
+ boolean isDirectory = false;
+
+ File f = new File(path);
+ if (f != null)
+ {
+ isDirectory = f.isDirectory();
+ }
+ if (isDirectory)
+ {
+ String[] ch = f.list();
+
+ directoryExistsAndIsEmpty = (ch == null) || (ch.length == 0);
+ }
+
+ return directoryExistsAndIsEmpty;
+ }
+
+ /**
* Returns <CODE>true</CODE> if the the provided string is a DN and
* <CODE>false</CODE> otherwise.
* @param dn the String we are analyzing.
--
Gitblit v1.10.0