From 7ec591ddc0861edc2fbee5ef0eabac4e023de1a6 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Thu, 28 Jun 2007 13:39:36 +0000
Subject: [PATCH] This commit address issue 1674 <https://opends.dev.java.net/issues/show_bug.cgi?id=1674> to make the webstart and offline installers cancelable. The plumbing for cancelability is already in place since the upgrader makes use of it. This commit for the most part implements the actions that the installers must perform when the operation is canceled.
---
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java | 71 ++++++++++++++++++++++++++++++++---
1 files changed, 65 insertions(+), 6 deletions(-)
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java
index 1e798dd..022dd14 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/webstart/WebStartInstaller.java
@@ -45,6 +45,7 @@
import org.opends.quicksetup.util.Utils;
import org.opends.quicksetup.util.ZipExtractor;
import org.opends.quicksetup.util.ServerController;
+import org.opends.quicksetup.util.FileManager;
/**
* This is an implementation of the Installer class that is used to install
@@ -109,12 +110,16 @@
setStatus(InstallProgressStep.DOWNLOADING);
+ checkAbort();
+
InputStream in =
getZipInputStream(getRatio(InstallProgressStep.EXTRACTING));
setStatus(InstallProgressStep.EXTRACTING);
notifyListeners(getTaskSeparator());
+ checkAbort();
+
createParentDirectoryIfRequired();
extractZipFiles(in, getRatio(InstallProgressStep.EXTRACTING),
getRatio(InstallProgressStep.CONFIGURING_SERVER));
@@ -127,6 +132,9 @@
{
LOG.log(Level.INFO, "Error closing zip input stream: "+t, t);
}
+
+ checkAbort();
+
setStatus(InstallProgressStep.CONFIGURING_SERVER);
notifyListeners(getTaskSeparator());
@@ -135,15 +143,24 @@
writeJavaHome();
setInstallation(new Installation(getUserData().getServerLocation()));
+ checkAbort();
+
setStatus(InstallProgressStep.CONFIGURING_SERVER);
configureServer();
+
+ checkAbort();
+
createData();
+ checkAbort();
+
if (Utils.isWindows() && getUserData().getEnableWindowsService())
{
notifyListeners(getTaskSeparator());
setStatus(InstallProgressStep.ENABLING_WINDOWS_SERVICE);
enableWindowsService();
+
+ checkAbort();
}
if (mustStart())
@@ -151,6 +168,8 @@
notifyListeners(getTaskSeparator());
setStatus(InstallProgressStep.STARTING_SERVER);
new ServerController(this).startServer();
+
+ checkAbort();
}
if (mustConfigureReplication())
@@ -159,6 +178,8 @@
notifyListeners(getTaskSeparator());
configureReplication();
+
+ checkAbort();
}
if (mustInitializeSuffixes())
@@ -166,6 +187,8 @@
notifyListeners(getTaskSeparator());
setStatus(InstallProgressStep.INITIALIZE_REPLICATED_SUFFIXES);
initializeSuffixes();
+
+ checkAbort();
}
if (mustCreateAds())
@@ -173,6 +196,8 @@
notifyListeners(getTaskSeparator());
setStatus(InstallProgressStep.CONFIGURING_ADS);
updateADS();
+
+ checkAbort();
}
if (mustStop())
@@ -182,17 +207,24 @@
new ServerController(this).stopServer();
}
+ checkAbort();
setStatus(InstallProgressStep.FINISHED_SUCCESSFULLY);
notifyListeners(null);
} catch (ApplicationException ex)
{
- notifyListeners(getLineBreak());
- notifyListenersOfLog();
- setStatus(InstallProgressStep.FINISHED_WITH_ERROR);
- String html = getFormattedError(ex, true);
- notifyListeners(html);
- LOG.log(Level.SEVERE, "Error installing.", ex);
+ if (ApplicationException.Type.CANCEL.equals(ex.getType())) {
+ uninstall();
+ setStatus(InstallProgressStep.FINISHED_CANCELED);
+ notifyListeners(null);
+ } else {
+ notifyListeners(getLineBreak());
+ notifyListenersOfLog();
+ setStatus(InstallProgressStep.FINISHED_WITH_ERROR);
+ String html = getFormattedError(ex, true);
+ notifyListeners(html);
+ LOG.log(Level.SEVERE, "Error installing.", ex);
+ }
}
catch (Throwable t)
{
@@ -338,6 +370,7 @@
}
hmRatio.put(InstallProgressStep.FINISHED_SUCCESSFULLY, 100);
+ hmRatio.put(InstallProgressStep.FINISHED_CANCELED, 100);
hmRatio.put(InstallProgressStep.FINISHED_WITH_ERROR, 100);
}
@@ -462,6 +495,32 @@
}
/**
+ * Uninstall what has already been installed.
+ */
+ private void uninstall() {
+ Installation installation = getInstallation();
+ FileManager fm = new FileManager(this);
+
+ // Stop the server if necessary
+ if (installation.getStatus().isServerRunning()) {
+ try {
+ new ServerController(installation).stopServer(true);
+ } catch (ApplicationException e) {
+ LOG.log(Level.INFO, "error stopping server", e);
+ }
+ }
+
+ uninstallServices();
+
+ try {
+ fm.deleteRecursively(installation.getRootDirectory(), null,
+ FileManager.DeletionPolicy.DELETE_ON_EXIT_IF_UNSUCCESSFUL);
+ } catch (ApplicationException e) {
+ LOG.log(Level.INFO, "error deleting files", e);
+ }
+ }
+
+ /**
* {@inheritDoc}
*/
protected String getInstallationPath()
--
Gitblit v1.10.0