From 8954178f7ee9f6bc45ac3070f3f483027a2064f4 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Mon, 02 Apr 2007 22:25:59 +0000
Subject: [PATCH] - Succeeded in removing the Utils.isUninstall() method. All the logic that was being controlled by if statements using this method has been moved to the applications themselves (except for a few hacks that I've documented in the code)
---
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/upgrader/Upgrader.java | 63 +
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java | 623 +++++++++++-
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java | 2
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/CurrentStepPanel.java | 32
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/Utils.java | 11
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/ButtonsPanel.java | 97 -
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java | 1054 +++++++++++---------
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallLauncher.java | 1
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/QuickSetup.java | 786 +--------------
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupDialog.java | 8
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserData.java | 2
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Step.java | 2
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/WizardStep.java | 42
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserDataException.java | 6
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties | 3
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/StepsPanel.java | 27
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Application.java | 166 +++
opendj-sdk/opends/resource/upgrade.bat | 2
18 files changed, 1,522 insertions(+), 1,405 deletions(-)
diff --git a/opendj-sdk/opends/resource/upgrade.bat b/opendj-sdk/opends/resource/upgrade.bat
index d0d4d4b..1e0bd31 100644
--- a/opendj-sdk/opends/resource/upgrade.bat
+++ b/opendj-sdk/opends/resource/upgrade.bat
@@ -60,7 +60,7 @@
goto callJava
:callLaunch
-"%DIR_HOME%\lib\winlauncher.exe" launch "%DIR_HOME%" "%JAVA_BIN%" %JAVA_ARGS% org.opends.quicksetup.uninstaller.UninstallLauncher
+"%DIR_HOME%\lib\winlauncher.exe" launch "%DIR_HOME%" "%JAVA_BIN%" %JAVA_ARGS% org.opends.quicksetup.upgrader.UpgradeLauncher
goto end
:callJava
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Application.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Application.java
index 2e10a20..9e8cbdc 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Application.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Application.java
@@ -61,7 +61,7 @@
Logger.getLogger(Application.class.getName());
/** The currently displayed wizard step. */
- private Step displayedStep;
+ private WizardStep displayedStep;
/** Represents current install state. */
protected CurrentInstallStatus installStatus;
@@ -608,7 +608,7 @@
* Returns the initial wizard step.
* @return Step representing the first step to show in the wizard
*/
- public abstract Step getFirstWizardStep();
+ public abstract WizardStep getFirstWizardStep();
/**
* Called by the quicksetup controller when the user advances to
@@ -619,7 +619,7 @@
* @param userData UserData representing the data specified by the user
* @param dlg QuickSetupDialog hosting the wizard
*/
- protected void setDisplayedWizardStep(Step step,
+ protected void setDisplayedWizardStep(WizardStep step,
UserData userData,
QuickSetupDialog dlg) {
this.displayedStep = step;
@@ -639,7 +639,7 @@
*/
protected abstract void setWizardDialogState(QuickSetupDialog dlg,
UserData userData,
- Step step);
+ WizardStep step);
/**
* Returns the installation path.
@@ -760,21 +760,173 @@
* Returns the set of wizard steps used in this application's wizard.
* @return Set of Step objects representing wizard steps
*/
- abstract public Set<Step> getWizardSteps();
+ abstract public Set<WizardStep> getWizardSteps();
/**
* Creates a wizard panel given a specific step.
* @param step for which a panel representation should be created
* @return QuickSetupStepPanel for representing the <code>step</code>
*/
- abstract public QuickSetupStepPanel createWizardStepPanel(Step step);
+ abstract public QuickSetupStepPanel createWizardStepPanel(WizardStep step);
/**
* Gets the next step in the wizard given a current step.
* @param step Step the current step
* @return Step the next step
*/
- abstract public Step getNextWizardStep(Step step);
+ abstract public WizardStep getNextWizardStep(WizardStep step);
+
+ /**
+ * Gets the previous step in the wizard given a current step.
+ * @param step Step the current step
+ * @return Step the previous step
+ */
+ abstract public WizardStep getPreviousWizardStep(WizardStep step);
+
+ /**
+ * Indicates whether or not the user is allowed to return to a previous
+ * step from <code>step</code>.
+ * @param step WizardStep for which the the return value indicates whether
+ * or not the user can return to a previous step
+ * @return boolean where true indicates the user can return to a previous
+ * step from <code>step</code>
+ */
+ public boolean canGoBack(WizardStep step) {
+ return !getFirstWizardStep().equals(step);
+ }
+
+ /**
+ * Indicates whether or not the user is allowed to move to a new
+ * step from <code>step</code>.
+ * @param step WizardStep for which the the return value indicates whether
+ * or not the user can move to a new step
+ * @return boolean where true indicates the user can move to a new
+ * step from <code>step</code>
+ */
+ public boolean canGoForward(WizardStep step) {
+ return getNextWizardStep(step) != null;
+ }
+
+ /**
+ * Inidicates whether or not the user is allowed to finish the wizard from
+ * <code>step</code>.
+ * @param step WizardStep for which the the return value indicates whether
+ * or not the user can finish the wizard
+ * @return boolean where true indicates the user can finish the wizard
+ */
+ public boolean canFinish(WizardStep step) {
+ return getNextWizardStep(step) != null;
+ }
+
+ /**
+ * Inidicates whether or not the user is allowed to quit the wizard from
+ * <code>step</code>.
+ * @param step WizardStep for which the the return value indicates whether
+ * or not the user can quit the wizard
+ * @return boolean where true indicates the user can quit the wizard
+ */
+ public boolean canQuit(WizardStep step) {
+ return false;
+ }
+
+ /**
+ * Inidicates whether or not the user is allowed to close the wizard from
+ * <code>step</code>.
+ * @param step WizardStep for which the the return value indicates whether
+ * or not the user can close the wizard
+ * @return boolean where true indicates the user can close the wizard
+ */
+ public boolean canClose(WizardStep step) {
+ return false;
+ }
+
+ /**
+ * Inidicates whether or not the user is allowed to cancel the wizard from
+ * <code>step</code>.
+ * @param step WizardStep for which the the return value indicates whether
+ * or not the user can cancel the wizard
+ * @return boolean where true indicates the user can cancel the wizard
+ */
+ public boolean canCancel(WizardStep step) {
+ return false;
+ }
+
+ /**
+ * Called when the user has clicked the 'previous' button.
+ * @param cStep WizardStep at which the user clicked the previous button
+ * @param qs QuickSetup controller
+ */
+ public abstract void previousClicked(WizardStep cStep, QuickSetup qs);
+
+ /**
+ * Called when the user has clicked the 'finish' button.
+ * @param cStep WizardStep at which the user clicked the previous button
+ * @param qs QuickSetup controller
+ */
+ public abstract void finishClicked(final WizardStep cStep,
+ final QuickSetup qs);
+
+ /**
+ * Called when the user has clicked the 'next' button.
+ * @param cStep WizardStep at which the user clicked the next button
+ * @param qs QuickSetup controller
+ */
+ public abstract void nextClicked(WizardStep cStep, QuickSetup qs);
+
+ /**
+ * Called when the user has clicked the 'close' button.
+ * @param cStep WizardStep at which the user clicked the close button
+ * @param qs QuickSetup controller
+ */
+ public abstract void closeClicked(WizardStep cStep, QuickSetup qs);
+
+ /**
+ * Called when the user has clicked the 'cancel' button.
+ * @param cStep WizardStep at which the user clicked the cancel button
+ * @param qs QuickSetup controller
+ */
+ public abstract void cancelClicked(WizardStep cStep, QuickSetup qs);
+
+ /**
+ * Called when the user has clicked the 'quit' button.
+ * @param step WizardStep at which the user clicked the quit button
+ * @param qs QuickSetup controller
+ */
+ abstract public void quitClicked(WizardStep step, QuickSetup qs);
+
+ /**
+ * Called whenever this application should update its user data from
+ * values found in QuickSetup.
+ * @param cStep current wizard step
+ * @param qs QuickSetup controller
+ * @throws UserDataException if there is a problem with the data
+ */
+ abstract protected void updateUserData(WizardStep cStep, QuickSetup qs)
+ throws UserDataException;
+
+ /**
+ * Gets the key for the close button's tool tip text.
+ * @return String key of the text in the resource bundle
+ */
+ public String getCloseButtonToolTip() {
+ return "close-button-tooltip";
+ }
+
+ /**
+ * Gets the key for the finish button's tool tip text.
+ * @return String key of the text in the resource bundle
+ */
+ public String getFinishButtonToolTip() {
+ return "finish-button-tooltip";
+ }
+
+ /**
+ * Gets the key for the finish button's label.
+ * @return String key of the text in the resource bundle
+ */
+ public String getFinishButtonLabel() {
+ return "finish-button-label";
+ }
/**
* This class is used to read the standard error and standard output of the
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/QuickSetup.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/QuickSetup.java
index a5dd54e..8533d80 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/QuickSetup.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/QuickSetup.java
@@ -35,7 +35,6 @@
import org.opends.quicksetup.installer.FieldName;
import org.opends.quicksetup.ui.QuickSetupDialog;
import org.opends.quicksetup.ui.UIFactory;
-import org.opends.quicksetup.uninstaller.UninstallUserData;
import org.opends.quicksetup.util.BackgroundTask;
import org.opends.quicksetup.util.ProgressMessageFormatter;
import org.opends.quicksetup.util.Utils;
@@ -77,7 +76,7 @@
private CurrentInstallStatus installStatus;
- private Step currentStep = Step.WELCOME;
+ private WizardStep currentStep;
private QuickSetupDialog dialog;
@@ -89,17 +88,6 @@
private ProgressDescriptor descriptorToDisplay;
- // Constants used to do checks
- private static final int MIN_DIRECTORY_MANAGER_PWD = 1;
-
- private static final int MIN_PORT_VALUE = 1;
-
- private static final int MAX_PORT_VALUE = 65535;
-
- private static final int MIN_NUMBER_ENTRIES = 1;
-
- private static final int MAX_NUMBER_ENTRIES = 10000;
-
// Update period of the dialogs.
private static final int UPDATE_PERIOD = 500;
@@ -246,47 +234,19 @@
} catch (Exception ex)
{
}
- synchronized (this)
- {
- if (Utils.isUninstall())
- {
- final ProgressDescriptor desc = descriptorToDisplay;
- if (desc != null)
- {
- if (desc != lastDisplayedDescriptor)
- {
- lastDisplayedDescriptor = desc;
+ synchronized (this) {
+ final ProgressDescriptor desc = descriptorToDisplay;
+ if (desc != null) {
+ if (desc != lastDisplayedDescriptor) {
+ lastDisplayedDescriptor = desc;
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- getDialog().displayProgress(desc);
- }
- });
- }
- doPool = desc != lastDescriptor;
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ getDialog().displayProgress(desc);
+ }
+ });
}
- }
- else
- {
- final ProgressDescriptor desc = descriptorToDisplay;
- if (desc != null)
- {
- if (desc != lastDisplayedDescriptor)
- {
- lastDisplayedDescriptor = desc;
-
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- getDialog().displayProgress(desc);
- }
- });
- }
- doPool = desc != lastDescriptor;
- }
+ doPool = desc != lastDescriptor;
}
}
}
@@ -298,55 +258,37 @@
*/
private void nextClicked()
{
- final Step cStep = getCurrentStep();
- switch (cStep)
- {
- case PROGRESS:
- throw new IllegalStateException(
- "Cannot click on next from progress step");
-
- case REVIEW:
- throw new IllegalStateException("Cannot click on next from review step");
-
- default:
- BackgroundTask worker = new BackgroundTask()
- {
- public Object processBackgroundTask() throws UserDataException {
- try
- {
- updateUserData(cStep);
- }
- catch (UserDataException uide)
- {
- throw uide;
- }
- catch (Throwable t)
- {
- throw new UserDataException(cStep,
- getThrowableMsg("bug-msg", t));
- }
- return null;
+ final WizardStep cStep = getCurrentStep();
+ application.nextClicked(cStep, this);
+ BackgroundTask worker = new BackgroundTask() {
+ public Object processBackgroundTask() throws UserDataException {
+ try {
+ application.updateUserData(cStep, QuickSetup.this);
}
-
- public void backgroundTaskCompleted(Object returnValue,
- Throwable throwable)
- {
- getDialog().workerFinished();
-
- if (throwable != null)
- {
- UserDataException ude = (UserDataException)throwable;
- displayError(ude.getLocalizedMessage(), getMsg("error-title"));
- }
- else
- {
- setCurrentStep(nextStep(cStep));
- }
+ catch (UserDataException uide) {
+ throw uide;
}
- };
- getDialog().workerStarted();
- worker.startBackgroundTask();
- }
+ catch (Throwable t) {
+ throw new UserDataException(cStep,
+ getThrowableMsg("bug-msg", t));
+ }
+ return null;
+ }
+
+ public void backgroundTaskCompleted(Object returnValue,
+ Throwable throwable) {
+ getDialog().workerFinished();
+
+ if (throwable != null) {
+ UserDataException ude = (UserDataException) throwable;
+ displayError(ude.getLocalizedMessage(), getMsg("error-title"));
+ } else {
+ setCurrentStep(application.getNextWizardStep(cStep));
+ }
+ }
+ };
+ getDialog().workerStarted();
+ worker.startBackgroundTask();
}
/**
@@ -355,82 +297,8 @@
*/
private void finishClicked()
{
- final Step cStep = getCurrentStep();
- switch (cStep)
- {
- case REVIEW:
- updateUserDataForReviewPanel();
- launchInstallation();
- setCurrentStep(Step.PROGRESS);
- break;
-
- case CONFIRM_UNINSTALL:
- BackgroundTask worker = new BackgroundTask()
- {
- public Object processBackgroundTask() throws UserDataException
- {
- try
- {
- updateUserUninstallDataForConfirmUninstallPanel();
- }
- catch (UserDataException uude)
- {
- throw uude;
- } catch (Throwable t)
- {
- throw new UserDataException(cStep,
- getThrowableMsg("bug-msg", t));
- }
- return CurrentInstallStatus.isServerRunning();
- }
-
- public void backgroundTaskCompleted(Object returnValue,
- Throwable throwable)
- {
- getDialog().workerFinished();
- if (throwable != null)
- {
- displayError(throwable.getLocalizedMessage(),
- getMsg("error-title"));
- } else
- {
- boolean serverRunning = (Boolean) returnValue;
- if (!serverRunning)
- {
- application.getUserData().setStopServer(false);
- if (displayConfirmation(
- getMsg("confirm-uninstall-server-not-running-msg"),
- getMsg("confirm-uninstall-server-not-running-title")))
- {
- launchUninstallation();
- setCurrentStep(nextStep(cStep));
- }
- }
- else
- {
- if (displayConfirmation(
- getMsg("confirm-uninstall-server-running-msg"),
- getMsg("confirm-uninstall-server-running-title")))
- {
- application.getUserData().setStopServer(true);
- launchUninstallation();
- setCurrentStep(nextStep(cStep));
- } else
- {
- application.getUserData().setStopServer(false);
- }
- }
- }
- }
- };
- getDialog().workerStarted();
- worker.startBackgroundTask();
- break;
-
- default:
- throw new IllegalStateException(
- "Cannot click on finish when we are not in the Review window");
- }
+ final WizardStep cStep = getCurrentStep();
+ application.finishClicked(cStep, this);
}
/**
@@ -439,20 +307,9 @@
*/
private void previousClicked()
{
- Step cStep = getCurrentStep();
- switch (cStep)
- {
- case WELCOME:
- throw new IllegalStateException(
- "Cannot click on previous from progress step");
-
- case PROGRESS:
- throw new IllegalStateException(
- "Cannot click on previous from progress step");
-
- default:
- setCurrentStep(previousStep(cStep));
- }
+ WizardStep cStep = getCurrentStep();
+ application.previousClicked(cStep, this);
+ setCurrentStep(application.getPreviousWizardStep(cStep));
}
/**
@@ -461,28 +318,8 @@
*/
private void quitClicked()
{
- Step cStep = getCurrentStep();
- switch (cStep)
- {
- case PROGRESS:
- throw new IllegalStateException(
- "Cannot click on quit from progress step");
-
- default:
- if (Utils.isUninstall())
- {
- quit();
- }
- else if (installStatus.isInstalled())
- {
- quit();
-
- } else if (displayConfirmation(getMsg("confirm-quit-install-msg"),
- getMsg("confirm-quit-install-title")))
- {
- quit();
- }
- }
+ WizardStep cStep = getCurrentStep();
+ application.quitClicked(cStep, this);
}
/**
@@ -491,18 +328,10 @@
*/
private void continueInstallClicked()
{
- Step cStep = getCurrentStep();
- switch (cStep)
- {
- case WELCOME:
- application.forceToDisplay();
- getDialog().forceToDisplay();
- setCurrentStep(Step.WELCOME);
- break;
- default:
- throw new IllegalStateException(
- "Continue only can be clicked on WELCOME step");
- }
+ // TODO: move this stuff to Installer?
+ application.forceToDisplay();
+ getDialog().forceToDisplay();
+ setCurrentStep(Step.WELCOME);
}
/**
@@ -511,35 +340,8 @@
*/
private void closeClicked()
{
- Step cStep = getCurrentStep();
- switch (cStep)
- {
- case PROGRESS:
- if (Utils.isUninstall())
- {
- boolean finished = application.isFinished();
- if (finished
- || displayConfirmation(getMsg("confirm-close-uninstall-msg"),
- getMsg("confirm-close-uninstall-title")))
- {
- quit();
- }
- } else
- {
- boolean finished = application.isFinished();
- if (finished
- || displayConfirmation(getMsg("confirm-close-install-msg"),
- getMsg("confirm-close-install-title")))
- {
- quit();
- }
- }
- break;
-
- default:
- throw new IllegalStateException(
- "Close only can be clicked on PROGRESS step");
- }
+ WizardStep cStep = getCurrentStep();
+ application.closeClicked(cStep, this);
}
/**
@@ -548,17 +350,8 @@
*/
private void cancelClicked()
{
- Step cStep = getCurrentStep();
- switch (cStep)
- {
- case CONFIRM_UNINSTALL:
- quit();
- break;
-
- default:
- throw new IllegalStateException(
- "Cancel only can be clicked on CONFIRM_UNINSTALL step");
- }
+ WizardStep cStep = getCurrentStep();
+ application.cancelClicked(cStep, this);
}
private void launchStatusPanelClicked()
@@ -626,402 +419,17 @@
* quit the program.
*
*/
- private void quit()
+ public void quit()
{
System.exit(0);
}
/**
- * These methods validate the data provided by the user in the panels and
- * update the userData object according to that content.
- *
- * @param cStep
- * the current step of the wizard
- *
- * @throws UserDataException if the data provided by the user is not
- * valid.
- *
- */
- private void updateUserData(Step cStep) throws UserDataException {
- switch (cStep)
- {
- case SERVER_SETTINGS:
- updateUserDataForServerSettingsPanel();
- break;
-
- case DATA_OPTIONS:
- updateUserDataForDataOptionsPanel();
- break;
-
- case REVIEW:
- updateUserDataForReviewPanel();
- break;
- }
- }
-
- /**
- * Validate the data provided by the user in the server settings panel and
- * update the userData object according to that content.
- *
- * @throws UserDataException if the data provided by the user is not
- * valid.
- *
- */
- private void updateUserDataForServerSettingsPanel()
- throws UserDataException {
- ArrayList<String> errorMsgs = new ArrayList<String>();
-
- if (isWebStart())
- {
- // Check the server location
- String serverLocation = getFieldStringValue(FieldName.SERVER_LOCATION);
-
- if ((serverLocation == null) || ("".equals(serverLocation.trim())))
- {
- errorMsgs.add(getMsg("empty-server-location"));
- displayFieldInvalid(FieldName.SERVER_LOCATION, true);
- } else if (!Utils.parentDirectoryExists(serverLocation))
- {
- String[] arg =
- { serverLocation };
- errorMsgs.add(getMsg("parent-directory-does-not-exist", arg));
- displayFieldInvalid(FieldName.SERVER_LOCATION, true);
- } else if (Utils.fileExists(serverLocation))
- {
- String[] arg =
- { serverLocation };
- errorMsgs.add(getMsg("file-exists", arg));
- displayFieldInvalid(FieldName.SERVER_LOCATION, true);
- } else if (Utils.directoryExistsAndIsNotEmpty(serverLocation))
- {
- String[] arg =
- { serverLocation };
- errorMsgs.add(getMsg("directory-exists-not-empty", arg));
- displayFieldInvalid(FieldName.SERVER_LOCATION, true);
- } else if (!Utils.canWrite(serverLocation))
- {
- String[] arg =
- { serverLocation };
- errorMsgs.add(getMsg("directory-not-writable", arg));
- displayFieldInvalid(FieldName.SERVER_LOCATION, true);
-
- } else if (!Utils.hasEnoughSpace(serverLocation,
- getRequiredInstallSpace()))
- {
- long requiredInMb = getRequiredInstallSpace() / (1024 * 1024);
- String[] args =
- { serverLocation, String.valueOf(requiredInMb) };
- errorMsgs.add(getMsg("not-enough-disk-space", args));
- displayFieldInvalid(FieldName.SERVER_LOCATION, true);
-
- } else
- {
- application.getUserData().setServerLocation(serverLocation);
- displayFieldInvalid(FieldName.SERVER_LOCATION, false);
- }
- }
-
- // Check the port
- String sPort = getFieldStringValue(FieldName.SERVER_PORT);
- try
- {
- int port = Integer.parseInt(sPort);
- if ((port < MIN_PORT_VALUE) || (port > MAX_PORT_VALUE))
- {
- String[] args =
- { String.valueOf(MIN_PORT_VALUE), String.valueOf(MAX_PORT_VALUE) };
- errorMsgs.add(getMsg("invalid-port-value-range", args));
- displayFieldInvalid(FieldName.SERVER_PORT, true);
- } else if (!Utils.canUseAsPort(port))
- {
- if (Utils.isPriviledgedPort(port))
- {
- errorMsgs.add(getMsg("cannot-bind-priviledged-port", new String[]
- { String.valueOf(port) }));
- } else
- {
- errorMsgs.add(getMsg("cannot-bind-port", new String[]
- { String.valueOf(port) }));
- }
- displayFieldInvalid(FieldName.SERVER_PORT, true);
-
- } else
- {
- application.getUserData().setServerPort(port);
- displayFieldInvalid(FieldName.SERVER_PORT, false);
- }
-
- } catch (NumberFormatException nfe)
- {
- String[] args =
- { String.valueOf(MIN_PORT_VALUE), String.valueOf(MAX_PORT_VALUE) };
- errorMsgs.add(getMsg("invalid-port-value-range", args));
- displayFieldInvalid(FieldName.SERVER_PORT, true);
- }
-
- // Check the Directory Manager DN
- String dmDn = getFieldStringValue(FieldName.DIRECTORY_MANAGER_DN);
-
- if ((dmDn == null) || (dmDn.trim().length() == 0))
- {
- errorMsgs.add(getMsg("empty-directory-manager-dn"));
- displayFieldInvalid(FieldName.DIRECTORY_MANAGER_DN, true);
- } else if (!Utils.isDn(dmDn))
- {
- errorMsgs.add(getMsg("not-a-directory-manager-dn"));
- displayFieldInvalid(FieldName.DIRECTORY_MANAGER_DN, true);
- } else if (Utils.isConfigurationDn(dmDn))
- {
- errorMsgs.add(getMsg("directory-manager-dn-is-config-dn"));
- displayFieldInvalid(FieldName.DIRECTORY_MANAGER_DN, true);
- } else
- {
- application.getUserData().setDirectoryManagerDn(dmDn);
- displayFieldInvalid(FieldName.DIRECTORY_MANAGER_DN, false);
- }
-
- // Check the provided passwords
- String pwd1 = getFieldStringValue(FieldName.DIRECTORY_MANAGER_PWD);
- String pwd2 = getFieldStringValue(FieldName.DIRECTORY_MANAGER_PWD_CONFIRM);
- if (pwd1 == null)
- {
- pwd1 = "";
- }
-
- boolean pwdValid = true;
- if (!pwd1.equals(pwd2))
- {
- errorMsgs.add(getMsg("not-equal-pwd"));
- displayFieldInvalid(FieldName.DIRECTORY_MANAGER_PWD_CONFIRM, true);
- pwdValid = false;
-
- }
- if (pwd1.length() < MIN_DIRECTORY_MANAGER_PWD)
- {
- errorMsgs.add(getMsg(("pwd-too-short"), new String[]
- { String.valueOf(MIN_DIRECTORY_MANAGER_PWD) }));
- displayFieldInvalid(FieldName.DIRECTORY_MANAGER_PWD, true);
- if ((pwd2 == null) || (pwd2.length() < MIN_DIRECTORY_MANAGER_PWD))
- {
- displayFieldInvalid(FieldName.DIRECTORY_MANAGER_PWD_CONFIRM, true);
- }
- pwdValid = false;
- }
-
- if (pwdValid)
- {
- application.getUserData().setDirectoryManagerPwd(pwd1);
- displayFieldInvalid(FieldName.DIRECTORY_MANAGER_PWD, false);
- displayFieldInvalid(FieldName.DIRECTORY_MANAGER_PWD_CONFIRM, false);
- }
-
- int defaultJMXPort = UserData.getDefaultJMXPort();
- if (defaultJMXPort != -1)
- {
- application.getUserData().setServerJMXPort(defaultJMXPort);
- }
-
- if (errorMsgs.size() > 0)
- {
- throw new UserDataException(Step.SERVER_SETTINGS,
- Utils.getStringFromCollection(errorMsgs, "\n"));
- }
- }
-
- /**
- * Validate the data provided by the user in the data options panel and update
- * the userData object according to that content.
- *
- * @throws UserDataException if the data provided by the user is not
- * valid.
- *
- */
- private void updateUserDataForDataOptionsPanel()
- throws UserDataException {
- ArrayList<String> errorMsgs = new ArrayList<String>();
-
- DataOptions dataOptions = null;
-
- // Check the base dn
- boolean validBaseDn = false;
- String baseDn = getFieldStringValue(FieldName.DIRECTORY_BASE_DN);
- if ((baseDn == null) || (baseDn.trim().length() == 0))
- {
- errorMsgs.add(getMsg("empty-base-dn"));
- displayFieldInvalid(FieldName.DIRECTORY_BASE_DN, true);
- } else if (!Utils.isDn(baseDn))
- {
- errorMsgs.add(getMsg("not-a-base-dn"));
- displayFieldInvalid(FieldName.DIRECTORY_BASE_DN, true);
- } else if (Utils.isConfigurationDn(baseDn))
- {
- errorMsgs.add(getMsg("base-dn-is-configuration-dn"));
- displayFieldInvalid(FieldName.DIRECTORY_BASE_DN, true);
- } else
- {
- displayFieldInvalid(FieldName.DIRECTORY_BASE_DN, false);
- validBaseDn = true;
- }
-
- // Check the data options
- DataOptions.Type type =
- (DataOptions.Type) getFieldValue(FieldName.DATA_OPTIONS);
-
- switch (type)
- {
- case IMPORT_FROM_LDIF_FILE:
- String ldifPath = getFieldStringValue(FieldName.LDIF_PATH);
- if ((ldifPath == null) || (ldifPath.trim().equals("")))
- {
- errorMsgs.add(getMsg("no-ldif-path"));
- displayFieldInvalid(FieldName.LDIF_PATH, true);
- } else if (!Utils.fileExists(ldifPath))
- {
- errorMsgs.add(getMsg("ldif-file-does-not-exist"));
- displayFieldInvalid(FieldName.LDIF_PATH, true);
- } else if (validBaseDn)
- {
- dataOptions = new DataOptions(type, baseDn, ldifPath);
- displayFieldInvalid(FieldName.LDIF_PATH, false);
- }
- break;
-
- case IMPORT_AUTOMATICALLY_GENERATED_DATA:
- // variable used to know if everything went ok during these
- // checks
- int startErrors = errorMsgs.size();
-
- // Check the number of entries
- String nEntries = getFieldStringValue(FieldName.NUMBER_ENTRIES);
- if ((nEntries == null) || (nEntries.trim().equals("")))
- {
- errorMsgs.add(getMsg("no-number-entries"));
- displayFieldInvalid(FieldName.NUMBER_ENTRIES, true);
- } else
- {
- boolean nEntriesValid = false;
- try
- {
- int n = Integer.parseInt(nEntries);
-
- nEntriesValid = n >= MIN_NUMBER_ENTRIES && n <= MAX_NUMBER_ENTRIES;
- } catch (NumberFormatException nfe)
- {
- }
-
- if (!nEntriesValid)
- {
- String[] args =
- { String.valueOf(MIN_NUMBER_ENTRIES),
- String.valueOf(MAX_NUMBER_ENTRIES) };
- errorMsgs.add(getMsg("invalid-number-entries-range", args));
- displayFieldInvalid(FieldName.NUMBER_ENTRIES, true);
- } else
- {
- displayFieldInvalid(FieldName.NUMBER_ENTRIES, false);
- }
- }
- if (startErrors == errorMsgs.size() && validBaseDn)
- {
- // No validation errors
- dataOptions = new DataOptions(type, baseDn, new Integer(nEntries));
- }
- break;
-
- default:
- displayFieldInvalid(FieldName.LDIF_PATH, false);
- displayFieldInvalid(FieldName.NUMBER_ENTRIES, false);
- if (validBaseDn)
- {
- dataOptions = new DataOptions(type, baseDn);
- }
- }
-
- if (dataOptions != null)
- {
- application.getUserData().setDataOptions(dataOptions);
- }
-
- if (errorMsgs.size() > 0)
- {
- throw new UserDataException(Step.DATA_OPTIONS,
- Utils.getStringFromCollection(errorMsgs, "\n"));
- }
- }
-
- /**
- * Update the userData object according to the content of the review
- * panel.
- *
- */
- private void updateUserDataForReviewPanel()
- {
- Boolean b = (Boolean) getFieldValue(FieldName.SERVER_START);
- application.getUserData().setStartServer(b.booleanValue());
- }
-
- /**
- * Update the UserData object according to the content of the review
- * panel.
- *
- */
- private void updateUserUninstallDataForConfirmUninstallPanel()
- throws UserDataException
- {
-
- // TODO: move this to the Uninstall application
-
- UninstallUserData uud = (UninstallUserData)application.getUserData();
- uud.setRemoveLibrariesAndTools(
- (Boolean)getFieldValue(FieldName.REMOVE_LIBRARIES_AND_TOOLS));
- uud.setRemoveDatabases(
- (Boolean)getFieldValue(FieldName.REMOVE_DATABASES));
- uud.setRemoveConfigurationAndSchema(
- (Boolean)getFieldValue(FieldName.REMOVE_CONFIGURATION_AND_SCHEMA));
- uud.setRemoveBackups(
- (Boolean)getFieldValue(FieldName.REMOVE_BACKUPS));
- uud.setRemoveLDIFs(
- (Boolean)getFieldValue(FieldName.REMOVE_LDIFS));
- uud.setRemoveLogs(
- (Boolean)getFieldValue(FieldName.REMOVE_LOGS));
-
- Set<String> dbs = new HashSet<String>();
- Set s = (Set)getFieldValue(FieldName.EXTERNAL_DB_DIRECTORIES);
- for (Object v: s)
- {
- dbs.add((String)v);
- }
-
- Set<String> logs = new HashSet<String>();
- s = (Set)getFieldValue(FieldName.EXTERNAL_LOG_FILES);
- for (Object v: s)
- {
- logs.add((String)v);
- }
-
- uud.setExternalDbsToRemove(dbs);
- uud.setExternalLogsToRemove(logs);
-
- if ((dbs.size() == 0) &&
- (logs.size() == 0) &&
- !uud.getRemoveLibrariesAndTools() &&
- !uud.getRemoveDatabases() &&
- !uud.getRemoveConfigurationAndSchema() &&
- !uud.getRemoveBackups() &&
- !uud.getRemoveLDIFs() &&
- !uud.getRemoveLogs())
- {
- throw new UserDataException(Step.CONFIRM_UNINSTALL,
- getMsg("nothing-selected-to-uninstall"));
- }
- }
-
- /**
* Launch the installation of Open DS. Depending on whether we are running a
* web start or not it will use on Installer object or other.
*
*/
- private void launchInstallation()
+ public void launchInstallation()
{
ProgressMessageFormatter formatter = getDialog().getFormatter();
@@ -1041,7 +449,7 @@
* Launch the uninstallation of Open DS.
*
*/
- private void launchUninstallation()
+ public void launchUninstallation()
{
application.addProgressUpdateListener(this);
new Thread(application).start();
@@ -1100,7 +508,7 @@
*
* @return the currently displayed Step of the wizard.
*/
- private Step getCurrentStep()
+ private WizardStep getCurrentStep()
{
return currentStep;
}
@@ -1112,7 +520,7 @@
*
* @param step The step to be displayed.
*/
- public void setCurrentStep(Step step)
+ public void setCurrentStep(WizardStep step)
{
if (step == null)
{
@@ -1123,60 +531,11 @@
}
/**
- * Gets the next step corresponding to the step passed as parameter.
- *
- * @param step the step of which we want to get the new step.
- * @return the next step for the current step.
- */
- public Step nextStep(Step step)
- {
- Step nextStep;
- if (step == Step.CONFIRM_UNINSTALL)
- {
- nextStep = Step.PROGRESS;
- }
- else
- {
- Iterator<Step> it = EnumSet.range(step, Step.PROGRESS).iterator();
- it.next();
- if (!it.hasNext())
- {
- throw new IllegalArgumentException("No next for step: " + step);
- }
- nextStep = it.next();
- }
- return nextStep;
- }
-
- /**
- * Gets the previous step corresponding to the step passed as parameter.
- *
- * @param step,
- * the step of which we want to get the previous step.
- * @return the next step for the current step.
- * @throws IllegalArgumentException
- * if the current step has not a previous step.
- */
- private Step previousStep(Step step)
- {
- Step previous = null;
- for (Step s : Step.values())
- {
- if (s == step)
- {
- return previous;
- }
- previous = s;
- }
- throw new IllegalArgumentException("No previous for step: " + step);
- }
-
- /**
* Get the dialog that is displayed.
*
* @return the dialog.
*/
- private QuickSetupDialog getDialog()
+ public QuickSetupDialog getDialog()
{
if (dialog == null)
{
@@ -1222,7 +581,7 @@
* the field name object.
* @return the string value for the field name.
*/
- private String getFieldStringValue(FieldName fieldName)
+ public String getFieldStringValue(FieldName fieldName)
{
String sValue = null;
@@ -1247,7 +606,7 @@
* the field name object.
* @return the value for the field name.
*/
- private Object getFieldValue(FieldName fieldName)
+ public Object getFieldValue(FieldName fieldName)
{
return getDialog().getFieldValue(fieldName);
}
@@ -1263,7 +622,7 @@
* @param invalid
* whether to mark the field valid or invalid.
*/
- private void displayFieldInvalid(FieldName fieldName, boolean invalid)
+ public void displayFieldInvalid(FieldName fieldName, boolean invalid)
{
getDialog().displayFieldInvalid(fieldName, invalid);
}
@@ -1313,22 +672,7 @@
{
return Utils.isWebStart();
}
-
- /**
- * Returns the number of free disk space in bytes required to install Open DS
- *
- * For the moment we just return 15 Megabytes. TODO we might want to have
- * something dynamic to calculate the required free disk space for the
- * installation.
- *
- * @return the number of free disk space required to install Open DS.
- */
- private long getRequiredInstallSpace()
- {
- return 15 * 1024 * 1024;
- }
}
-
/**
* This class is just used to specify which are the default values that will be
* proposed to the user in the Data Options panel of the Installation wizard.
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Step.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Step.java
index 20ebe82..5569240 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Step.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Step.java
@@ -32,7 +32,7 @@
* the installation and uninstallation wizards.
*
*/
-public enum Step
+public enum Step implements WizardStep
{
/**
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserData.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserData.java
index 18cb4d2..59791bc 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserData.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserData.java
@@ -48,6 +48,8 @@
* Creates a user data object with default values.
*/
public UserData() {
+ startServer = true;
+
DataOptions defaultDataOptions = new DefaultDataOptions();
setServerLocation(Utils.getDefaultServerLocation());
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserDataException.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserDataException.java
index 2fcf813..26df344 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserDataException.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserDataException.java
@@ -37,7 +37,7 @@
{
private static final long serialVersionUID = 1798143194655443132L;
- private Step step;
+ private WizardStep step;
private String localizedMessage;
@@ -46,7 +46,7 @@
* @param step the step in the wizard where the exception occurred.
* @param localizedMessage the localized message describing the error.
*/
- public UserDataException(Step step, String localizedMessage)
+ public UserDataException(WizardStep step, String localizedMessage)
{
super(localizedMessage);
this.step = step;
@@ -66,7 +66,7 @@
* Returns the step of the wizard in which this exception occurred.
* @return the step of the wizard in which this exception occurred.
*/
- public Step getStep()
+ public WizardStep getStep()
{
return step;
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/WizardStep.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/WizardStep.java
new file mode 100644
index 0000000..9c255fc
--- /dev/null
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/WizardStep.java
@@ -0,0 +1,42 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE
+ * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * When distributing Covered Code, include this CDDL HEADER in each
+ * file and include the License file at
+ * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
+ * add the following below this CDDL HEADER, with the fields enclosed
+ * by brackets "[]" replaced with your own identifying information:
+ * Portions Copyright [yyyy] [name of copyright owner]
+ *
+ * CDDL HEADER END
+ *
+ *
+ * Portions Copyright 2007 Sun Microsystems, Inc.
+ */
+
+package org.opends.quicksetup;
+
+/**
+ * Step in a QuickSetup wizard application.
+ */
+public interface WizardStep {
+
+ /**
+ * Gets the message key associated with the display name of this step.
+ * @return String message key for accessing this step's display name
+ * in a message bundle
+ */
+ String getMessageKey();
+
+}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
index b9690c0..47b6a25 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java
@@ -26,14 +26,11 @@
*/
package org.opends.quicksetup.installer;
-import static org.opends.quicksetup.Step.WELCOME;
+import static org.opends.quicksetup.Step.*;
import java.io.File;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.Set;
-import java.util.EnumSet;
+import java.util.*;
import java.awt.event.WindowEvent;
import org.opends.quicksetup.ui.*;
@@ -65,6 +62,19 @@
/* Indicates that we've detected that there is something installed */
boolean forceToDisplaySetup = false;
+ // Constants used to do checks
+ private static final int MIN_DIRECTORY_MANAGER_PWD = 1;
+
+ private static final int MIN_PORT_VALUE = 1;
+
+ private static final int MAX_PORT_VALUE = 65535;
+
+ private static final int MIN_NUMBER_ENTRIES = 1;
+
+ private static final int MAX_NUMBER_ENTRIES = 10000;
+
+ private List<WizardStep> lstSteps = new ArrayList<WizardStep>();
+
/**
* An static String that contains the class name of ConfigFileHandler.
*/
@@ -72,6 +82,17 @@
"org.opends.server.extensions.ConfigFileHandler";
/**
+ * Creates a default instance.
+ */
+ public Installer() {
+ lstSteps.add(WELCOME);
+ lstSteps.add(SERVER_SETTINGS);
+ lstSteps.add(DATA_OPTIONS);
+ lstSteps.add(REVIEW);
+ lstSteps.add(PROGRESS);
+ }
+
+ /**
* {@inheritDoc}
*/
public void forceToDisplay() {
@@ -81,6 +102,127 @@
/**
* {@inheritDoc}
*/
+ public boolean canGoBack(WizardStep step) {
+ return step != WELCOME &&
+ step != PROGRESS;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canGoForward(WizardStep step) {
+ return step != REVIEW &&
+ step != PROGRESS;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canFinish(WizardStep step) {
+ return step == REVIEW;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canQuit(WizardStep step) {
+ return step != PROGRESS;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canClose(WizardStep step) {
+ return step == PROGRESS;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canCancel(WizardStep step) {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void previousClicked(WizardStep cStep) {
+ if (cStep == WELCOME) {
+ throw new IllegalStateException(
+ "Cannot click on previous from progress step");
+ } else if (cStep == PROGRESS) {
+ throw new IllegalStateException(
+ "Cannot click on previous from progress step");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void finishClicked(final WizardStep cStep, final QuickSetup qs) {
+ if (cStep == Step.REVIEW) {
+ updateUserDataForReviewPanel(qs);
+ qs.launchInstallation();
+ qs.setCurrentStep(Step.PROGRESS);
+ } else {
+ throw new IllegalStateException(
+ "Cannot click on finish when we are not in the Review window");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void nextClicked(WizardStep cStep, QuickSetup qs) {
+ if (cStep == PROGRESS) {
+ throw new IllegalStateException(
+ "Cannot click on next from progress step");
+ } else if (cStep == REVIEW) {
+ throw new IllegalStateException("Cannot click on next from review step");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void closeClicked(WizardStep cStep, QuickSetup qs) {
+ if (cStep == PROGRESS) {
+ if (isFinished()
+ || qs.displayConfirmation(getMsg("confirm-close-install-msg"),
+ getMsg("confirm-close-install-title"))) {
+ qs.quit();
+ }
+ } else {
+ throw new IllegalStateException(
+ "Close only can be clicked on PROGRESS step");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void cancelClicked(WizardStep cStep, QuickSetup qs) {
+ // do nothing;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void quitClicked(WizardStep cStep, QuickSetup qs) {
+ if (cStep == PROGRESS) {
+ throw new IllegalStateException(
+ "Cannot click on quit from progress step");
+ } else if (installStatus.isInstalled()) {
+ qs.quit();
+ } else if (qs.displayConfirmation(getMsg("confirm-quit-install-msg"),
+ getMsg("confirm-quit-install-title"))) {
+ qs.quit();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public ButtonName getInitialFocusButtonName() {
ButtonName name = null;
if (!installStatus.isInstalled() || forceToDisplaySetup)
@@ -118,35 +260,25 @@
/**
* {@inheritDoc}
*/
- public Set<Step> getWizardSteps() {
- return EnumSet.of(WELCOME,
- Step.SERVER_SETTINGS,
- Step.DATA_OPTIONS,
- Step.REVIEW,
- Step.PROGRESS);
+ public Set<WizardStep> getWizardSteps() {
+ return Collections.unmodifiableSet(new HashSet<WizardStep>(lstSteps));
}
/**
* {@inheritDoc}
*/
- public QuickSetupStepPanel createWizardStepPanel(Step step) {
+ public QuickSetupStepPanel createWizardStepPanel(WizardStep step) {
QuickSetupStepPanel p = null;
- switch (step) {
- case WELCOME:
+ if (step == WELCOME) {
p = new InstallWelcomePanel();
- break;
- case SERVER_SETTINGS:
+ } else if (step == SERVER_SETTINGS) {
p = new ServerSettingsPanel(getUserData());
- break;
- case DATA_OPTIONS:
+ } else if (step == DATA_OPTIONS) {
p = new DataOptionsPanel(getUserData());
- break;
- case REVIEW:
+ } else if (step == REVIEW) {
p = new ReviewPanel(getUserData());
- break;
- case PROGRESS:
+ } else if (step == PROGRESS) {
p = new ProgressPanel();
- break;
}
return p;
}
@@ -173,6 +305,27 @@
/**
* {@inheritDoc}
*/
+ public String getCloseButtonToolTip() {
+ return "close-button-install-tooltip";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getFinishButtonToolTip() {
+ return "finish-button-install-tooltip";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void previousClicked(WizardStep cStep, QuickSetup qs) {
+ // do nothing;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public String getFrameTitle() {
return getMsg("frame-install-title");
}
@@ -186,45 +339,28 @@
*/
protected void setWizardDialogState(QuickSetupDialog dlg,
UserData userData,
- Step step) {
+ WizardStep step) {
if (!installStatus.isInstalled() || forceToDisplaySetup) {
// Set the default button for the frame
- switch (step) {
- case REVIEW:
+ if (step == REVIEW) {
dlg.setDefaultButton(ButtonName.FINISH);
- break;
-
- case PROGRESS:
- dlg.setDefaultButton(ButtonName.CLOSE);
- break;
-
- default:
- dlg.setDefaultButton(ButtonName.NEXT);
- }
-
- // Set the focus for the current step
- switch (step) {
- case WELCOME:
- dlg.setFocusOnButton(ButtonName.NEXT);
- break;
-
- case SERVER_SETTINGS:
- // The focus is set by the panel itself
- break;
-
- case DATA_OPTIONS:
- // The focus is set by the panel itself
- break;
-
- case REVIEW:
dlg.setFocusOnButton(ButtonName.FINISH);
- break;
-
- case PROGRESS:
- dlg.setFocusOnButton(ButtonName.CLOSE);
- dlg.setButtonEnabled(ButtonName.CLOSE, false);
- break;
+ } else if (step == PROGRESS) {
+ dlg.setDefaultButton(ButtonName.CLOSE);
+ } else if (step == WELCOME) {
+ dlg.setFocusOnButton(ButtonName.NEXT);
+ } else if (step == SERVER_SETTINGS) {
+ // The focus is set by the panel itself
+ } else if (step == DATA_OPTIONS) {
+ // The focus is set by the panel itself
+ } else if (step == REVIEW) {
+ // do nothing?
+ } else if (step == PROGRESS) {
+ dlg.setFocusOnButton(ButtonName.CLOSE);
+ dlg.setButtonEnabled(ButtonName.CLOSE, false);
+ } else {
+ dlg.setDefaultButton(ButtonName.NEXT);
}
}
}
@@ -240,27 +376,32 @@
/**
* {@inheritDoc}
*/
- public Step getFirstWizardStep() {
+ public WizardStep getFirstWizardStep() {
return WELCOME;
}
/**
* {@inheritDoc}
*/
- public Step getNextWizardStep(Step step) {
- Step nextStep = null;
- if (step != null) {
- if (step.equals(Step.WELCOME)) {
- nextStep = Step.SERVER_SETTINGS;
- } else if (step.equals(Step.SERVER_SETTINGS)) {
- nextStep = Step.DATA_OPTIONS;
- } else if (step.equals(Step.DATA_OPTIONS)) {
- nextStep = Step.REVIEW;
- } else if (step.equals(Step.REVIEW)) {
- nextStep = Step.PROGRESS;
- }
+ public WizardStep getNextWizardStep(WizardStep step) {
+ WizardStep next = null;
+ int i = lstSteps.indexOf(step);
+ if (i != -1 && i + 1 < lstSteps.size()) {
+ next = lstSteps.get(i + 1);
}
- return nextStep;
+ return next;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public WizardStep getPreviousWizardStep(WizardStep step) {
+ WizardStep prev = null;
+ int i = lstSteps.indexOf(step);
+ if (i != -1 && i > 0) {
+ prev = lstSteps.get(i - 1);
+ }
+ return prev;
}
/**
@@ -559,6 +700,29 @@
}
/**
+ * These methods validate the data provided by the user in the panels and
+ * update the userData object according to that content.
+ *
+ * @param cStep
+ * the current step of the wizard
+ * @param qs QuickStart controller
+ * @throws UserDataException if the data provided by the user is not
+ * valid.
+ *
+ */
+ protected void updateUserData(WizardStep cStep, QuickSetup qs)
+ throws UserDataException
+ {
+ if (cStep == SERVER_SETTINGS) {
+ updateUserDataForServerSettingsPanel(qs);
+ } else if (cStep == DATA_OPTIONS) {
+ updateUserDataForDataOptionsPanel(qs);
+ } else if (cStep == REVIEW) {
+ updateUserDataForReviewPanel(qs);
+ }
+ }
+
+ /**
* Returns the default backend name (the one that will be created).
* @return the default backend name (the one that will be created).
*/
@@ -575,4 +739,321 @@
return Utils.getPath(getInstallationPath(),
Utils.getBinariesRelativePath());
}
+
+ /**
+ * Validate the data provided by the user in the server settings panel and
+ * update the userData object according to that content.
+ *
+ * @throws UserDataException if the data provided by the user is not
+ * valid.
+ *
+ */
+ private void updateUserDataForServerSettingsPanel(QuickSetup qs)
+ throws UserDataException {
+ ArrayList<String> errorMsgs = new ArrayList<String>();
+
+ if (Utils.isWebStart())
+ {
+ // Check the server location
+ String serverLocation = qs.getFieldStringValue(FieldName.SERVER_LOCATION);
+
+ if ((serverLocation == null) || ("".equals(serverLocation.trim())))
+ {
+ errorMsgs.add(getMsg("empty-server-location"));
+ qs.displayFieldInvalid(FieldName.SERVER_LOCATION, true);
+ } else if (!Utils.parentDirectoryExists(serverLocation))
+ {
+ String[] arg =
+ { serverLocation };
+ errorMsgs.add(getMsg("parent-directory-does-not-exist", arg));
+ qs.displayFieldInvalid(FieldName.SERVER_LOCATION, true);
+ } else if (Utils.fileExists(serverLocation))
+ {
+ String[] arg =
+ { serverLocation };
+ errorMsgs.add(getMsg("file-exists", arg));
+ qs.displayFieldInvalid(FieldName.SERVER_LOCATION, true);
+ } else if (Utils.directoryExistsAndIsNotEmpty(serverLocation))
+ {
+ String[] arg =
+ { serverLocation };
+ errorMsgs.add(getMsg("directory-exists-not-empty", arg));
+ qs.displayFieldInvalid(FieldName.SERVER_LOCATION, true);
+ } else if (!Utils.canWrite(serverLocation))
+ {
+ String[] arg =
+ { serverLocation };
+ errorMsgs.add(getMsg("directory-not-writable", arg));
+ qs.displayFieldInvalid(FieldName.SERVER_LOCATION, true);
+
+ } else if (!Utils.hasEnoughSpace(serverLocation,
+ getRequiredInstallSpace()))
+ {
+ long requiredInMb = getRequiredInstallSpace() / (1024 * 1024);
+ String[] args =
+ { serverLocation, String.valueOf(requiredInMb) };
+ errorMsgs.add(getMsg("not-enough-disk-space", args));
+ qs.displayFieldInvalid(FieldName.SERVER_LOCATION, true);
+
+ } else
+ {
+ getUserData().setServerLocation(serverLocation);
+ qs.displayFieldInvalid(FieldName.SERVER_LOCATION, false);
+ }
+ }
+
+ // Check the port
+ String sPort = qs.getFieldStringValue(FieldName.SERVER_PORT);
+ try
+ {
+ int port = Integer.parseInt(sPort);
+ if ((port < MIN_PORT_VALUE) || (port > MAX_PORT_VALUE))
+ {
+ String[] args =
+ { String.valueOf(MIN_PORT_VALUE), String.valueOf(MAX_PORT_VALUE) };
+ errorMsgs.add(getMsg("invalid-port-value-range", args));
+ qs.displayFieldInvalid(FieldName.SERVER_PORT, true);
+ } else if (!Utils.canUseAsPort(port))
+ {
+ if (Utils.isPriviledgedPort(port))
+ {
+ errorMsgs.add(getMsg("cannot-bind-priviledged-port", new String[]
+ { String.valueOf(port) }));
+ } else
+ {
+ errorMsgs.add(getMsg("cannot-bind-port", new String[]
+ { String.valueOf(port) }));
+ }
+ qs.displayFieldInvalid(FieldName.SERVER_PORT, true);
+
+ } else
+ {
+ getUserData().setServerPort(port);
+ qs.displayFieldInvalid(FieldName.SERVER_PORT, false);
+ }
+
+ } catch (NumberFormatException nfe)
+ {
+ String[] args =
+ { String.valueOf(MIN_PORT_VALUE), String.valueOf(MAX_PORT_VALUE) };
+ errorMsgs.add(getMsg("invalid-port-value-range", args));
+ qs.displayFieldInvalid(FieldName.SERVER_PORT, true);
+ }
+
+ // Check the Directory Manager DN
+ String dmDn = qs.getFieldStringValue(FieldName.DIRECTORY_MANAGER_DN);
+
+ if ((dmDn == null) || (dmDn.trim().length() == 0))
+ {
+ errorMsgs.add(getMsg("empty-directory-manager-dn"));
+ qs.displayFieldInvalid(FieldName.DIRECTORY_MANAGER_DN, true);
+ } else if (!Utils.isDn(dmDn))
+ {
+ errorMsgs.add(getMsg("not-a-directory-manager-dn"));
+ qs.displayFieldInvalid(FieldName.DIRECTORY_MANAGER_DN, true);
+ } else if (Utils.isConfigurationDn(dmDn))
+ {
+ errorMsgs.add(getMsg("directory-manager-dn-is-config-dn"));
+ qs.displayFieldInvalid(FieldName.DIRECTORY_MANAGER_DN, true);
+ } else
+ {
+ getUserData().setDirectoryManagerDn(dmDn);
+ qs.displayFieldInvalid(FieldName.DIRECTORY_MANAGER_DN, false);
+ }
+
+ // Check the provided passwords
+ String pwd1 = qs.getFieldStringValue(FieldName.DIRECTORY_MANAGER_PWD);
+ String pwd2 =
+ qs.getFieldStringValue(FieldName.DIRECTORY_MANAGER_PWD_CONFIRM);
+ if (pwd1 == null)
+ {
+ pwd1 = "";
+ }
+
+ boolean pwdValid = true;
+ if (!pwd1.equals(pwd2))
+ {
+ errorMsgs.add(getMsg("not-equal-pwd"));
+ qs.displayFieldInvalid(FieldName.DIRECTORY_MANAGER_PWD_CONFIRM, true);
+ pwdValid = false;
+
+ }
+ if (pwd1.length() < MIN_DIRECTORY_MANAGER_PWD)
+ {
+ errorMsgs.add(getMsg(("pwd-too-short"), new String[]
+ { String.valueOf(MIN_DIRECTORY_MANAGER_PWD) }));
+ qs.displayFieldInvalid(FieldName.DIRECTORY_MANAGER_PWD, true);
+ if ((pwd2 == null) || (pwd2.length() < MIN_DIRECTORY_MANAGER_PWD))
+ {
+ qs.displayFieldInvalid(FieldName.DIRECTORY_MANAGER_PWD_CONFIRM, true);
+ }
+ pwdValid = false;
+ }
+
+ if (pwdValid)
+ {
+ getUserData().setDirectoryManagerPwd(pwd1);
+ qs.displayFieldInvalid(FieldName.DIRECTORY_MANAGER_PWD, false);
+ qs.displayFieldInvalid(FieldName.DIRECTORY_MANAGER_PWD_CONFIRM, false);
+ }
+
+ int defaultJMXPort = UserData.getDefaultJMXPort();
+ if (defaultJMXPort != -1)
+ {
+ getUserData().setServerJMXPort(defaultJMXPort);
+ }
+
+ if (errorMsgs.size() > 0)
+ {
+ throw new UserDataException(Step.SERVER_SETTINGS,
+ Utils.getStringFromCollection(errorMsgs, "\n"));
+ }
+ }
+
+ /**
+ * Validate the data provided by the user in the data options panel and update
+ * the userData object according to that content.
+ *
+ * @throws UserDataException if the data provided by the user is not
+ * valid.
+ *
+ */
+ private void updateUserDataForDataOptionsPanel(QuickSetup qs)
+ throws UserDataException {
+ ArrayList<String> errorMsgs = new ArrayList<String>();
+
+ DataOptions dataOptions = null;
+
+ // Check the base dn
+ boolean validBaseDn = false;
+ String baseDn = qs.getFieldStringValue(FieldName.DIRECTORY_BASE_DN);
+ if ((baseDn == null) || (baseDn.trim().length() == 0))
+ {
+ errorMsgs.add(getMsg("empty-base-dn"));
+ qs.displayFieldInvalid(FieldName.DIRECTORY_BASE_DN, true);
+ } else if (!Utils.isDn(baseDn))
+ {
+ errorMsgs.add(getMsg("not-a-base-dn"));
+ qs.displayFieldInvalid(FieldName.DIRECTORY_BASE_DN, true);
+ } else if (Utils.isConfigurationDn(baseDn))
+ {
+ errorMsgs.add(getMsg("base-dn-is-configuration-dn"));
+ qs.displayFieldInvalid(FieldName.DIRECTORY_BASE_DN, true);
+ } else
+ {
+ qs.displayFieldInvalid(FieldName.DIRECTORY_BASE_DN, false);
+ validBaseDn = true;
+ }
+
+ // Check the data options
+ DataOptions.Type type =
+ (DataOptions.Type) qs.getFieldValue(FieldName.DATA_OPTIONS);
+
+ switch (type)
+ {
+ case IMPORT_FROM_LDIF_FILE:
+ String ldifPath = qs.getFieldStringValue(FieldName.LDIF_PATH);
+ if ((ldifPath == null) || (ldifPath.trim().equals("")))
+ {
+ errorMsgs.add(getMsg("no-ldif-path"));
+ qs.displayFieldInvalid(FieldName.LDIF_PATH, true);
+ } else if (!Utils.fileExists(ldifPath))
+ {
+ errorMsgs.add(getMsg("ldif-file-does-not-exist"));
+ qs.displayFieldInvalid(FieldName.LDIF_PATH, true);
+ } else if (validBaseDn)
+ {
+ dataOptions = new DataOptions(type, baseDn, ldifPath);
+ qs.displayFieldInvalid(FieldName.LDIF_PATH, false);
+ }
+ break;
+
+ case IMPORT_AUTOMATICALLY_GENERATED_DATA:
+ // variable used to know if everything went ok during these
+ // checks
+ int startErrors = errorMsgs.size();
+
+ // Check the number of entries
+ String nEntries = qs.getFieldStringValue(FieldName.NUMBER_ENTRIES);
+ if ((nEntries == null) || (nEntries.trim().equals("")))
+ {
+ errorMsgs.add(getMsg("no-number-entries"));
+ qs.displayFieldInvalid(FieldName.NUMBER_ENTRIES, true);
+ } else
+ {
+ boolean nEntriesValid = false;
+ try
+ {
+ int n = Integer.parseInt(nEntries);
+
+ nEntriesValid = n >= MIN_NUMBER_ENTRIES && n <= MAX_NUMBER_ENTRIES;
+ } catch (NumberFormatException nfe)
+ {
+ }
+
+ if (!nEntriesValid)
+ {
+ String[] args =
+ { String.valueOf(MIN_NUMBER_ENTRIES),
+ String.valueOf(MAX_NUMBER_ENTRIES) };
+ errorMsgs.add(getMsg("invalid-number-entries-range", args));
+ qs.displayFieldInvalid(FieldName.NUMBER_ENTRIES, true);
+ } else
+ {
+ qs.displayFieldInvalid(FieldName.NUMBER_ENTRIES, false);
+ }
+ }
+ if (startErrors == errorMsgs.size() && validBaseDn)
+ {
+ // No validation errors
+ dataOptions = new DataOptions(type, baseDn, new Integer(nEntries));
+ }
+ break;
+
+ default:
+ qs.displayFieldInvalid(FieldName.LDIF_PATH, false);
+ qs.displayFieldInvalid(FieldName.NUMBER_ENTRIES, false);
+ if (validBaseDn)
+ {
+ dataOptions = new DataOptions(type, baseDn);
+ }
+ }
+
+ if (dataOptions != null)
+ {
+ getUserData().setDataOptions(dataOptions);
+ }
+
+ if (errorMsgs.size() > 0)
+ {
+ throw new UserDataException(Step.DATA_OPTIONS,
+ Utils.getStringFromCollection(errorMsgs, "\n"));
+ }
+ }
+
+ /**
+ * Update the userData object according to the content of the review
+ * panel.
+ *
+ */
+ private void updateUserDataForReviewPanel(QuickSetup qs)
+ {
+ Boolean b = (Boolean) qs.getFieldValue(FieldName.SERVER_START);
+ getUserData().setStartServer(b.booleanValue());
+ }
+
+ /**
+ * Returns the number of free disk space in bytes required to install Open DS
+ *
+ * For the moment we just return 15 Megabytes. TODO we might want to have
+ * something dynamic to calculate the required free disk space for the
+ * installation.
+ *
+ * @return the number of free disk space required to install Open DS.
+ */
+ private long getRequiredInstallSpace()
+ {
+ return 15 * 1024 * 1024;
+ }
+
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java
index ec3d44c..80995f4 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/offline/OfflineInstaller.java
@@ -156,7 +156,7 @@
* Initialize the different map used in this class.
*
*/
- private void initMaps()
+ protected void initMaps()
{
initSummaryMap(hmSummary);
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
index 7be0483..d3b29ec 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties
@@ -187,11 +187,14 @@
next-button-tooltip=Go to Next Step
previous-button-label=< Previous
previous-button-tooltip=Go to Previous Step
+finish-button-label=Finish
finish-button-install-label=Finish
finish-button-uninstall-label=Uninstall
finish-button-install-tooltip=Finish Installation and Setup
finish-button-uninstall-tooltip=Finish Uninstall
+finish-button-tooltip=Finish QuickSetup
close-button-label=Close
+close-button-tooltip=Close QuickSetup Window
close-button-install-tooltip=Close QuickSetup Window
close-button-uninstall-tooltip=Close Uninstall Window
quit-button-label=Quit
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/ButtonsPanel.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/ButtonsPanel.java
index 5f16a82..5ef5d89 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/ButtonsPanel.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/ButtonsPanel.java
@@ -39,10 +39,12 @@
import javax.swing.JPanel;
import org.opends.quicksetup.ButtonName;
-import org.opends.quicksetup.Step;
+import org.opends.quicksetup.WizardStep;
+import org.opends.quicksetup.Application;
+import org.opends.quicksetup.uninstaller.Uninstaller;
+import org.opends.quicksetup.installer.Installer;
import org.opends.quicksetup.event.ButtonActionListener;
import org.opends.quicksetup.event.ButtonEvent;
-import org.opends.quicksetup.util.Utils;
/**
* This class contains the buttons in the bottom of the Install/Uninstall
@@ -69,12 +71,16 @@
private JButton cancelButton;
+ private Application application;
+
/**
* Default constructor.
+ * @param application Application running in QuickSetup
*
*/
- public ButtonsPanel()
+ public ButtonsPanel(Application application)
{
+ this.application = application;
createButtons();
layoutButtons();
}
@@ -104,66 +110,14 @@
*
* @param step the step in the wizard.
*/
- public void setDisplayedStep(Step step)
+ public void setDisplayedStep(WizardStep step)
{
- switch (step)
- {
- case WELCOME:
-
- previousButton.setVisible(false);
- nextButton.setVisible(true);
- finishButton.setVisible(false);
- quitButton.setVisible(true);
- closeButton.setVisible(false);
- cancelButton.setVisible(false);
-
- break;
-
- case REVIEW:
-
- previousButton.setVisible(true);
- nextButton.setVisible(false);
- finishButton.setVisible(true);
- quitButton.setVisible(true);
- closeButton.setVisible(false);
- cancelButton.setVisible(false);
-
- break;
-
- case PROGRESS:
-
- // TO COMPLETE: if there is an error we might want to change
- // this
- // like for instance coming back
- previousButton.setVisible(false);
- nextButton.setVisible(false);
- finishButton.setVisible(false);
- quitButton.setVisible(false);
- closeButton.setVisible(true);
- cancelButton.setVisible(false);
-
- break;
-
- case CONFIRM_UNINSTALL:
-
- previousButton.setVisible(false);
- nextButton.setVisible(false);
- finishButton.setVisible(true);
- quitButton.setVisible(false);
- closeButton.setVisible(false);
- cancelButton.setVisible(true);
-
- break;
-
- default:
-
- previousButton.setVisible(true);
- nextButton.setVisible(true);
- finishButton.setVisible(false);
- quitButton.setVisible(true);
- closeButton.setVisible(false);
- cancelButton.setVisible(false);
- }
+ previousButton.setVisible(application.canGoBack(step));
+ nextButton.setVisible(application.canGoForward(step));
+ finishButton.setVisible(application.canFinish(step));
+ quitButton.setVisible(application.canQuit(step));
+ closeButton.setVisible(application.canClose(step));
+ cancelButton.setVisible(application.canCancel(step));
}
/**
@@ -227,14 +181,11 @@
quitButton =
createButton("quit-button-label", tooltip, ButtonName.QUIT);
- tooltip = Utils.isUninstall()?
- "close-button-uninstall-tooltip":"close-button-install-tooltip";
+ tooltip = application.getCloseButtonToolTip();
closeButton = createButton("close-button-label", tooltip, ButtonName.CLOSE);
- String label = Utils.isUninstall()?
- "finish-button-uninstall-label":"finish-button-install-label";
- tooltip = Utils.isUninstall()?
- "finish-button-uninstall-tooltip":"finish-button-install-tooltip";
+ String label = application.getFinishButtonLabel();
+ tooltip = application.getFinishButtonToolTip();
finishButton = createButton(label, tooltip, ButtonName.FINISH);
cancelButton =
@@ -275,8 +226,9 @@
// Set as opaque to inherit the background color of ButtonsPanel
nextFinishPanel.setOpaque(false);
nextFinishPanel.add(nextButton, gbcAux);
- if (!Utils.isUninstall())
- {
+
+ // TODO: remove this hack
+ if (application instanceof Installer) {
nextFinishPanel.add(finishButton, gbcAux);
}
width =
@@ -295,8 +247,9 @@
gbc.weightx = 0.0;
gbc.fill = GridBagConstraints.NONE;
gbc.insets.left = UIFactory.HORIZONTAL_INSET_BETWEEN_BUTTONS;
- if (Utils.isUninstall())
- {
+
+ // TODO: remove this hack
+ if (application instanceof Uninstaller) {
gbc.insets.right = UIFactory.HORIZONTAL_INSET_BETWEEN_BUTTONS;
add(finishButton, gbc);
gbc.insets.right = 0;
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/CurrentStepPanel.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/CurrentStepPanel.java
index a1eea93..86d2b1c 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/CurrentStepPanel.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/CurrentStepPanel.java
@@ -35,8 +35,8 @@
import org.opends.quicksetup.event.ButtonActionListener;
import org.opends.quicksetup.installer.FieldName;
+import org.opends.quicksetup.installer.Installer;
import org.opends.quicksetup.*;
-import org.opends.quicksetup.util.Utils;
/**
* This is the class that contains the panel on the right-top part of the
@@ -55,8 +55,10 @@
{
private static final long serialVersionUID = 5474803491510999334L;
- private HashMap<Step, QuickSetupStepPanel> hmPanels =
- new HashMap<Step, QuickSetupStepPanel>();
+ private HashMap<WizardStep, QuickSetupStepPanel> hmPanels =
+ new HashMap<WizardStep, QuickSetupStepPanel>();
+
+ private Application application;
/**
* The constructor of this class.
@@ -64,6 +66,7 @@
*/
public CurrentStepPanel(Application app)
{
+ this.application = app;
createLayout(app);
}
@@ -75,7 +78,7 @@
public Object getFieldValue(FieldName fieldName)
{
Object value = null;
- for (Step s : hmPanels.keySet())
+ for (WizardStep s : hmPanels.keySet())
{
value = getPanel(s).getFieldValue(fieldName);
if (value != null)
@@ -96,7 +99,7 @@
*/
public void displayFieldInvalid(FieldName fieldName, boolean invalid)
{
- for (Step s : hmPanels.keySet())
+ for (WizardStep s : hmPanels.keySet())
{
getPanel(s).displayFieldInvalid(fieldName, invalid);
}
@@ -119,9 +122,9 @@
private void createLayout(Application app)
{
- Set<Step> steps = app.getWizardSteps();
+ Set<WizardStep> steps = app.getWizardSteps();
if (steps != null) {
- for (Step step : steps) {
+ for (WizardStep step : steps) {
QuickSetupStepPanel panel = app.createWizardStepPanel(step);
if (panel != null) {
hmPanels.put(step, panel);
@@ -132,7 +135,7 @@
int minWidth = 0;
int minHeight = 0;
setLayout(new CardLayout());
- for (Step s : hmPanels.keySet())
+ for (WizardStep s : hmPanels.keySet())
{
minWidth = Math.max(minWidth, getPanel(s).getMinimumWidth());
minHeight = Math.max(minHeight, getPanel(s).getMinimumHeight());
@@ -140,7 +143,8 @@
}
// For aesthetical reasons we add a little bit of height
- if (!Utils.isUninstall())
+ // TODO: remove this hack
+ if (application instanceof Installer)
{
minHeight += UIFactory.EXTRA_DIALOG_HEIGHT;
}
@@ -156,7 +160,7 @@
*/
public void addButtonActionListener(ButtonActionListener l)
{
- for (Step s : hmPanels.keySet())
+ for (WizardStep s : hmPanels.keySet())
{
getPanel(s).addButtonActionListener(l);
}
@@ -168,7 +172,7 @@
*/
public void removeButtonActionListener(ButtonActionListener l)
{
- for (Step s : hmPanels.keySet())
+ for (WizardStep s : hmPanels.keySet())
{
getPanel(s).removeButtonActionListener(l);
}
@@ -181,7 +185,7 @@
* @param userData the UserData object that must be used to populate
* the panels.
*/
- public void setDisplayedStep(Step step, UserData userData)
+ public void setDisplayedStep(WizardStep step, UserData userData)
{
CardLayout cl = (CardLayout) (getLayout());
getPanel(step).beginDisplay(userData);
@@ -196,7 +200,7 @@
*/
public void displayProgress(ProgressDescriptor descriptor)
{
- for (Step s : hmPanels.keySet())
+ for (WizardStep s : hmPanels.keySet())
{
getPanel(s).displayProgress(descriptor);
}
@@ -207,7 +211,7 @@
* @param step the step for which we want to get the panel.
* @return the panel for the provided step.
*/
- private QuickSetupStepPanel getPanel(Step step)
+ private QuickSetupStepPanel getPanel(WizardStep step)
{
return hmPanels.get(step);
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupDialog.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupDialog.java
index 3a8f10d..206c35d 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupDialog.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/QuickSetupDialog.java
@@ -73,7 +73,7 @@
private ButtonsPanel buttonsPanel;
- private Step displayedStep;
+ private WizardStep displayedStep;
private CurrentInstallStatus installStatus;
@@ -168,7 +168,7 @@
* @param userData the UserData object that must be used to populate
* the panels.
*/
- public void setDisplayedStep(Step step, UserData userData)
+ public void setDisplayedStep(WizardStep step, UserData userData)
{
displayedStep = step;
@@ -182,7 +182,7 @@
* Returns the currently displayed step.
* @return the currently displayed step.
*/
- public Step getDisplayedStep()
+ public WizardStep getDisplayedStep()
{
return displayedStep;
}
@@ -416,7 +416,7 @@
{
if (buttonsPanel == null)
{
- buttonsPanel = new ButtonsPanel();
+ buttonsPanel = new ButtonsPanel(application);
}
return buttonsPanel;
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/StepsPanel.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/StepsPanel.java
index 93e5226..b26d655 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/StepsPanel.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/StepsPanel.java
@@ -37,8 +37,8 @@
import javax.swing.JLabel;
import javax.swing.JPanel;
-import org.opends.quicksetup.Step;
import org.opends.quicksetup.Application;
+import org.opends.quicksetup.WizardStep;
/**
* This class displays the different steps of the wizard. It appears on the
@@ -52,9 +52,11 @@
{
private static final long serialVersionUID = -2003945907121690657L;
- HashMap<Step, JLabel> hmLabels = new HashMap<Step, JLabel>();
+ HashMap<WizardStep, JLabel> hmLabels = new HashMap<WizardStep, JLabel>();
- HashMap<Step, JLabel> hmIcons = new HashMap<Step, JLabel>();
+ HashMap<WizardStep, JLabel> hmIcons = new HashMap<WizardStep, JLabel>();
+
+ Application application = null;
/**
* Creates a StepsPanel.
@@ -62,6 +64,7 @@
*/
public StepsPanel(Application app)
{
+ this.application = app;
createLayout(app);
}
@@ -71,11 +74,11 @@
*
* @param step the step in the wizard.
*/
- public void setDisplayedStep(Step step)
+ public void setDisplayedStep(WizardStep step)
{
- for (Step s : Step.values())
+ for (WizardStep s : application.getWizardSteps())
{
- if (s == step)
+ if (s.equals(step))
{
getIcon(s).setVisible(true);
UIFactory.setTextStyle(getLabel(s), UIFactory.TextStyle.CURRENT_STEP);
@@ -111,10 +114,10 @@
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.WEST;
- HashMap<Step, String> hmText = new HashMap<Step, String>();
- ArrayList<Step> orderedSteps = new ArrayList<Step>();
+ HashMap<WizardStep, String> hmText = new HashMap<WizardStep, String>();
+ ArrayList<WizardStep> orderedSteps = new ArrayList<WizardStep>();
- Step step = app.getFirstWizardStep();
+ WizardStep step = app.getFirstWizardStep();
hmText.put(step, getMsg(step.getMessageKey()));
orderedSteps.add(step);
while (null != (step = app.getNextWizardStep(step))) {
@@ -122,7 +125,7 @@
orderedSteps.add(step);
}
- for (Step s : orderedSteps)
+ for (WizardStep s : orderedSteps)
{
if (s != orderedSteps.get(0))
{
@@ -187,7 +190,7 @@
* @param step the step for which we want to retrieve the JLabel.
* @return the label associated with the given step.
*/
- private JLabel getLabel(Step step)
+ private JLabel getLabel(WizardStep step)
{
return hmLabels.get(step);
}
@@ -197,7 +200,7 @@
* @param step the step for which we want to retrieve the Icon.
* @return the icon associated with the given step.
*/
- private JLabel getIcon(Step step)
+ private JLabel getIcon(WizardStep step)
{
return hmIcons.get(step);
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallLauncher.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallLauncher.java
index 0fb0adc..4e10057 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallLauncher.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallLauncher.java
@@ -71,7 +71,6 @@
*/
protected void willLaunchGui() {
System.out.println(getMsg("uninstall-launcher-launching-gui"));
- System.setProperty("org.opends.quicksetup.uninstall", "true");
System.setProperty("org.opends.quicksetup.Application.class",
"org.opends.quicksetup.uninstaller.Uninstaller");
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java
index 7ee1c77..8d1af1f 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java
@@ -28,9 +28,14 @@
package org.opends.quicksetup.uninstaller;
import org.opends.quicksetup.*;
+import static org.opends.quicksetup.Step.PROGRESS;
+import static org.opends.quicksetup.Step.REVIEW;
+import org.opends.quicksetup.installer.FieldName;
import org.opends.quicksetup.ui.*;
import org.opends.quicksetup.util.Utils;
+import org.opends.quicksetup.util.BackgroundTask;
import org.opends.server.tools.ConfigureWindowsService;
+import org.opends.server.protocols.ldap.LDAPResultCode;
import javax.swing.*;
import java.io.*;
@@ -45,10 +50,10 @@
private ProgressStep status = UninstallProgressStep.NOT_STARTED;
private HashMap<ProgressStep, Integer> hmRatio =
- new HashMap<ProgressStep, Integer>();
+ new HashMap<ProgressStep, Integer>();
private HashMap<ProgressStep, String> hmSummary =
- new HashMap<ProgressStep, String>();
+ new HashMap<ProgressStep, String>();
private ApplicationException ue;
@@ -73,14 +78,14 @@
/**
* {@inheritDoc}
*/
- public Step getFirstWizardStep() {
+ public WizardStep getFirstWizardStep() {
return Step.CONFIRM_UNINSTALL;
}
/**
* {@inheritDoc}
*/
- public Step getNextWizardStep(Step step) {
+ public WizardStep getNextWizardStep(WizardStep step) {
Step nextStep = null;
if (step != null && step.equals(Step.CONFIRM_UNINSTALL)) {
nextStep = Step.PROGRESS;
@@ -91,39 +96,271 @@
/**
* {@inheritDoc}
*/
+ public WizardStep getPreviousWizardStep(WizardStep step) {
+ Step prevStep = null;
+ if (step != null && step.equals(Step.PROGRESS)) {
+ prevStep = Step.CONFIRM_UNINSTALL;
+ }
+ return prevStep;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canGoBack(WizardStep step) {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canGoForward(WizardStep step) {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canFinish(WizardStep step) {
+ return step == Step.CONFIRM_UNINSTALL;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canQuit(WizardStep step) {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canClose(WizardStep step) {
+ return step == Step.PROGRESS;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canCancel(WizardStep step) {
+ return step == Step.CONFIRM_UNINSTALL;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void nextClicked(WizardStep cStep, QuickSetup qs) {
+ if (cStep == PROGRESS) {
+ throw new IllegalStateException(
+ "Cannot click on next from progress step");
+ } else if (cStep == REVIEW) {
+ throw new IllegalStateException("Cannot click on next from review step");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void closeClicked(WizardStep cStep, QuickSetup qs) {
+ if (cStep == PROGRESS) {
+ if (isFinished()
+ || qs.displayConfirmation(getMsg("confirm-close-uninstall-msg"),
+ getMsg("confirm-close-uninstall-title")))
+ {
+ qs.quit();
+ }
+ } else {
+ throw new IllegalStateException(
+ "Close only can be clicked on PROGRESS step");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void cancelClicked(WizardStep cStep, QuickSetup qs) {
+ if (cStep == Step.CONFIRM_UNINSTALL) {
+ qs.quit();
+ } else {
+ throw new IllegalStateException(
+ "Cancel only can be clicked on CONFIRM_UNINSTALL step");
+ }
+ }
+
+ /**
+ * Update the UserData object according to the content of the review
+ * panel.
+ */
+ private void updateUserUninstallDataForConfirmUninstallPanel(QuickSetup qs)
+ throws UserDataException {
+ UninstallUserData uud = (UninstallUserData) getUserData();
+ uud.setRemoveLibrariesAndTools(
+ (Boolean) qs.getFieldValue(FieldName.REMOVE_LIBRARIES_AND_TOOLS));
+ uud.setRemoveDatabases(
+ (Boolean) qs.getFieldValue(FieldName.REMOVE_DATABASES));
+ uud.setRemoveConfigurationAndSchema(
+ (Boolean) qs.getFieldValue(
+ FieldName.REMOVE_CONFIGURATION_AND_SCHEMA));
+ uud.setRemoveBackups(
+ (Boolean) qs.getFieldValue(FieldName.REMOVE_BACKUPS));
+ uud.setRemoveLDIFs(
+ (Boolean) qs.getFieldValue(FieldName.REMOVE_LDIFS));
+ uud.setRemoveLogs(
+ (Boolean) qs.getFieldValue(FieldName.REMOVE_LOGS));
+
+ Set<String> dbs = new HashSet<String>();
+ Set s = (Set) qs.getFieldValue(FieldName.EXTERNAL_DB_DIRECTORIES);
+ for (Object v : s) {
+ dbs.add((String) v);
+ }
+
+ Set<String> logs = new HashSet<String>();
+ s = (Set) qs.getFieldValue(FieldName.EXTERNAL_LOG_FILES);
+ for (Object v : s) {
+ logs.add((String) v);
+ }
+
+ uud.setExternalDbsToRemove(dbs);
+ uud.setExternalLogsToRemove(logs);
+
+ if ((dbs.size() == 0) &&
+ (logs.size() == 0) &&
+ !uud.getRemoveLibrariesAndTools() &&
+ !uud.getRemoveDatabases() &&
+ !uud.getRemoveConfigurationAndSchema() &&
+ !uud.getRemoveBackups() &&
+ !uud.getRemoveLDIFs() &&
+ !uud.getRemoveLogs()) {
+ throw new UserDataException(Step.CONFIRM_UNINSTALL,
+ getMsg("nothing-selected-to-uninstall"));
+ }
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void quitClicked(WizardStep step, QuickSetup qs) {
+ if (step == Step.PROGRESS) {
+ throw new IllegalStateException(
+ "Cannot click on quit from progress step");
+ }
+ qs.quit();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getCloseButtonToolTip() {
+ return "close-button-uninstall-tooltip";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getFinishButtonToolTip() {
+ return "finish-button-uninstall-tooltip";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getFinishButtonLabel() {
+ return "finish-button-uninstall-label";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void previousClicked(WizardStep cStep, QuickSetup qs) {
+ if (cStep == Step.PROGRESS) {
+ throw new IllegalStateException(
+ "Cannot click on previous from progress step");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void finishClicked(final WizardStep cStep, final QuickSetup qs) {
+ if (cStep == Step.CONFIRM_UNINSTALL) {
+ BackgroundTask worker = new BackgroundTask() {
+ public Object processBackgroundTask() throws UserDataException {
+ try {
+ updateUserUninstallDataForConfirmUninstallPanel(qs);
+ }
+ catch (UserDataException uude) {
+ throw uude;
+ } catch (Throwable t) {
+ throw new UserDataException(cStep,
+ getThrowableMsg("bug-msg", t));
+ }
+ return CurrentInstallStatus.isServerRunning();
+ }
+
+ public void backgroundTaskCompleted(Object returnValue,
+ Throwable throwable) {
+ qs.getDialog().workerFinished();
+ if (throwable != null) {
+ qs.displayError(throwable.getLocalizedMessage(),
+ getMsg("error-title"));
+ } else {
+ boolean serverRunning = (Boolean) returnValue;
+ if (!serverRunning) {
+ getUserData().setStopServer(false);
+ if (qs.displayConfirmation(
+ getMsg("confirm-uninstall-server-not-running-msg"),
+ getMsg("confirm-uninstall-server-not-running-title"))) {
+ qs.launchUninstallation();
+ qs.setCurrentStep(getNextWizardStep(cStep));
+ }
+ } else {
+ if (qs.displayConfirmation(
+ getMsg("confirm-uninstall-server-running-msg"),
+ getMsg("confirm-uninstall-server-running-title"))) {
+ getUserData().setStopServer(true);
+ qs.launchUninstallation();
+ qs.setCurrentStep(getNextWizardStep(cStep));
+ } else {
+ getUserData().setStopServer(false);
+ }
+ }
+ }
+ }
+ };
+ qs.getDialog().workerStarted();
+ worker.startBackgroundTask();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void updateUserData(WizardStep step, QuickSetup qs) {
+ // do nothing;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
protected void setWizardDialogState(QuickSetupDialog dlg,
UserData userData,
- Step step) {
- // Set the default button for the frame
- switch (step) {
- case CONFIRM_UNINSTALL:
- dlg.setDefaultButton(ButtonName.FINISH);
- break;
-
- case PROGRESS:
- dlg.setDefaultButton(ButtonName.CLOSE);
- break;
- }
-
- // Set the focus for the current step
- switch (step) {
- case CONFIRM_UNINSTALL:
- dlg.setFocusOnButton(ButtonName.FINISH);
- break;
-
- case PROGRESS:
- dlg.setFocusOnButton(ButtonName.CLOSE);
- dlg.setButtonEnabled(ButtonName.CLOSE, false);
- break;
- }
+ WizardStep step) {
+ if (step == Step.CONFIRM_UNINSTALL) {
+ dlg.setDefaultButton(ButtonName.FINISH);
+ dlg.setFocusOnButton(ButtonName.FINISH);
+ } else if (step == Step.PROGRESS) {
+ dlg.setDefaultButton(ButtonName.CLOSE);
+ dlg.setFocusOnButton(ButtonName.CLOSE);
+ dlg.setButtonEnabled(ButtonName.CLOSE, false);
+ }
}
/**
* {@inheritDoc}
*/
public UserData createUserData(String[] args, CurrentInstallStatus status)
- throws UserDataException
- {
+ throws UserDataException {
return cliHelper.createUserData(args, status);
}
@@ -137,86 +374,72 @@
/**
* Returns the ApplicationException that might occur during installation or
* <CODE>null</CODE> if no exception occurred.
+ *
* @return the ApplicationException that might occur during installation or
- * <CODE>null</CODE> if no exception occurred.
+ * <CODE>null</CODE> if no exception occurred.
*/
- public ApplicationException getException()
- {
+ public ApplicationException getException() {
return ue;
}
/**
* Initialize the different map used in this class.
- *
*/
- private void initMaps()
- {
+ private void initMaps() {
hmSummary.put(UninstallProgressStep.NOT_STARTED,
- getFormattedSummary(getMsg("summary-uninstall-not-started")));
+ getFormattedSummary(getMsg("summary-uninstall-not-started")));
hmSummary.put(UninstallProgressStep.STOPPING_SERVER,
- getFormattedSummary(getMsg("summary-stopping")));
+ getFormattedSummary(getMsg("summary-stopping")));
hmSummary.put(UninstallProgressStep.DISABLING_WINDOWS_SERVICE,
- getFormattedSummary(getMsg("summary-disabling-windows-service")));
+ getFormattedSummary(getMsg("summary-disabling-windows-service")));
hmSummary.put(UninstallProgressStep.DELETING_EXTERNAL_DATABASE_FILES,
- getFormattedSummary(getMsg("summary-deleting-external-db-files")));
+ getFormattedSummary(getMsg("summary-deleting-external-db-files")));
hmSummary.put(UninstallProgressStep.DELETING_EXTERNAL_LOG_FILES,
- getFormattedSummary(getMsg("summary-deleting-external-log-files")));
+ getFormattedSummary(getMsg("summary-deleting-external-log-files")));
hmSummary.put(UninstallProgressStep.REMOVING_EXTERNAL_REFERENCES,
- getFormattedSummary(getMsg("summary-deleting-external-references")));
+ getFormattedSummary(
+ getMsg("summary-deleting-external-references")));
hmSummary.put(UninstallProgressStep.DELETING_INSTALLATION_FILES,
- getFormattedSummary(getMsg("summary-deleting-installation-files")));
+ getFormattedSummary(getMsg("summary-deleting-installation-files")));
String successMsg;
- if (Utils.isCli())
- {
- if (getUninstallUserData().getRemoveLibrariesAndTools())
- {
+ if (Utils.isCli()) {
+ if (getUninstallUserData().getRemoveLibrariesAndTools()) {
String[] arg = new String[1];
- if (Utils.isWindows())
- {
- arg[0] = getUninstallBatFile()+getLineBreak()+
- getTab()+getLibrariesPath();
- }
- else
- {
- arg[0] = getLibrariesPath();
+ if (Utils.isWindows()) {
+ arg[0] = getUninstallBatFile() + getLineBreak() +
+ getTab() + getLibrariesPath();
+ } else {
+ arg[0] = getLibrariesPath();
}
successMsg = getMsg(
- "summary-uninstall-finished-successfully-remove-jarfiles-cli",
- arg);
- }
- else
- {
+ "summary-uninstall-finished-successfully-remove-jarfiles-cli",
+ arg);
+ } else {
successMsg = getMsg("summary-uninstall-finished-successfully-cli");
}
- }
- else
- {
- if (getUninstallUserData().getRemoveLibrariesAndTools())
- {
+ } else {
+ if (getUninstallUserData().getRemoveLibrariesAndTools()) {
String[] arg = {getLibrariesPath()};
successMsg = getMsg(
- "summary-uninstall-finished-successfully-remove-jarfiles", arg);
- }
- else
- {
+ "summary-uninstall-finished-successfully-remove-jarfiles", arg);
+ } else {
successMsg = getMsg("summary-uninstall-finished-successfully");
}
}
hmSummary.put(UninstallProgressStep.FINISHED_SUCCESSFULLY,
- getFormattedSuccess(successMsg));
+ getFormattedSuccess(successMsg));
hmSummary.put(UninstallProgressStep.FINISHED_WITH_ERROR,
- getFormattedError(getMsg("summary-uninstall-finished-with-error")));
-
+ getFormattedError(getMsg("summary-uninstall-finished-with-error")));
/*
- * hmTime contains the relative time that takes for each task to be
- * accomplished. For instance if stopping takes twice the time of
- * deleting files, the value for downloading will be the double of the
- * value for extracting.
- */
+ * hmTime contains the relative time that takes for each task to be
+ * accomplished. For instance if stopping takes twice the time of
+ * deleting files, the value for downloading will be the double of the
+ * value for extracting.
+ */
HashMap<UninstallProgressStep, Integer> hmTime =
- new HashMap<UninstallProgressStep, Integer>();
+ new HashMap<UninstallProgressStep, Integer>();
hmTime.put(UninstallProgressStep.STOPPING_SERVER, 15);
hmTime.put(UninstallProgressStep.DISABLING_WINDOWS_SERVICE, 5);
hmTime.put(UninstallProgressStep.DELETING_EXTERNAL_DATABASE_FILES, 30);
@@ -226,41 +449,35 @@
int totalTime = 0;
ArrayList<UninstallProgressStep> steps =
- new ArrayList<UninstallProgressStep>();
- if (getUserData().getStopServer())
- {
+ new ArrayList<UninstallProgressStep>();
+ if (getUserData().getStopServer()) {
totalTime += hmTime.get(UninstallProgressStep.STOPPING_SERVER);
steps.add(UninstallProgressStep.STOPPING_SERVER);
}
- if (isWindowsServiceEnabled())
- {
+ if (isWindowsServiceEnabled()) {
totalTime += hmTime.get(UninstallProgressStep.DISABLING_WINDOWS_SERVICE);
steps.add(UninstallProgressStep.DISABLING_WINDOWS_SERVICE);
}
totalTime += hmTime.get(UninstallProgressStep.DELETING_INSTALLATION_FILES);
steps.add(UninstallProgressStep.DELETING_INSTALLATION_FILES);
- if (getUninstallUserData().getExternalDbsToRemove().size() > 0)
- {
+ if (getUninstallUserData().getExternalDbsToRemove().size() > 0) {
totalTime += hmTime.get(
- UninstallProgressStep.DELETING_EXTERNAL_DATABASE_FILES);
+ UninstallProgressStep.DELETING_EXTERNAL_DATABASE_FILES);
steps.add(UninstallProgressStep.DELETING_EXTERNAL_DATABASE_FILES);
}
- if (getUninstallUserData().getExternalLogsToRemove().size() > 0)
- {
+ if (getUninstallUserData().getExternalLogsToRemove().size() > 0) {
totalTime += hmTime.get(
- UninstallProgressStep.DELETING_EXTERNAL_LOG_FILES);
+ UninstallProgressStep.DELETING_EXTERNAL_LOG_FILES);
steps.add(UninstallProgressStep.DELETING_EXTERNAL_LOG_FILES);
}
int cumulatedTime = 0;
- for (UninstallProgressStep s : steps)
- {
+ for (UninstallProgressStep s : steps) {
Integer statusTime = hmTime.get(s);
hmRatio.put(s, (100 * cumulatedTime) / totalTime);
- if (statusTime != null)
- {
+ if (statusTime != null) {
cumulatedTime += statusTime;
}
}
@@ -271,35 +488,28 @@
/**
* Actually performs the uninstall in this thread. The thread is blocked.
- *
*/
- public void run()
- {
+ public void run() {
initMaps();
PrintStream origErr = System.err;
PrintStream origOut = System.out;
- try
- {
+ try {
PrintStream err = new ErrorPrintStream();
PrintStream out = new OutputPrintStream();
- if (!Utils.isCli())
- {
- System.setErr(err);
- System.setOut(out);
+ if (!Utils.isCli()) {
+ System.setErr(err);
+ System.setOut(out);
}
boolean displaySeparator = false;
- if (getUserData().getStopServer())
- {
+ if (getUserData().getStopServer()) {
status = UninstallProgressStep.STOPPING_SERVER;
stopServer();
displaySeparator = true;
}
- if (isWindowsServiceEnabled())
- {
+ if (isWindowsServiceEnabled()) {
status = UninstallProgressStep.DISABLING_WINDOWS_SERVICE;
- if (displaySeparator)
- {
+ if (displaySeparator) {
notifyListeners(getTaskSeparator());
}
disableWindowsService();
@@ -307,11 +517,9 @@
}
Set<String> dbsToDelete = getUninstallUserData().getExternalDbsToRemove();
- if (dbsToDelete.size() > 0)
- {
+ if (dbsToDelete.size() > 0) {
status = UninstallProgressStep.DELETING_EXTERNAL_DATABASE_FILES;
- if (displaySeparator)
- {
+ if (displaySeparator) {
notifyListeners(getTaskSeparator());
}
@@ -321,12 +529,10 @@
Set<String> logsToDelete =
getUninstallUserData().getExternalLogsToRemove();
- if (logsToDelete.size() > 0)
- {
+ if (logsToDelete.size() > 0) {
status = UninstallProgressStep.DELETING_EXTERNAL_LOG_FILES;
- if (displaySeparator)
- {
+ if (displaySeparator) {
notifyListeners(getTaskSeparator());
}
@@ -336,52 +542,44 @@
UninstallUserData userData = getUninstallUserData();
boolean somethingToDelete = userData.getRemoveBackups() ||
- userData.getRemoveConfigurationAndSchema() ||
- userData.getRemoveDatabases() ||
- userData.getRemoveLDIFs() ||
- userData.getRemoveLibrariesAndTools() ||
- userData.getRemoveLogs();
- if (displaySeparator && somethingToDelete)
- {
+ userData.getRemoveConfigurationAndSchema() ||
+ userData.getRemoveDatabases() ||
+ userData.getRemoveLDIFs() ||
+ userData.getRemoveLibrariesAndTools() ||
+ userData.getRemoveLogs();
+ if (displaySeparator && somethingToDelete) {
notifyListeners(getTaskSeparator());
}
- if (somethingToDelete)
- {
+ if (somethingToDelete) {
status = UninstallProgressStep.DELETING_INSTALLATION_FILES;
deleteInstallationFiles(getRatio(status),
- getRatio(UninstallProgressStep.FINISHED_SUCCESSFULLY));
+ getRatio(UninstallProgressStep.FINISHED_SUCCESSFULLY));
}
status = UninstallProgressStep.FINISHED_SUCCESSFULLY;
- if (Utils.isCli())
- {
- notifyListeners(getLineBreak()+getLineBreak()+getSummary(status));
- }
- else
- {
+ if (Utils.isCli()) {
+ notifyListeners(getLineBreak() + getLineBreak() + getSummary(status));
+ } else {
notifyListeners(null);
}
- } catch (ApplicationException ex)
- {
+ } catch (ApplicationException ex) {
ue = ex;
status = UninstallProgressStep.FINISHED_WITH_ERROR;
String msg = getFormattedError(ex, true);
notifyListeners(msg);
}
- catch (Throwable t)
- {
+ catch (Throwable t) {
ue = new ApplicationException(
- ApplicationException.Type.BUG,
- getThrowableMsg("bug-msg", t), t);
+ ApplicationException.Type.BUG,
+ getThrowableMsg("bug-msg", t), t);
status = UninstallProgressStep.FINISHED_WITH_ERROR;
String msg = getFormattedError(ue, true);
notifyListeners(msg);
}
- if (!Utils.isCli())
- {
- System.setErr(origErr);
- System.setOut(origOut);
+ if (!Utils.isCli()) {
+ System.setErr(origErr);
+ System.setOut(origOut);
}
}
@@ -395,24 +593,24 @@
/**
* Returns an integer that specifies which percentage of the whole
* installation has been completed.
+ *
* @param step the UninstallProgressStep for which we want to get the ratio.
* @return an integer that specifies which percentage of the whole
- * uninstallation has been completed.
+ * uninstallation has been completed.
*/
- public Integer getRatio(ProgressStep step)
- {
+ public Integer getRatio(ProgressStep step) {
return hmRatio.get(step);
}
/**
* Returns an formatted representation of the summary for the specified
* UninstallProgressStep.
+ *
* @param step the UninstallProgressStep for which we want to get the summary.
* @return an formatted representation of the summary for the specified
- * UninstallProgressStep.
+ * UninstallProgressStep.
*/
- public String getSummary(ProgressStep step)
- {
+ public String getSummary(ProgressStep step) {
return hmSummary.get(step);
}
@@ -448,44 +646,41 @@
/**
* {@inheritDoc}
*/
- public Set<Step> getWizardSteps() {
- return EnumSet.of(Step.CONFIRM_UNINSTALL,
- Step.PROGRESS);
+ public Set<WizardStep> getWizardSteps() {
+ Set<WizardStep> setSteps = new HashSet<WizardStep>();
+ setSteps.add(Step.CONFIRM_UNINSTALL);
+ setSteps.add(Step.PROGRESS);
+ return Collections.unmodifiableSet(setSteps);
}
/**
* {@inheritDoc}
*/
- public QuickSetupStepPanel createWizardStepPanel(Step step) {
+ public QuickSetupStepPanel createWizardStepPanel(WizardStep step) {
QuickSetupStepPanel p = null;
- switch (step) {
- case CONFIRM_UNINSTALL:
- p = new ConfirmUninstallPanel(installStatus);
- break;
- case PROGRESS:
- p = new ProgressPanel();
- break;
+ if (step == Step.CONFIRM_UNINSTALL) {
+ p = new ConfirmUninstallPanel(installStatus);
+ } else if (step == Step.PROGRESS) {
+ p = new ProgressPanel();
}
return p;
}
/**
* This methods stops the server.
+ *
* @throws ApplicationException if something goes wrong.
*/
- private void stopServer() throws ApplicationException
- {
+ private void stopServer() throws ApplicationException {
notifyListeners(getFormattedProgress(getMsg("progress-stopping")) +
- getLineBreak());
+ getLineBreak());
ArrayList<String> argList = new ArrayList<String>();
- if (Utils.isWindows())
- {
+ if (Utils.isWindows()) {
argList.add(Utils.getPath(getBinariesPath(),
Utils.getWindowsStopFileName()));
- } else
- {
+ } else {
argList.add(Utils.getPath(getBinariesPath(),
Utils.getUnixStopFileName()));
}
@@ -499,14 +694,15 @@
*/
env.remove("JAVA_BIN");
- try
- {
+ try {
Process process = pb.start();
BufferedReader err =
- new BufferedReader(new InputStreamReader(process.getErrorStream()));
+ new BufferedReader(
+ new InputStreamReader(process.getErrorStream()));
BufferedReader out =
- new BufferedReader(new InputStreamReader(process.getInputStream()));
+ new BufferedReader(
+ new InputStreamReader(process.getInputStream()));
/* Create these objects to resend the stop process output to the details
* area.
@@ -516,12 +712,9 @@
int returnValue = process.waitFor();
- int clientSideError =
- org.opends.server.protocols.ldap.LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR;
- if ((returnValue == clientSideError) || (returnValue == 0))
- {
- if (Utils.isWindows())
- {
+ int clientSideError = LDAPResultCode.CLIENT_SIDE_CONNECT_ERROR;
+ if ((returnValue == clientSideError) || (returnValue == 0)) {
+ if (Utils.isWindows()) {
/*
* Sometimes the server keeps some locks on the files.
* TODO: remove this code once stop-ds returns properly when server
@@ -530,42 +723,34 @@
int nTries = 10;
boolean stopped = false;
- for (int i=0; i<nTries && !stopped; i++)
- {
+ for (int i = 0; i < nTries && !stopped; i++) {
stopped = !CurrentInstallStatus.isServerRunning();
- if (!stopped)
- {
+ if (!stopped) {
String msg =
- getFormattedLog(getMsg("progress-server-waiting-to-stop"))+
- getLineBreak();
+ getFormattedLog(getMsg("progress-server-waiting-to-stop")) +
+ getLineBreak();
notifyListeners(msg);
- try
- {
+ try {
Thread.sleep(5000);
}
- catch (Exception ex)
- {
+ catch (Exception ex) {
}
}
}
- if (!stopped)
- {
+ if (!stopped) {
returnValue = -1;
}
}
}
- if (returnValue == clientSideError)
- {
+ if (returnValue == clientSideError) {
String msg = getLineBreak() +
- getFormattedLog(getMsg("progress-server-already-stopped"))+
- getLineBreak();
+ getFormattedLog(getMsg("progress-server-already-stopped")) +
+ getLineBreak();
notifyListeners(msg);
- }
- else if (returnValue != 0)
- {
+ } else if (returnValue != 0) {
String[] arg = {String.valueOf(returnValue)};
String msg = getMsg("error-stopping-server-code", arg);
@@ -576,133 +761,111 @@
throw new ApplicationException(ApplicationException.Type.STOP_ERROR,
msg,
null);
- }
- else
- {
+ } else {
String msg = getFormattedLog(getMsg("progress-server-stopped"));
notifyListeners(msg);
}
- } catch (IOException ioe)
- {
+ } catch (IOException ioe) {
throw new ApplicationException(ApplicationException.Type.STOP_ERROR,
- getThrowableMsg("error-stopping-server", ioe), ioe);
+ getThrowableMsg("error-stopping-server", ioe), ioe);
}
- catch (InterruptedException ie)
- {
+ catch (InterruptedException ie) {
throw new ApplicationException(ApplicationException.Type.BUG,
- getThrowableMsg("error-stopping-server", ie), ie);
+ getThrowableMsg("error-stopping-server", ie), ie);
}
}
/**
* Deletes the external database files specified in the provided Set.
+ *
* @param dbFiles the database directories to be deleted.
* @throws ApplicationException if something goes wrong.
*/
private void deleteExternalDatabaseFiles(Set<String> dbFiles)
- throws ApplicationException
- {
+ throws ApplicationException {
notifyListeners(getFormattedProgress(
- getMsg("progress-deleting-external-db-files")) +
- getLineBreak());
- for (String path : dbFiles)
- {
+ getMsg("progress-deleting-external-db-files")) +
+ getLineBreak());
+ for (String path : dbFiles) {
deleteRecursively(new File(path));
}
}
/**
* Deletes the external database files specified in the provided Set.
+ *
* @param logFiles the log files to be deleted.
* @throws ApplicationException if something goes wrong.
*/
private void deleteExternalLogFiles(Set<String> logFiles)
- throws ApplicationException
- {
+ throws ApplicationException {
notifyListeners(getFormattedProgress(
- getMsg("progress-deleting-external-log-files")) +
- getLineBreak());
- for (String path : logFiles)
- {
+ getMsg("progress-deleting-external-log-files")) +
+ getLineBreak());
+ for (String path : logFiles) {
deleteRecursively(new File(path));
}
}
/**
* Deletes the files under the installation path.
+ *
* @throws ApplicationException if something goes wrong.
*/
private void deleteInstallationFiles(int minRatio, int maxRatio)
- throws ApplicationException
- {
+ throws ApplicationException {
notifyListeners(getFormattedProgress(
- getMsg("progress-deleting-installation-files")) +
- getLineBreak());
+ getMsg("progress-deleting-installation-files")) +
+ getLineBreak());
File f = new File(Utils.getInstallPathFromClasspath());
InstallationFilesToDeleteFilter filter =
- new InstallationFilesToDeleteFilter();
+ new InstallationFilesToDeleteFilter();
File[] rootFiles = f.listFiles();
- if (rootFiles != null)
- {
+ if (rootFiles != null) {
/* The following is done to have a moving progress bar when we delete
* the installation files.
*/
int totalRatio = 0;
ArrayList<Integer> cumulatedRatio = new ArrayList<Integer>();
- for (int i=0; i<rootFiles.length; i++)
- {
- if (filter.accept(rootFiles[i]))
- {
- int relativeRatio;
- if (equalsOrDescendant(rootFiles[i], new File(getLibrariesPath())))
- {
- relativeRatio = 10;
- }
- else if (equalsOrDescendant(rootFiles[i], new File(getBinariesPath())))
- {
- relativeRatio = 5;
- }
- else if (equalsOrDescendant(rootFiles[i], new File(getConfigPath())))
- {
- relativeRatio = 5;
- }
- else if (equalsOrDescendant(rootFiles[i], new File(getBackupsPath())))
- {
- relativeRatio = 20;
- }
- else if (equalsOrDescendant(rootFiles[i], new File(getLDIFsPath())))
- {
- relativeRatio = 20;
- }
- else if (equalsOrDescendant(rootFiles[i],
- new File(getDatabasesPath())))
- {
- relativeRatio = 50;
- }
- else if (equalsOrDescendant(rootFiles[i], new File(getLogsPath())))
- {
- relativeRatio = 30;
- }
- else
- {
- relativeRatio = 2;
- }
- cumulatedRatio.add(totalRatio);
- totalRatio += relativeRatio;
- }
- else
- {
- cumulatedRatio.add(totalRatio);
- }
+ for (int i = 0; i < rootFiles.length; i++) {
+ if (filter.accept(rootFiles[i])) {
+ int relativeRatio;
+ if (equalsOrDescendant(rootFiles[i], new File(getLibrariesPath()))) {
+ relativeRatio = 10;
+ } else
+ if (equalsOrDescendant(rootFiles[i], new File(getBinariesPath()))) {
+ relativeRatio = 5;
+ } else
+ if (equalsOrDescendant(rootFiles[i], new File(getConfigPath()))) {
+ relativeRatio = 5;
+ } else
+ if (equalsOrDescendant(rootFiles[i], new File(getBackupsPath()))) {
+ relativeRatio = 20;
+ } else
+ if (equalsOrDescendant(rootFiles[i], new File(getLDIFsPath()))) {
+ relativeRatio = 20;
+ } else if (equalsOrDescendant(rootFiles[i],
+ new File(getDatabasesPath()))) {
+ relativeRatio = 50;
+ } else
+ if (equalsOrDescendant(rootFiles[i], new File(getLogsPath()))) {
+ relativeRatio = 30;
+ } else {
+ relativeRatio = 2;
+ }
+ cumulatedRatio.add(totalRatio);
+ totalRatio += relativeRatio;
+ } else {
+ cumulatedRatio.add(totalRatio);
+ }
}
Iterator<Integer> it = cumulatedRatio.iterator();
- for (int i=0; i<rootFiles.length; i++)
- {
+ for (int i = 0; i < rootFiles.length; i++) {
int beforeRatio = minRatio +
- ((it.next() * (maxRatio - minRatio)) / totalRatio);
+ ((it.next() * (maxRatio - minRatio)) / totalRatio);
hmRatio.put(UninstallProgressStep.DELETING_INSTALLATION_FILES,
- beforeRatio);
+ beforeRatio);
deleteRecursively(rootFiles[i], filter);
}
hmRatio.put(UninstallProgressStep.DELETING_INSTALLATION_FILES, maxRatio);
@@ -711,171 +874,150 @@
/**
* Returns the path to the quicksetup jar file.
+ *
* @return the path to the quicksetup jar file.
*/
- private String getQuicksetupJarPath()
- {
+ private String getQuicksetupJarPath() {
return Utils.getPath(getLibrariesPath(), "quicksetup.jar");
}
/**
* Returns the path to the opends jar file.
+ *
* @return the path to the opends jar file.
*/
- private String getOpenDSJarPath()
- {
+ private String getOpenDSJarPath() {
return Utils.getPath(getLibrariesPath(), "OpenDS.jar");
}
-
-
/**
* Returns the path to the uninstall.bat file.
+ *
* @return the path to the uninstall.bat file.
*/
- private String getUninstallBatFile()
- {
+ private String getUninstallBatFile() {
return Utils.getPath(Utils.getInstallPathFromClasspath(), "uninstall.bat");
}
/**
* Returns the path to the backup files under the install path.
+ *
* @return the path to the backup files under the install path.
*/
- private String getBackupsPath()
- {
+ private String getBackupsPath() {
return Utils.getPath(Utils.getInstallPathFromClasspath(),
- Utils.getBackupsRelativePath());
+ Utils.getBackupsRelativePath());
}
/**
* Returns the path to the LDIF files under the install path.
+ *
* @return the path to the LDIF files under the install path.
*/
- private String getLDIFsPath()
- {
+ private String getLDIFsPath() {
return Utils.getPath(Utils.getInstallPathFromClasspath(),
- Utils.getLDIFsRelativePath());
+ Utils.getLDIFsRelativePath());
}
/**
* Returns the path to the config files under the install path.
+ *
* @return the path to the config files under the install path.
*/
- private String getConfigPath()
- {
+ private String getConfigPath() {
return Utils.getPath(Utils.getInstallPathFromClasspath(),
- Utils.getConfigRelativePath());
+ Utils.getConfigRelativePath());
}
/**
* Returns the path to the log files under the install path.
+ *
* @return the path to the log files under the install path.
*/
- private String getLogsPath()
- {
+ private String getLogsPath() {
return Utils.getPath(Utils.getInstallPathFromClasspath(),
- Utils.getLogsRelativePath());
+ Utils.getLogsRelativePath());
}
/**
* Returns the path to the database files under the install path.
+ *
* @return the path to the database files under the install path.
*/
- private String getDatabasesPath()
- {
+ private String getDatabasesPath() {
return Utils.getPath(Utils.getInstallPathFromClasspath(),
- Utils.getDatabasesRelativePath());
+ Utils.getDatabasesRelativePath());
}
/**
* Deletes everything below the specified file.
+ *
* @param file the path to be deleted.
* @throws ApplicationException if something goes wrong.
*/
- private void deleteRecursively(File file) throws ApplicationException
- {
+ private void deleteRecursively(File file) throws ApplicationException {
deleteRecursively(file, null);
}
/**
* Deletes everything below the specified file.
- * @param file the path to be deleted.
+ *
+ * @param file the path to be deleted.
* @param filter the filter of the files to know if the file can be deleted
- * directly or not.
+ * directly or not.
* @throws ApplicationException if something goes wrong.
*/
private void deleteRecursively(File file, FileFilter filter)
- throws ApplicationException
- {
- if (file.exists())
- {
- if (file.isFile())
- {
- if (filter != null)
- {
- if (filter.accept(file))
- {
+ throws ApplicationException {
+ if (file.exists()) {
+ if (file.isFile()) {
+ if (filter != null) {
+ if (filter.accept(file)) {
delete(file);
}
- }
- else
- {
+ } else {
delete(file);
}
- }
- else
- {
+ } else {
File[] children = file.listFiles();
- if (children != null)
- {
- for (int i=0; i<children.length; i++)
- {
+ if (children != null) {
+ for (int i = 0; i < children.length; i++) {
deleteRecursively(children[i], filter);
}
}
- if (filter != null)
- {
- if (filter.accept(file))
- {
+ if (filter != null) {
+ if (filter.accept(file)) {
delete(file);
}
- }
- else
- {
+ } else {
delete(file);
}
}
- }
- else
- {
+ } else {
// Just tell that the file/directory does not exist.
String[] arg = {file.toString()};
notifyListeners(getFormattedWarning(
- getMsg("deleting-file-does-not-exist", arg)));
+ getMsg("deleting-file-does-not-exist", arg)));
}
}
/**
* Deletes the specified file.
+ *
* @param file the file to be deleted.
* @throws ApplicationException if something goes wrong.
*/
- private void delete(File file) throws ApplicationException
- {
+ private void delete(File file) throws ApplicationException {
String[] arg = {file.getAbsolutePath()};
boolean isFile = file.isFile();
- if (isFile)
- {
+ if (isFile) {
notifyListeners(getFormattedWithPoints(
- getMsg("progress-deleting-file", arg)));
- }
- else
- {
+ getMsg("progress-deleting-file", arg)));
+ } else {
notifyListeners(getFormattedWithPoints(
- getMsg("progress-deleting-directory", arg)));
+ getMsg("progress-deleting-directory", arg)));
}
boolean delete = false;
@@ -885,99 +1027,81 @@
* is stopped.
*/
int nTries = 5;
- for (int i=0; i<nTries && !delete; i++)
- {
+ for (int i = 0; i < nTries && !delete; i++) {
delete = file.delete();
- if (!delete)
- {
- try
- {
+ if (!delete) {
+ try {
Thread.sleep(1000);
}
- catch (Exception ex)
- {
+ catch (Exception ex) {
}
}
}
- if (!delete)
- {
+ if (!delete) {
String errMsg;
- if (isFile)
- {
+ if (isFile) {
errMsg = getMsg("error-deleting-file", arg);
- }
- else
- {
+ } else {
errMsg = getMsg("error-deleting-directory", arg);
}
throw new ApplicationException(
- ApplicationException.Type.FILE_SYSTEM_ERROR, errMsg, null);
+ ApplicationException.Type.FILE_SYSTEM_ERROR, errMsg, null);
}
- notifyListeners(getFormattedDone()+getLineBreak());
+ notifyListeners(getFormattedDone() + getLineBreak());
}
- private boolean equalsOrDescendant(File file, File directory)
- {
+ private boolean equalsOrDescendant(File file, File directory) {
return file.equals(directory) ||
- Utils.isDescendant(file.toString(), directory.toString());
+ Utils.isDescendant(file.toString(), directory.toString());
}
/**
* {@inheritDoc}
*/
- protected String getBinariesPath()
- {
+ protected String getBinariesPath() {
return Utils.getPath(Utils.getInstallPathFromClasspath(),
- Utils.getBinariesRelativePath());
+ Utils.getBinariesRelativePath());
}
+
/**
* This class is used to read the standard error and standard output of the
* Stop process.
- *
+ * <p/>
* When a new log message is found notifies the
* UninstallProgressUpdateListeners of it. If an error occurs it also
* notifies the listeners.
- *
*/
- private class StopReader
- {
+ private class StopReader {
private boolean isFirstLine;
/**
* The protected constructor.
- * @param reader the BufferedReader of the stop process.
+ *
+ * @param reader the BufferedReader of the stop process.
* @param isError a boolean indicating whether the BufferedReader
- * corresponds to the standard error or to the standard output.
+ * corresponds to the standard error or to the standard output.
*/
- public StopReader(final BufferedReader reader,final boolean isError)
- {
+ public StopReader(final BufferedReader reader, final boolean isError) {
final String errorTag =
- isError ? "error-reading-erroroutput" : "error-reading-output";
+ isError ? "error-reading-erroroutput" : "error-reading-output";
isFirstLine = true;
- Thread t = new Thread(new Runnable()
- {
- public void run()
- {
- try
- {
+ Thread t = new Thread(new Runnable() {
+ public void run() {
+ try {
String line = reader.readLine();
- while (line != null)
- {
+ while (line != null) {
StringBuilder buf = new StringBuilder();
- if (!isFirstLine)
- {
+ if (!isFirstLine) {
buf.append(formatter.getLineBreak());
}
- if (isError)
- {
+ if (isError) {
buf.append(getFormattedLogError(line));
- } else
- {
+ } else {
buf.append(getFormattedLog(line));
}
notifyListeners(buf.toString());
@@ -985,13 +1109,11 @@
line = reader.readLine();
}
- } catch (IOException ioe)
- {
+ } catch (IOException ioe) {
String errorMsg = getThrowableMsg(errorTag, ioe);
notifyListeners(errorMsg);
- } catch (Throwable t)
- {
+ } catch (Throwable t) {
String errorMsg = getThrowableMsg(errorTag, t);
notifyListeners(errorMsg);
}
@@ -1006,8 +1128,7 @@
* required to know which are the files that can be deleted directly and which
* not.
*/
- class InstallationFilesToDeleteFilter implements FileFilter
- {
+ class InstallationFilesToDeleteFilter implements FileFilter {
File quicksetupFile = new File(getQuicksetupJarPath());
File openDSFile = new File(getOpenDSJarPath());
File librariesFile = new File(getLibrariesPath());
@@ -1015,64 +1136,57 @@
File uninstallBatFile = new File(getUninstallBatFile());
File installationPath = new File(Utils.getInstallPathFromClasspath());
+
/**
* {@inheritDoc}
*/
- public boolean accept(File file)
- {
+ public boolean accept(File file) {
UninstallUserData userData = getUninstallUserData();
boolean[] uData = {
- userData.getRemoveLibrariesAndTools(),
- userData.getRemoveLibrariesAndTools(),
- userData.getRemoveDatabases(),
- userData.getRemoveLogs(),
- userData.getRemoveConfigurationAndSchema(),
- userData.getRemoveBackups(),
- userData.getRemoveLDIFs()
+ userData.getRemoveLibrariesAndTools(),
+ userData.getRemoveLibrariesAndTools(),
+ userData.getRemoveDatabases(),
+ userData.getRemoveLogs(),
+ userData.getRemoveConfigurationAndSchema(),
+ userData.getRemoveBackups(),
+ userData.getRemoveLDIFs()
};
String[] parentFiles = {
- getLibrariesPath(),
- getBinariesPath(),
- getDatabasesPath(),
- getLogsPath(),
- getConfigPath(),
- getBackupsPath(),
- getLDIFsPath()
+ getLibrariesPath(),
+ getBinariesPath(),
+ getDatabasesPath(),
+ getLogsPath(),
+ getConfigPath(),
+ getBackupsPath(),
+ getLDIFsPath()
};
- boolean accept =
- !installationPath.equals(file)
- && !equalsOrDescendant(file, librariesFile)
- && !quicksetupFile.equals(file)
- && !openDSFile.equals(file);
+ boolean accept =
+ !installationPath.equals(file)
+ && !equalsOrDescendant(file, librariesFile)
+ && !quicksetupFile.equals(file)
+ && !openDSFile.equals(file);
- if (accept && Utils.isWindows() && Utils.isCli())
- {
- accept = !uninstallBatFile.equals(file);
- }
+ if (accept && Utils.isWindows() && Utils.isCli()) {
+ accept = !uninstallBatFile.equals(file);
+ }
- for (int i=0; i<uData.length && accept; i++)
- {
- accept &= uData[i] ||
- !equalsOrDescendant(file, new File(parentFiles[i]));
- }
+ for (int i = 0; i < uData.length && accept; i++) {
+ accept &= uData[i] ||
+ !equalsOrDescendant(file, new File(parentFiles[i]));
+ }
- return accept;
+ return accept;
}
}
- private boolean isWindowsServiceEnabled()
- {
- if (isWindowsServiceEnabled == null)
- {
+ private boolean isWindowsServiceEnabled() {
+ if (isWindowsServiceEnabled == null) {
if (ConfigureWindowsService.serviceState(null, null) ==
- ConfigureWindowsService.SERVICE_STATE_ENABLED)
- {
+ ConfigureWindowsService.SERVICE_STATE_ENABLED) {
isWindowsServiceEnabled = Boolean.TRUE;
- }
- else
- {
+ } else {
isWindowsServiceEnabled = Boolean.FALSE;
}
}
@@ -1081,25 +1195,25 @@
/**
* This methods disables this server as a Windows service.
+ *
* @throws ApplicationException if something goes wrong.
*/
- protected void disableWindowsService() throws ApplicationException
- {
+ protected void disableWindowsService() throws ApplicationException {
notifyListeners(getFormattedProgress(
- getMsg("progress-disabling-windows-service")));
+ getMsg("progress-disabling-windows-service")));
int code = ConfigureWindowsService.disableService(System.out, System.err);
String errorMessage = getMsg("error-disabling-windows-service");
- switch (code)
- {
+ switch (code) {
case ConfigureWindowsService.SERVICE_DISABLE_SUCCESS:
- break;
+ break;
case ConfigureWindowsService.SERVICE_ALREADY_DISABLED:
- break;
+ break;
default:
- throw new ApplicationException(
- ApplicationException.Type.WINDOWS_SERVICE_ERROR, errorMessage, null);
+ throw new ApplicationException(
+ ApplicationException.Type.WINDOWS_SERVICE_ERROR,
+ errorMessage, null);
}
}
@@ -1107,22 +1221,18 @@
* This class is used to notify the UninstallProgressUpdateListeners of events
* that are written to the standard error. These classes just create an
* ErrorPrintStream and then they do a call to System.err with it.
- *
+ * <p/>
* The class just reads what is written to the standard error, obtains an
* formatted representation of it and then notifies the
* UninstallProgressUpdateListeners with the formatted messages.
- *
*/
- protected class ErrorPrintStream extends PrintStream
- {
+ protected class ErrorPrintStream extends PrintStream {
private boolean isFirstLine;
/**
* Default constructor.
- *
*/
- public ErrorPrintStream()
- {
+ public ErrorPrintStream() {
super(new ByteArrayOutputStream(), true);
isFirstLine = true;
}
@@ -1130,13 +1240,10 @@
/**
* {@inheritDoc}
*/
- public void println(String msg)
- {
- if (isFirstLine)
- {
+ public void println(String msg) {
+ if (isFirstLine) {
notifyListeners(getFormattedLogError(msg));
- } else
- {
+ } else {
notifyListeners(formatter.getLineBreak() + getFormattedLogError(msg));
}
isFirstLine = false;
@@ -1145,17 +1252,14 @@
/**
* {@inheritDoc}
*/
- public void write(byte[] b, int off, int len)
- {
- if (b == null)
- {
+ public void write(byte[] b, int off, int len) {
+ if (b == null) {
throw new NullPointerException("b is null");
}
- if (off + len > b.length)
- {
+ if (off + len > b.length) {
throw new IndexOutOfBoundsException(
- "len + off are bigger than the length of the byte array");
+ "len + off are bigger than the length of the byte array");
}
println(new String(b, off, len));
}
@@ -1165,22 +1269,18 @@
* This class is used to notify the UninstallProgressUpdateListeners of events
* that are written to the standard output. These classes just create an
* OutputPrintStream and then they do a call to System.out with it.
- *
+ * <p/>
* The class just reads what is written to the standard output, obtains an
* formatted representation of it and then notifies the
* UninstallProgressUpdateListeners with the formatted messages.
- *
*/
- protected class OutputPrintStream extends PrintStream
- {
+ protected class OutputPrintStream extends PrintStream {
private boolean isFirstLine;
/**
* Default constructor.
- *
*/
- public OutputPrintStream()
- {
+ public OutputPrintStream() {
super(new ByteArrayOutputStream(), true);
isFirstLine = true;
}
@@ -1188,13 +1288,10 @@
/**
* {@inheritDoc}
*/
- public void println(String msg)
- {
- if (isFirstLine)
- {
+ public void println(String msg) {
+ if (isFirstLine) {
notifyListeners(getFormattedLog(msg));
- } else
- {
+ } else {
notifyListeners(formatter.getLineBreak() + getFormattedLog(msg));
}
isFirstLine = false;
@@ -1203,17 +1300,14 @@
/**
* {@inheritDoc}
*/
- public void write(byte[] b, int off, int len)
- {
- if (b == null)
- {
+ public void write(byte[] b, int off, int len) {
+ if (b == null) {
throw new NullPointerException("b is null");
}
- if (off + len > b.length)
- {
+ if (off + len > b.length) {
throw new IndexOutOfBoundsException(
- "len + off are bigger than the length of the byte array");
+ "len + off are bigger than the length of the byte array");
}
println(new String(b, off, len));
@@ -1221,7 +1315,7 @@
}
private UninstallUserData getUninstallUserData() {
- return (UninstallUserData)getUserData();
+ return (UninstallUserData) getUserData();
}
}
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 672260c..d4f05a8 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
@@ -51,8 +51,8 @@
/**
* {@inheritDoc}
*/
- public Step getFirstWizardStep() {
- return Step.WELCOME;
+ public WizardStep getFirstWizardStep() {
+ return null;
}
/**
@@ -60,7 +60,7 @@
*/
protected void setWizardDialogState(QuickSetupDialog dlg,
UserData userData,
- Step step) {
+ WizardStep step) {
}
/**
@@ -121,27 +121,78 @@
/**
* {@inheritDoc}
*/
- public Set<Step> getWizardSteps() {
+ public Set<WizardStep> getWizardSteps() {
return null;
}
/**
* {@inheritDoc}
*/
- public QuickSetupStepPanel createWizardStepPanel(Step step) {
+ public QuickSetupStepPanel createWizardStepPanel(WizardStep step) {
return null;
}
/**
* {@inheritDoc}
*/
- public Step getNextWizardStep(Step step) {
+ public Step getNextWizardStep(WizardStep step) {
return null;
}
/**
* {@inheritDoc}
*/
+ public WizardStep getPreviousWizardStep(WizardStep step) {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void quitClicked(WizardStep step, QuickSetup qs) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void updateUserData(WizardStep cStep, QuickSetup qs)
+ throws UserDataException
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void previousClicked(WizardStep cStep, QuickSetup qs) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void finishClicked(final WizardStep cStep, final QuickSetup qs) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void nextClicked(WizardStep cStep, QuickSetup qs) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void closeClicked(WizardStep cStep, QuickSetup qs) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void cancelClicked(WizardStep cStep, QuickSetup qs) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public void run() {
}
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 30684c3..3d37c2e 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
@@ -826,17 +826,6 @@
}
/**
- * Returns <CODE>true</CODE> if this is an uninstallation and
- * <CODE>false</CODE> otherwise.
- * @return <CODE>true</CODE> if this is an uninstallation and
- * <CODE>false</CODE> otherwise.
- */
- public static boolean isUninstall()
- {
- return "true".equals(System.getProperty("org.opends.quicksetup.uninstall"));
- }
-
- /**
* Returns <CODE>true</CODE> if this is executed from command line and
* <CODE>false</CODE> otherwise.
* @return <CODE>true</CODE> if this is executed from command line and
--
Gitblit v1.10.0