From 7054d27e8676f4c9661b28ed50ae63df22b23af4 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Tue, 07 Aug 2007 22:32:50 +0000
Subject: [PATCH] The following modifications have the following goals:
---
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/InstallerHelper.java | 61
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/Installer.java | 86
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/QuickSetupLog.java | 19
opendj-sdk/opends/resource/uninstall.bat | 4
opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/BaseDNDescriptor.java | 2
opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallLauncher.java | 16
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installandupgrader/ui/WelcomePanel.java | 18
opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConnectionProtocolPolicy.java | 2
opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java | 1958 ++++++++++++++++++++++++++
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/ButtonsPanel.java | 30
opendj-sdk/opends/resource/bin/status-panel.bat | 2
opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ServerStatusDescriptor.java | 2
opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConfigException.java | 2
opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/DatabaseDescriptor.java | 2
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserData.java | 2
opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ListenerDescriptor.java | 2
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/HtmlProgressMessageFormatter.java | 12
opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelLauncher.java | 4
opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromLDAP.java | 4
opendj-sdk/opends/tests/gui-tests/quickUninstall.xml.stubs | 2
opendj-sdk/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java | 3
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/resources/Resources.properties | 147 -
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Application.java | 74
opendj-sdk/opends/build.xml | 92
opendj-sdk/opends/resource/bin/status.bat | 2
opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/SplashScreen.java | 4
opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelController.java | 14
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/CliApplicationHelper.java | 6
opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusCli.java | 8
opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallUserData.java | 24
/dev/null | 1595 ---------------------
opendj-sdk/opends/resource/bin/status | 2
opendj-sdk/opends/resource/bin/status-panel | 2
opendj-sdk/opends/src/ads/org/opends/admin/ads/util/ConnectionUtils.java | 1
opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallData.java | 111 +
opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromFile.java | 4
opendj-sdk/opends/resource/uninstall | 4
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installandupgrader/InstallAndUpgrader.java | 28
opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusLog.java | 2
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/StepsPanel.java | 2
opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallProgressStep.java | 15
opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ServerStatusPooler.java | 8
opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java | 14
43 files changed, 2,398 insertions(+), 1,994 deletions(-)
diff --git a/opendj-sdk/opends/build.xml b/opendj-sdk/opends/build.xml
index 890626a..0a30429 100644
--- a/opendj-sdk/opends/build.xml
+++ b/opendj-sdk/opends/build.xml
@@ -77,13 +77,13 @@
<property name="quicksetup.src.dir" location="src/quicksetup" />
<property name="quicksetup.classes.dir"
location="${build.dir}/quicksetup/classes" />
+ <property name="quicksetup.globalcompile.classes.dir"
+ location="${classes.dir}/org/opends/quicksetup" />
<property name="ads.src.dir" location="src/ads" />
- <property name="ads.class.dir" location="${classes.dir}/org/opends/admin/ads"/>
+ <property name="ads.classes.dir" location="${classes.dir}/org/opends/admin/ads"/>
- <!-- Properties for use with the Status Panel. -->
- <property name="statuspanel.src.dir" location="src/statuspanel" />
- <property name="statuspanel.classes.dir"
- location="${build.dir}/statuspanel/classes" />
+ <!-- Properties for use with the GUI Tools that go in OpenDS jar. -->
+ <property name="guitools.src.dir" location="src/guitools" />
<!-- Properties for coverage diff reports -->
<property name="cvgdiff.dir" location="build/diff" />
@@ -391,7 +391,7 @@
<checkstyle config="${checkstyle.dir}/opends-checkstyle.xml"
failOnViolation="true">
- <fileset dir="${statuspanel.src.dir}" includes="**/*.java" />
+ <fileset dir="${guitools.src.dir}" includes="**/*.java" />
<formatter type="plain" />
</checkstyle>
@@ -422,7 +422,7 @@
<!-- Compile the Directory Server source files. -->
<target name="cleancompile"
- depends="cleaninit,compilequicksetup,weave,compilestatuspanel"
+ depends="cleaninit,compilequicksetup,weave"
description="Recompile the Directory Server source files.">
</target>
@@ -433,7 +433,7 @@
description="Compile the Directory Server source files.">
<mkdir dir="${classes.dir}" />
- <javac srcdir="${src.dir}:${admin.src.dir}:${ads.src.dir}" destdir="${classes.dir}"
+ <javac srcdir="${src.dir}:${admin.src.dir}:${ads.src.dir}:${quicksetup.src.dir}:${guitools.src.dir}" destdir="${classes.dir}"
excludes="**/package-info.java"
debug="on" debuglevel="${build.debuglevel}" source="1.5" target="1.5"
deprecation="true" fork="true" memoryInitialSize="${MEM}"
@@ -444,11 +444,16 @@
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
+ <fileset dir="${build.dir}/build-tools">
+ <include name="build-tools.jar" />
+ </fileset>
</classpath>
</javac>
<copy todir="${classes.dir}">
<fileset dir="${src.dir}" includes="**/*.properties" />
+ <fileset dir="${quicksetup.src.dir}" includes="**/*.properties, **/*.gif, **/*.png" />
+ <fileset dir="${guitools.src.dir}" includes="**/*.properties, **/*.gif, **/*.png" />
</copy>
</target>
@@ -462,7 +467,7 @@
- <target name="weave" if="weave.enabled" depends="compilestatuspanel, prepweave">
+ <target name="weave" if="weave.enabled" depends="prepweave">
<echo message=" Weaving the source code with automatic AspectJ debug logging."/>
<echo message=" Build with -DWEAVE_ENABLED=false to turn this off."/>
<taskdef resource="org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties">
@@ -530,30 +535,6 @@
</target>
-
- <!-- Compile the Status Panel source files. -->
- <target name="compilestatuspanel" depends="compilequicksetup"
- description="Compile the Status Panel source files.">
- <mkdir dir="${statuspanel.classes.dir}" />
- <javac srcdir="${statuspanel.src.dir}" destdir="${statuspanel.classes.dir}"
- debug="on" debuglevel="${build.debuglevel}" source="1.5"
- target="1.5" deprecation="true" fork="true" memoryInitialSize="${MEM}"
- memoryMaximumSize="${MEM}">
- <compilerarg value="-Xlint:all" />
-
- <classpath>
- <pathelement path="${classes.dir}"/>
- <pathelement path="${quicksetup.classes.dir}"/>
- </classpath>
- </javac>
- <copy todir="${statuspanel.classes.dir}">
- <fileset dir="${statuspanel.src.dir}"
- includes="**/*.properties, **/*.gif, **/*.png" />
- </copy>
- </target>
-
-
-
<!--
! Rebuild the Directory Server without destroying any existing configuration
! or data. It will only overwrite the libraries, classes, and scripts, and
@@ -591,14 +572,13 @@
<delete file="${pdir}.zip" />
<delete dir="${quicksetup.classes.dir}" />
<delete file="${package.dir}/lib/quicksetup.jar" />
- <delete file="${package.dir}/lib/statuspanel.jar" />
<!-- Regenerate configuration files if necessary -->
<antcall target="compileadmin" />
<!-- Recreate the classes directory and recompile into it. -->
<mkdir dir="${classes.dir}" />
- <javac srcdir="${src.dir}:${admin.src.dir}:${ads.src.dir}"
+ <javac srcdir="${src.dir}:${admin.src.dir}:${ads.src.dir}:${quicksetup.src.dir}:${guitools.src.dir}"
destdir="${classes.dir}"
debug="on" debuglevel="${build.debuglevel}" source="1.5" target="1.5"
deprecation="true" fork="true" memoryInitialSize="${MEM}"
@@ -609,16 +589,23 @@
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
+ <fileset dir="${build.dir}/build-tools">
+ <include name="build-tools.jar" />
+ </fileset>
</classpath>
</javac>
<copy todir="${classes.dir}">
<fileset dir="${src.dir}" includes="**/*.properties" />
+ <fileset dir="${quicksetup.src.dir}" includes="**/*.properties, **/*.gif, **/*.png" />
+ <fileset dir="${guitools.src.dir}" includes="**/*.properties, **/*.gif, **/*.png" />
</copy>
<!-- Generate the OpenDS.jar file -->
<jar jarfile="${pdir}/lib/${SHORT_NAME}.jar"
- basedir="${classes.dir}" compress="true" index="true" />
+ basedir="${classes.dir}"
+ excludes="${ads.classes.dir}, ${quicksetup.globalcompile.classes.dir}"
+ compress="true" index="true" />
<!-- Recreate the quicksetup classes directory and recompile into it. -->
<mkdir dir="${quicksetup.classes.dir}" />
@@ -668,29 +655,6 @@
<jar jarfile="${pdir}/lib/quicksetup.jar"
basedir="${quicksetup.classes.dir}" compress="true" index="true" />
- <!-- Recreate the statuspanel classes directory and recompile into it. -->
- <mkdir dir="${statuspanel.classes.dir}" />
- <javac srcdir="${statuspanel.src.dir}" destdir="${statuspanel.classes.dir}"
- debug="on" debuglevel="${build.debuglevel}" source="1.5" target="1.5"
- deprecation="true" fork="true" memoryInitialSize="${MEM}"
- memoryMaximumSize="${MEM}">
- <compilerarg value="-Xlint:all" />
- <classpath>
- <fileset dir="${pdir}/lib">
- <include name="${SHORT_NAME}.jar" />
- </fileset>
- </classpath>
- </javac>
-
- <copy todir="${statuspanel.classes.dir}">
- <fileset dir="${statuspanel.src.dir}"
- includes="**/*.properties, **/*.gif, **/*.png"/>
- </copy>
-
- <!-- Generate the statuspanel.jar file -->
- <jar jarfile="${pdir}/lib/statuspanel.jar"
- basedir="${statuspanel.classes.dir}" compress="true" index="true" />
-
<!-- Regenerate example plugin. -->
<antcall target="example-plugin" />
</target>
@@ -724,16 +688,14 @@
<mkdir dir="${pdir}/locks" />
<mkdir dir="${pdir}/logs" />
- <delete dir="${ads.class.dir}" />
<jar jarfile="${pdir}/lib/${SHORT_NAME}.jar"
- basedir="${classes.dir}" compress="true" index="true" />
+ basedir="${classes.dir}"
+ excludes="${ads.classes.dir}, ${quicksetup.globalcompile.classes.dir}"
+ compress="true" index="true" />
<jar jarfile="${pdir}/lib/quicksetup.jar"
basedir="${quicksetup.classes.dir}" compress="true" index="true" />
- <jar jarfile="${pdir}/lib/statuspanel.jar"
- basedir="${statuspanel.classes.dir}" compress="true" index="true" />
-
<copy todir="${pdir}/lib">
<fileset file="${lib.dir}/*.jar" />
</copy>
@@ -1624,7 +1586,7 @@
dirmode="755" />
<zipfileset dir="${quicksetup.src.dir}" excludes="**/.svn" filemode="644"
dirmode="755" />
- <zipfileset dir="${statuspanel.src.dir}" excludes="**/.svn" filemode="644"
+ <zipfileset dir="${guitools.src.dir}" excludes="**/.svn" filemode="644"
dirmode="755" />
</zip>
</target>
diff --git a/opendj-sdk/opends/resource/bin/status b/opendj-sdk/opends/resource/bin/status
index 211e09d..69f182f 100644
--- a/opendj-sdk/opends/resource/bin/status
+++ b/opendj-sdk/opends/resource/bin/status
@@ -27,7 +27,7 @@
# This script may be used to display the status panel.
-OPENDS_INVOKE_CLASS="org.opends.statuspanel.StatusCli"
+OPENDS_INVOKE_CLASS="org.opends.guitools.statuspanel.StatusCli"
export OPENDS_INVOKE_CLASS
SCRIPT_DIR=`dirname "${0}"`
diff --git a/opendj-sdk/opends/resource/bin/status-panel b/opendj-sdk/opends/resource/bin/status-panel
index e294e3d..fe62e37 100644
--- a/opendj-sdk/opends/resource/bin/status-panel
+++ b/opendj-sdk/opends/resource/bin/status-panel
@@ -27,7 +27,7 @@
# This script may be used to display the status panel.
-OPENDS_INVOKE_CLASS="org.opends.statuspanel.StatusPanelLauncher"
+OPENDS_INVOKE_CLASS="org.opends.guitools.statuspanel.StatusPanelLauncher"
export OPENDS_INVOKE_CLASS
SCRIPT_DIR=`dirname "${0}"`
diff --git a/opendj-sdk/opends/resource/bin/status-panel.bat b/opendj-sdk/opends/resource/bin/status-panel.bat
index 9265104..834db2d 100644
--- a/opendj-sdk/opends/resource/bin/status-panel.bat
+++ b/opendj-sdk/opends/resource/bin/status-panel.bat
@@ -57,7 +57,7 @@
set PATH=%SystemRoot%
-"%DIR_HOME%\lib\winlauncher.exe" launch "%JAVA_BIN%" %JAVA_ARGS% org.opends.statuspanel.StatusPanelLauncher %*
+"%DIR_HOME%\lib\winlauncher.exe" launch "%JAVA_BIN%" %JAVA_ARGS% org.opends.guitools.statuspanel.StatusPanelLauncher %*
goto end
diff --git a/opendj-sdk/opends/resource/bin/status.bat b/opendj-sdk/opends/resource/bin/status.bat
index 5cec45a..1c95429 100644
--- a/opendj-sdk/opends/resource/bin/status.bat
+++ b/opendj-sdk/opends/resource/bin/status.bat
@@ -27,6 +27,6 @@
setlocal
-set OPENDS_INVOKE_CLASS="org.opends.statuspanel.StatusCli"
+set OPENDS_INVOKE_CLASS="org.opends.guitools.statuspanel.StatusCli"
set SCRIPT_NAME_ARG="-Dorg.opends.server.scriptName=status"
for %%i in (%~sf0) do call "%%~dPsi\..\lib\_server-script.bat" %*
diff --git a/opendj-sdk/opends/resource/uninstall b/opendj-sdk/opends/resource/uninstall
index f5834d0..019df2e 100644
--- a/opendj-sdk/opends/resource/uninstall
+++ b/opendj-sdk/opends/resource/uninstall
@@ -117,7 +117,7 @@
# Launch the uninstall process.
-"${JAVA_BIN}" org.opends.quicksetup.uninstaller.UninstallLauncher "${@}"
+"${JAVA_BIN}" org.opends.guitools.uninstaller.UninstallLauncher "${@}"
RETURN_CODE=$?
if test ${RETURN_CODE} -eq 50
@@ -126,4 +126,4 @@
exit 0
else
exit ${RETURN_CODE}
-fi
\ No newline at end of file
+fi
diff --git a/opendj-sdk/opends/resource/uninstall.bat b/opendj-sdk/opends/resource/uninstall.bat
index 58eaee4..f37c39c 100644
--- a/opendj-sdk/opends/resource/uninstall.bat
+++ b/opendj-sdk/opends/resource/uninstall.bat
@@ -72,11 +72,11 @@
goto callJava
:callLaunch
-"%DIR_HOME%\lib\winlauncher.exe" launch "%JAVA_BIN%" %JAVA_ARGS% org.opends.quicksetup.uninstaller.UninstallLauncher
+"%DIR_HOME%\lib\winlauncher.exe" launch "%JAVA_BIN%" %JAVA_ARGS% org.opends.guitools.uninstaller.UninstallLauncher
goto end
:callJava
-"%JAVA_BIN%" %JAVA_ARGS% org.opends.quicksetup.uninstaller.UninstallLauncher %*
+"%JAVA_BIN%" %JAVA_ARGS% org.opends.guitools.uninstaller.UninstallLauncher %*
rem return part
if %errorlevel% == 50 goto version
diff --git a/opendj-sdk/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java b/opendj-sdk/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java
index c396951..d5c9903 100644
--- a/opendj-sdk/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java
+++ b/opendj-sdk/opends/src/ads/org/opends/admin/ads/ServerDescriptor.java
@@ -723,6 +723,9 @@
v = getFirstValue(sr, "ds-cfg-replication-server-id");
desc.serverProperties.put(ServerProperty.REPLICATION_SERVER_ID,
Integer.parseInt(v));
+ Set<String> values = getValues(sr, "ds-cfg-replication-server");
+ desc.serverProperties.put(ServerProperty.EXTERNAL_REPLICATION_SERVERS,
+ values);
}
}
catch (NameNotFoundException nse)
diff --git a/opendj-sdk/opends/src/ads/org/opends/admin/ads/util/ConnectionUtils.java b/opendj-sdk/opends/src/ads/org/opends/admin/ads/util/ConnectionUtils.java
index c0c1aab..0d117c0 100644
--- a/opendj-sdk/opends/src/ads/org/opends/admin/ads/util/ConnectionUtils.java
+++ b/opendj-sdk/opends/src/ads/org/opends/admin/ads/util/ConnectionUtils.java
@@ -133,6 +133,7 @@
} catch (Throwable t)
{
+ t.printStackTrace();
pair[1] = t;
}
}
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/BaseDNDescriptor.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/BaseDNDescriptor.java
similarity index 98%
rename from opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/BaseDNDescriptor.java
rename to opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/BaseDNDescriptor.java
index b23cc38..08398dc 100644
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/BaseDNDescriptor.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/BaseDNDescriptor.java
@@ -25,7 +25,7 @@
* Portions Copyright 2007 Sun Microsystems, Inc.
*/
-package org.opends.statuspanel;
+package org.opends.guitools.statuspanel;
import org.opends.quicksetup.util.Utils;
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ConfigException.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConfigException.java
similarity index 96%
rename from opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ConfigException.java
rename to opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConfigException.java
index a247e27..3b69fce 100644
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ConfigException.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConfigException.java
@@ -25,7 +25,7 @@
* Portions Copyright 2007 Sun Microsystems, Inc.
*/
-package org.opends.statuspanel;
+package org.opends.guitools.statuspanel;
/**
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ConfigFromFile.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromFile.java
similarity index 99%
rename from opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ConfigFromFile.java
rename to opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromFile.java
index 538965e..8ca9099 100644
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ConfigFromFile.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromFile.java
@@ -25,7 +25,7 @@
* Portions Copyright 2007 Sun Microsystems, Inc.
*/
-package org.opends.statuspanel;
+package org.opends.guitools.statuspanel;
import java.io.IOException;
import java.util.HashSet;
@@ -45,9 +45,9 @@
import org.opends.server.types.Entry;
import org.opends.server.types.LDIFImportConfig;
import org.opends.server.types.ObjectClass;
+import org.opends.guitools.i18n.ResourceProvider;
import org.opends.quicksetup.util.Utils;
import org.opends.quicksetup.Installation;
-import org.opends.statuspanel.i18n.ResourceProvider;
/**
* This class is used to retrieve configuration information directly from the
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ConfigFromLDAP.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromLDAP.java
similarity index 99%
rename from opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ConfigFromLDAP.java
rename to opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromLDAP.java
index c4e21b9..03d00d3 100644
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ConfigFromLDAP.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConfigFromLDAP.java
@@ -25,7 +25,7 @@
* Portions Copyright 2007 Sun Microsystems, Inc.
*/
-package org.opends.statuspanel;
+package org.opends.guitools.statuspanel;
import java.util.HashMap;
import java.util.HashSet;
@@ -42,8 +42,8 @@
import javax.naming.ldap.InitialLdapContext;
import javax.naming.ldap.LdapName;
-import org.opends.statuspanel.i18n.ResourceProvider;
import org.opends.admin.ads.util.ApplicationTrustManager;
+import org.opends.guitools.i18n.ResourceProvider;
import org.opends.quicksetup.util.Utils;
/**
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ConnectionProtocolPolicy.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConnectionProtocolPolicy.java
similarity index 96%
rename from opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ConnectionProtocolPolicy.java
rename to opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConnectionProtocolPolicy.java
index 817cea9..e020d53 100644
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ConnectionProtocolPolicy.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ConnectionProtocolPolicy.java
@@ -25,7 +25,7 @@
* Portions Copyright 2007 Sun Microsystems, Inc.
*/
-package org.opends.statuspanel;
+package org.opends.guitools.statuspanel;
/** Policy to follow to choose the protocol to be used. */
public enum ConnectionProtocolPolicy
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/DatabaseDescriptor.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/DatabaseDescriptor.java
similarity index 98%
rename from opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/DatabaseDescriptor.java
rename to opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/DatabaseDescriptor.java
index 05a1af9..cb07d1c 100644
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/DatabaseDescriptor.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/DatabaseDescriptor.java
@@ -25,7 +25,7 @@
* Portions Copyright 2007 Sun Microsystems, Inc.
*/
-package org.opends.statuspanel;
+package org.opends.guitools.statuspanel;
import java.util.SortedSet;
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ListenerDescriptor.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ListenerDescriptor.java
similarity index 98%
rename from opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ListenerDescriptor.java
rename to opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ListenerDescriptor.java
index 90d6568..a9ea0c3 100644
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ListenerDescriptor.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ListenerDescriptor.java
@@ -25,7 +25,7 @@
* Portions Copyright 2007 Sun Microsystems, Inc.
*/
-package org.opends.statuspanel;
+package org.opends.guitools.statuspanel;
/**
* This class is used to represent a Listener and is aimed to be used by the
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ServerStatusDescriptor.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ServerStatusDescriptor.java
similarity index 99%
rename from opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ServerStatusDescriptor.java
rename to opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ServerStatusDescriptor.java
index ecfc56c..5a79858 100644
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ServerStatusDescriptor.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ServerStatusDescriptor.java
@@ -25,7 +25,7 @@
* Portions Copyright 2007 Sun Microsystems, Inc.
*/
-package org.opends.statuspanel;
+package org.opends.guitools.statuspanel;
import java.io.File;
import java.util.Set;
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ServerStatusPooler.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ServerStatusPooler.java
similarity index 97%
rename from opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ServerStatusPooler.java
rename to opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ServerStatusPooler.java
index 9652cbe..61033c9 100644
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ServerStatusPooler.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/ServerStatusPooler.java
@@ -25,7 +25,7 @@
* Portions Copyright 2007 Sun Microsystems, Inc.
*/
-package org.opends.statuspanel;
+package org.opends.guitools.statuspanel;
import java.io.File;
import java.util.HashSet;
@@ -33,11 +33,11 @@
import java.util.logging.Logger;
import org.opends.admin.ads.util.ApplicationTrustManager;
+import org.opends.guitools.i18n.ResourceProvider;
+import org.opends.guitools.statuspanel.event.ServerStatusChangeEvent;
+import org.opends.guitools.statuspanel.event.ServerStatusChangeListener;
import org.opends.quicksetup.Installation;
import org.opends.quicksetup.util.Utils;
-import org.opends.statuspanel.event.ServerStatusChangeEvent;
-import org.opends.statuspanel.event.ServerStatusChangeListener;
-import org.opends.statuspanel.i18n.ResourceProvider;
/**
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/SplashScreen.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/SplashScreen.java
similarity index 96%
rename from opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/SplashScreen.java
rename to opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/SplashScreen.java
index 7d8043a..35c0023 100644
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/SplashScreen.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/SplashScreen.java
@@ -25,7 +25,7 @@
* Portions Copyright 2007 Sun Microsystems, Inc.
*/
-package org.opends.statuspanel;
+package org.opends.guitools.statuspanel;
import javax.swing.SwingUtilities;
@@ -65,7 +65,7 @@
try
{
statusPanelClass = Class.forName(
- "org.opends.statuspanel.StatusPanelController");
+ "org.opends.guitools.statuspanel.StatusPanelController");
statusPanel = statusPanelClass.newInstance();
statusPanelClass.getMethod("initialize", new Class[]
{ String[].class }).invoke(statusPanel, new Object[]
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusCli.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusCli.java
similarity index 99%
rename from opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusCli.java
rename to opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusCli.java
index 97bef45..c550abb 100644
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusCli.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusCli.java
@@ -25,7 +25,7 @@
* Portions Copyright 2007 Sun Microsystems, Inc.
*/
-package org.opends.statuspanel;
+package org.opends.guitools.statuspanel;
import java.io.BufferedReader;
import java.io.File;
@@ -49,15 +49,15 @@
import org.opends.admin.ads.util.ApplicationKeyManager;
import org.opends.admin.ads.util.ApplicationTrustManager;
+import org.opends.guitools.i18n.ResourceProvider;
+import org.opends.guitools.statuspanel.ui.DatabasesTableModel;
+import org.opends.guitools.statuspanel.ui.ListenersTableModel;
import org.opends.quicksetup.Installation;
import org.opends.quicksetup.QuickSetupLog;
import org.opends.quicksetup.util.Utils;
import org.opends.server.core.DirectoryServer;
-import org.opends.statuspanel.i18n.ResourceProvider;
-import org.opends.statuspanel.ui.DatabasesTableModel;
-import org.opends.statuspanel.ui.ListenersTableModel;
import static org.opends.server.messages.MessageHandler.getMessage;
import static org.opends.server.messages.ToolMessages.*;
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusLog.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusLog.java
similarity index 98%
rename from opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusLog.java
rename to opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusLog.java
index 970b4c1..59c5a58 100644
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusLog.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusLog.java
@@ -24,7 +24,7 @@
*
* Portions Copyright 2007 Sun Microsystems, Inc.
*/
-package org.opends.statuspanel;
+package org.opends.guitools.statuspanel;
import java.io.File;
import java.io.IOException;
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusPanelController.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelController.java
similarity index 98%
rename from opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusPanelController.java
rename to opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelController.java
index 358690c..404ba34 100644
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusPanelController.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelController.java
@@ -25,7 +25,7 @@
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
-package org.opends.statuspanel;
+package org.opends.guitools.statuspanel;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
@@ -40,6 +40,12 @@
import org.opends.server.core.DirectoryServer;
import org.opends.admin.ads.util.ApplicationTrustManager;
+import org.opends.guitools.i18n.ResourceProvider;
+import org.opends.guitools.statuspanel.event.ServerStatusChangeEvent;
+import org.opends.guitools.statuspanel.event.ServerStatusChangeListener;
+import org.opends.guitools.statuspanel.event.StatusPanelButtonListener;
+import org.opends.guitools.statuspanel.ui.LoginDialog;
+import org.opends.guitools.statuspanel.ui.StatusPanelDialog;
import org.opends.quicksetup.Installation;
import org.opends.quicksetup.ui.ProgressDialog;
import org.opends.quicksetup.ui.UIFactory;
@@ -48,12 +54,6 @@
import org.opends.quicksetup.util.HtmlProgressMessageFormatter;
import org.opends.quicksetup.util.Utils;
-import org.opends.statuspanel.event.ServerStatusChangeEvent;
-import org.opends.statuspanel.event.ServerStatusChangeListener;
-import org.opends.statuspanel.event.StatusPanelButtonListener;
-import org.opends.statuspanel.i18n.ResourceProvider;
-import org.opends.statuspanel.ui.LoginDialog;
-import org.opends.statuspanel.ui.StatusPanelDialog;
/**
* This is the main class of the status panel.
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusPanelLauncher.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelLauncher.java
similarity index 98%
rename from opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusPanelLauncher.java
rename to opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelLauncher.java
index dc92fcf..2e9704c 100644
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusPanelLauncher.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/statuspanel/StatusPanelLauncher.java
@@ -24,7 +24,7 @@
*
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
-package org.opends.statuspanel;
+package org.opends.guitools.statuspanel;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -33,13 +33,13 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+import org.opends.guitools.i18n.ResourceProvider;
import org.opends.quicksetup.util.Utils;
import org.opends.quicksetup.Installation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.args.ArgumentParser;
import org.opends.server.util.args.BooleanArgument;
-import org.opends.statuspanel.i18n.ResourceProvider;
import static org.opends.server.messages.ToolMessages.*;
import static org.opends.server.tools.ToolConstants.*;
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallCliHelper.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
similarity index 97%
rename from opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallCliHelper.java
rename to opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
index 85049dc..4afdca8 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallCliHelper.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
@@ -25,9 +25,9 @@
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
-package org.opends.quicksetup.uninstaller;
+package org.opends.guitools.uninstaller;
-
+import org.opends.guitools.i18n.ResourceProvider;
import org.opends.quicksetup.*;
import org.opends.quicksetup.util.Utils;
@@ -143,6 +143,15 @@
}
/**
+ * Gets the resource provider instance.
+ * @return ResourceProvider instance
+ */
+ protected ResourceProvider getI18n()
+ {
+ return ResourceProvider.getInstance();
+ }
+
+ /**
* Commodity method used to ask the user to confirm the deletion of certain
* parts of the server. It updates the provided UserData object
* accordingly. Returns <CODE>true</CODE> if the user cancels and <CODE>
@@ -402,5 +411,4 @@
}
return confirm;
}
-
}
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallData.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallData.java
new file mode 100644
index 0000000..6c0806d
--- /dev/null
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallData.java
@@ -0,0 +1,111 @@
+/*
+ * 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.guitools.uninstaller;
+
+import java.io.IOException;
+import java.util.Iterator;
+
+import org.opends.admin.ads.ADSContext;
+import org.opends.quicksetup.Configuration;
+import org.opends.quicksetup.Installation;
+import org.opends.quicksetup.util.Utils;
+
+/**
+ * This is a convenience class used to represent the current configuraton and
+ * status of the server to know which kind of questions we must ask to the user
+ * (the server is running, it is configured for replication, it contains an
+ * ADS...).
+ *
+ * The difference with Installation class is that it provides read only
+ * information that is computed in the constructor of the class and not
+ * on demand. This way we can construct the object outside the event thread
+ * and then read it inside the event thread without blocking the display.
+ */
+public class UninstallData
+{
+ private boolean isServerRunning;
+ private boolean isADS;
+ private boolean isReplicationServer;
+ private int replicationServerPort;
+
+ /**
+ * The constructor for UninstallData.
+ * @param installation the object describing the installation.
+ * @throws IOException if there was an error retrieving the current
+ * installation configuration.
+ */
+ public UninstallData(Installation installation) throws IOException
+ {
+ isServerRunning = installation.getStatus().isServerRunning();
+ Configuration conf = new Configuration(installation,
+ installation.getCurrentConfigurationFile());
+ Iterator<String> it = conf.getBaseDNs().iterator();
+ while (it.hasNext() && !isADS)
+ {
+ isADS = Utils.areDnsEqual(it.next(),
+ ADSContext.getAdministrationSuffixDN());
+ }
+ isReplicationServer = conf.isReplicationServer();
+ replicationServerPort = conf.getReplicationPort();
+ }
+
+ /**
+ * Returns whether this server is configured as an ADS or not.
+ * @return <CODE>true</CODE> if the server is configured as an ADS and
+ * <CODE>false</CODE> otherwise.
+ */
+ public boolean isADS() {
+ return isADS;
+ }
+
+ /**
+ * Returns whether this server is configured as a replication server or not.
+ * @return <CODE>true</CODE> if the server is configured as a replication
+ * server and <CODE>false</CODE> otherwise.
+ */
+ public boolean isReplicationServer() {
+ return isReplicationServer;
+ }
+
+ /**
+ * Returns whether this server is running or not.
+ * @return <CODE>true</CODE> if the server is running and <CODE>false</CODE>
+ * otherwise.
+ */
+ public boolean isServerRunning() {
+ return isServerRunning;
+ }
+
+ /**
+ * Returns the port of the replication server. -1 if it is not defined.
+ * @return the port of the replication server. -1 if it is not defined.
+ */
+ public int getReplicationServerPort() {
+ return replicationServerPort;
+ }
+}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallLauncher.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallLauncher.java
similarity index 93%
rename from opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallLauncher.java
rename to opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallLauncher.java
index eb5f0e3..3ad72c0 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallLauncher.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallLauncher.java
@@ -25,7 +25,7 @@
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
-package org.opends.quicksetup.uninstaller;
+package org.opends.guitools.uninstaller;
import static org.opends.server.messages.ToolMessages.*;
import static org.opends.server.tools.ToolConstants.*;
@@ -33,6 +33,7 @@
import java.io.File;
import java.util.logging.Logger;
+import org.opends.guitools.i18n.ResourceProvider;
import org.opends.quicksetup.CliApplication;
import org.opends.quicksetup.Launcher;
import org.opends.quicksetup.Installation;
@@ -69,7 +70,9 @@
public static void main(String[] args) {
try {
QuickSetupLog.initLogFileHandler(
- File.createTempFile(LOG_FILE_PREFIX, LOG_FILE_SUFFIX));
+ File.createTempFile(LOG_FILE_PREFIX, LOG_FILE_SUFFIX),
+ "org.opends.guitools.uninstaller");
+
} catch (Throwable t) {
System.err.println("Unable to initialize log");
t.printStackTrace();
@@ -149,7 +152,7 @@
protected void willLaunchGui() {
System.out.println(getMsg("uninstall-launcher-launching-gui"));
System.setProperty("org.opends.quicksetup.Application.class",
- "org.opends.quicksetup.uninstaller.Uninstaller");
+ org.opends.guitools.uninstaller.Uninstaller.class.getName());
}
/**
@@ -166,4 +169,11 @@
return getI18n().getMsg("frame-uninstall-title");
}
+ /**
+ * {@inheritDoc}
+ */
+ protected ResourceProvider getI18n()
+ {
+ return ResourceProvider.getInstance();
+ }
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallProgressStep.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallProgressStep.java
similarity index 85%
rename from opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallProgressStep.java
rename to opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallProgressStep.java
index 889286c..50fc7e6 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallProgressStep.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallProgressStep.java
@@ -25,7 +25,7 @@
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
-package org.opends.quicksetup.uninstaller;
+package org.opends.guitools.uninstaller;
import org.opends.quicksetup.ProgressStep;
@@ -40,6 +40,11 @@
NOT_STARTED,
/**
+ * Unconfiguring replication in remote servers.
+ */
+ UNCONFIGURING_REPLICATION,
+
+ /**
* Stopping server.
*/
STOPPING_SERVER,
@@ -75,6 +80,11 @@
FINISHED_SUCCESSFULLY,
/**
+ * Installation finished with a non critical error updating remote servers.
+ */
+ FINISHED_WITH_ERROR_ON_REMOTE,
+
+ /**
* Installation finished with an error.
*/
FINISHED_WITH_ERROR;
@@ -84,7 +94,8 @@
*/
public boolean isLast() {
return this == FINISHED_SUCCESSFULLY ||
- this == FINISHED_WITH_ERROR;
+ this == FINISHED_WITH_ERROR ||
+ this == FINISHED_WITH_ERROR_ON_REMOTE;
}
/**
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallUserData.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallUserData.java
similarity index 88%
rename from opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallUserData.java
rename to opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallUserData.java
index 5e15eda..132e45f 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/UninstallUserData.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/UninstallUserData.java
@@ -25,7 +25,7 @@
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
-package org.opends.quicksetup.uninstaller;
+package org.opends.guitools.uninstaller;
import org.opends.quicksetup.UserData;
@@ -45,6 +45,7 @@
private boolean removeBackups;
private boolean removeLDIFs;
private boolean removeConfigurationAndSchema;
+ private boolean updateRemoteReplication;
/**
* Sets the database directories located outside the installation which must
@@ -206,4 +207,25 @@
{
return removeConfigurationAndSchema;
}
+
+ /**
+ * Sets whether to update remote replication configuration or not.
+ * @param updateRemoteReplication update remote replication configuration
+ * or not.
+ */
+ public void setUpdateRemoteReplication(boolean updateRemoteReplication)
+ {
+ this.updateRemoteReplication = updateRemoteReplication;
+ }
+
+ /**
+ * Returns whether the user wants to update remote replication configuration
+ * or not.
+ * @return <CODE>true</CODE> if the user wants to update remote replication
+ * configuration and <CODE>false</CODE> otherwise.
+ */
+ public boolean getUpdateRemoteReplication()
+ {
+ return updateRemoteReplication;
+ }
}
diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java
new file mode 100644
index 0000000..5b82226
--- /dev/null
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/uninstaller/Uninstaller.java
@@ -0,0 +1,1958 @@
+/*
+ * 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 2006-2007 Sun Microsystems, Inc.
+ */
+
+package org.opends.guitools.uninstaller;
+
+import org.opends.quicksetup.*;
+
+import static org.opends.quicksetup.Step.FINISHED;
+import static org.opends.quicksetup.Step.PROGRESS;
+import static org.opends.quicksetup.Step.REVIEW;
+
+import org.opends.admin.ads.ADSContext;
+import org.opends.admin.ads.ADSContextException;
+import org.opends.admin.ads.ReplicaDescriptor;
+import org.opends.admin.ads.ServerDescriptor;
+import org.opends.admin.ads.TopologyCache;
+import org.opends.admin.ads.TopologyCacheException;
+import org.opends.admin.ads.util.ApplicationTrustManager;
+import org.opends.guitools.i18n.ResourceProvider;
+import org.opends.guitools.uninstaller.ui.ConfirmUninstallPanel;
+import org.opends.guitools.uninstaller.ui.LoginDialog;
+import org.opends.quicksetup.ui.*;
+import org.opends.quicksetup.util.Utils;
+import org.opends.quicksetup.util.BackgroundTask;
+import org.opends.quicksetup.util.ServerController;
+import org.opends.server.admin.AttributeTypePropertyDefinition;
+import org.opends.server.admin.ClassLoaderProvider;
+import org.opends.server.admin.ClassPropertyDefinition;
+import org.opends.server.admin.ManagedObjectNotFoundException;
+import org.opends.server.admin.client.ManagementContext;
+import org.opends.server.admin.client.ldap.JNDIDirContextAdaptor;
+import org.opends.server.admin.client.ldap.LDAPManagementContext;
+import org.opends.server.admin.std.client.MultimasterDomainCfgClient;
+import
+org.opends.server.admin.std.client.MultimasterSynchronizationProviderCfgClient;
+import org.opends.server.admin.std.client.ReplicationServerCfgClient;
+import org.opends.server.admin.std.client.RootCfgClient;
+import org.opends.server.core.DirectoryServer;
+import org.opends.server.tools.ConfigureWindowsService;
+
+import java.io.*;
+import java.net.InetAddress;
+import java.net.URI;
+import java.security.cert.X509Certificate;
+import java.util.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.awt.event.WindowEvent;
+
+import javax.naming.Context;
+import javax.naming.directory.SearchControls;
+import javax.naming.ldap.InitialLdapContext;
+import javax.swing.JFrame;
+import javax.swing.SwingUtilities;
+
+/**
+ * This class is in charge of performing the uninstallation of Open DS.
+ */
+public class Uninstaller extends GuiApplication implements CliApplication {
+
+ private ProgressStep status = UninstallProgressStep.NOT_STARTED;
+ private boolean runStarted;
+ private boolean errorOnRemoteOccurred;
+
+ private HashMap<ProgressStep, Integer> hmRatio =
+ new HashMap<ProgressStep, Integer>();
+
+ private HashMap<ProgressStep, String> hmSummary =
+ new HashMap<ProgressStep, String>();
+
+ private ApplicationException ue;
+
+ private Boolean isWindowsServiceEnabled;
+
+ private UninstallCliHelper cliHelper = new UninstallCliHelper();
+
+ private static final Logger LOG =
+ Logger.getLogger(Uninstaller.class.getName());
+
+ private LoginDialog loginDialog;
+ private ProgressDialog startProgressDlg;
+ private StringBuffer startProgressDetails = new StringBuffer();
+ private UninstallData conf;
+ private String replicationServerHostPort;
+ private TopologyCache lastLoadedCache;
+ private ApplicationTrustManager trustManager =
+ new ApplicationTrustManager(null);
+
+ /**
+ * Default constructor.
+ */
+ public Uninstaller()
+ {
+ super();
+
+ /* Do some initialization required to use the administration framework
+ * classes. Note that this is not done in the installer code because
+ * when the basic configuration of the server is performed (using
+ * ConfigureDS) this initialization is done.
+ */
+ DirectoryServer.bootstrapClient();
+ // Bootstrap definition classes.
+ try
+ {
+ ClassLoaderProvider.getInstance().enable();
+ }
+ catch (Throwable t)
+ {
+ LOG.log(Level.WARNING, "Error enabling admin framework class loader: "+t,
+ t);
+ }
+
+ // Switch off class name validation in client.
+ ClassPropertyDefinition.setAllowClassValidation(false);
+
+ // Switch off attribute type name validation in client.
+ AttributeTypePropertyDefinition.setCheckSchema(false);
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public String getFrameTitle() {
+ return getMsg("frame-uninstall-title");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public UserData createUserData() {
+ return new UninstallUserData();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public WizardStep getFirstWizardStep() {
+ return Step.CONFIRM_UNINSTALL;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public WizardStep getNextWizardStep(WizardStep step) {
+ Step nextStep = null;
+ if (step != null && step.equals(Step.CONFIRM_UNINSTALL)) {
+ nextStep = Step.PROGRESS;
+ }
+ else if (Step.PROGRESS.equals(step))
+ {
+ nextStep = Step.FINISHED;
+ }
+ return nextStep;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public WizardStep getPreviousWizardStep(WizardStep step) {
+ Step prevStep = null;
+ if (step != null && step.equals(Step.PROGRESS)) {
+ prevStep = Step.CONFIRM_UNINSTALL;
+ }
+ else if (Step.FINISHED.equals(step))
+ {
+ prevStep = Step.PROGRESS;
+ }
+ return prevStep;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public WizardStep getFinishedStep() {
+ return Step.FINISHED;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean finishOnLeft()
+ {
+ return false;
+ }
+
+ /**
+ * {@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 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");
+ } else if (cStep == FINISHED) {
+ throw new IllegalStateException(
+ "Cannot click on next from finished 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 if (cStep == FINISHED)
+ {
+ qs.quit();
+ } else {
+ throw new IllegalStateException(
+ "Close only can be clicked on PROGRESS step");
+ }
+ }
+
+ /**
+ * Update the UserData object according to the content of the review
+ * panel.
+ */
+ private void updateUserUninstallDataForConfirmUninstallPanel(QuickSetup qs)
+ throws UserDataException {
+ UninstallUserData uud = getUninstallUserData();
+ 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));
+ // This is updated on the method handleTopologyCache
+ uud.setUpdateRemoteReplication(false);
+
+ 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");
+ }
+ else if (step == Step.FINISHED) {
+ throw new IllegalStateException(
+ "Cannot click on quit from finished step");
+ }
+ qs.quit();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getCloseButtonToolTipKey() {
+ return "close-button-uninstall-tooltip";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getFinishButtonToolTipKey() {
+ return "finish-button-uninstall-tooltip";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getFinishButtonLabelKey() {
+ return "finish-button-uninstall-label";
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void previousClicked(WizardStep cStep, QuickSetup qs) {
+ if (cStep == PROGRESS) {
+ throw new IllegalStateException(
+ "Cannot click on previous from progress step");
+ }
+ else if (cStep == FINISHED) {
+ throw new IllegalStateException(
+ "Cannot click on previous from finished step");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void notifyListeners(Integer ratio, String currentPhaseSummary,
+ final String newLogDetail)
+ {
+ if (runStarted)
+ {
+ super.notifyListeners(ratio, currentPhaseSummary, newLogDetail);
+ }
+ else
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ if (startProgressDlg != null)
+ {
+ if (newLogDetail != null)
+ {
+ startProgressDetails.append(newLogDetail);
+ startProgressDlg.setDetails(startProgressDetails.toString());
+ }
+ }
+ }
+ });
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean finishClicked(final WizardStep cStep, final QuickSetup qs) {
+ if (cStep == Step.CONFIRM_UNINSTALL) {
+ BackgroundTask worker = new BackgroundTask() {
+ public Object processBackgroundTask() throws UserDataException {
+ try {
+ updateUserUninstallDataForConfirmUninstallPanel(qs);
+ return new UninstallData(Installation.getLocal());
+ }
+ catch (UserDataException uude) {
+ throw uude;
+ } catch (Throwable t) {
+ LOG.log(Level.WARNING, "Error processing task: "+t, t);
+ throw new UserDataException(Step.CONFIRM_UNINSTALL,
+ getThrowableMsg("bug-msg", t));
+ }
+ }
+
+ public void backgroundTaskCompleted(Object returnValue,
+ Throwable throwable) {
+ qs.getDialog().workerFinished();
+ if (throwable != null) {
+ if (throwable instanceof UserDataException)
+ {
+ qs.displayError(throwable.getLocalizedMessage(),
+ getMsg("error-title"));
+ }
+ else
+ {
+ LOG.log(Level.WARNING, "Error processing task: "+throwable,
+ throwable);
+ qs.displayError(throwable.toString(), getMsg("error-title"));
+ }
+ } else {
+ conf = (UninstallData)returnValue;
+ if (conf.isADS() && conf.isReplicationServer())
+ {
+ if (conf.isServerRunning())
+ {
+ if (qs.displayConfirmation(
+ getMsg("confirm-uninstall-replication-server-running-msg"),
+ getMsg(
+ "confirm-uninstall-replication-server-running-title")))
+ {
+ askForAuthenticationAndLaunch(qs);
+ }
+ else
+ {
+ if (qs.displayConfirmation(
+ getMsg("confirm-uninstall-server-running-msg"),
+ getMsg("confirm-uninstall-server-running-title")))
+ {
+ getUserData().setStopServer(true);
+ qs.launch();
+ qs.setCurrentStep(
+ getNextWizardStep(Step.CONFIRM_UNINSTALL));
+ } else {
+ getUserData().setStopServer(false);
+ }
+ }
+ }
+ else
+ {
+ if (qs.displayConfirmation(
+ getMsg(
+ "confirm-uninstall-replication-server-not-running-msg"),
+ getMsg(
+ "confirm-uninstall-replication-server-not-running-title"
+ )))
+ {
+ boolean startWorked = startServer(qs.getDialog().getFrame());
+ if (startWorked)
+ {
+ askForAuthenticationAndLaunch(qs);
+ }
+ else
+ {
+ getUserData().setStopServer(false);
+ if (qs.displayConfirmation(
+ getMsg("confirm-uninstall-server-not-running-msg"),
+ getMsg("confirm-uninstall-server-not-running-title")))
+ {
+ qs.launch();
+ qs.setCurrentStep(
+ getNextWizardStep(Step.CONFIRM_UNINSTALL));
+ }
+ }
+ }
+ else
+ {
+ getUserData().setStopServer(false);
+ if (qs.displayConfirmation(
+ getMsg("confirm-uninstall-server-not-running-msg"),
+ getMsg("confirm-uninstall-server-not-running-title")))
+ {
+ qs.launch();
+ qs.setCurrentStep(
+ getNextWizardStep(Step.CONFIRM_UNINSTALL));
+ }
+ }
+ }
+ }
+ else if (!conf.isServerRunning())
+ {
+ getUserData().setStopServer(false);
+ if (qs.displayConfirmation(
+ getMsg("confirm-uninstall-server-not-running-msg"),
+ getMsg("confirm-uninstall-server-not-running-title")))
+ {
+ qs.launch();
+ qs.setCurrentStep(getNextWizardStep(
+ Step.CONFIRM_UNINSTALL));
+ }
+ } else {
+ if (qs.displayConfirmation(
+ getMsg("confirm-uninstall-server-running-msg"),
+ getMsg("confirm-uninstall-server-running-title"))) {
+ getUserData().setStopServer(true);
+ qs.launch();
+ qs.setCurrentStep(getNextWizardStep(
+ Step.CONFIRM_UNINSTALL));
+ } else {
+ getUserData().setStopServer(false);
+ }
+ }
+ }
+ }
+ };
+ qs.getDialog().workerStarted();
+ worker.startBackgroundTask();
+ }
+ // Uninstaller is responsible for updating user data and launching
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void updateUserData(WizardStep step, QuickSetup qs) {
+ // do nothing;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setWizardDialogState(QuickSetupDialog dlg,
+ UserData userData,
+ WizardStep step) {
+ if (step == Step.CONFIRM_UNINSTALL) {
+ dlg.setDefaultButton(ButtonName.FINISH);
+ dlg.setFocusOnButton(ButtonName.FINISH);
+ } else if ((step == PROGRESS) || (step == FINISHED)) {
+ dlg.setDefaultButton(ButtonName.CLOSE);
+ dlg.setFocusOnButton(ButtonName.CLOSE);
+ dlg.setButtonEnabled(ButtonName.CLOSE, false);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ * @param launcher
+ */
+ public UserData createUserData(Launcher launcher)
+ throws UserDataException {
+ return cliHelper.createUserData(launcher.getArguments());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getInstallationPath() {
+ return Utils.getInstallPathFromClasspath();
+ }
+
+ /**
+ * 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.
+ */
+ public ApplicationException getRunError() {
+ return ue;
+ }
+
+ /**
+ * Initialize the different map used in this class.
+ */
+ private void initMaps() {
+ hmSummary.put(UninstallProgressStep.NOT_STARTED,
+ getFormattedSummary(getMsg("summary-uninstall-not-started")));
+ hmSummary.put(UninstallProgressStep.STOPPING_SERVER,
+ getFormattedSummary(getMsg("summary-stopping")));
+ hmSummary.put(UninstallProgressStep.UNCONFIGURING_REPLICATION,
+ getFormattedSummary(getMsg("summary-unconfiguring-replication")));
+ hmSummary.put(UninstallProgressStep.DISABLING_WINDOWS_SERVICE,
+ getFormattedSummary(getMsg("summary-disabling-windows-service")));
+ hmSummary.put(UninstallProgressStep.DELETING_EXTERNAL_DATABASE_FILES,
+ getFormattedSummary(getMsg("summary-deleting-external-db-files")));
+ hmSummary.put(UninstallProgressStep.DELETING_EXTERNAL_LOG_FILES,
+ getFormattedSummary(getMsg("summary-deleting-external-log-files")));
+ hmSummary.put(UninstallProgressStep.REMOVING_EXTERNAL_REFERENCES,
+ getFormattedSummary(
+ getMsg("summary-deleting-external-references")));
+ hmSummary.put(UninstallProgressStep.DELETING_INSTALLATION_FILES,
+ getFormattedSummary(getMsg("summary-deleting-installation-files")));
+
+ String successMsg;
+ Installation installation = getInstallation();
+ String libPath = Utils.getPath(installation.getLibrariesDirectory());
+ if (Utils.isCli()) {
+ if (getUninstallUserData().getRemoveLibrariesAndTools()) {
+ String[] arg = new String[1];
+ if (Utils.isWindows()) {
+ arg[0] = installation.getUninstallBatFile() + getLineBreak() +
+ getTab() + libPath;
+ } else {
+ arg[0] = libPath;
+ }
+ successMsg = getMsg(
+ "summary-uninstall-finished-successfully-remove-jarfiles-cli",
+ arg);
+ } else {
+ successMsg = getMsg("summary-uninstall-finished-successfully-cli");
+ }
+ } else {
+ if (getUninstallUserData().getRemoveLibrariesAndTools()) {
+ String[] arg = {libPath};
+ successMsg = getMsg(
+ "summary-uninstall-finished-successfully-remove-jarfiles", arg);
+ } else {
+ successMsg = getMsg("summary-uninstall-finished-successfully");
+ }
+ }
+ hmSummary.put(UninstallProgressStep.FINISHED_SUCCESSFULLY,
+ getFormattedSuccess(successMsg));
+
+ String nonCriticalMsg;
+ if (Utils.isCli())
+ {
+ nonCriticalMsg =
+ getMsg("summary-uninstall-finished-with-error-on-remote");
+ }
+ else
+ {
+ nonCriticalMsg =
+ getMsg("summary-uninstall-finished-with-error-on-remote-cli");
+ }
+ hmSummary.put(UninstallProgressStep.FINISHED_WITH_ERROR_ON_REMOTE,
+ getFormattedWarning(nonCriticalMsg));
+ hmSummary.put(UninstallProgressStep.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.
+ */
+ HashMap<UninstallProgressStep, Integer> hmTime =
+ new HashMap<UninstallProgressStep, Integer>();
+ hmTime.put(UninstallProgressStep.UNCONFIGURING_REPLICATION, 5);
+ hmTime.put(UninstallProgressStep.STOPPING_SERVER, 15);
+ hmTime.put(UninstallProgressStep.DISABLING_WINDOWS_SERVICE, 5);
+ hmTime.put(UninstallProgressStep.DELETING_EXTERNAL_DATABASE_FILES, 30);
+ hmTime.put(UninstallProgressStep.DELETING_EXTERNAL_LOG_FILES, 5);
+ hmTime.put(UninstallProgressStep.REMOVING_EXTERNAL_REFERENCES, 5);
+ hmTime.put(UninstallProgressStep.DELETING_INSTALLATION_FILES, 10);
+
+ int totalTime = 0;
+ ArrayList<UninstallProgressStep> steps =
+ new ArrayList<UninstallProgressStep>();
+ if (getUninstallUserData().getUpdateRemoteReplication()) {
+ totalTime += hmTime.get(UninstallProgressStep.UNCONFIGURING_REPLICATION);
+ steps.add(UninstallProgressStep.UNCONFIGURING_REPLICATION);
+ }
+ if (getUserData().getStopServer()) {
+ totalTime += hmTime.get(UninstallProgressStep.STOPPING_SERVER);
+ steps.add(UninstallProgressStep.STOPPING_SERVER);
+ }
+ 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) {
+ totalTime += hmTime.get(
+ UninstallProgressStep.DELETING_EXTERNAL_DATABASE_FILES);
+ steps.add(UninstallProgressStep.DELETING_EXTERNAL_DATABASE_FILES);
+ }
+
+ if (getUninstallUserData().getExternalLogsToRemove().size() > 0) {
+ totalTime += hmTime.get(
+ UninstallProgressStep.DELETING_EXTERNAL_LOG_FILES);
+ steps.add(UninstallProgressStep.DELETING_EXTERNAL_LOG_FILES);
+ }
+
+ int cumulatedTime = 0;
+ for (UninstallProgressStep s : steps) {
+ Integer statusTime = hmTime.get(s);
+ hmRatio.put(s, (100 * cumulatedTime) / totalTime);
+ if (statusTime != null) {
+ cumulatedTime += statusTime;
+ }
+ }
+
+ hmRatio.put(UninstallProgressStep.FINISHED_SUCCESSFULLY, 100);
+ hmRatio.put(UninstallProgressStep.FINISHED_WITH_ERROR_ON_REMOTE, 100);
+ hmRatio.put(UninstallProgressStep.FINISHED_WITH_ERROR, 100);
+ }
+
+ /**
+ * Actually performs the uninstall in this thread. The thread is blocked.
+ */
+ public void run() {
+ runStarted = true;
+ initMaps();
+ PrintStream origErr = System.err;
+ PrintStream origOut = System.out;
+ try {
+ PrintStream err = new ErrorPrintStream();
+ PrintStream out = new OutputPrintStream();
+ if (!Utils.isCli()) {
+ System.setErr(err);
+ System.setOut(out);
+ }
+
+ boolean displaySeparator = false;
+
+ if (getUninstallUserData().getUpdateRemoteReplication())
+ {
+ status = UninstallProgressStep.UNCONFIGURING_REPLICATION;
+ removeRemoteServerReferences();
+ displaySeparator = true;
+ }
+
+ if (getUserData().getStopServer()) {
+ status = UninstallProgressStep.STOPPING_SERVER;
+ if (displaySeparator) {
+ notifyListeners(getTaskSeparator());
+ }
+ new ServerController(this).stopServer();
+ displaySeparator = true;
+ }
+ if (isWindowsServiceEnabled()) {
+ status = UninstallProgressStep.DISABLING_WINDOWS_SERVICE;
+ if (displaySeparator) {
+ notifyListeners(getTaskSeparator());
+ }
+ disableWindowsService();
+ displaySeparator = true;
+ }
+
+ Set<String> dbsToDelete = getUninstallUserData().getExternalDbsToRemove();
+ if (dbsToDelete.size() > 0) {
+ status = UninstallProgressStep.DELETING_EXTERNAL_DATABASE_FILES;
+ if (displaySeparator) {
+ notifyListeners(getTaskSeparator());
+ }
+
+ deleteExternalDatabaseFiles(dbsToDelete);
+ displaySeparator = true;
+ }
+
+ Set<String> logsToDelete =
+ getUninstallUserData().getExternalLogsToRemove();
+ if (logsToDelete.size() > 0) {
+ status = UninstallProgressStep.DELETING_EXTERNAL_LOG_FILES;
+
+ if (displaySeparator) {
+ notifyListeners(getTaskSeparator());
+ }
+
+ deleteExternalLogFiles(logsToDelete);
+ displaySeparator = true;
+ }
+
+ UninstallUserData userData = getUninstallUserData();
+ boolean somethingToDelete = userData.getRemoveBackups() ||
+ userData.getRemoveConfigurationAndSchema() ||
+ userData.getRemoveDatabases() ||
+ userData.getRemoveLDIFs() ||
+ userData.getRemoveLibrariesAndTools() ||
+ userData.getRemoveLogs();
+ if (displaySeparator && somethingToDelete) {
+ notifyListeners(getTaskSeparator());
+ }
+
+ if (somethingToDelete) {
+ status = UninstallProgressStep.DELETING_INSTALLATION_FILES;
+ deleteInstallationFiles(getRatio(status),
+ getRatio(UninstallProgressStep.FINISHED_SUCCESSFULLY));
+ }
+ if (errorOnRemoteOccurred)
+ {
+ status = UninstallProgressStep.FINISHED_WITH_ERROR_ON_REMOTE;
+ }
+ else
+ {
+ status = UninstallProgressStep.FINISHED_SUCCESSFULLY;
+ }
+ if (Utils.isCli()) {
+ notifyListeners(getLineBreak() + getLineBreak() + getSummary(status));
+ } else {
+ notifyListeners(null);
+ }
+
+ } catch (ApplicationException ex) {
+ ue = ex;
+ status = UninstallProgressStep.FINISHED_WITH_ERROR;
+ String msg = getFormattedError(ex, true);
+ notifyListeners(msg);
+ }
+ catch (Throwable t) {
+ ue = new ApplicationException(
+ ApplicationReturnCode.ReturnCode.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);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ProgressStep getCurrentProgressStep() {
+ return status;
+ }
+
+ /**
+ * 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.
+ */
+ 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.
+ */
+ public String getSummary(ProgressStep step) {
+ return hmSummary.get(step);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isFinished() {
+ return getCurrentProgressStep() ==
+ UninstallProgressStep.FINISHED_SUCCESSFULLY
+ || getCurrentProgressStep() ==
+ UninstallProgressStep.FINISHED_WITH_ERROR
+ || getCurrentProgressStep() ==
+ UninstallProgressStep.FINISHED_WITH_ERROR_ON_REMOTE;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isCancellable() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void cancel() {
+ // do nothing; not cancellable
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void windowClosing(QuickSetupDialog dlg, WindowEvent evt) {
+ if ((dlg.getDisplayedStep() == PROGRESS) ||
+ (dlg.getDisplayedStep() == FINISHED)) {
+ // Simulate a close button event
+ dlg.notifyButtonEvent(ButtonName.CLOSE);
+ } else {
+ // Simulate a quit button event
+ dlg.notifyButtonEvent(ButtonName.QUIT);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ButtonName getInitialFocusButtonName() {
+ return ButtonName.FINISH;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Set<? extends WizardStep> getWizardSteps() {
+ Set<WizardStep> setSteps = new HashSet<WizardStep>();
+ setSteps.add(Step.CONFIRM_UNINSTALL);
+ setSteps.add(Step.PROGRESS);
+ setSteps.add(Step.FINISHED);
+ return Collections.unmodifiableSet(setSteps);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public QuickSetupStepPanel createWizardStepPanel(WizardStep step) {
+ QuickSetupStepPanel p = null;
+ if (step == Step.CONFIRM_UNINSTALL) {
+ p = new ConfirmUninstallPanel(this, installStatus);
+ } else if (step == Step.PROGRESS) {
+ p = new ProgressPanel(this);
+ } else if (step == Step.FINISHED) {
+ p = new FinishedPanel(this);
+ }
+ return p;
+ }
+
+ /**
+ * 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 {
+ notifyListeners(getFormattedProgress(
+ 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 {
+ notifyListeners(getFormattedProgress(
+ 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 {
+ notifyListeners(getFormattedProgress(
+ getMsg("progress-deleting-installation-files")) +
+ getLineBreak());
+ File f = new File(Utils.getInstallPathFromClasspath());
+ InstallationFilesToDeleteFilter filter =
+ new InstallationFilesToDeleteFilter();
+ File[] rootFiles = f.listFiles();
+ 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])) {
+ Installation installation = getInstallation();
+ int relativeRatio;
+ if (equalsOrDescendant(rootFiles[i],
+ installation.getLibrariesDirectory())) {
+ relativeRatio = 10;
+ } else
+ if (equalsOrDescendant(rootFiles[i],
+ installation.getBinariesDirectory())) {
+ relativeRatio = 5;
+ } else
+ if (equalsOrDescendant(rootFiles[i],
+ installation.getConfigurationDirectory())) {
+ relativeRatio = 5;
+ } else
+ if (equalsOrDescendant(rootFiles[i],
+ installation.getBackupDirectory())) {
+ relativeRatio = 20;
+ } else
+ if (equalsOrDescendant(rootFiles[i],
+ installation.getLdifDirectory())) {
+ relativeRatio = 20;
+ } else if (equalsOrDescendant(rootFiles[i],
+ installation.getDatabasesDirectory())) {
+ relativeRatio = 50;
+ } else
+ if (equalsOrDescendant(rootFiles[i],
+ installation.getLogsDirectory())) {
+ 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++) {
+ int beforeRatio = minRatio +
+ ((it.next() * (maxRatio - minRatio)) / totalRatio);
+ hmRatio.put(UninstallProgressStep.DELETING_INSTALLATION_FILES,
+ beforeRatio);
+ deleteRecursively(rootFiles[i], filter);
+ }
+ hmRatio.put(UninstallProgressStep.DELETING_INSTALLATION_FILES, maxRatio);
+ }
+ }
+
+ /**
+ * 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 {
+ deleteRecursively(file, null);
+ }
+
+ /**
+ * Deletes everything below the specified file.
+ *
+ * @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.
+ * @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)) {
+ delete(file);
+ }
+ } else {
+ delete(file);
+ }
+ } else {
+ File[] children = file.listFiles();
+ if (children != null) {
+ for (int i = 0; i < children.length; i++) {
+ deleteRecursively(children[i], filter);
+ }
+ }
+ if (filter != null) {
+ if (filter.accept(file)) {
+ delete(file);
+ }
+ } else {
+ delete(file);
+ }
+ }
+ } else {
+ // Just tell that the file/directory does not exist.
+ String[] arg = {file.toString()};
+ notifyListeners(getFormattedWarning(
+ getMsg("progress-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 {
+ String[] arg = {file.getAbsolutePath()};
+ boolean isFile = file.isFile();
+
+ if (isFile) {
+ notifyListeners(getFormattedWithPoints(
+ getMsg("progress-deleting-file", arg)));
+ } else {
+ notifyListeners(getFormattedWithPoints(
+ getMsg("progress-deleting-directory", arg)));
+ }
+
+ boolean delete = false;
+ /*
+ * Sometimes the server keeps some locks on the files.
+ * This is dependent on the OS so there is no much we can do here.
+ */
+ int nTries = 5;
+ for (int i = 0; i < nTries && !delete; i++) {
+ delete = file.delete();
+ if (!delete) {
+ try {
+ Thread.sleep(1000);
+ }
+ catch (Exception ex) {
+ }
+ }
+ }
+
+ if (!delete) {
+ String errMsg;
+ if (isFile) {
+ errMsg = getMsg("error-deleting-file", arg);
+ } else {
+ errMsg = getMsg("error-deleting-directory", arg);
+ }
+ throw new ApplicationException(
+ ApplicationReturnCode.ReturnCode.FILE_SYSTEM_ACCESS_ERROR,
+ errMsg, null);
+ }
+
+ notifyListeners(getFormattedDone() + getLineBreak());
+ }
+
+ private boolean equalsOrDescendant(File file, File directory) {
+ return file.equals(directory) || Utils.isDescendant(file, directory);
+ }
+
+ /**
+ * This class is used to get the files that are not binaries. This is
+ * required to know which are the files that can be deleted directly and which
+ * not.
+ */
+ class InstallationFilesToDeleteFilter implements FileFilter {
+ Installation installation = getInstallation();
+ File quicksetupFile = installation.getQuicksetupJarFile();
+ File openDSFile = installation.getOpenDSJarFile();
+ File librariesFile = installation.getLibrariesDirectory();
+ File activationFile = new File(librariesFile, "activation.jar");
+ File aspectRuntimeFile = new File(librariesFile, "aspectjrt.jar");
+ File uninstallBatFile = installation.getUninstallBatFile();
+
+ File installationPath = installation.getRootDirectory();
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean accept(File file) {
+ UninstallUserData userData = getUninstallUserData();
+ boolean[] uData = {
+ userData.getRemoveLibrariesAndTools(),
+ userData.getRemoveLibrariesAndTools(),
+ userData.getRemoveDatabases(),
+ userData.getRemoveLogs(),
+ userData.getRemoveConfigurationAndSchema(),
+ userData.getRemoveBackups(),
+ userData.getRemoveLDIFs()
+ };
+
+ Installation installation = getInstallation();
+ File[] parentFiles = {
+ installation.getLibrariesDirectory(),
+ installation.getBinariesDirectory(),
+ installation.getDatabasesDirectory(),
+ installation.getLogsDirectory(),
+ installation.getConfigurationDirectory(),
+ installation.getBackupDirectory(),
+ installation.getLdifDirectory()
+ };
+
+ boolean accept =
+ !installationPath.equals(file)
+ && !equalsOrDescendant(file, librariesFile)
+ && !quicksetupFile.equals(file)
+ && !openDSFile.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, parentFiles[i]);
+ }
+
+ LOG.log(Level.INFO, "accept for :"+file+" is: "+accept);
+ return accept;
+ }
+ }
+
+ private boolean isWindowsServiceEnabled() {
+ if (isWindowsServiceEnabled == null) {
+ if (ConfigureWindowsService.serviceState(null, null) ==
+ ConfigureWindowsService.SERVICE_STATE_ENABLED) {
+ isWindowsServiceEnabled = Boolean.TRUE;
+ } else {
+ isWindowsServiceEnabled = Boolean.FALSE;
+ }
+ }
+ return isWindowsServiceEnabled.booleanValue();
+ }
+
+ /**
+ * Returns a ResourceProvider instance.
+ * @return a ResourceProvider instance.
+ */
+ public ResourceProvider getI18n()
+ {
+ return ResourceProvider.getInstance();
+ }
+
+ /**
+ * This methods disables this server as a Windows service.
+ *
+ * @throws ApplicationException if something goes wrong.
+ */
+ protected void disableWindowsService() throws ApplicationException {
+ notifyListeners(getFormattedProgress(
+ getMsg("progress-disabling-windows-service")));
+ int code = ConfigureWindowsService.disableService(System.out, System.err);
+
+ String errorMessage = getMsg("error-disabling-windows-service",
+ getInstallationPath());
+
+ switch (code) {
+ case ConfigureWindowsService.SERVICE_DISABLE_SUCCESS:
+ break;
+ case ConfigureWindowsService.SERVICE_ALREADY_DISABLED:
+ break;
+ default:
+ throw new ApplicationException(
+ ApplicationReturnCode.ReturnCode.WINDOWS_SERVICE_ERROR,
+ errorMessage, null);
+ }
+ }
+
+ private UninstallUserData getUninstallUserData() {
+ return (UninstallUserData) getUserData();
+ }
+
+ /**
+ * Tries to start the server and launches a progress dialog. This method
+ * assumes that is being called from the event thread.
+ * @return <CODE>true</CODE> if the server could be started and <CODE>
+ * false</CODE> otherwise.
+ * @param frame the JFrame to be used as parent of the progress dialog.
+ */
+ private boolean startServer(JFrame frame)
+ {
+ startProgressDetails = new StringBuffer();
+ startProgressDlg = new ProgressDialog(frame);
+ startProgressDlg.setSummary(
+ getFormattedSummary(getMsg("summary-starting")));
+ startProgressDlg.setDetails("");
+ startProgressDlg.setCloseButtonEnabled(false);
+ final Boolean[] returnValue = new Boolean[] {Boolean.FALSE};
+ Thread t = new Thread(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ new ServerController(Uninstaller.this).startServer();
+ final boolean isServerRunning =
+ Installation.getLocal().getStatus().isServerRunning();
+ returnValue[0] = isServerRunning;
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ if (isServerRunning)
+ {
+ startProgressDlg.setSummary(getFormattedSuccess(
+ getMsg("summary-start-success")));
+ }
+ else
+ {
+ startProgressDlg.setSummary(getFormattedError(
+ getMsg("summary-start-error")));
+ }
+ startProgressDlg.setCloseButtonEnabled(true);
+ }
+ });
+ }
+ catch (Throwable t)
+ {
+ String msg = getFormattedError(t, true);
+ notifyListeners(msg);
+ }
+ }
+ });
+ t.start();
+ startProgressDlg.pack();
+ Utilities.centerOnComponent(startProgressDlg, frame);
+ startProgressDlg.setModal(true);
+ startProgressDlg.setVisible(true);
+ startProgressDlg = null;
+ return returnValue[0];
+ }
+
+ /**
+ * This method displays a login dialog message, asking the user to provide
+ * authentication to retrieve information from the ADS and update the
+ * remote servers. Then it tries to connect to the remote servers.
+ *
+ * @param qs the QuickSetup object.
+ */
+ private void askForAuthenticationAndLaunch(final QuickSetup qs)
+ {
+ if (loginDialog == null)
+ {
+ loginDialog = new LoginDialog(qs.getDialog().getFrame(), trustManager);
+ loginDialog.pack();
+ }
+ Utilities.centerOnComponent(loginDialog, qs.getDialog().getFrame());
+ loginDialog.setModal(true);
+ loginDialog.setVisible(true);
+ if (!loginDialog.isCancelled())
+ {
+ final InitialLdapContext ctx = loginDialog.getContext();
+
+ replicationServerHostPort = loginDialog.getHostName() + ":" +
+ conf.getReplicationServerPort();
+
+ BackgroundTask worker = new BackgroundTask()
+ {
+ public Object processBackgroundTask()throws TopologyCacheException
+ {
+ ADSContext adsContext = new ADSContext(ctx);
+ TopologyCache cache = new TopologyCache(adsContext,
+ getTrustManager());
+ cache.reloadTopology();
+ return cache;
+ }
+ public void backgroundTaskCompleted(Object returnValue,
+ Throwable throwable) {
+ qs.getDialog().workerFinished();
+ if (throwable != null)
+ {
+ if (throwable instanceof TopologyCacheException)
+ {
+ qs.displayError(
+ getStringRepresentation((TopologyCacheException)throwable),
+ getMsg("error-title"));
+ }
+ else
+ {
+ qs.displayError(
+ getThrowableMsg("bug-msg", null, throwable),
+ getMsg("error-title"));
+ }
+ }
+ else
+ {
+ TopologyCache cache = (TopologyCache)returnValue;
+ handleTopologyCache(qs, cache);
+ }
+ }
+ };
+
+ qs.getDialog().workerStarted();
+ worker.startBackgroundTask();
+ }
+ else
+ {
+ if (qs.displayConfirmation(
+ getMsg("confirm-uninstall-server-running-msg"),
+ getMsg("confirm-uninstall-server-running-title")))
+ {
+ getUserData().setStopServer(true);
+ qs.launch();
+ qs.setCurrentStep(getNextWizardStep(Step.CONFIRM_UNINSTALL));
+ } else {
+ getUserData().setStopServer(false);
+ }
+ }
+ }
+
+ /**
+ * Method that interacts with the user depending on what errors where
+ * encountered in the TopologyCache object. This method assumes that the
+ * TopologyCache has been reloaded.
+ * Note: this method assumes that is being called from the event thread.
+ * @param qs the QuickSetup object for the application.
+ * @param cache the TopologyCache.
+ */
+ private void handleTopologyCache(QuickSetup qs, TopologyCache cache)
+ {
+ boolean stopProcessing = false;
+ Set<TopologyCacheException> exceptions =
+ new HashSet<TopologyCacheException>();
+ /* Analyze if we had any exception while loading servers. For the moment
+ * only throw the exception found if the user did not provide the
+ * Administrator DN and this caused a problem authenticating in one server
+ * or if there is a certificate problem.
+ */
+ Set<ServerDescriptor> servers = cache.getServers();
+ for (ServerDescriptor server : servers)
+ {
+ TopologyCacheException e = server.getLastException();
+ if (e != null)
+ {
+ exceptions.add(e);
+ }
+ }
+ Set<String> exceptionMsgs = new LinkedHashSet<String>();
+ /* Check the exceptions and see if we throw them or not. */
+ for (TopologyCacheException e : exceptions)
+ {
+ if (stopProcessing)
+ {
+ break;
+ }
+ switch (e.getType())
+ {
+ case NOT_GLOBAL_ADMINISTRATOR:
+ String errorMsg = getMsg("not-global-administrator-provided");
+ qs.displayError(errorMsg, getMsg("error-title"));
+ stopProcessing = true;
+ break;
+ case GENERIC_CREATING_CONNECTION:
+ if ((e.getCause() != null) &&
+ Utils.isCertificateException(e.getCause()))
+ {
+ UserDataCertificateException.Type excType;
+ ApplicationTrustManager.Cause cause = null;
+ if (e.getTrustManager() != null)
+ {
+ cause = e.getTrustManager().getLastRefusedCause();
+ }
+ LOG.log(Level.INFO, "Certificate exception cause: "+cause);
+ if (cause == ApplicationTrustManager.Cause.NOT_TRUSTED)
+ {
+ excType = UserDataCertificateException.Type.NOT_TRUSTED;
+ }
+ else if (cause == ApplicationTrustManager.Cause.HOST_NAME_MISMATCH)
+ {
+ excType = UserDataCertificateException.Type.HOST_NAME_MISMATCH;
+ }
+ else
+ {
+ excType = null;
+ }
+ if (excType != null)
+ {
+ String h;
+ int p;
+ try
+ {
+ URI uri = new URI(e.getLdapUrl());
+ h = uri.getHost();
+ p = uri.getPort();
+ }
+ catch (Throwable t)
+ {
+ LOG.log(Level.WARNING,
+ "Error parsing ldap url of TopologyCacheException.", t);
+ h = getMsg("not-available-label");
+ p = -1;
+ }
+ UserDataCertificateException exc =
+ new UserDataCertificateException(Step.REPLICATION_OPTIONS,
+ getMsg("certificate-exception", h, String.valueOf(p)),
+ e.getCause(), h, p,
+ e.getTrustManager().getLastRefusedChain(),
+ e.getTrustManager().getLastRefusedAuthType(), excType);
+ handleCertificateException(qs, exc, cache);
+ stopProcessing = true;
+ }
+ }
+ }
+ exceptionMsgs.add(getStringRepresentation(e));
+ }
+ if (!stopProcessing && (exceptionMsgs.size() > 0))
+ {
+ String confirmationMsg =
+ getMsg("error-reading-registered-servers-confirm",
+ Utils.getStringFromCollection(exceptionMsgs, "\n"));
+ stopProcessing = !qs.displayConfirmation(confirmationMsg,
+ getMsg("confirmation-title"));
+ }
+ if (!stopProcessing)
+ {
+ stopProcessing = !qs.displayConfirmation(
+ getMsg("confirm-uninstall-server-running-msg"),
+ getMsg("confirm-uninstall-server-running-title"));
+ }
+ if (!stopProcessing)
+ {
+ // Launch everything
+ lastLoadedCache = cache;
+ getUninstallUserData().setUpdateRemoteReplication(true);
+ getUserData().setStopServer(true);
+ qs.launch();
+ qs.setCurrentStep(getNextWizardStep(Step.CONFIRM_UNINSTALL));
+ }
+ }
+
+ /**
+ * Displays a dialog asking the user to accept a certificate if the user
+ * accepts it, we update the trust manager and call again to the method that
+ * handles the action of clicking on "Finish".
+ * This method assumes that we are being called from the event thread.
+ */
+ private void handleCertificateException(final QuickSetup qs,
+ UserDataCertificateException ce, final TopologyCache cache)
+ {
+ CertificateDialog dlg =
+ new CertificateDialog(qs.getDialog().getFrame(), ce);
+ dlg.pack();
+ dlg.setVisible(true);
+ if (dlg.isAccepted())
+ {
+ X509Certificate[] chain = ce.getChain();
+ String authType = ce.getAuthType();
+ String host = ce.getHost();
+
+ if ((chain != null) && (authType != null) && (host != null))
+ {
+ LOG.log(Level.INFO, "Accepting certificate presented by host "+host);
+ getTrustManager().acceptCertificate(chain, authType, host);
+ BackgroundTask worker = new BackgroundTask()
+ {
+ public Object processBackgroundTask()throws TopologyCacheException
+ {
+ cache.reloadTopology();
+ return cache;
+ }
+ public void backgroundTaskCompleted(Object returnValue,
+ Throwable throwable) {
+ qs.getDialog().workerFinished();
+ if (throwable != null)
+ {
+ if (throwable instanceof TopologyCacheException)
+ {
+ qs.displayError(
+ getStringRepresentation((TopologyCacheException)throwable),
+ getMsg("error-title"));
+ }
+ else
+ {
+ qs.displayError(
+ getThrowableMsg("bug-msg", null, throwable),
+ getMsg("error-title"));
+ }
+ }
+ else
+ {
+ handleTopologyCache(qs, cache);
+ }
+ }
+ };
+
+ qs.getDialog().workerStarted();
+ worker.startBackgroundTask();
+ }
+ else
+ {
+ if (chain == null)
+ {
+ LOG.log(Level.WARNING,
+ "The chain is null for the UserDataCertificateException");
+ }
+ if (authType == null)
+ {
+ LOG.log(Level.WARNING,
+ "The auth type is null for the UserDataCertificateException");
+ }
+ if (host == null)
+ {
+ LOG.log(Level.WARNING,
+ "The host is null for the UserDataCertificateException");
+ }
+ }
+ }
+ }
+
+ /**
+ * This method updates the replication in the remote servers. It does not
+ * thrown any exception and works in a best effort mode.
+ * It also tries to delete the server registration entry from the remote ADS
+ * servers.
+ */
+ private void removeRemoteServerReferences()
+ {
+ Set<ServerDescriptor> servers = lastLoadedCache.getServers();
+ Map<ADSContext.ServerProperty, Object> serverADSProperties = null;
+ for (ServerDescriptor server : servers)
+ {
+ if (isServerToUninstall(server))
+ {
+ serverADSProperties = server.getAdsProperties();
+ break;
+ }
+ }
+ if (serverADSProperties == null)
+ {
+ LOG.log(Level.WARNING, "The server ADS properties for the server to "+
+ "uninstall could not be found.");
+ }
+ for (ServerDescriptor server : servers)
+ {
+ if (server.getAdsProperties() != serverADSProperties)
+ {
+ removeReferences(server, serverADSProperties);
+ }
+ }
+ }
+
+ /**
+ * This method updates the replication in the remote server represented by
+ * a given ServerProperty object. It does not thrown any exception and works
+ * in a best effort mode.
+ * It also tries to delete the server registration entry from the remote ADS
+ * servers if the serverADSProperties object passed is not null.
+ * @param server the ServerDescriptor object representing the server where
+ * we want to remove references to the server that we are trying to uninstall.
+ * @param serverADSProperties the Map with the ADS properties of the server
+ * that we are trying to uninstall.
+ */
+ private void removeReferences(ServerDescriptor server,
+ Map<ADSContext.ServerProperty, Object> serverADSProperties)
+ {
+ /* First check if the server must be updated based in the contents of the
+ * ServerDescriptor object. */
+ boolean hasReferences = false;
+
+ Object v = server.getServerProperties().get(
+ ServerDescriptor.ServerProperty.IS_REPLICATION_SERVER);
+ if (Boolean.TRUE.equals(v))
+ {
+ Set replicationServers = (Set<?>)server.getServerProperties().get(
+ ServerDescriptor.ServerProperty.EXTERNAL_REPLICATION_SERVERS);
+ if (replicationServers != null)
+ {
+ for (Object o : replicationServers)
+ {
+ if (replicationServerHostPort.equalsIgnoreCase((String)o))
+ {
+ hasReferences = true;
+ break;
+ }
+ }
+ }
+ }
+
+ if (!hasReferences)
+ {
+ for (ReplicaDescriptor replica : server.getReplicas())
+ {
+ if (replica.isReplicated())
+ {
+ for (Object o : replica.getReplicationServers())
+ {
+ if (replicationServerHostPort.equalsIgnoreCase((String)o))
+ {
+ hasReferences = true;
+ break;
+ }
+ }
+ }
+ if (hasReferences)
+ {
+ break;
+ }
+ }
+ }
+
+ if (hasReferences)
+ {
+ LOG.log(Level.INFO, "Updating references in: "+ server.getHostPort(true));
+ notifyListeners(getFormattedWithPoints(
+ getMsg("progress-removing-references", server.getHostPort(true))));
+ InitialLdapContext ctx = null;
+ try
+ {
+ String dn =
+ ADSContext.getAdministratorDN(loginDialog.getAdministratorUid());
+ String pwd = loginDialog.getAdministratorPwd();
+ ctx = getRemoteConnection(server, dn, pwd, getTrustManager());
+ try
+ {
+ /*
+ * Search for the config to check that it is the directory manager.
+ */
+ SearchControls searchControls = new SearchControls();
+ searchControls.setCountLimit(1);
+ searchControls.setSearchScope(
+ SearchControls. OBJECT_SCOPE);
+ searchControls.setReturningAttributes(new String[] {"*"});
+ ctx.search("cn=config", "objectclass=*", searchControls);
+ }
+ catch (Throwable t)
+ {
+ System.out.println("FUCK: "+t);
+ t.printStackTrace();
+ }
+ // Update replication servers and domains. If the domain
+ // is an ADS, then remove it from there.
+ removeReferences(ctx, server.getHostPort(true), serverADSProperties);
+
+ notifyListeners(getFormattedDone() + getLineBreak());
+ }
+ catch (ApplicationException ae)
+ {
+ errorOnRemoteOccurred = true;
+ String html = getFormattedError(ae, true);
+ notifyListeners(html);
+ LOG.log(Level.INFO, "Error updating replication references in: "+
+ server.getHostPort(true), ae);
+ }
+ if (ctx != null)
+ {
+ try
+ {
+ ctx.close();
+ }
+ catch (Throwable t)
+ {
+ }
+ }
+ }
+ }
+
+ /**
+ * This method updates the replication in the remote server using the
+ * provided InitialLdapContext.
+ * It also tries to delete the server registration entry from the remote ADS
+ * servers if the serverADSProperties object passed is not null.
+ * @param ctx the connection to the remote server where we want to remove
+ * references to the server that we are trying to uninstall.
+ * @param serverDisplay an String representation that is used to identify
+ * the remote server in the log messages we present to the user.
+ * @param serverADSProperties the Map with the ADS properties of the server
+ * that we are trying to uninstall.
+ * @throws ApplicationException if an error occurs while updating the remote
+ * OpenDS server configuration.
+ */
+ private void removeReferences(InitialLdapContext ctx, String serverDisplay,
+ Map<ADSContext.ServerProperty, Object> serverADSProperties)
+ throws ApplicationException
+ {
+ try
+ {
+ ManagementContext mCtx = LDAPManagementContext.createFromContext(
+ JNDIDirContextAdaptor.adapt(ctx));
+ RootCfgClient root = mCtx.getRootConfiguration();
+ MultimasterSynchronizationProviderCfgClient sync =
+ (MultimasterSynchronizationProviderCfgClient)
+ root.getSynchronizationProvider("Multimaster Synchronization");
+ if (sync.hasReplicationServer())
+ {
+ ReplicationServerCfgClient replicationServer =
+ sync.getReplicationServer();
+ Set<String> replServers = replicationServer.getReplicationServer();
+ if (replServers != null)
+ {
+ String replServer = null;
+ for (String o : replServers)
+ {
+ if (replicationServerHostPort.equalsIgnoreCase(o))
+ {
+ replServer = o;
+ break;
+ }
+ }
+ if (replServer != null)
+ {
+ LOG.log(Level.INFO, "Updating references in replication server on "+
+ serverDisplay+".");
+ replServers.remove(replServer);
+ if (replServers.size() > 0)
+ {
+ replicationServer.setReplicationServer(replServers);
+ replicationServer.commit();
+ }
+ else
+ {
+ sync.removeReplicationServer();
+ sync.commit();
+ }
+ }
+ }
+ }
+ String[] domainNames = sync.listMultimasterDomains();
+ if (domainNames != null)
+ {
+ for (int i=0; i<domainNames.length; i++)
+ {
+ MultimasterDomainCfgClient domain =
+ sync.getMultimasterDomain(domainNames[i]);
+ Set<String> replServers = domain.getReplicationServer();
+ if (replServers != null)
+ {
+ String replServer = null;
+ for (String o : replServers)
+ {
+ if (replicationServerHostPort.equalsIgnoreCase(o))
+ {
+ replServer = o;
+ break;
+ }
+ }
+ if (replServer != null)
+ {
+ LOG.log(Level.INFO, "Updating references in domain " +
+ domain.getReplicationDN()+" on " + serverDisplay + ".");
+ replServers.remove(replServer);
+ if (replServers.size() > 0)
+ {
+ domain.setReplicationServer(replServers);
+ domain.commit();
+ }
+ else
+ {
+ sync.removeMultimasterDomain(domainNames[i]);
+ sync.commit();
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (ManagedObjectNotFoundException monfe)
+ {
+ // It does not exist.
+ LOG.log(Level.INFO, "No synchronization found on "+ serverDisplay+".",
+ monfe);
+ }
+ catch (Throwable t)
+ {
+ LOG.log(Level.WARNING,
+ "Error removing references in replication server on "+
+ serverDisplay+": "+t, t);
+ String errorMessage = getMsg("error-configuring-remote-generic",
+ serverDisplay, t.toString());
+ throw new ApplicationException(
+ ApplicationReturnCode.ReturnCode.CONFIGURATION_ERROR, errorMessage,
+ t);
+ }
+ ADSContext adsContext = new ADSContext(ctx);
+
+ try
+ {
+ if (adsContext.hasAdminData() && (serverADSProperties != null))
+ {
+ adsContext.unregisterServer(serverADSProperties);
+ }
+ }
+ catch (ADSContextException ace)
+ {
+ if (ace.getError() !=
+ ADSContextException.ErrorType.NOT_YET_REGISTERED)
+ {
+ String[] args = {serverDisplay, ace.toString()};
+ throw new ApplicationException(
+ ApplicationReturnCode.ReturnCode.CONFIGURATION_ERROR,
+ getMsg("remote-ads-exception", args), ace);
+ }
+ else
+ {
+ // Nothing to do: this may occur if the new server has been
+ // unregistered on another server and the modification has
+ // been already propagated by replication.
+ }
+ }
+ }
+
+ /**
+ * Tells whether this ServerDescriptor object represents the server that we
+ * are trying to uninstall or not.
+ * @param server the ServerDescriptor object to analyze.
+ * @return <CODE>true</CODE> if the ServerDescriptor object represents the
+ * server that we are trying to uninstall and <CODE>false</CODE> otherwise.
+ */
+ private boolean isServerToUninstall(ServerDescriptor server)
+ {
+ boolean isServerToUninstall = false;
+ String path = (String)server.getAdsProperties().get(
+ ADSContext.ServerProperty.INSTANCE_PATH);
+ if (path == null)
+ {
+ // Compare the port of the URL we used.
+ try
+ {
+ String usedUrl = (String)
+ loginDialog.getContext().getEnvironment().get(Context.PROVIDER_URL);
+ boolean isSecure = usedUrl.toLowerCase().startsWith("ldaps");
+ URI uri = new URI(usedUrl);
+ int port = uri.getPort();
+ ServerDescriptor.ServerProperty property;
+ if (isSecure)
+ {
+ property = ServerDescriptor.ServerProperty.LDAPS_PORT;
+ }
+ else
+ {
+ property = ServerDescriptor.ServerProperty.LDAP_PORT;
+ }
+ ArrayList ports = (ArrayList)server.getServerProperties().get(property);
+ isServerToUninstall = ports.contains(port);
+ }
+ catch (Throwable t)
+ {
+ LOG.log(Level.WARNING, "Failing checking the port: "+t, t);
+ }
+ }
+ else
+ {
+ File f = new File(path);
+ isServerToUninstall =
+ f.equals(Installation.getLocal().getRootDirectory());
+ }
+
+ if (isServerToUninstall)
+ {
+ // TODO: the host name comparison made here does not necessarily work in
+ // all environments...
+ String hostName = server.getHostName();
+ boolean hostNameEquals = false;
+ try
+ {
+ InetAddress localAddress = InetAddress.getLocalHost();
+ InetAddress[] addresses = InetAddress.getAllByName(hostName);
+ for (int i=0; i<addresses.length && !hostNameEquals; i++)
+ {
+ hostNameEquals = localAddress.equals(addresses[i]);
+ }
+ }
+ catch (Throwable t)
+ {
+ LOG.log(Level.WARNING, "Failing checking host names: "+t, t);
+ }
+ isServerToUninstall = hostNameEquals;
+ }
+ return isServerToUninstall;
+ }
+}
+
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 789d738..327d4c8 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Application.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/Application.java
@@ -27,7 +27,11 @@
package org.opends.quicksetup;
+import org.opends.admin.ads.ADSContext;
+import org.opends.admin.ads.ServerDescriptor;
+import org.opends.admin.ads.TopologyCacheException;
import org.opends.admin.ads.util.ApplicationTrustManager;
+import org.opends.admin.ads.util.ServerLoader;
import org.opends.quicksetup.event.ProgressNotifier;
import org.opends.quicksetup.event.ProgressUpdateListener;
import org.opends.quicksetup.util.ServerController;
@@ -40,9 +44,13 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
+import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
+import javax.naming.NamingException;
+import javax.naming.ldap.InitialLdapContext;
+
/**
* This class represents an application that can be run in the context of
* QuickSetup. Examples of applications might be 'installer', 'uninstaller'
@@ -280,7 +288,7 @@
* Returns a ResourceProvider instance.
* @return a ResourceProvider instance.
*/
- protected ResourceProvider getI18n()
+ public ResourceProvider getI18n()
{
return ResourceProvider.getInstance();
}
@@ -651,6 +659,70 @@
}
/**
+ * Returns a localized representation of a TopologyCacheException object.
+ * @param e the exception we want to obtain the representation from.
+ * @return a localized representation of a TopologyCacheException object.
+ */
+ protected String getStringRepresentation(TopologyCacheException e)
+ {
+ StringBuilder buf = new StringBuilder();
+
+ String ldapUrl = e.getLdapUrl();
+ if (ldapUrl != null)
+ {
+ String hostName = ldapUrl.substring(ldapUrl.indexOf("://") + 3);
+ buf.append(getMsg("server-error", hostName) + " ");
+ }
+ if (e.getCause() instanceof NamingException)
+ {
+ buf.append(getThrowableMsg("bug-msg", null, e.getCause()));
+ }
+ else
+ {
+ // This is unexpected.
+ buf.append(getThrowableMsg("bug-msg", null, e.getCause()));
+ }
+ return buf.toString();
+ }
+
+ /**
+ * Gets an InitialLdapContext based on the information that appears on the
+ * provided ServerDescriptor object. Note that the server is assumed to be
+ * registered and that contains a Map with ADSContext.ServerProperty keys.
+ * @param server the object describing the server.
+ * @param trustManager the trust manager to be used to establish the
+ * connection.
+ * @param dn the dn to be used to authenticate.
+ * @param pwd the pwd to be used to authenticate.
+ * @return the InitialLdapContext to the remote server.
+ * @throws ApplicationException if something goes wrong.
+ */
+ protected InitialLdapContext getRemoteConnection(ServerDescriptor server,
+ String dn, String pwd, ApplicationTrustManager trustManager)
+ throws ApplicationException
+ {
+ Map<ADSContext.ServerProperty, Object> adsProperties =
+ server.getAdsProperties();
+ ServerLoader loader = new ServerLoader(adsProperties, dn, pwd,
+ trustManager);
+
+ InitialLdapContext ctx = null;
+ try
+ {
+ ctx = loader.createContext();
+ }
+ catch (NamingException ne)
+ {
+ String errorMessage = getMsg("cannot-connect-to-remote-generic",
+ server.getHostPort(true), ne.toString(true));
+ throw new ApplicationException(
+ ApplicationReturnCode.ReturnCode.CONFIGURATION_ERROR, errorMessage,
+ ne);
+ }
+ return ctx;
+ }
+
+ /**
* This class is used to notify the ProgressUpdateListeners of events
* that are written to the standard error. It is used in WebStartInstaller
* and in OfflineInstaller. These classes just create a ErrorPrintStream and
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/CliApplicationHelper.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/CliApplicationHelper.java
index 52b9983..536ca94 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/CliApplicationHelper.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/CliApplicationHelper.java
@@ -344,7 +344,7 @@
* @param key String key
* @return String message
*/
- protected static String getMsg(String key)
+ protected String getMsg(String key)
{
return org.opends.server.util.StaticUtils.wrapText(getI18n().getMsg(key),
Utils.getCommandLineMaxLineWidth());
@@ -357,7 +357,7 @@
* @param args String[] args
* @return String message
*/
- protected static String getMsg(String key, String... args)
+ protected String getMsg(String key, String... args)
{
return org.opends.server.util.StaticUtils.wrapText(
getI18n().getMsg(key, args), Utils.getCommandLineMaxLineWidth());
@@ -367,7 +367,7 @@
* Gets the resource provider instance.
* @return ResourceProvider instance
*/
- protected static ResourceProvider getI18n()
+ protected ResourceProvider getI18n()
{
return ResourceProvider.getInstance();
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/QuickSetupLog.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/QuickSetupLog.java
index 41f8853..9511cd6 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/QuickSetupLog.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/QuickSetupLog.java
@@ -45,6 +45,7 @@
static public final String LOG_FILE_SUFFIX = ".log";
static private File logFile = null;
+ static private FileHandler fileHandler = null;
/**
* Creates a new file handler for writing log messages to the file indicated
@@ -55,7 +56,7 @@
static public void initLogFileHandler(File file) throws IOException {
if (!isInitialized()) {
logFile = file;
- FileHandler fileHandler = new FileHandler(logFile.getCanonicalPath());
+ fileHandler = new FileHandler(logFile.getCanonicalPath());
fileHandler.setFormatter(new SimpleFormatter());
Logger logger = Logger.getLogger("org.opends.quicksetup");
logger.addHandler(fileHandler);
@@ -68,6 +69,22 @@
}
/**
+ * Creates a new file handler for writing log messages of a given package
+ * to the file indicated by <code>file</code>.
+ * @param file log file to which log messages will be written.
+ * @param packageName the name of the package of the classes that generate
+ * log messages.
+ * @throws IOException if something goes wrong
+ */
+ static public void initLogFileHandler(File file, String packageName)
+ throws IOException {
+ initLogFileHandler(file);
+ Logger logger = Logger.getLogger(packageName);
+ logger.addHandler(fileHandler);
+ logger.setUseParentHandlers(false);
+ }
+
+ /**
* Prevents messages written to loggers from appearing in the console
* output.
*/
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 c6203ce..25611a8 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserData.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/UserData.java
@@ -595,7 +595,7 @@
String name = "";
try
{
- name = java.net.InetAddress.getLocalHost().getHostName();
+ name = java.net.InetAddress.getLocalHost().getCanonicalHostName();
}
catch (Throwable t)
{
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installandupgrader/InstallAndUpgrader.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installandupgrader/InstallAndUpgrader.java
index 7b8ea6b..48c323a 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installandupgrader/InstallAndUpgrader.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installandupgrader/InstallAndUpgrader.java
@@ -124,17 +124,7 @@
*/
public UserData getUserData()
{
- if (userData == null) {
- userData = (InstallAndUpgradeUserData)createUserData();
- }
- return userData;
- }
-
- /**
- * {@inheritDoc}
- */
- public UserData createUserData() {
- return new InstallAndUpgradeUserData();
+ return getDelegateApplication().getUserData();
}
/**
@@ -466,7 +456,7 @@
if (cStep == Step.WELCOME)
{
Boolean isUpgrade = (Boolean)qs.getFieldValue(FieldName.IS_UPGRADE);
- ((InstallAndUpgradeUserData)getUserData()).setUpgrade(isUpgrade);
+ getInstallAndUpgradeUserData().setUpgrade(isUpgrade);
if (isUpgrade)
{
upgrader.updateUserData(UpgradeWizardStep.WELCOME, qs);
@@ -519,7 +509,7 @@
private GuiApplication getDelegateApplication()
{
GuiApplication application;
- if (((InstallAndUpgradeUserData)getUserData()).isUpgrade())
+ if (getInstallAndUpgradeUserData().isUpgrade())
{
application = upgrader;
}
@@ -529,4 +519,16 @@
}
return application;
}
+
+ /**
+ * Returns the install and upgrader specific user data.
+ * @return the install and upgrader specific user data.
+ */
+ public InstallAndUpgradeUserData getInstallAndUpgradeUserData()
+ {
+ if (userData == null) {
+ userData = new InstallAndUpgradeUserData();
+ }
+ return userData;
+ }
}
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installandupgrader/ui/WelcomePanel.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installandupgrader/ui/WelcomePanel.java
index 4dbe215..621ba57 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installandupgrader/ui/WelcomePanel.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installandupgrader/ui/WelcomePanel.java
@@ -32,7 +32,6 @@
import org.opends.quicksetup.UserData;
import org.opends.quicksetup.event.BrowseActionListener;
import org.opends.quicksetup.event.ButtonEvent;
-import org.opends.quicksetup.installandupgrader.InstallAndUpgradeUserData;
import org.opends.quicksetup.installandupgrader.InstallAndUpgrader;
import org.opends.server.util.DynamicConstants;
@@ -60,12 +59,17 @@
private JButton butBrowse;
+ private InstallAndUpgrader appl;
+
+ private boolean initialized = false;
+
/**
* Default constructor.
* @param application Upgrader application
*/
public WelcomePanel(InstallAndUpgrader application) {
super(application);
+ appl = application;
}
/**
@@ -73,10 +77,14 @@
*/
public void beginDisplay(UserData data) {
super.beginDisplay(data);
- tcServerLocation.setText(data.getServerLocation());
- boolean isUpgrade = ((InstallAndUpgradeUserData)data).isUpgrade();
- rbInstall.setSelected(!isUpgrade);
- rbUpgrade.setSelected(isUpgrade);
+ if (!initialized)
+ {
+ tcServerLocation.setText(data.getServerLocation());
+ boolean isUpgrade = appl.getInstallAndUpgradeUserData().isUpgrade();
+ rbInstall.setSelected(!isUpgrade);
+ rbUpgrade.setSelected(isUpgrade);
+ initialized = true;
+ }
checkEnablingState();
}
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 34e69fb..664d310 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
@@ -62,7 +62,6 @@
import org.opends.admin.ads.TopologyCache;
import org.opends.admin.ads.TopologyCacheException;
import org.opends.admin.ads.util.ApplicationTrustManager;
-import org.opends.admin.ads.util.ServerLoader;
import org.opends.quicksetup.ui.*;
import org.opends.quicksetup.util.Utils;
import org.opends.quicksetup.*;
@@ -1158,7 +1157,24 @@
{
if (registeredNewServerOnRemote)
{
- adsContext.unregisterServer(getNewServerAdsProperties());
+ try
+ {
+ adsContext.unregisterServer(getNewServerAdsProperties());
+ }
+ catch (ADSContextException ace)
+ {
+ if (ace.getError() !=
+ ADSContextException.ErrorType.NOT_YET_REGISTERED)
+ {
+ throw ace;
+ }
+ else
+ {
+ // Nothing to do: this may occur if the new server has been
+ // unregistered on another server and the modification has
+ // been already propagated by replication.
+ }
+ }
}
if (createdAdministrator)
{
@@ -3728,28 +3744,6 @@
return Utils.isCertificateException(t);
}
- private String getStringRepresentation(TopologyCacheException e)
- {
- StringBuilder buf = new StringBuilder();
-
- String ldapUrl = e.getLdapUrl();
- if (ldapUrl != null)
- {
- String hostName = ldapUrl.substring(ldapUrl.indexOf("://") + 3);
- buf.append(getMsg("server-error", hostName) + " ");
- }
- if (e.getCause() instanceof NamingException)
- {
- buf.append(getThrowableMsg("bug-msg", null, e.getCause()));
- }
- else
- {
- // This is unexpected.
- buf.append(getThrowableMsg("bug-msg", null, e.getCause()));
- }
- return buf.toString();
- }
-
private Map<ServerDescriptor, Integer> getRemoteWithNoReplicationPort(
UserData userData)
{
@@ -3815,6 +3809,16 @@
}
}
+
+ /**
+ * Gets an InitialLdapContext based on the information that appears on the
+ * provided ServerDescriptor.
+ * @param server the object describing the server.
+ * @param trustManager the trust manager to be used to establish the
+ * connection.
+ * @return the InitialLdapContext to the remote server.
+ * @throws ApplicationException if something goes wrong.
+ */
private InitialLdapContext getRemoteConnection(ServerDescriptor server,
ApplicationTrustManager trustManager) throws ApplicationException
{
@@ -3837,7 +3841,7 @@
if (auth.useSecureConnection())
{
adsProperties.put(ADSContext.ServerProperty.LDAPS_PORT,
- String.valueOf(auth.getPort()));
+ String.valueOf(auth.getPort()));
adsProperties.put(ADSContext.ServerProperty.LDAPS_ENABLED, "true");
}
else
@@ -3846,29 +3850,10 @@
String.valueOf(auth.getPort()));
adsProperties.put(ADSContext.ServerProperty.LDAP_ENABLED, "true");
}
+ server.setAdsProperties(adsProperties);
}
- else
- {
- adsProperties = server.getAdsProperties();
- }
-
- ServerLoader loader = new ServerLoader(adsProperties, auth.getDn(),
- auth.getPwd(), trustManager);
-
- InitialLdapContext ctx = null;
- try
- {
- ctx = loader.createContext();
- }
- catch (NamingException ne)
- {
- String errorMessage = getMsg("cannot-connect-to-remote-generic",
- server.getHostPort(true), ne.toString(true));
- throw new ApplicationException(
- ApplicationReturnCode.ReturnCode.CONFIGURATION_ERROR, errorMessage,
- ne);
- }
- return ctx;
+ return getRemoteConnection(server, auth.getDn(), auth.getPwd(),
+ trustManager);
}
private void initializeSuffix(InitialLdapContext ctx, int replicaId,
@@ -4044,12 +4029,12 @@
if (lastLogMsg == null)
{
errorMsg = getMsg("error-during-initialization-no-log",
- sourceServerDisplay);
+ sourceServerDisplay, state);
}
else
{
errorMsg = getMsg("error-during-initialization-log",
- sourceServerDisplay, lastLogMsg);
+ sourceServerDisplay, lastLogMsg, state);
}
if (helper.isCompletedWithErrors(state))
@@ -4062,9 +4047,10 @@
ApplicationException ae = new ApplicationException(
ApplicationReturnCode.ReturnCode.APPLICATION_ERROR, errorMsg,
null);
- if ((lastLogMsg != null) &&
+ if ((lastLogMsg == null) ||
helper.isPeersNotFoundError(lastLogMsg))
{
+ // Assume that this is a peer not found error.
throw new PeerNotFoundException(errorMsg);
}
else
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/InstallerHelper.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/InstallerHelper.java
index 9385e73..2428735 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/InstallerHelper.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/installer/InstallerHelper.java
@@ -30,10 +30,7 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
@@ -55,22 +52,16 @@
import org.opends.server.admin.std.client.*;
import org.opends.server.admin.std.meta.*;
import org.opends.server.backends.task.TaskState;
-import org.opends.server.core.DirectoryServer;
-import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.messages.CoreMessages;
import org.opends.server.messages.ReplicationMessages;
import org.opends.server.tools.ConfigureDS;
import org.opends.server.tools.ConfigureWindowsService;
import org.opends.server.tools.ImportLDIF;
-import org.opends.server.types.Attribute;
-import org.opends.server.types.AttributeType;
-import org.opends.server.types.AttributeValue;
import org.opends.server.types.DN;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.Entry;
import org.opends.server.types.ExistingFileBehavior;
import org.opends.server.types.LDIFExportConfig;
-import org.opends.server.types.ObjectClass;
import org.opends.server.util.LDIFException;
import org.opends.server.util.LDIFWriter;
import org.opends.server.util.StaticUtils;
@@ -280,7 +271,8 @@
"Multimaster Synchronization",
new ArrayList<DefaultBehaviorException>());
sync.setJavaImplementationClass(
- "org.opends.server.replication.plugin.MultimasterReplication");
+ org.opends.server.replication.plugin.MultimasterReplication.class.
+ getName());
sync.setEnabled(Boolean.TRUE);
synchProviderCreated = true;
synchProviderEnabled = false;
@@ -443,7 +435,6 @@
*/
if (replConf.isSynchProviderCreated())
{
- MultimasterSynchronizationProviderCfgClient sync = null;
try
{
root.removeSynchronizationProvider("Multimaster Synchronization");
@@ -476,6 +467,7 @@
if (replServers != null)
{
replServers.removeAll(replConf.getNewReplicationServers());
+ replicationServer.setReplicationServer(replServers);
replicationServer.commit();
}
}
@@ -495,6 +487,7 @@
if (replServers != null)
{
replServers.removeAll(domain.getAddedReplicationServers());
+ d.setReplicationServer(replServers);
d.commit();
}
}
@@ -585,52 +578,6 @@
return logMsg.indexOf(
"="+ReplicationMessages.MSGID_NO_REACHABLE_PEER_IN_THE_DOMAIN) != -1;
}
- private void addConfigEntry(ConfigFileHandler configFileHandler, DN dn,
- String[] ocs, String[] attributeNames, String[][] attributeValues)
- throws DirectoryException
- {
- HashMap<ObjectClass,String> objectClasses =
- new HashMap<ObjectClass,String>();
- HashMap<AttributeType,List<Attribute>> userAttributes =
- new HashMap<AttributeType,List<Attribute>>();
- HashMap<AttributeType,List<Attribute>> operationalAttributes =
- new HashMap<AttributeType,List<Attribute>>();
-
- for (int j=0; j<ocs.length; j++)
- {
- String ocName = ocs[j];
- ObjectClass objectClass = DirectoryServer.getObjectClass(ocName);
- if (objectClass == null)
- {
- objectClass = DirectoryServer.getDefaultObjectClass(ocName);
- }
- objectClasses.put(objectClass, ocName);
- }
- for (int j=0; j<attributeNames.length; j++)
- {
- String attrName = attributeNames[j];
- AttributeType attrType = DirectoryServer.getAttributeType(attrName);
- if (attrType == null)
- {
- attrType = DirectoryServer.getDefaultAttributeType(attrName);
- }
- String[] attrValues = attributeValues[j];
- LinkedHashSet<AttributeValue> valueSet =
- new LinkedHashSet<AttributeValue>();
- for (int k=0; k<attrValues.length; k++)
- {
- AttributeValue attributeValue = new AttributeValue(attrType,
- attrValues[k]);
- valueSet.add(attributeValue);
- }
- ArrayList<Attribute> attrList = new ArrayList<Attribute>();
- attrList.add(new Attribute(attrType, attrName, null, valueSet));
- userAttributes.put(attrType, attrList);
- }
- Entry entry = new Entry(dn, objectClasses, userAttributes,
- operationalAttributes);
- configFileHandler.addEntry(entry, null);
- }
private int getReplicationId(Set<Integer> usedIds)
{
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 691c68d..5fabe83 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
@@ -41,52 +41,7 @@
failed. Check file {0} for more details.\n\n\
Launching command line Setup...
-#
-# Uninstall command line messages
-#
-uninstall-launcher-usage-description=This utility may be used to uninstall the \
-Directory Server.
-uninstall-launcher-launching-gui=Launching graphical uninstall...
-uninstall-launcher-launching-cli=Launching command line uninstall...
-uninstall-launcher-gui-launched-failed=\n\nThe graphical Uninstall launch \
-failed.\n\nLaunching command line Uninstall...
-uninstall-launcher-gui-launched-failed-details=\n\nThe graphical Uninstall \
-launch failed. Check file {0} for more details.\n\nLaunching command line \
-Uninstall...
-cli-uninstall-unknown-argument=Unknown argument {0}
-cli-uninstall-yes-short=y
-cli-uninstall-yes-long=yes
-cli-uninstall-no-short=n
-cli-uninstall-no-long=no
-cli-uninstall-confirm-prompt={0}\n[{1}]:
-cli-uninstall-string-prompt={0}\n[{1}]:
-cli-uninstall-error-reading-stdin=Unexpected error reading standard input.
-cli-uninstall-what-to-delete=Do you want to remove all components of \
-OpenDS or select the components to remove?\n\
-1. Remove all components\n\
-2. Select the components to be removed\n\
-3. Neither; Quit the uninstaller
-cli-uninstall-confirm-libraries-binaries=Remove Server Libraries and \
-Administrative Tools?
-cli-uninstall-confirm-databases=Remove Database Contents?
-cli-uninstall-confirm-logs=Remove Log Files?
-cli-uninstall-confirm-configuration-schema=Remove Configuration and Schema \
-Files?
-cli-uninstall-confirm-backups=Remove Backup Files Contained in bak Directory?
-cli-uninstall-confirm-ldifs=Remove LDIF Export Files Contained in ldif \
-Directory?
-cli-uninstall-confirm-outsidedbs=The Directory Server contains database files \
-in the following locations outside the server path:\n{0}\nRemove these files?
-cli-uninstall-confirm-outsidelogs=The Directory Server contains log files in \
-the following locations outside the server path:\n{0}\nRemove these files?
-cli-uninstall-nothing-to-be-uninstalled=You must select something to be \
-uninstalled.
-cli-uninstall-confirm-stop=The OpenDS server is currently running and \
-must be stopped before uninstallation can continue.\nStop the Server and \
-permanently delete the files?
-cli-uninstall-confirm-delete-files=The files will be permanently deleted, are \
-you sure you want to continue?
-cli-uninstall-server-stopped=The Server is Stopped.
+
#
# Upgrade command line messages
@@ -125,7 +80,6 @@
# Dialog titles
#
frame-install-title=OpenDS QuickSetup
-frame-uninstall-title=OpenDS Uninstall
frame-upgrade-title=OpenDS QuickUpgrade
#
@@ -137,22 +91,18 @@
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-upgrade-tooltip=Finish Upgrade
finish-button-tooltip=Finish Setup
close-button-label=Close
close-button-tooltip=Close Setup Window
close-progress-button-tooltip=Close Progress Dialog
close-button-install-tooltip=Close Setup Window
-close-button-uninstall-tooltip=Close Uninstall Window
quit-button-label=Quit
quit-button-install-tooltip=Quit Setup
quit-button-upgrade-tooltip=Quit Upgrade
cancel-button-label=Cancel
cancel-button-tooltip=Cancel the currently running operation
-cancel-button-uninstall-tooltip=Cancel Uninstall
shutdown-button-label=Shutdown
continue-button-label=Continue
continue-button-install-tooltip=Continue with Setup
@@ -171,9 +121,6 @@
confirm-quit-install-title=Confirmation Required
confirm-quit-install-msg=Are you sure you want to quit OpenDS \
QuickSetup?\nIf you click 'Yes' nothing will be installed on your system.
-confirm-close-uninstall-title=Confirmation Required
-confirm-close-uninstall-msg=OpenDS Uninstall has not yet completed.\nAre you \
-sure you want to close the Uninstall Window?
confirm-cancel-upgrade-title=Confirmation Required
confirm-cancel-upgrade-msg=OpenDS QuickUpgrade has not yet completed.\nIf you \
click 'Yes' any changes that have been made to the server being upgraded \
@@ -181,27 +128,6 @@
confirm-quit-upgrade-title=Confirmation Required
confirm-quit-upgrade-msg=Are you sure you want to quit OpenDS \
QuickUpgrade?\nIf you click 'Yes' nothing will be upgraded on your system.
-confirm-uninstall-server-not-running-msg=Confirm Uninstall\n\
-All selected files will be permanently deleted, are you sure you \
-want to continue?
-confirm-uninstall-server-not-running-title=Confirm Uninstall
-confirm-uninstall-server-running-msg=Server is Running\n\
-The OpenDS server is currently running and must be stopped before \
-uninstallation can continue. Do you want the uninstaller to stop \
-the server for you and continue with the uninstall? If you click \
-No, you will need to stop the server manually to continue.
-confirm-uninstall-replication-server-running-title=Confirmation Required
-confirm-uninstall-replication-server-running-msg=This server is configured to \
-perform replication.\nIn order to remove references to this server in other \
-servers you must provide administrator authentication.\n\nClick on 'Yes' to \
-provide authentication to remove the remote references.
-confirm-uninstall-replication-server-not-running-title=Confirmation Required
-confirm-uninstall-replication-server-not-running-msg=This server is configured \
-to perform replication.\nIn order to remove references to this server in other \
-servers the server will be started and then you must provide administrator \
-authentication.\n\nClick on 'Yes' to start the server and then provide \
-authentication to remove the remote references.
-confirm-uninstall-server-running-title=Server is Running
confirm-cancel-title=Confirmation Required
confirm-cancel-prompt=Cancel the running operation?
network-error-title=Network Error
@@ -344,8 +270,6 @@
automatically.
invalid-number-entries-range=The number of user entries to generate \
automatically must be an integer between {0} and {1}.
-# Confirm Uninstall Panel
-nothing-selected-to-uninstall=You must select something to be uninstalled.
# Directory Manager authentication to shutdown in Windows
not-a-directory-manager-in-config=The provided DN is not one of the \
Administrative User DN.
@@ -372,7 +296,6 @@
review-step=Review
progress-step=Progress
finished-step=Finished
-confirm-uninstall-step=Uninstall Options
step-upgrade-choose-version=Choose Version
#
@@ -804,44 +727,6 @@
finished-panel-title=Finished
#
-# Confirm Uninstall Panel specific labels
-#
-confirm-uninstall-panel-title=Uninstall Options
-# The following line contains some HTML tags. translators should respect them.
-# Concerning the URL, depending on how works the product page translators
-# have to modify it or not: if the server uses the locale of the browser to display
-# a language there is no translation to be done but if we have specific URL for
-# each language the URL must be localized.
-confirm-uninstall-panel-instructions=The OpenDS Uninstall tool will remove all \
-parts of the OpenDS server you have selected below from your system. If all \
-are selected, the server will be removed entirely.
-server-path-label=Server Path:
-remove-label=Remove:
-remove-libraries-and-tools-label=Server Libraries and Administrative Tools
-remove-databases-label=Database Contents
-remove-logs-label=Log Files
-remove-schema-and-configuration-label=Configuration and Schema Files
-remove-backups-label=Backup Files Contained in bak Directory
-remove-ldifs-label=LDIF Export Files Contained in ldif Directory
-remove-libraries-and-tools-tooltip=Remove Server Libraries and Administrative \
-Tools
-remove-databases-tooltip=Remove Database Contents
-remove-logs-tooltip=Remove Log Files
-remove-schema-and-configuration-tooltip=Remove Configuration and Schema Files
-remove-backups-tooltip=Remove Backup Files Contained in bak Directory
-remove-ldifs-tooltip=Remove LDIF Export Files Contained in ldif Directory
-delete-outside-dbs-msg=The Directory Server contains database files in the \
-following locations outside the server path:
-delete-outside-dbs-label=Delete these Database Files
-delete-outside-dbs-tooltip=Check this box to Delete the Database Files located \
-outside the install directory
-delete-outside-logs-msg=The Directory Server contains log files in the \
-following locations outside the server path:
-delete-outside-logs-label=Delete these Log Files
-delete-outside-logs-tooltip=Check this box to Delete the Log Files located \
-outside the install directory
-
-#
# Miscellaneous labels
#
browse-button-label=Browse...
@@ -860,7 +745,6 @@
# Progress Summary Labels
#
summary-install-not-started=Starting QuickSetup...
-summary-uninstall-not-started=Starting Uninstallation...
summary-downloading=Downloading Binary Files...
summary-extracting=Extracting Binary Files...
summary-configuring=Configuring Directory Server...
@@ -891,29 +775,7 @@
configuration status, click \
Launch Status Panel. Note that you can launch this tool \
later using {2}.<br><INPUT type="submit" value="Launch Status Panel"></INPUT>
-
summary-stopping=Stopping Directory Server...
-summary-disabling-windows-service=Disabling Windows Service...
-summary-deleting-external-db-files=Deleting Database Files outside the \
-Installation Path...
-summary-deleting-external-log-files=Deleting Log Files outside the \
-Installation Path...
-summary-deleting-external-references=Deleting External References...
-summary-deleting-installation-files=Deleting Files under the Installation \
-Path...
-summary-uninstall-finished-successfully-remove-jarfiles=<b>OpenDS Uninstall \
-Completed Successfully.</b><br><br>To complete the uninstallation, you must \
-delete manually the following files and directories:<br>{0}
-summary-uninstall-finished-successfully=<b>OpenDS Uninstall Completed \
-Successfully.</b>
-summary-uninstall-finished-successfully-remove-jarfiles-cli=OpenDS Uninstall \
-Completed Successfully.\nTo complete the uninstallation, you must \
-delete manually the following files and directories:\n{0}
-summary-uninstall-finished-successfully-cli=OpenDS Uninstall Completed \
-Successfully.
-summary-uninstall-finished-with-error=An error occurred. Check 'Details' text \
-area for more information.
-
summary-upgrade-not-started=Starting Upgrade...
summary-upgrade-initializing=Initializing Upgrade...
summary-upgrade-downloading=Downloading Build...
@@ -1103,10 +965,11 @@
initialize-progress-with-processed= {0} entries processed.
initialize-progress-with-unprocessed={0} remaining to be processed.
error-during-initialization-no-log=Error during the initialization with \
-contents from server {0}. Check the error logs of {0} for more information.
+contents from server {0}. Task state: {1}. Check the error logs of {0} for \
+more information.
error-during-initialization-log=Error during the initialization with \
-contents from server {0}. Last log details: {1}. Check the error logs of the \
-server for more information.
+contents from server {0}. Last log details: {1}. Task state: {2}. Check the \
+error logs of the server for more information.
error-pooling-initialization=Error reading the progress of the initialization \
with contents from server {0}.
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 dd0b8bc..f8d117c 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
@@ -165,27 +165,33 @@
private void createButtons()
{
nextButton =
- createButton("next-button-label", "next-button-tooltip",
+ createButton(getMsg("next-button-label"), getMsg("next-button-tooltip"),
ButtonName.NEXT);
previousButton =
- createButton("previous-button-label", "previous-button-tooltip",
+ createButton(getMsg("previous-button-label"),
+ getMsg("previous-button-tooltip"),
ButtonName.PREVIOUS);
String tooltip;
GuiApplication application = getApplication();
- tooltip = application.getQuitButtonToolTipKey();
+ tooltip =
+ application.getI18n().getMsg(application.getQuitButtonToolTipKey());
quitButton =
- createButton("quit-button-label", tooltip, ButtonName.QUIT);
+ createButton(getMsg("quit-button-label"), tooltip, ButtonName.QUIT);
- tooltip = application.getCloseButtonToolTipKey();
- closeButton = createButton("close-button-label", tooltip, ButtonName.CLOSE);
+ tooltip =
+ application.getI18n().getMsg(application.getCloseButtonToolTipKey());
+ closeButton = createButton(getMsg("close-button-label"),
+ tooltip, ButtonName.CLOSE);
- String label = application.getFinishButtonLabelKey();
- tooltip = application.getFinishButtonToolTipKey();
+ String label =
+ application.getI18n().getMsg(application.getFinishButtonLabelKey());
+ tooltip =
+ application.getI18n().getMsg(application.getFinishButtonToolTipKey());
finishButton = createButton(label, tooltip, ButtonName.FINISH);
}
@@ -271,15 +277,15 @@
/**
* Create a button.
- * @param labelKey the key in the properties file for the label.
- * @param tooltipKey the key in the properties file for the tooltip.
+ * @param label the label of the button.
+ * @param tooltip the tooltip of the button.
* @param buttonName the ButtonName.
* @return a new button with the specified parameters.
*/
- private JButton createButton(String labelKey, String tooltipKey,
+ private JButton createButton(String label, String tooltip,
ButtonName buttonName)
{
- JButton b = UIFactory.makeJButton(getMsg(labelKey), getMsg(tooltipKey));
+ JButton b = UIFactory.makeJButton(label, tooltip);
final ButtonName fButtonName = buttonName;
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/ConfirmUninstallPanel.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/ConfirmUninstallPanel.java
deleted file mode 100644
index 0a836ab..0000000
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/ui/ConfirmUninstallPanel.java
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * 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 2006-2007 Sun Microsystems, Inc.
- */
-
-package org.opends.quicksetup.ui;
-
-import org.opends.quicksetup.CurrentInstallStatus;
-import org.opends.quicksetup.Installation;
-import org.opends.quicksetup.Configuration;
-import org.opends.quicksetup.util.Utils;
-
-import javax.swing.*;
-import javax.swing.border.EmptyBorder;
-import java.awt.*;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.io.IOException;
-
-/**
- * This is the panel displayed when the user is uninstalling Open DS. It is
- * basically a panel with the text informing of the consequences of uninstalling
- * the server and asking for confirmation.
- *
- */
-public class ConfirmUninstallPanel extends QuickSetupStepPanel
-{
- private static final Logger LOG =
- Logger.getLogger(ConfirmUninstallPanel.class.getName());
-
- private static final long serialVersionUID = 81730510134697056L;
-
- private CurrentInstallStatus installStatus;
- private Set<String> outsideDbs;
- private Set<String> outsideLogs;
-
- private HashMap<FieldName, JCheckBox> hmCbs =
- new HashMap<FieldName, JCheckBox>();
-
- /**
- * The constructor of this class.
- * @param application Application this panel represents
- * @param installStatus the object describing the current installation status.
- *
- */
- public ConfirmUninstallPanel(GuiApplication application,
- CurrentInstallStatus installStatus)
- {
- super(application);
- this.installStatus = installStatus;
- }
-
- /**
- * {@inheritDoc}
- */
- public Object getFieldValue(FieldName fieldName)
- {
- Object value = null;
- switch (fieldName)
- {
- case EXTERNAL_DB_DIRECTORIES:
- Set<String> s1 = new HashSet<String>();
- if (outsideDbs.size() > 0)
- {
- if (getCheckBox(FieldName.EXTERNAL_DB_DIRECTORIES).isSelected())
- {
- s1.addAll(outsideDbs);
- }
- }
- value = s1;
- break;
-
- case EXTERNAL_LOG_FILES:
- Set<String> s2 = new HashSet<String>();
- if (outsideLogs.size() > 0)
- {
- if (getCheckBox(FieldName.EXTERNAL_LOG_FILES).isSelected())
- {
- s2.addAll(outsideLogs);
- }
- }
- value = s2;
- break;
- default:
- JCheckBox cb = getCheckBox(fieldName);
- value = new Boolean(cb.isSelected());
- break;
- }
- return value;
- }
-
- /**
- * {@inheritDoc}
- */
- protected String getTitle()
- {
- return getMsg("confirm-uninstall-panel-title");
- }
-
- /**
- * {@inheritDoc}
- */
- protected Component createInputPanel()
- {
- FieldName[] fieldNames = {
- FieldName.REMOVE_LIBRARIES_AND_TOOLS,
- FieldName.REMOVE_DATABASES,
- FieldName.REMOVE_LOGS,
- FieldName.REMOVE_CONFIGURATION_AND_SCHEMA,
- FieldName.REMOVE_BACKUPS,
- FieldName.REMOVE_LDIFS,
- };
-
- String[] labels = {
- getMsg("remove-libraries-and-tools-label"),
- getMsg("remove-databases-label"),
- getMsg("remove-logs-label"),
- getMsg("remove-schema-and-configuration-label"),
- getMsg("remove-backups-label"),
- getMsg("remove-ldifs-label"),
- };
-
- String[] tooltips = {
- getMsg("remove-libraries-and-tools-tooltip"),
- getMsg("remove-databases-tooltip"),
- getMsg("remove-logs-tooltip"),
- getMsg("remove-schema-and-configuration-tooltip"),
- getMsg("remove-backups-tooltip"),
- getMsg("remove-ldifs-tooltip"),
- };
-
- for (int i=0; i<fieldNames.length; i++)
- {
- JCheckBox cb = UIFactory.makeJCheckBox(labels[i], tooltips[i],
- UIFactory.TextStyle.INSTRUCTIONS);
- cb.setSelected(true);
- hmCbs.put(fieldNames[i], cb);
- }
-
-
- JPanel panel = new JPanel(new GridBagLayout());
- panel.setOpaque(false);
-
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.insets = UIFactory.getEmptyInsets();
-
- JPanel p = new JPanel(new GridBagLayout());
- p.setOpaque(false);
- gbc.weightx = 0.0;
- gbc.gridwidth = GridBagConstraints.RELATIVE;
- gbc.anchor = GridBagConstraints.WEST;
- p.add(UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
- getMsg("server-path-label"),
- UIFactory.TextStyle.PRIMARY_FIELD_VALID), gbc);
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.insets.left = UIFactory.LEFT_INSET_SECONDARY_FIELD;
- p.add(UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
- Utils.getInstallPathFromClasspath(), UIFactory.TextStyle.INSTRUCTIONS),
- gbc);
-
- FieldName[] names = {
- FieldName.REMOVE_LIBRARIES_AND_TOOLS,
- FieldName.REMOVE_DATABASES,
- FieldName.REMOVE_LOGS,
- FieldName.REMOVE_CONFIGURATION_AND_SCHEMA,
- FieldName.REMOVE_BACKUPS,
- FieldName.REMOVE_LDIFS
- };
-
- for (int i=0; i<names.length; i++)
- {
- gbc.gridwidth = GridBagConstraints.RELATIVE;
- p.add(Box.createHorizontalGlue(), gbc);
- gbc.insets.left = 0;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.insets.left = UIFactory.LEFT_INSET_SECONDARY_FIELD;
- p.add(getCheckBox(names[i]), gbc);
- }
-
- gbc.weightx = 1.0;
- gbc.fill = GridBagConstraints.NONE;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.anchor = GridBagConstraints.WEST;
- gbc.insets.left = 0;
-
- panel.add(p, gbc);
-
- Installation installation = Installation.getLocal();
- Configuration config = installation.getCurrentConfiguration();
- try {
- outsideDbs = config.getOutsideDbs();
- } catch (IOException ioe) {
- LOG.log(Level.INFO, "Unable to determin outside databases", ioe);
- }
-
- try {
- outsideLogs = config.getOutsideLogs();
- } catch (IOException ioe) {
- LOG.log(Level.INFO, "Unable to determin outside logs", ioe);
- }
-
-
- gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.weightx = 1.0;
- if (outsideDbs.size() > 0)
- {
- JPanel dbPanel = createDbPanel();
- panel.add(dbPanel, gbc);
- }
-
- if (outsideLogs.size() > 0)
- {
- JPanel logPanel = createLogPanel();
- panel.add(logPanel, gbc);
- }
-
- addVerticalGlue(panel);
-
- return panel;
- }
-
- /**
- * {@inheritDoc}
- */
- protected String getInstructions()
- {
- return getMsg("confirm-uninstall-panel-instructions");
- }
-
- /**
- * Creates a panel to ask the user if (s)he wants to remove the databases
- * located outside the installation path.
- * @return a panel to ask the user if (s)he wants to remove the databases
- * located outside the installation path.
- */
- private JPanel createDbPanel()
- {
- JCheckBox cbOutsideDbs = UIFactory.makeJCheckBox(
- getMsg("delete-outside-dbs-label"),
- getMsg("delete-outside-dbs-tooltip"), UIFactory.TextStyle.INSTRUCTIONS);
- cbOutsideDbs.setSelected(true);
- hmCbs.put(FieldName.EXTERNAL_DB_DIRECTORIES, cbOutsideDbs);
-
- return createOutsidePathPanel(cbOutsideDbs, outsideDbs,
- "delete-outside-dbs-msg");
- }
-
- /**
- * Creates a panel to ask the user if (s)he wants to remove the logs located
- * outside the installation path.
- * @return a panel to ask the user if (s)he wants to remove the logs located
- * outside the installation path.
- */
- private JPanel createLogPanel()
- {
- JCheckBox cbOutsideLogs = UIFactory.makeJCheckBox(
- getMsg("delete-outside-logs-label"),
- getMsg("delete-outside-logs-tooltip"),
- UIFactory.TextStyle.INSTRUCTIONS);
- cbOutsideLogs.setSelected(true);
- hmCbs.put(FieldName.EXTERNAL_LOG_FILES, cbOutsideLogs);
-
- return createOutsidePathPanel(cbOutsideLogs, outsideLogs,
- "delete-outside-logs-msg");
- }
-
- private JPanel createOutsidePathPanel(JCheckBox cb, Set<String> paths,
- String msgKey)
- {
- JPanel panel = new JPanel(new GridBagLayout());
- panel.setOpaque(false);
-
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.insets = UIFactory.getEmptyInsets();
- gbc.weightx = 1.0;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.anchor = GridBagConstraints.WEST;
- gbc.fill = GridBagConstraints.HORIZONTAL;
-
- panel.add(UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, getMsg(msgKey),
- UIFactory.TextStyle.INSTRUCTIONS), gbc);
- DefaultListModel listModel = new DefaultListModel();
- for (String path : paths)
- {
- listModel.addElement(path);
- }
- JList list = UIFactory.makeJList(UIFactory.TextStyle.INSTRUCTIONS);
- list.setModel(listModel);
- list.setBackground(UIFactory.CURRENT_STEP_PANEL_BACKGROUND);
- list.setVisibleRowCount(Math.min(3, listModel.getSize()));
- JScrollPane scroll = new JScrollPane(list);
- scroll.setViewportBorder(new EmptyBorder(0, 0, 0, 0));
- gbc.insets.left = UIFactory.LEFT_INSET_RADIO_SUBORDINATE;
- panel.add(scroll, gbc);
-
- gbc.insets.left = 0;
- panel.add(cb, gbc);
-
- return panel;
- }
-
- /**
- * Returns the checkbox corresponding to the provided FieldName.
- * @param fieldName the FieldName object.
- * @return the checkbox corresponding to the provided FieldName.
- */
- private JCheckBox getCheckBox(FieldName fieldName)
- {
- JCheckBox cb = hmCbs.get(fieldName);
- if (cb == null)
- {
- throw new IllegalArgumentException("The FieldName "+fieldName+
- " has no checkbox associated.");
- }
- return cb;
- }
-}
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 ead0388..ac6c8d1 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
@@ -137,7 +137,7 @@
boolean first = true;
for (WizardStep s : orderedSteps)
{
- hmText.put(s, getMsg(s.getMessageKey()));
+ hmText.put(s, app.getI18n().getMsg(s.getMessageKey()));
JPanel subPanel = new JPanel(new GridBagLayout());
subPanel.setOpaque(false);
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
deleted file mode 100644
index 7ca05df..0000000
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/uninstaller/Uninstaller.java
+++ /dev/null
@@ -1,1035 +0,0 @@
-/*
- * 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 2006-2007 Sun Microsystems, Inc.
- */
-
-package org.opends.quicksetup.uninstaller;
-
-import org.opends.quicksetup.*;
-
-import static org.opends.quicksetup.Step.FINISHED;
-import static org.opends.quicksetup.Step.PROGRESS;
-import static org.opends.quicksetup.Step.REVIEW;
-import org.opends.quicksetup.ui.*;
-import org.opends.quicksetup.util.Utils;
-import org.opends.quicksetup.util.BackgroundTask;
-import org.opends.quicksetup.util.ServerController;
-import org.opends.server.tools.ConfigureWindowsService;
-
-import java.io.*;
-import java.util.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.awt.event.WindowEvent;
-
-/**
- * This class is in charge of performing the uninstallation of Open DS.
- */
-public class Uninstaller extends GuiApplication implements CliApplication {
-
- private ProgressStep status = UninstallProgressStep.NOT_STARTED;
-
- private HashMap<ProgressStep, Integer> hmRatio =
- new HashMap<ProgressStep, Integer>();
-
- private HashMap<ProgressStep, String> hmSummary =
- new HashMap<ProgressStep, String>();
-
- private ApplicationException ue;
-
- private Boolean isWindowsServiceEnabled;
-
- private UninstallCliHelper cliHelper = new UninstallCliHelper();
-
- private static final Logger LOG =
- Logger.getLogger(Uninstaller.class.getName());
-
- /**
- * {@inheritDoc}
- */
- public String getFrameTitle() {
- return getMsg("frame-uninstall-title");
- }
-
- /**
- * {@inheritDoc}
- */
- public UserData createUserData() {
- return new UninstallUserData();
- }
-
- /**
- * {@inheritDoc}
- */
- public WizardStep getFirstWizardStep() {
- return Step.CONFIRM_UNINSTALL;
- }
-
- /**
- * {@inheritDoc}
- */
- public WizardStep getNextWizardStep(WizardStep step) {
- Step nextStep = null;
- if (step != null && step.equals(Step.CONFIRM_UNINSTALL)) {
- nextStep = Step.PROGRESS;
- }
- else if (Step.PROGRESS.equals(step))
- {
- nextStep = Step.FINISHED;
- }
- return nextStep;
- }
-
- /**
- * {@inheritDoc}
- */
- public WizardStep getPreviousWizardStep(WizardStep step) {
- Step prevStep = null;
- if (step != null && step.equals(Step.PROGRESS)) {
- prevStep = Step.CONFIRM_UNINSTALL;
- }
- else if (Step.FINISHED.equals(step))
- {
- prevStep = Step.PROGRESS;
- }
- return prevStep;
- }
-
- /**
- * {@inheritDoc}
- */
- public WizardStep getFinishedStep() {
- return Step.FINISHED;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean finishOnLeft()
- {
- return false;
- }
-
- /**
- * {@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 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");
- } else if (cStep == FINISHED) {
- throw new IllegalStateException(
- "Cannot click on next from finished 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 if (cStep == FINISHED)
- {
- qs.quit();
- } else {
- throw new IllegalStateException(
- "Close only can be clicked on PROGRESS 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");
- }
- else if (step == Step.FINISHED) {
- throw new IllegalStateException(
- "Cannot click on quit from finished step");
- }
- qs.quit();
- }
-
- /**
- * {@inheritDoc}
- */
- public String getCloseButtonToolTipKey() {
- return "close-button-uninstall-tooltip";
- }
-
- /**
- * {@inheritDoc}
- */
- public String getFinishButtonToolTipKey() {
- return "finish-button-uninstall-tooltip";
- }
-
- /**
- * {@inheritDoc}
- */
- public String getFinishButtonLabelKey() {
- return "finish-button-uninstall-label";
- }
-
- /**
- * {@inheritDoc}
- */
- public void previousClicked(WizardStep cStep, QuickSetup qs) {
- if (cStep == PROGRESS) {
- throw new IllegalStateException(
- "Cannot click on previous from progress step");
- }
- else if (cStep == FINISHED) {
- throw new IllegalStateException(
- "Cannot click on previous from finished step");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean 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) {
- LOG.log(Level.WARNING, "Error processing task: "+t, t);
- throw new UserDataException(cStep,
- getThrowableMsg("bug-msg", t));
- }
- Status status = Installation.getLocal().getStatus();
- return status.isServerRunning();
- }
-
- public void backgroundTaskCompleted(Object returnValue,
- Throwable throwable) {
- qs.getDialog().workerFinished();
- if (throwable != null) {
- if (throwable instanceof UserDataException)
- {
- qs.displayError(throwable.getLocalizedMessage(),
- getMsg("error-title"));
- }
- else
- {
- LOG.log(Level.WARNING, "Error processing task: "+throwable,
- throwable);
- qs.displayError(throwable.toString(), 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.launch();
- qs.setCurrentStep(getNextWizardStep(cStep));
- }
- } else {
- if (qs.displayConfirmation(
- getMsg("confirm-uninstall-server-running-msg"),
- getMsg("confirm-uninstall-server-running-title"))) {
- getUserData().setStopServer(true);
- qs.launch();
- qs.setCurrentStep(getNextWizardStep(cStep));
- } else {
- getUserData().setStopServer(false);
- }
- }
- }
- }
- };
- qs.getDialog().workerStarted();
- worker.startBackgroundTask();
- }
- // Uninstaller is responsible for updating user data and launching
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public void updateUserData(WizardStep step, QuickSetup qs) {
- // do nothing;
- }
-
- /**
- * {@inheritDoc}
- */
- public void setWizardDialogState(QuickSetupDialog dlg,
- UserData userData,
- WizardStep step) {
- if (step == Step.CONFIRM_UNINSTALL) {
- dlg.setDefaultButton(ButtonName.FINISH);
- dlg.setFocusOnButton(ButtonName.FINISH);
- } else if ((step == PROGRESS) || (step == FINISHED)) {
- dlg.setDefaultButton(ButtonName.CLOSE);
- dlg.setFocusOnButton(ButtonName.CLOSE);
- dlg.setButtonEnabled(ButtonName.CLOSE, false);
- }
- }
-
- /**
- * {@inheritDoc}
- * @param launcher
- */
- public UserData createUserData(Launcher launcher)
- throws UserDataException {
- return cliHelper.createUserData(launcher.getArguments());
- }
-
- /**
- * {@inheritDoc}
- */
- public String getInstallationPath() {
- return Utils.getInstallPathFromClasspath();
- }
-
- /**
- * 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.
- */
- public ApplicationException getRunError() {
- return ue;
- }
-
- /**
- * Initialize the different map used in this class.
- */
- private void initMaps() {
- hmSummary.put(UninstallProgressStep.NOT_STARTED,
- getFormattedSummary(getMsg("summary-uninstall-not-started")));
- hmSummary.put(UninstallProgressStep.STOPPING_SERVER,
- getFormattedSummary(getMsg("summary-stopping")));
- hmSummary.put(UninstallProgressStep.DISABLING_WINDOWS_SERVICE,
- getFormattedSummary(getMsg("summary-disabling-windows-service")));
- hmSummary.put(UninstallProgressStep.DELETING_EXTERNAL_DATABASE_FILES,
- getFormattedSummary(getMsg("summary-deleting-external-db-files")));
- hmSummary.put(UninstallProgressStep.DELETING_EXTERNAL_LOG_FILES,
- getFormattedSummary(getMsg("summary-deleting-external-log-files")));
- hmSummary.put(UninstallProgressStep.REMOVING_EXTERNAL_REFERENCES,
- getFormattedSummary(
- getMsg("summary-deleting-external-references")));
- hmSummary.put(UninstallProgressStep.DELETING_INSTALLATION_FILES,
- getFormattedSummary(getMsg("summary-deleting-installation-files")));
-
- String successMsg;
- Installation installation = getInstallation();
- String libPath = Utils.getPath(installation.getLibrariesDirectory());
- if (Utils.isCli()) {
- if (getUninstallUserData().getRemoveLibrariesAndTools()) {
- String[] arg = new String[1];
- if (Utils.isWindows()) {
- arg[0] = installation.getUninstallBatFile() + getLineBreak() +
- getTab() + libPath;
- } else {
- arg[0] = libPath;
- }
- successMsg = getMsg(
- "summary-uninstall-finished-successfully-remove-jarfiles-cli",
- arg);
- } else {
- successMsg = getMsg("summary-uninstall-finished-successfully-cli");
- }
- } else {
- if (getUninstallUserData().getRemoveLibrariesAndTools()) {
- String[] arg = {libPath};
- successMsg = getMsg(
- "summary-uninstall-finished-successfully-remove-jarfiles", arg);
- } else {
- successMsg = getMsg("summary-uninstall-finished-successfully");
- }
- }
- hmSummary.put(UninstallProgressStep.FINISHED_SUCCESSFULLY,
- getFormattedSuccess(successMsg));
- hmSummary.put(UninstallProgressStep.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.
- */
- HashMap<UninstallProgressStep, Integer> hmTime =
- 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);
- hmTime.put(UninstallProgressStep.DELETING_EXTERNAL_LOG_FILES, 5);
- hmTime.put(UninstallProgressStep.REMOVING_EXTERNAL_REFERENCES, 5);
- hmTime.put(UninstallProgressStep.DELETING_INSTALLATION_FILES, 10);
-
- int totalTime = 0;
- ArrayList<UninstallProgressStep> steps =
- new ArrayList<UninstallProgressStep>();
- if (getUserData().getStopServer()) {
- totalTime += hmTime.get(UninstallProgressStep.STOPPING_SERVER);
- steps.add(UninstallProgressStep.STOPPING_SERVER);
- }
- 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) {
- totalTime += hmTime.get(
- UninstallProgressStep.DELETING_EXTERNAL_DATABASE_FILES);
- steps.add(UninstallProgressStep.DELETING_EXTERNAL_DATABASE_FILES);
- }
-
- if (getUninstallUserData().getExternalLogsToRemove().size() > 0) {
- totalTime += hmTime.get(
- UninstallProgressStep.DELETING_EXTERNAL_LOG_FILES);
- steps.add(UninstallProgressStep.DELETING_EXTERNAL_LOG_FILES);
- }
-
- int cumulatedTime = 0;
- for (UninstallProgressStep s : steps) {
- Integer statusTime = hmTime.get(s);
- hmRatio.put(s, (100 * cumulatedTime) / totalTime);
- if (statusTime != null) {
- cumulatedTime += statusTime;
- }
- }
-
- hmRatio.put(UninstallProgressStep.FINISHED_SUCCESSFULLY, 100);
- hmRatio.put(UninstallProgressStep.FINISHED_WITH_ERROR, 100);
- }
-
- /**
- * Actually performs the uninstall in this thread. The thread is blocked.
- */
- public void run() {
- initMaps();
- PrintStream origErr = System.err;
- PrintStream origOut = System.out;
- try {
- PrintStream err = new ErrorPrintStream();
- PrintStream out = new OutputPrintStream();
- if (!Utils.isCli()) {
- System.setErr(err);
- System.setOut(out);
- }
-
- boolean displaySeparator = false;
- if (getUserData().getStopServer()) {
- status = UninstallProgressStep.STOPPING_SERVER;
- new ServerController(this).stopServer();
- displaySeparator = true;
- }
- if (isWindowsServiceEnabled()) {
- status = UninstallProgressStep.DISABLING_WINDOWS_SERVICE;
- if (displaySeparator) {
- notifyListeners(getTaskSeparator());
- }
- disableWindowsService();
- displaySeparator = true;
- }
-
- Set<String> dbsToDelete = getUninstallUserData().getExternalDbsToRemove();
- if (dbsToDelete.size() > 0) {
- status = UninstallProgressStep.DELETING_EXTERNAL_DATABASE_FILES;
- if (displaySeparator) {
- notifyListeners(getTaskSeparator());
- }
-
- deleteExternalDatabaseFiles(dbsToDelete);
- displaySeparator = true;
- }
-
- Set<String> logsToDelete =
- getUninstallUserData().getExternalLogsToRemove();
- if (logsToDelete.size() > 0) {
- status = UninstallProgressStep.DELETING_EXTERNAL_LOG_FILES;
-
- if (displaySeparator) {
- notifyListeners(getTaskSeparator());
- }
-
- deleteExternalLogFiles(logsToDelete);
- displaySeparator = true;
- }
-
- UninstallUserData userData = getUninstallUserData();
- boolean somethingToDelete = userData.getRemoveBackups() ||
- userData.getRemoveConfigurationAndSchema() ||
- userData.getRemoveDatabases() ||
- userData.getRemoveLDIFs() ||
- userData.getRemoveLibrariesAndTools() ||
- userData.getRemoveLogs();
- if (displaySeparator && somethingToDelete) {
- notifyListeners(getTaskSeparator());
- }
-
- if (somethingToDelete) {
- status = UninstallProgressStep.DELETING_INSTALLATION_FILES;
- deleteInstallationFiles(getRatio(status),
- getRatio(UninstallProgressStep.FINISHED_SUCCESSFULLY));
- }
- status = UninstallProgressStep.FINISHED_SUCCESSFULLY;
- if (Utils.isCli()) {
- notifyListeners(getLineBreak() + getLineBreak() + getSummary(status));
- } else {
- notifyListeners(null);
- }
-
- } catch (ApplicationException ex) {
- ue = ex;
- status = UninstallProgressStep.FINISHED_WITH_ERROR;
- String msg = getFormattedError(ex, true);
- notifyListeners(msg);
- }
- catch (Throwable t) {
- ue = new ApplicationException(
- ApplicationReturnCode.ReturnCode.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);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public ProgressStep getCurrentProgressStep() {
- return status;
- }
-
- /**
- * 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.
- */
- 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.
- */
- public String getSummary(ProgressStep step) {
- return hmSummary.get(step);
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isFinished() {
- return getCurrentProgressStep() ==
- UninstallProgressStep.FINISHED_SUCCESSFULLY
- || getCurrentProgressStep() ==
- UninstallProgressStep.FINISHED_WITH_ERROR;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isCancellable() {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- public void cancel() {
- // do nothing; not cancellable
- }
-
- /**
- * {@inheritDoc}
- */
- public void windowClosing(QuickSetupDialog dlg, WindowEvent evt) {
- if ((dlg.getDisplayedStep() == PROGRESS) ||
- (dlg.getDisplayedStep() == FINISHED)) {
- // Simulate a close button event
- dlg.notifyButtonEvent(ButtonName.CLOSE);
- } else {
- // Simulate a quit button event
- dlg.notifyButtonEvent(ButtonName.QUIT);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- public ButtonName getInitialFocusButtonName() {
- return ButtonName.FINISH;
- }
-
- /**
- * {@inheritDoc}
- */
- public Set<? extends WizardStep> getWizardSteps() {
- Set<WizardStep> setSteps = new HashSet<WizardStep>();
- setSteps.add(Step.CONFIRM_UNINSTALL);
- setSteps.add(Step.PROGRESS);
- setSteps.add(Step.FINISHED);
- return Collections.unmodifiableSet(setSteps);
- }
-
- /**
- * {@inheritDoc}
- */
- public QuickSetupStepPanel createWizardStepPanel(WizardStep step) {
- QuickSetupStepPanel p = null;
- if (step == Step.CONFIRM_UNINSTALL) {
- p = new ConfirmUninstallPanel(this, installStatus);
- } else if (step == Step.PROGRESS) {
- p = new ProgressPanel(this);
- } else if (step == Step.FINISHED) {
- p = new FinishedPanel(this);
- }
- return p;
- }
-
- /**
- * 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 {
- notifyListeners(getFormattedProgress(
- 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 {
- notifyListeners(getFormattedProgress(
- 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 {
- notifyListeners(getFormattedProgress(
- getMsg("progress-deleting-installation-files")) +
- getLineBreak());
- File f = new File(Utils.getInstallPathFromClasspath());
- InstallationFilesToDeleteFilter filter =
- new InstallationFilesToDeleteFilter();
- File[] rootFiles = f.listFiles();
- 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])) {
- Installation installation = getInstallation();
- int relativeRatio;
- if (equalsOrDescendant(rootFiles[i],
- installation.getLibrariesDirectory())) {
- relativeRatio = 10;
- } else
- if (equalsOrDescendant(rootFiles[i],
- installation.getBinariesDirectory())) {
- relativeRatio = 5;
- } else
- if (equalsOrDescendant(rootFiles[i],
- installation.getConfigurationDirectory())) {
- relativeRatio = 5;
- } else
- if (equalsOrDescendant(rootFiles[i],
- installation.getBackupDirectory())) {
- relativeRatio = 20;
- } else
- if (equalsOrDescendant(rootFiles[i],
- installation.getLdifDirectory())) {
- relativeRatio = 20;
- } else if (equalsOrDescendant(rootFiles[i],
- installation.getDatabasesDirectory())) {
- relativeRatio = 50;
- } else
- if (equalsOrDescendant(rootFiles[i],
- installation.getLogsDirectory())) {
- 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++) {
- int beforeRatio = minRatio +
- ((it.next() * (maxRatio - minRatio)) / totalRatio);
- hmRatio.put(UninstallProgressStep.DELETING_INSTALLATION_FILES,
- beforeRatio);
- deleteRecursively(rootFiles[i], filter);
- }
- hmRatio.put(UninstallProgressStep.DELETING_INSTALLATION_FILES, maxRatio);
- }
- }
-
- /**
- * 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 {
- deleteRecursively(file, null);
- }
-
- /**
- * Deletes everything below the specified file.
- *
- * @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.
- * @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)) {
- delete(file);
- }
- } else {
- delete(file);
- }
- } else {
- File[] children = file.listFiles();
- if (children != null) {
- for (int i = 0; i < children.length; i++) {
- deleteRecursively(children[i], filter);
- }
- }
- if (filter != null) {
- if (filter.accept(file)) {
- delete(file);
- }
- } else {
- delete(file);
- }
- }
- } else {
- // Just tell that the file/directory does not exist.
- String[] arg = {file.toString()};
- notifyListeners(getFormattedWarning(
- getMsg("progress-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 {
- String[] arg = {file.getAbsolutePath()};
- boolean isFile = file.isFile();
-
- if (isFile) {
- notifyListeners(getFormattedWithPoints(
- getMsg("progress-deleting-file", arg)));
- } else {
- notifyListeners(getFormattedWithPoints(
- getMsg("progress-deleting-directory", arg)));
- }
-
- boolean delete = false;
- /*
- * Sometimes the server keeps some locks on the files.
- * TODO: remove this code once stop-ds returns properly when server
- * is stopped.
- */
- int nTries = 5;
- for (int i = 0; i < nTries && !delete; i++) {
- delete = file.delete();
- if (!delete) {
- try {
- Thread.sleep(1000);
- }
- catch (Exception ex) {
- }
- }
- }
-
- if (!delete) {
- String errMsg;
- if (isFile) {
- errMsg = getMsg("error-deleting-file", arg);
- } else {
- errMsg = getMsg("error-deleting-directory", arg);
- }
- throw new ApplicationException(
- ApplicationReturnCode.ReturnCode.FILE_SYSTEM_ACCESS_ERROR,
- errMsg, null);
- }
-
- notifyListeners(getFormattedDone() + getLineBreak());
- }
-
- private boolean equalsOrDescendant(File file, File directory) {
- return file.equals(directory) || Utils.isDescendant(file, directory);
- }
-
- /**
- * This class is used to get the files that are not binaries. This is
- * required to know which are the files that can be deleted directly and which
- * not.
- */
- class InstallationFilesToDeleteFilter implements FileFilter {
- Installation installation = getInstallation();
- File quicksetupFile = installation.getQuicksetupJarFile();
- File openDSFile = installation.getOpenDSJarFile();
- File librariesFile = installation.getLibrariesDirectory();
- File activationFile = new File(librariesFile, "activation.jar");
- File aspectRuntimeFile = new File(librariesFile, "aspectjrt.jar");
- File uninstallBatFile = installation.getUninstallBatFile();
-
- File installationPath = installation.getRootDirectory();
-
- /**
- * {@inheritDoc}
- */
- public boolean accept(File file) {
- UninstallUserData userData = getUninstallUserData();
- boolean[] uData = {
- userData.getRemoveLibrariesAndTools(),
- userData.getRemoveLibrariesAndTools(),
- userData.getRemoveDatabases(),
- userData.getRemoveLogs(),
- userData.getRemoveConfigurationAndSchema(),
- userData.getRemoveBackups(),
- userData.getRemoveLDIFs()
- };
-
- Installation installation = getInstallation();
- File[] parentFiles = {
- installation.getLibrariesDirectory(),
- installation.getBinariesDirectory(),
- installation.getDatabasesDirectory(),
- installation.getLogsDirectory(),
- installation.getConfigurationDirectory(),
- installation.getBackupDirectory(),
- installation.getLdifDirectory()
- };
-
- boolean accept =
- !installationPath.equals(file)
- && !equalsOrDescendant(file, librariesFile)
- && !quicksetupFile.equals(file)
- && !openDSFile.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, parentFiles[i]);
- }
-
- LOG.log(Level.INFO, "accept for :"+file+" is: "+accept);
- return accept;
- }
- }
-
- private boolean isWindowsServiceEnabled() {
- if (isWindowsServiceEnabled == null) {
- if (ConfigureWindowsService.serviceState(null, null) ==
- ConfigureWindowsService.SERVICE_STATE_ENABLED) {
- isWindowsServiceEnabled = Boolean.TRUE;
- } else {
- isWindowsServiceEnabled = Boolean.FALSE;
- }
- }
- return isWindowsServiceEnabled.booleanValue();
- }
-
- /**
- * This methods disables this server as a Windows service.
- *
- * @throws ApplicationException if something goes wrong.
- */
- protected void disableWindowsService() throws ApplicationException {
- notifyListeners(getFormattedProgress(
- getMsg("progress-disabling-windows-service")));
- int code = ConfigureWindowsService.disableService(System.out, System.err);
-
- String errorMessage = getMsg("error-disabling-windows-service",
- getInstallationPath());
-
- switch (code) {
- case ConfigureWindowsService.SERVICE_DISABLE_SUCCESS:
- break;
- case ConfigureWindowsService.SERVICE_ALREADY_DISABLED:
- break;
- default:
- throw new ApplicationException(
- ApplicationReturnCode.ReturnCode.WINDOWS_SERVICE_ERROR,
- errorMessage, null);
- }
- }
-
- private UninstallUserData getUninstallUserData() {
- return (UninstallUserData) getUserData();
- }
-
-}
-
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/HtmlProgressMessageFormatter.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/HtmlProgressMessageFormatter.java
index 4cf6862..433623d 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/HtmlProgressMessageFormatter.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/HtmlProgressMessageFormatter.java
@@ -480,6 +480,18 @@
private String getHtmlStack(Throwable ex)
{
StringBuilder buf = new StringBuilder();
+ buf.append(SPACE)
+ .append(SPACE)
+ .append(SPACE)
+ .append(SPACE)
+ .append(SPACE)
+ .append(SPACE)
+ .append(SPACE)
+ .append(SPACE)
+ .append(SPACE)
+ .append(SPACE)
+ .append(getHtml(ex.toString()))
+ .append(Constants.HTML_LINE_BREAK);
StackTraceElement[] stack = ex.getStackTrace();
for (StackTraceElement aStack : stack) {
buf.append(SPACE)
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/event/ServerStatusChangeEvent.java b/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/event/ServerStatusChangeEvent.java
deleted file mode 100644
index d2a4e13..0000000
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/event/ServerStatusChangeEvent.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.statuspanel.event;
-
-import org.opends.statuspanel.ServerStatusDescriptor;
-
-/**
- * The event that is generated when there is a change of the server status.
- *
- * In the current implementation this events are generated by the
- * ServerStatusPooler object and are notified to the objects implementing
- * ServerStatusChangeListener (StatusPanelController object).
- *
- */
-public class ServerStatusChangeEvent
-{
- private ServerStatusDescriptor statusDescriptor;
-
- /**
- * Constructor of the ServerStatusChangeEvent.
- * @param statusDescriptor the object describing the current server status
- * and configuration.
- */
- public ServerStatusChangeEvent(ServerStatusDescriptor statusDescriptor)
- {
- this.statusDescriptor = statusDescriptor;
- }
-
- /**
- * Returns the ServerStatusDescriptor object.
- * @return the ServerStatusDescriptor object.
- */
- public ServerStatusDescriptor getStatusDescriptor()
- {
- return statusDescriptor;
- }
-
-}
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/event/ServerStatusChangeListener.java b/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/event/ServerStatusChangeListener.java
deleted file mode 100644
index eb3403a..0000000
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/event/ServerStatusChangeListener.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.statuspanel.event;
-
-/**
- * Interface that implement the objects that want to receive notifications of
- * changes in the server status.
- *
- */
-public interface ServerStatusChangeListener
-{
- /**
- * Method called when an change in the server status occurs.
- *
- * @param ev the ServerStatusChangeEvent describing the change that occurred
- * in the server status.
- */
- public void statusChanged(ServerStatusChangeEvent ev);
-}
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/event/StatusPanelButtonListener.java b/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/event/StatusPanelButtonListener.java
deleted file mode 100644
index 47c69af..0000000
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/event/StatusPanelButtonListener.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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.statuspanel.event;
-
-/**
- * Interface used to be notified of the button actions that can occur in the
- * StatusPanelDialog.
- *
- * In the current implementation StatusPanelController implements this
- * interface.
- *
- */
-public interface StatusPanelButtonListener
-{
- /**
- * Method called when user clicks on Authenticate button.
- */
- public void authenticateClicked();
- /**
- * Method called when user clicks on Start button.
- */
- public void startClicked();
- /**
- * Method called when user clicks on Restart button.
- */
- public void restartClicked();
- /**
- * Method called when user clicks on Stop button.
- */
- public void stopClicked();
- /**
- * Method called when user clicks on Quit button.
- */
- public void quitClicked();
-}
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/i18n/ResourceProvider.java b/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/i18n/ResourceProvider.java
deleted file mode 100644
index 0d0d403..0000000
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/i18n/ResourceProvider.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * 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.statuspanel.i18n;
-
-import java.text.MessageFormat;
-import java.util.ResourceBundle;
-
-/**
- * This class is used to retrieve localized messages from Resources.properties
- * files. This class extends org.opends.quicksetup.i18n.ResourceProvider so
- * that it first looks for properties in the Resources.properties located in
- * the org.opends.quicksetup.resources package and then if they are not there
- * looks for properties in org.opends.statuspanel.resources.
- *
- * This is done to avoid duplication of properties between the setup and the
- * status panel.
- *
- */
-public class ResourceProvider
-extends org.opends.quicksetup.i18n.ResourceProvider
-{
- private ResourceBundle bundle;
-
- private static ResourceProvider instance;
-
- private static final String BUNDLE_NAME =
- "org.opends.statuspanel.resources.Resources";
-
- private ResourceProvider()
- {
- }
-
- /**
- * Provides an instance of the ResourceProvider. The instance is unique for
- * this process (which implies that during the process lifetime we can only
- * have messages in one language).
- *
- * @return an instance of ResourceProvider.
- */
- public static ResourceProvider getInstance()
- {
- if (instance == null)
- {
- instance = new ResourceProvider();
- }
- return instance;
- }
-
- /**
- * Gets a localized message for a key value. In the properties file we have
- * something of type:
- * key=value
- * @param key the key in the properties file.
- * @return the value associated to the key in the properties file.
- * @throws IllegalArgumentException if the key could not be found in the
- * properties file.
- */
- public String getMsg(String key) throws IllegalArgumentException
- {
- String msg;
- try
- {
- /* First try to quick setup resource provider as it contains most of
- * the labels.
- */
- msg = super.getMsg(key);
- }
- catch (Exception ex)
- {
- /* Now try with the status panel specific resources.
- */
- try
- {
- msg = getResourceBundle().getString(key);
-
- } catch (java.util.MissingResourceException e)
- {
- // The less brutal alternative here is to do msg = key instead
- // of
- // throwing an exception but this helps being strict with
- // resources
- // (so I prefer to keep it as it is at least at the beginning)
- throw new IllegalArgumentException("Unknown Resource Bundle key: " +
- key);
- }
- }
- return msg;
- }
-
- /**
- * Gets a localized message for a key value. In the properties file we have
- * something of type:
- * key=value
- *
- * For instance if we pass as key "mykey" and as arguments {"value1"} and
- * in the properties file we have:
- * mykey=value with argument {0}.
- *
- * This method will return "value with argument value1".
- *
- * @param key the key in the properties file.
- * @param args the arguments to be passed to generate the resulting value.
- * @return the value associated to the key in the properties file.
- * @throws IllegalArgumentException if the key could not be found in the
- * properties file.
- */
- public String getMsg(String key, String... args)
- throws IllegalArgumentException
- {
- String msg;
- try
- {
- /* First try to quick setup resource provider as it contains most of
- * the labels.
- */
- msg = super.getMsg(key, args);
- }
- catch (Exception ex)
- {
- /* Now try with the status panel specific resources.
- */
- try
- {
- String pattern = getResourceBundle().getString(key);
- MessageFormat mf = new MessageFormat(pattern);
-
- msg = mf.format(args);
- } catch (java.util.MissingResourceException e)
- {
- // The less brutal alternative here is to do msg = key instead
- // of
- // throwing an exception but this helps being strict with
- // resources
- // (so I prefer to keep it as it is at least at the beginning)
- throw new IllegalArgumentException("Unknown Resource Bundle key: " +
- key);
- }
- }
- return msg;
- }
-
- /**
- * The ResourceBundle that will be used to get the localized messages.
- * @return the ResourceBundle that will be used to get the localized
- * messages.
- */
- private ResourceBundle getResourceBundle()
- {
- if (bundle == null)
- {
- try
- {
- bundle =
- ResourceBundle.getBundle(BUNDLE_NAME, getLocale(), this
- .getClass().getClassLoader());
- } catch (java.util.MissingResourceException e)
- {
- throw new IllegalStateException("Could not retrieve Resource Bundle: "
- + BUNDLE_NAME, e);
-
- }
- }
-
- return bundle;
- }
-}
-
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/resources/Resources.properties b/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/resources/Resources.properties
deleted file mode 100644
index 0256a03..0000000
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/resources/Resources.properties
+++ /dev/null
@@ -1,159 +0,0 @@
-# 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 2006-2007 Sun Microsystems, Inc.
-#
-#
-# This file contains the primary Directory Server configuration. It must not
-# be directly edited while the server is online. The server configuration
-# should only be managed using the administration utilities provided with the
-# Directory Server.
-
-#
-# StatusPanel launcher
-#
-status-panel-launcher-usage-description=This utility may be used to display \
-the Status Panel window which displays basic server information and allows to \
-start, stop and restart the server.
-status-panel-launcher-gui-launch-failed=Could not launch Status Panel. Check \
-that you have access to the display.
-status-panel-launcher-gui-launch-failed-details=Could not launch Status \
-Panel. Check that you have access to the display. Check file {0} for details.
-
-#
-# StatusPanel
-#
-statuspanel-dialog-title=OpenDS Status Panel
-quit-status-panel-button-tooltip=Quit Status Panel
-server-status-title=Server Status
-server-status-label=Server Run Status:
-not-available-server-down-tooltip=<html>Information is only available if \
-server is running and you are authenticated<br>as an administrative user.
-not-available-authentication-required-tooltip=<html>Information is only \
-available if you are authenticated<br>as an administrative user.
-stop-button-label=Stop
-stop-button-tooltip=Stops the Directory Server
-start-button-label=Start
-start-button-tooltip=Starts the Directory Server
-restart-button-label=Restart
-restart-button-tooltip=Restarts the Directory Server
-connections-label=Open Connections:
-server-details-title=Server Details
-administrative-users-label=Administrative Users:
-installation-path-label=Installation Path:
-opends-version-label=OpenDS Version:
-java-version-label=Java Version:
-login-dialog-title=Authentication Required
-server-started-label=Started
-server-stopped-label=Stopped
-server-starting-label=Starting
-server-stopping-label=Stopping
-server-unknown-status-label=Unknown
-cannot-connect-to-login-with-cause=Could not connect to the Directory \
-Server with the provided credentials. The possible causes for this are:\n{0}
-cannot-connect-to-login-without-cause=Could not connect to the Directory \
-Server with the provided credentials.\nCheck that the Administrative User DN \
-and password are valid.
-error-starting-server-generic=Could not Start server.
-authenticate-button-label=Authenticate
-authenticate-status-panel-button-tooltip=Authenticate as an administrative \
-user to view all monitoring information
-listeners-title=Listener Ports
-address-port-column=Address:Port
-protocol-column=Protocol
-state-column=State
-databases-title=Data Sources
-backendid-column=Backend ID
-basedn-column=Base DN
-number-entries-column=Entries
-replicated-column=Replication
-missing-changes-column=Missing Changes
-age-of-oldest-missing-change-column=<html>Age of Oldest<br>Missing \
-Change<br>(hh:mm:ss)
-age-of-oldest-missing-change-column-cli=Age of Oldest Missing Change (hh:mm:ss)
-enabled-label=Enabled
-disabled-label=Disabled
-unknown-label=--
-not-applicable-label=--
-ldap-protocol-label=LDAP
-ldaps-protocol-label=LDAPS
-jmx-protocol-label=JMX
-jmx-secure-protocol-label=JMX (Secure)
-undefined-protocol-label=-Unknown-
-error-reading-config-file=Error reading the configuration file.
-could-not-find-valid-ldapurl=Error reading the configuration file.\n\
-This could be caused because there is not an enabled LDAP port for the \
-specified connection parameters or because you do not have read rights on the \
-configuration file.
-number-entries-multiple-suffixes-in-db={0} (for all base DNs in {1})
-error-reading-config-ldap=Error reading data from server. Verify the \
-authentication information provided.\nDetails: {0}
-no-dbs-found=-No LDAP Databases Found-
-no-listeners-found=-No Listener Ports Found-
-suffix-replicated-label=Enabled
-suffix-not-replicated-label=Disabled
-
-#
-# Confirmation messages
-#
-confirm-stop-message=Are you sure you want to Stop the Directory Server?
-confirm-stop-title=Confirmation Required
-confirm-restart-message=Are you sure you want to Restart the Directory Server?
-confirm-restart-title=Confirmation Required
-
-#
-# Login Dialog
-#
-login-dialog-msg=You must provide an Administrative User DN and password \
-to retrieve monitoring information.
-login-dn-label=Administrative User DN:
-login-dn-tooltip=Enter the distinguished name (DN) of the \
-Administrative User account that will used to retrieve monitoring information
-login-pwd-label=Administrative User Password:
-login-pwd-tooltip=Enter the password of the \
-Administrative User account that will used to retrieve monitoring information
-login-dialog-server-not-running-msg=The Directory Server is not running. \
-Click OK to continue to the Status Panel.
-login-dialog-server-not-running-title=Directory Server not Running
-login-ok-button-tooltip=Proceed with authentication
-login-cancel-button-tooltip=Close Login Dialog
-
-#
-# Status Command Line
-#
-cli-status-pwd-and-pwd-file-provided=You cannot provide Bind Password (-w or \
---bindPassword) and Bind Password File (-W or --bindPasswordFile) at the same \
-time.
-cli-status-error-reading-pwd-file=Could not read the password from \
-file {0}. Check that the file path is correct, that you have access rights to \
-it and that it contains a password.
-cli-status-ldapauth-password-prompt=Password for user {0}:
-status-cli-usage-description=This utility may be used to display basic server \
-information
-not-available-authentication-required-cli-label=<not available> (*)
-not-available-authentication-required-cli-legend=* Information only available \
-if you provide authentication information when launching the status \
-command.
-not-available-server-down-cli-label=<not available> (*)
-not-available-server-down-cli-legend=* Information only available if server is \
-running and you provide authentication information when launching the status \
-command.
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ui/DatabasesTableModel.java b/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ui/DatabasesTableModel.java
deleted file mode 100644
index e17b884..0000000
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ui/DatabasesTableModel.java
+++ /dev/null
@@ -1,590 +0,0 @@
-/*
- * 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.statuspanel.ui;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.TreeSet;
-
-import javax.swing.table.AbstractTableModel;
-
-import org.opends.quicksetup.ui.SortableTableModel;
-import org.opends.statuspanel.BaseDNDescriptor;
-import org.opends.statuspanel.i18n.ResourceProvider;
-
-/**
- * This class is just a table model used to display the information about
- * databases in a table.
- *
- */
-public class DatabasesTableModel extends AbstractTableModel
-implements SortableTableModel, Comparator<BaseDNDescriptor>
-{
- private static final long serialVersionUID = -5650762484071136983L;
- private HashSet<BaseDNDescriptor> data = new HashSet<BaseDNDescriptor>();
- private ArrayList<BaseDNDescriptor> dataArray =
- new ArrayList<BaseDNDescriptor>();
- private final String[] COLUMN_NAMES = {
- getMsg("basedn-column"),
- getMsg("backendid-column"),
- getMsg("number-entries-column"),
- getMsg("replicated-column"),
- getMsg("missing-changes-column"),
- getMsg("age-of-oldest-missing-change-column")
- };
- private int sortColumn = 0;
- private boolean sortAscending = true;
- private boolean displayReplicationInformation;
-
- /**
- * Constructor for this table model.
- * @param displayReplicationInformation whether to display replication
- * monitoring information or not.
- */
- public DatabasesTableModel(boolean displayReplicationInformation)
- {
- this.displayReplicationInformation = displayReplicationInformation;
- }
-
- /**
- * Sets the data for this table model.
- * @param newData the data for this table model.
- */
- public void setData(Set<BaseDNDescriptor> newData)
- {
- if (!newData.equals(data))
- {
- data.clear();
- data.addAll(newData);
- dataArray.clear();
- TreeSet<BaseDNDescriptor> sortedSet =
- new TreeSet<BaseDNDescriptor>(this);
- sortedSet.addAll(data);
- dataArray.addAll(sortedSet);
- fireTableDataChanged();
- }
- }
-
- /**
- * Updates the table model contents and sorts its contents depending on the
- * sort options set by the user.
- */
- public void forceResort()
- {
- dataArray.clear();
- TreeSet<BaseDNDescriptor> sortedSet =
- new TreeSet<BaseDNDescriptor>(this);
- sortedSet.addAll(data);
- dataArray.addAll(sortedSet);
- fireTableDataChanged();
- }
-
- /**
- * Comparable implementation.
- * @param desc1 the first replica descriptor to compare.
- * @param desc2 the second replica descriptor to compare.
- * @return 1 if according to the sorting options set by the user the first
- * database descriptor must be put before the second descriptor, 0 if they
- * are equivalent in terms of sorting and -1 if the second descriptor must
- * be put before the first descriptor.
- */
- public int compare(BaseDNDescriptor desc1, BaseDNDescriptor desc2)
- {
- int result = 0;
- if (sortColumn == 0)
- {
- result = compareDns(desc1, desc2);
-
- if (result == 0)
- {
- result = compareBackendIDs(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareEntries(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareRepl(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareMissingChanges(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareAgeOfOldestMissingChange(desc1, desc2);
- }
- }
-
- if (sortColumn == 1)
- {
- result = compareBackendIDs(desc1, desc2);
-
- if (result == 0)
- {
- result = compareDns(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareEntries(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareRepl(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareMissingChanges(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareAgeOfOldestMissingChange(desc1, desc2);
- }
- }
- else if (sortColumn == 2)
- {
- result = compareEntries(desc1, desc2);
-
- if (result == 0)
- {
- result = compareBackendIDs(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareDns(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareRepl(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareMissingChanges(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareAgeOfOldestMissingChange(desc1, desc2);
- }
- }
- else if (sortColumn == 3)
- {
- result = compareRepl(desc1, desc2);
-
- if (result == 0)
- {
- result = compareBackendIDs(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareDns(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareEntries(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareMissingChanges(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareAgeOfOldestMissingChange(desc1, desc2);
- }
- }
- else if (sortColumn == 4)
- {
- result = compareMissingChanges(desc1, desc2);
-
- if (result == 0)
- {
- result = compareBackendIDs(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareDns(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareEntries(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareRepl(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareAgeOfOldestMissingChange(desc1, desc2);
- }
- }
- else if (sortColumn == 5)
- {
- result = compareAgeOfOldestMissingChange(desc1, desc2);
-
- if (result == 0)
- {
- result = compareBackendIDs(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareDns(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareEntries(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareRepl(desc1, desc2);
- }
-
- if (result == 0)
- {
- result = compareMissingChanges(desc1, desc2);
- }
- }
-
- if (!sortAscending)
- {
- result = -result;
- }
-
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getColumnCount()
- {
- return displayReplicationInformation ? 6 : 4;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getRowCount()
- {
- return dataArray.size();
- }
-
- /**
- * {@inheritDoc}
- */
- public Object getValueAt(int row, int col)
- {
- Object v;
- BaseDNDescriptor desc = dataArray.get(row);
- if (col == 0)
- {
- v = desc.getDn();
- }
- else if (col == 1)
- {
- v = desc.getDatabase().getBackendID();
- }
- else if (col == 2)
- {
- v = getValueForEntries(desc);
- }
- else if (col == 3)
- {
- v = getStringForReplState(desc);
- }
- else if (col == 4)
- {
- v = getValueForMissingChanges(desc);
- }
- else if (col == 5)
- {
- v = getValueForOldestMissingChange(desc);
- }
- else
- {
- throw new IllegalArgumentException("Invalid col number: "+col);
- }
- return v;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getColumnName(int col) {
- return COLUMN_NAMES[col];
- }
-
- /**
- * Returns whether the sort is ascending or descending.
- * @return <CODE>true</CODE> if the sort is ascending and <CODE>false</CODE>
- * otherwise.
- */
- public boolean isSortAscending()
- {
- return sortAscending;
- }
-
- /**
- * Sets whether to sort ascending of descending.
- * @param sortAscending whether to sort ascending or descending.
- */
- public void setSortAscending(boolean sortAscending)
- {
- this.sortAscending = sortAscending;
- }
-
- /**
- * Returns the column index used to sort.
- * @return the column index used to sort.
- */
- public int getSortColumn()
- {
- return sortColumn;
- }
-
- /**
- * Sets the column index used to sort.
- * @param sortColumn column index used to sort..
- */
- public void setSortColumn(int sortColumn)
- {
- this.sortColumn = sortColumn;
- }
-
- /*
- * Several comparison methods to be able to sort the table model.
- */
- private int compareBackendIDs(BaseDNDescriptor desc1, BaseDNDescriptor desc2)
- {
- return desc1.getDatabase().getBackendID().compareTo(
- desc2.getDatabase().getBackendID());
- }
-
- private int compareEntries(BaseDNDescriptor desc1, BaseDNDescriptor desc2)
- {
- int n1 = desc1.getDatabase().getEntries();
- int n2 = desc2.getDatabase().getEntries();
- return compareIntegers(n1, n2);
- }
-
- private int compareIntegers(int n1, int n2)
- {
- if (n1 == n2)
- {
- return 0;
- }
- if (n1 > n2)
- {
- return 1;
- }
- return -1;
- }
-
- private int compareDns(BaseDNDescriptor desc1, BaseDNDescriptor desc2)
- {
- return desc1.getDn().compareTo(desc2.getDn());
- }
-
- private int compareRepl(BaseDNDescriptor desc1, BaseDNDescriptor desc2)
- {
- return (String.valueOf(desc1.getType()).compareTo(
- String.valueOf(desc2.getType())));
- }
-
- private int compareMissingChanges(BaseDNDescriptor desc1,
- BaseDNDescriptor desc2)
- {
- return compareIntegers(desc1.getMissingChanges(),
- desc2.getMissingChanges());
- }
-
- private int compareAgeOfOldestMissingChange(BaseDNDescriptor desc1,
- BaseDNDescriptor desc2)
- {
- return compareIntegers(desc1.getAgeOfOldestMissingChange(),
- desc2.getAgeOfOldestMissingChange());
- }
-
- /**
- * Returns the Object describing the number of entries of a given Base DN.
- * The Object will be an Integer unless the database of the Base DN contains
- * several Base DNs. In this case we return a String.
- * @param rep the Base DN object to handle.
- * @return the Object describing the number of entries of a given Base DN.
- */
- private Object getValueForEntries(BaseDNDescriptor rep)
- {
- Object v;
- int nEntries = rep.getDatabase().getEntries();
- if ((rep.getDatabase().getBaseDns().size() > 1) &&
- (nEntries >= 0))
- {
- String[] args = {
- String.valueOf(nEntries),
- rep.getDatabase().getBackendID()
- };
- v = getMsg("number-entries-multiple-suffixes-in-db", args);
- }
- else
- {
- v = new Integer(nEntries);
- }
- return v;
- }
-
- /**
- * Returns the Object describing the number of missing changes of a given Base
- * DN. The Object will be a String unless the base DN is
- * replicated and we could not find a valid value (in this case we return
- * an Integer with the invalid value).
- * @param rep the Base DN object to handle.
- * @return the Object describing the number of missing changes of
- * a given Base DN.
- */
- private Object getValueForMissingChanges(BaseDNDescriptor rep)
- {
- Object v;
- if (rep.getType() == BaseDNDescriptor.Type.REPLICATED)
- {
- v = new Integer(rep.getMissingChanges());
- }
- else
- {
- v = getMsg("not-applicable-label");
- }
- return v;
- }
-
- /**
- * Returns the Object describing the age of oldest missing change of
- * a given Base DN. The Object will be a String unless the base DN is
- * replicated and we could not find a valid value (in this case we return
- * an Integer with the invalid value).
- * @param rep the Base DN object to handle.
- * @return the Object describing the age of oldest missing change of
- * a given Base DN.
- */
- private Object getValueForOldestMissingChange(BaseDNDescriptor rep)
- {
- Object v;
- if (rep.getType() == BaseDNDescriptor.Type.REPLICATED)
- {
- int age = rep.getAgeOfOldestMissingChange();
- if (age >= 0)
- {
- int remainingSeconds = age % 60;
- int minutes = age / 60;
- int remainingMinutes = minutes % 60;
- int hours = minutes / 60;
-
- String sMinutes = (remainingMinutes>=10)?
- String.valueOf(remainingMinutes) : "0"+remainingMinutes;
-
- String sSeconds = (remainingSeconds>=10)?
- String.valueOf(remainingSeconds) : "0"+remainingSeconds;
-
- String sHours = (hours>=10)?String.valueOf(hours):"0"+hours;
-
- v = sHours+":"+sMinutes+":"+sSeconds;
- }
- else
- {
- v = new Integer(age);
- }
- }
- else
- {
- v = getMsg("not-applicable-label");
- }
- return v;
- }
-
- /**
- * Returns the localized String describing the replication state of
- * a given Base DN.
- * @param rep the Base DN object to handle.
- * @return the localized String describing the replication state of
- * a given Base DN.
- */
- private String getStringForReplState(BaseDNDescriptor rep)
- {
- String s;
- if (rep.getType() == BaseDNDescriptor.Type.REPLICATED)
- {
- s = getMsg("suffix-replicated-label");
- }
- else
- {
- s = getMsg("suffix-not-replicated-label");
- }
- return s;
- }
-
- /**
- * The following three methods are just commodity methods to get localized
- * messages.
- */
- private String getMsg(String key)
- {
- return getI18n().getMsg(key);
- }
-
- private String getMsg(String key, String[] args)
- {
- return getI18n().getMsg(key, args);
- }
-
- private ResourceProvider getI18n()
- {
- return ResourceProvider.getInstance();
- }
-}
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ui/ListenersTableModel.java b/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ui/ListenersTableModel.java
deleted file mode 100644
index 5b9b0b3..0000000
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ui/ListenersTableModel.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * 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.statuspanel.ui;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.TreeSet;
-
-import javax.swing.table.AbstractTableModel;
-
-import org.opends.quicksetup.ui.SortableTableModel;
-import org.opends.statuspanel.ListenerDescriptor;
-import org.opends.statuspanel.i18n.ResourceProvider;
-
-/**
- * This class is just a table model used to display the information about
- * listeners in a table.
- *
- */
-public class ListenersTableModel extends AbstractTableModel
-implements SortableTableModel, Comparator<ListenerDescriptor>
-{
- private static final long serialVersionUID = -1121308303480078376L;
- private HashSet<ListenerDescriptor> data = new HashSet<ListenerDescriptor>();
- private ArrayList<ListenerDescriptor> dataArray =
- new ArrayList<ListenerDescriptor>();
- private final String[] COLUMN_NAMES = {
- getMsg("address-port-column"),
- getMsg("protocol-column"),
- getMsg("state-column")
- };
- private int sortColumn = 0;
- private boolean sortAscending = true;
-
- /**
- * Sets the data for this table model.
- * @param newData the data for this table model.
- */
- public void setData(Set<ListenerDescriptor> newData)
- {
- if (!newData.equals(data))
- {
- data.clear();
- data.addAll(newData);
- dataArray.clear();
- TreeSet<ListenerDescriptor> sortedSet =
- new TreeSet<ListenerDescriptor>(this);
- sortedSet.addAll(data);
- dataArray.addAll(sortedSet);
- fireTableDataChanged();
- }
- }
-
- /**
- * Updates the table model contents and sorts its contents depending on the
- * sort options set by the user.
- */
- public void forceResort()
- {
- dataArray.clear();
- TreeSet<ListenerDescriptor> sortedSet =
- new TreeSet<ListenerDescriptor>(this);
- sortedSet.addAll(data);
- dataArray.addAll(sortedSet);
- fireTableDataChanged();
- }
-
- /**
- * Comparable implementation.
- * @param desc1 the first listener descriptor to compare.
- * @param desc2 the second listener descriptor to compare.
- * @return 1 if according to the sorting options set by the user the first
- * listener descriptor must be put before the second descriptor, 0 if they
- * are equivalent in terms of sorting and -1 if the second descriptor must
- * be put before the first descriptor.
- */
- public int compare(ListenerDescriptor desc1, ListenerDescriptor desc2)
- {
- int result = 0;
- if (sortColumn == 0)
- {
- result = desc1.getAddressPort().compareTo(desc2.getAddressPort());
-
- if (result == 0)
- {
- result = desc1.getProtocolDescription().compareTo(
- desc2.getProtocolDescription());
- }
-
- if (result == 0)
- {
- result = desc1.getState().compareTo(desc2.getState());
- }
- }
- else if (sortColumn == 1)
- {
- result = desc1.getProtocolDescription().compareTo(
- desc2.getProtocolDescription());
-
- if (result == 0)
- {
- result = desc1.getAddressPort().compareTo(desc2.getAddressPort());
- }
-
- if (result == 0)
- {
- result = desc1.getState().compareTo(desc2.getState());
- }
- }
- else
- {
- result = desc1.getState().compareTo(desc2.getState());
-
- if (result == 0)
- {
- result = desc1.getAddressPort().compareTo(desc2.getAddressPort());
- }
-
- if (result == 0)
- {
- result = desc1.getProtocolDescription().compareTo(
- desc2.getProtocolDescription());
- }
- }
-
- if (!sortAscending)
- {
- result = -result;
- }
-
- return result;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getColumnCount()
- {
- return 3;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getRowCount()
- {
- return dataArray.size();
- }
-
- /**
- * {@inheritDoc}
- */
- public Object getValueAt(int row, int col)
- {
- Object v;
- ListenerDescriptor desc = dataArray.get(row);
- if (col == 0)
- {
- v = desc.getAddressPort();
- }
- else if (col == 1)
- {
- v = desc.getProtocolDescription().toString();
- }
- else
- {
- switch (desc.getState())
- {
- case ENABLED:
- v = getMsg("enabled-label");
- break;
-
- case DISABLED:
- v = getMsg("disabled-label");
- break;
-
- case UNKNOWN:
- v = getMsg("unknown-label");
- break;
-
- default:
- throw new IllegalStateException("Unknown state: "+desc.getState());
- }
- }
- return v;
- }
-
- /**
- * {@inheritDoc}
- */
- public String getColumnName(int col) {
- return COLUMN_NAMES[col];
- }
-
-
- /**
- * Returns whether the sort is ascending or descending.
- * @return <CODE>true</CODE> if the sort is ascending and <CODE>false</CODE>
- * otherwise.
- */
- public boolean isSortAscending()
- {
- return sortAscending;
- }
-
- /**
- * Sets whether to sort ascending of descending.
- * @param sortAscending whether to sort ascending or descending.
- */
- public void setSortAscending(boolean sortAscending)
- {
- this.sortAscending = sortAscending;
- }
-
- /**
- * Returns the column index used to sort.
- * @return the column index used to sort.
- */
- public int getSortColumn()
- {
- return sortColumn;
- }
-
- /**
- * Sets the column index used to sort.
- * @param sortColumn column index used to sort..
- */
- public void setSortColumn(int sortColumn)
- {
- this.sortColumn = sortColumn;
- }
-
- /**
- * The following three methods are just commodity methods to get localized
- * messages.
- */
- private String getMsg(String key)
- {
- return getI18n().getMsg(key);
- }
-
- private ResourceProvider getI18n()
- {
- return ResourceProvider.getInstance();
- }
-}
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ui/LoginDialog.java b/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ui/LoginDialog.java
deleted file mode 100644
index 42bce6b..0000000
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ui/LoginDialog.java
+++ /dev/null
@@ -1,832 +0,0 @@
-/*
- * 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 2006-2007 Sun Microsystems, Inc.
- */
-
-package org.opends.statuspanel.ui;
-
-import java.awt.Dimension;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.net.URI;
-import java.security.cert.X509Certificate;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.naming.NamingException;
-import javax.naming.directory.SearchControls;
-import javax.naming.ldap.InitialLdapContext;
-import javax.swing.Box;
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTextField;
-import javax.swing.SwingUtilities;
-import javax.swing.text.JTextComponent;
-
-import org.opends.admin.ads.util.ApplicationTrustManager;
-import org.opends.quicksetup.Installation;
-import org.opends.quicksetup.Step;
-import org.opends.quicksetup.UserDataCertificateException;
-import org.opends.quicksetup.event.MinimumSizeComponentListener;
-import org.opends.quicksetup.ui.CertificateDialog;
-import org.opends.quicksetup.ui.UIFactory;
-import org.opends.quicksetup.ui.Utilities;
-import org.opends.quicksetup.util.BackgroundTask;
-import org.opends.quicksetup.util.Utils;
-
-import org.opends.statuspanel.ConfigException;
-import org.opends.statuspanel.ConfigFromFile;
-import org.opends.statuspanel.ConnectionProtocolPolicy;
-import org.opends.statuspanel.i18n.ResourceProvider;
-
-/**
- * This class is a dialog that appears when the user must provide authentication
- * to connect to the Directory Server in order to be able to display
- * information.
- */
-public class LoginDialog extends JDialog
-{
- private static final long serialVersionUID = 9049606381601152500L;
-
- private JFrame parent;
-
- private JLabel lDn;
- private JLabel lPwd;
-
- private JTextField tfDn;
- private JTextField tfPwd;
-
- private JButton cancelButton;
- private JButton okButton;
-
- private boolean isCancelled = true;
-
- private ConfigFromFile conf;
-
- private ApplicationTrustManager trustManager;
- private ConnectionProtocolPolicy policy;
-
- private String usedUrl;
-
- private static final Logger LOG =
- Logger.getLogger(LoginDialog.class.getName());
-
- /**
- * Constructor of the LoginDialog.
- * @param parent the parent frame for this dialog.
- * @param trustManager the trust manager to be used for the secure
- * connections.
- * @param policy the configuration policy to be used (whether we prefer the
- * most secure, the less secure, a specific method...).
- */
- public LoginDialog(JFrame parent, ApplicationTrustManager trustManager,
- ConnectionProtocolPolicy policy)
- {
- super(parent);
- setTitle(getMsg("login-dialog-title"));
- this.parent = parent;
- getContentPane().add(createPanel());
- if (trustManager == null)
- {
- throw new IllegalArgumentException("The trustmanager cannot be null.");
- }
- this.trustManager = trustManager;
- this.policy = policy;
- /*
- * TODO: find a way to calculate this dynamically. This is done to avoid
- * all the text in a single line.
- */
- setPreferredSize(new Dimension(500, 250));
- addComponentListener(new MinimumSizeComponentListener(this, 500, 250));
- getRootPane().setDefaultButton(okButton);
- }
-
- /**
- * Returns <CODE>true</CODE> if the user clicked on cancel and
- * <CODE>false</CODE> otherwise.
- * @return <CODE>true</CODE> if the user clicked on cancel and
- * <CODE>false</CODE> otherwise.
- */
- public boolean isCancelled()
- {
- return isCancelled;
- }
-
- /**
- * {@inheritDoc}
- *
- */
- public void setVisible(boolean visible)
- {
- cancelButton.setEnabled(true);
- okButton.setEnabled(true);
- if (visible)
- {
- tfPwd.setText("");
- tfPwd.requestFocusInWindow();
- UIFactory.setTextStyle(lDn,
- UIFactory.TextStyle.PRIMARY_FIELD_VALID);
- UIFactory.setTextStyle(lPwd,
- UIFactory.TextStyle.PRIMARY_FIELD_VALID);
- getRootPane().setDefaultButton(okButton);
- }
- super.setVisible(visible);
- }
-
- /**
- * Returns the Directory Manager DN provided by the user.
- * @return the Directory Manager DN provided by the user.
- */
- public String getDirectoryManagerDn()
- {
- return tfDn.getText();
- }
-
- /**
- * Returns the Directory Manager password provided by the user.
- * @return the Directory Manager password provided by the user.
- */
- public String getDirectoryManagerPwd()
- {
- return tfPwd.getText();
- }
-
- /**
- * Creates and returns the panel of the dialog.
- * @return the panel of the dialog.
- */
- private JPanel createPanel()
- {
- JPanel p1 = new JPanel(new GridBagLayout());
- p1.setBackground(UIFactory.CURRENT_STEP_PANEL_BACKGROUND);
- p1.setBorder(UIFactory.DIALOG_PANEL_BORDER);
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.gridwidth = GridBagConstraints.RELATIVE;
- gbc.anchor = GridBagConstraints.NORTHWEST;
- gbc.insets = UIFactory.getCurrentStepPanelInsets();
- p1.add(UIFactory.makeJLabel(UIFactory.IconType.INFORMATION_LARGE, null,
- UIFactory.TextStyle.NO_STYLE), gbc);
- gbc.weightx = 1.0;
- gbc.fill = GridBagConstraints.BOTH;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.insets.left = 0;
- String msg = getMsg("login-dialog-msg");
-
- JTextComponent textPane =
- UIFactory.makeHtmlPane(msg, UIFactory.INSTRUCTIONS_FONT);
- textPane.setOpaque(false);
- textPane.setEditable(false);
- p1.add(textPane, gbc);
-
- JPanel p2 = new JPanel(new GridBagLayout());
- p2.setOpaque(false);
- gbc.gridwidth = GridBagConstraints.RELATIVE;
- gbc.weightx = 0.0;
- gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
- gbc.insets.left = 0;
- gbc.anchor = GridBagConstraints.WEST;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- lDn = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
- getMsg("login-dn-label"),
- UIFactory.TextStyle.PRIMARY_FIELD_VALID);
- p2.add(lDn, gbc);
- gbc.weightx = 1.0;
- gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- tfDn = UIFactory.makeJTextField(getProposedAdministrativeUserDn(),
- getMsg("login-dn-tooltip"),
- UIFactory.DN_FIELD_SIZE, UIFactory.TextStyle.TEXTFIELD);
- p2.add(tfDn, gbc);
-
- gbc.insets.top = 0;
- gbc.gridwidth = GridBagConstraints.RELATIVE;
- gbc.weightx = 0.0;
- gbc.insets.left = 0;
- lPwd = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
- getMsg("login-pwd-label"),
- UIFactory.TextStyle.PRIMARY_FIELD_VALID);
- p2.add(lPwd, gbc);
- gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD;
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- JPanel p3 = new JPanel(new GridBagLayout());
- p3.setOpaque(false);
- tfPwd = UIFactory.makeJPasswordField(null,
- getMsg("login-pwd-tooltip"),
- UIFactory.PASSWORD_FIELD_SIZE, UIFactory.TextStyle.PASSWORD_FIELD);
- p2.add(p3, gbc);
- gbc.insets = UIFactory.getEmptyInsets();
- gbc.gridwidth = GridBagConstraints.RELATIVE;
- gbc.weightx = 0.0;
- p3.add(tfPwd, gbc);
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.weightx = 1.0;
- p3.add(Box.createHorizontalGlue(), gbc);
-
-
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.insets = UIFactory.getEmptyInsets();
- gbc.gridwidth = GridBagConstraints.RELATIVE;
- gbc.weightx = 0.0;
- gbc.insets.top = 0;
- p1.add(Box.createHorizontalGlue(), gbc);
- gbc.weightx = 1.0;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- p1.add(p2, gbc);
- gbc.weighty = 1.0;
- gbc.fill = GridBagConstraints.VERTICAL;
- p1.add(Box.createVerticalGlue(), gbc);
-
- JPanel buttonPanel = new JPanel(new GridBagLayout());
- buttonPanel.setOpaque(false);
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.weightx = 1.0;
- gbc.insets = UIFactory.getEmptyInsets();
- gbc.gridwidth = 3;
- buttonPanel.add(Box.createHorizontalGlue(), gbc);
- gbc.gridwidth = GridBagConstraints.RELATIVE;
- gbc.fill = GridBagConstraints.NONE;
- gbc.weightx = 0.0;
- okButton =
- UIFactory.makeJButton(getMsg("ok-button-label"),
- getMsg("login-ok-button-tooltip"));
- buttonPanel.add(okButton, gbc);
- okButton.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent ev)
- {
- okClicked();
- }
- });
-
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.insets.left = UIFactory.HORIZONTAL_INSET_BETWEEN_BUTTONS;
- cancelButton =
- UIFactory.makeJButton(getMsg("cancel-button-label"),
- getMsg("login-cancel-button-tooltip"));
- buttonPanel.add(cancelButton, gbc);
- cancelButton.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent ev)
- {
- cancelClicked();
- }
- });
-
- JPanel p = new JPanel(new GridBagLayout());
- p.setBackground(UIFactory.DEFAULT_BACKGROUND);
- gbc.insets = UIFactory.getEmptyInsets();
- gbc.fill = GridBagConstraints.BOTH;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- p.add(p1, gbc);
- gbc.weighty = 0.0;
- gbc.insets = UIFactory.getButtonsPanelInsets();
- p.add(buttonPanel, gbc);
-
- return p;
- }
-
- /**
- * Returns the first administrative user DN found in the configuration file.
- * @return the first administrative user DN found in the configuration file.
- */
- private String getProposedAdministrativeUserDn()
- {
- String dn;
- Set<String> dns = getAdministrativeUserDns();
- if (dns.size() > 0)
- {
- dn = dns.iterator().next();
- }
- else
- {
- dn = null;
- }
- return dn;
- }
-
- /**
- * Method called when user clicks on cancel.
- *
- */
- private void cancelClicked()
- {
- isCancelled = true;
- dispose();
- }
-
- /**
- * Method called when user clicks on OK.
- *
- */
- private void okClicked()
- {
- BackgroundTask worker = new BackgroundTask()
- {
- public Object processBackgroundTask() throws NamingException,
- ConfigException
- {
- Boolean isServerRunning = Boolean.TRUE;
- InitialLdapContext ctx = null;
- try
- {
- String ldapUrl = getConfig().getLDAPURL();
- String startTlsUrl = getConfig().getStartTLSURL();
- String ldapsUrl = getConfig().getLDAPSURL();
- switch (policy)
- {
- case USE_STARTTLS:
- if (startTlsUrl != null)
- {
- usedUrl = startTlsUrl;
- ctx = Utils.createStartTLSContext(startTlsUrl, tfDn.getText(),
- tfPwd.getText(), Utils.getDefaultLDAPTimeout(), null,
- getTrustManager(), null);
- }
- else
- {
- throw new ConfigException(getMsg("could-not-find-valid-ldapurl"));
- }
- break;
- case USE_LDAPS:
- if (ldapsUrl != null)
- {
- usedUrl = ldapsUrl;
- ctx = Utils.createLdapsContext(ldapsUrl, tfDn.getText(),
- tfPwd.getText(), Utils.getDefaultLDAPTimeout(), null,
- getTrustManager());
- }
- else
- {
- throw new ConfigException(getMsg("could-not-find-valid-ldapurl"));
- }
- break;
- case USE_LDAP:
- if (ldapUrl != null)
- {
- usedUrl = ldapUrl;
- ctx = Utils.createLdapContext(ldapUrl, tfDn.getText(),
- tfPwd.getText(), Utils.getDefaultLDAPTimeout(), null);
- }
- else
- {
- throw new ConfigException(getMsg("could-not-find-valid-ldapurl"));
- }
- break;
- case USE_MOST_SECURE_AVAILABLE:
- if (ldapsUrl != null)
- {
- usedUrl = ldapsUrl;
- ctx = Utils.createLdapsContext(ldapsUrl, tfDn.getText(),
- tfPwd.getText(), Utils.getDefaultLDAPTimeout(), null,
- getTrustManager());
- }
- else if (startTlsUrl != null)
- {
- usedUrl = startTlsUrl;
- ctx = Utils.createStartTLSContext(startTlsUrl, tfDn.getText(),
- tfPwd.getText(), Utils.getDefaultLDAPTimeout(), null,
- getTrustManager(), null);
- }
- else if (ldapUrl != null)
- {
- usedUrl = ldapUrl;
- ctx = Utils.createLdapContext(ldapUrl, tfDn.getText(),
- tfPwd.getText(), Utils.getDefaultLDAPTimeout(), null);
- }
- else
- {
- throw new ConfigException(getMsg("could-not-find-valid-ldapurl"));
- }
- break;
- case USE_LESS_SECURE_AVAILABLE:
- if (ldapUrl != null)
- {
- usedUrl = ldapUrl;
- ctx = Utils.createLdapContext(ldapUrl, tfDn.getText(),
- tfPwd.getText(), Utils.getDefaultLDAPTimeout(), null);
- }
- else if (ldapsUrl != null)
- {
- usedUrl = ldapsUrl;
- ctx = Utils.createLdapsContext(ldapsUrl, tfDn.getText(),
- tfPwd.getText(), Utils.getDefaultLDAPTimeout(), null,
- getTrustManager());
- }
- else
- {
- throw new ConfigException(getMsg("could-not-find-valid-ldapurl"));
- }
- break;
- default:
- throw new IllegalStateException("Unknown connection policy: "+
- policy);
- }
-
- /*
- * Search for the config to check that it is the directory manager.
- */
- SearchControls searchControls = new SearchControls();
- searchControls.setCountLimit(1);
- searchControls.setSearchScope(
- SearchControls. OBJECT_SCOPE);
- searchControls.setReturningAttributes(
- new String[] {"dn"});
- ctx.search("cn=config", "objectclass=*", searchControls);
-
- } catch (NamingException ne)
- {
- if (isServerRunning())
- {
- throw ne;
- }
- isServerRunning = Boolean.FALSE;
- } catch (ConfigException e)
- {
- throw e;
- } catch (IllegalStateException ise)
- {
- throw ise;
-
- } catch (Throwable t)
- {
- throw new IllegalStateException("Unexpected throwable.", t);
- }
- finally
- {
- if (ctx != null)
- try
- {
- ctx.close();
- }
- catch (Throwable t)
- {
- }
- }
- return isServerRunning;
- }
-
- public void backgroundTaskCompleted(Object returnValue,
- Throwable throwable)
- {
- if (throwable != null)
- {
- LOG.log(Level.INFO, "Error connecting: " + throwable, throwable);
- if (Utils.isCertificateException(throwable))
- {
- ApplicationTrustManager.Cause cause =
- trustManager.getLastRefusedCause();
-
- LOG.log(Level.INFO, "Certificate exception cause: "+cause);
- UserDataCertificateException.Type excType = null;
- if (cause == ApplicationTrustManager.Cause.NOT_TRUSTED)
- {
- excType = UserDataCertificateException.Type.NOT_TRUSTED;
- }
- else if (cause ==
- ApplicationTrustManager.Cause.HOST_NAME_MISMATCH)
- {
- excType = UserDataCertificateException.Type.HOST_NAME_MISMATCH;
- }
- else
- {
- String msg = Utils.getThrowableMsg(getI18n(),
- "error-connecting-to-local", null, throwable);
- displayError(msg, getMsg("error-title"));
- }
-
- if (excType != null)
- {
- String h;
- int p;
- try
- {
- URI uri = new URI(usedUrl);
- h = uri.getHost();
- p = uri.getPort();
- }
- catch (Throwable t)
- {
- LOG.log(Level.WARNING,
- "Error parsing ldap url of ldap url.", t);
- h = getMsg("not-available-label");
- p = -1;
- }
- UserDataCertificateException udce =
- new UserDataCertificateException(Step.REPLICATION_OPTIONS,
- getMsg("certificate-exception",
- new String[] {h, String.valueOf(p)}),
- throwable, h, p,
- getTrustManager().getLastRefusedChain(),
- getTrustManager().getLastRefusedAuthType(), excType);
-
- handleCertificateException(udce);
- }
- }
- else if (throwable instanceof NamingException)
- {
- boolean dnInvalid = false;
- boolean pwdInvalid = false;
-
- String dn = tfDn.getText();
- ArrayList<String> possibleCauses = new ArrayList<String>();
- if ("".equals(dn.trim()))
- {
- dnInvalid = true;
- possibleCauses.add(getMsg("empty-directory-manager-dn"));
- }
- else if (!Utils.isDn(dn))
- {
- dnInvalid = true;
- possibleCauses.add(getMsg("not-a-directory-manager-dn"));
- }
- else
- {
- boolean found = false;
- Iterator<String> it = getAdministrativeUserDns().iterator();
- while (it.hasNext() && !found)
- {
- found = Utils.areDnsEqual(dn, it.next());
- }
- if (!found)
- {
- dnInvalid = true;
- possibleCauses.add(getMsg("not-a-directory-manager-in-config"));
- }
- }
-
- if ("".equals(tfPwd.getText()))
- {
- pwdInvalid = true;
- possibleCauses.add(getMsg("empty-pwd"));
- }
- if (dnInvalid)
- {
- UIFactory.setTextStyle(lDn,
- UIFactory.TextStyle.PRIMARY_FIELD_INVALID);
- }
- else
- {
- UIFactory.setTextStyle(lDn,
- UIFactory.TextStyle.PRIMARY_FIELD_VALID);
- pwdInvalid = true;
- }
- if (pwdInvalid)
- {
- UIFactory.setTextStyle(lPwd,
- UIFactory.TextStyle.PRIMARY_FIELD_INVALID);
- }
- else
- {
- UIFactory.setTextStyle(lPwd,
- UIFactory.TextStyle.PRIMARY_FIELD_VALID);
- }
- if (possibleCauses.size() > 0)
- {
- // Message with causes
- String[] arg = {
- Utils.getStringFromCollection(possibleCauses, "\n")
- };
- displayError(
- getMsg("cannot-connect-to-login-with-cause", arg),
- getMsg("error-title"));
- }
- else
- {
- // Generic message
- displayError(
- getMsg("cannot-connect-to-login-without-cause"),
- getMsg("error-title"));
- }
- }
- else if (throwable instanceof ConfigException)
- {
- displayError(throwable.getMessage(), getMsg("error-title"));
- }
- else
- {
- // This is a bug
- throwable.printStackTrace();
- displayError(
- Utils.getThrowableMsg(getI18n(), "bug-msg", null, throwable),
- getMsg("error-title"));
- }
- cancelButton.setEnabled(true);
- okButton.setEnabled(true);
- } else
- {
- if (Boolean.FALSE.equals(returnValue))
- {
- displayInformationMessage(
- getMsg("login-dialog-server-not-running-msg"),
- getMsg("login-dialog-server-not-running-title"));
- }
- UIFactory.setTextStyle(lDn,
- UIFactory.TextStyle.PRIMARY_FIELD_VALID);
- UIFactory.setTextStyle(lPwd,
- UIFactory.TextStyle.PRIMARY_FIELD_VALID);
- isCancelled = false;
- cancelButton.setEnabled(true);
- okButton.setEnabled(true);
- dispose();
- }
- }
- };
- cancelButton.setEnabled(false);
- okButton.setEnabled(false);
- worker.startBackgroundTask();
- }
-
- /**
- * Displays an error message dialog.
- *
- * @param msg
- * the error message.
- * @param title
- * the title for the dialog.
- */
- private void displayError(String msg, String title)
- {
- Utilities.displayError(parent, msg, title);
- toFront();
-
- }
-
- /**
- * Displays an information message dialog.
- *
- * @param msg
- * the information message.
- * @param title
- * the title for the dialog.
- */
- private void displayInformationMessage(String msg, String title)
- {
- Utilities.displayInformationMessage(parent, msg, title);
- toFront();
- }
-
- /**
- * Returns the administrative user DNs found in the config file.
- * @return the administrative user DNs found in the config file.
- */
- private Set<String> getAdministrativeUserDns()
- {
- return getConfig().getAdministrativeUsers();
- }
-
- /**
- * Returns whether the server is running or not.
- * @return <CODE>true</CODE> if the server is running and <CODE>false</CODE>
- * otherwise.
- */
- private boolean isServerRunning()
- {
- return Installation.getLocal().getStatus().isServerRunning();
- }
-
- /**
- * Returns the ConfigFromFile object that contains the configuration read
- * from the config file.
- * @return the ConfigFromFile object that contains the configuration read
- * from the config file.
- */
- private ConfigFromFile getConfig()
- {
- if (conf == null)
- {
- conf = new ConfigFromFile();
- conf.readConfiguration();
- }
- return conf;
- }
-
- /* The following three methods are just commodity methods to retrieve
- * localized messages */
- private String getMsg(String key)
- {
- return getI18n().getMsg(key);
- }
-
- private String getMsg(String key, String[] args)
- {
- return getI18n().getMsg(key, args);
- }
-
- private ResourceProvider getI18n()
- {
- return ResourceProvider.getInstance();
- }
-
- /**
- * Returns the trust manager that can be used to establish secure connections.
- * @return the trust manager that can be used to establish secure connections.
- */
- private ApplicationTrustManager getTrustManager()
- {
- return trustManager;
- }
-
- /**
- * Displays a dialog asking the user to accept a certificate if the user
- * accepts it, we update the trust manager and simulate a click on "OK" to
- * re-check the authentication.
- * This method assumes that we are being called from the event thread.
- */
- private void handleCertificateException(UserDataCertificateException ce)
- {
- CertificateDialog dlg = new CertificateDialog(parent, ce);
- dlg.pack();
- dlg.setVisible(true);
- if (dlg.isAccepted())
- {
- X509Certificate[] chain = ce.getChain();
- String authType = ce.getAuthType();
- String host = ce.getHost();
-
- if ((chain != null) && (authType != null) && (host != null))
- {
- LOG.log(Level.INFO, "Accepting certificate presented by host "+host);
- getTrustManager().acceptCertificate(chain, authType, host);
- /* Simulate a click on the OK by calling in the okClicked method. */
- SwingUtilities.invokeLater(new Runnable()
- {
- public void run()
- {
- okClicked();
- }
- });
- }
- else
- {
- if (chain == null)
- {
- LOG.log(Level.WARNING,
- "The chain is null for the UserDataCertificateException");
- }
- if (authType == null)
- {
- LOG.log(Level.WARNING,
- "The auth type is null for the UserDataCertificateException");
- }
- if (host == null)
- {
- LOG.log(Level.WARNING,
- "The host is null for the UserDataCertificateException");
- }
- }
- }
- }
-
- /**
- * Method written for testing purposes.
- * @param args the arguments to be passed to the test program.
- */
- public static void main(String[] args)
- {
- try
- {
- // UIFactory.initialize();
- LoginDialog dlg = new LoginDialog(new JFrame(),
- new ApplicationTrustManager(null),
- ConnectionProtocolPolicy.USE_MOST_SECURE_AVAILABLE);
- dlg.pack();
- dlg.setVisible(true);
- } catch (Exception ex)
- {
- ex.printStackTrace();
- }
- }
-}
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ui/StatusPanelDialog.java b/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ui/StatusPanelDialog.java
deleted file mode 100644
index db938c3..0000000
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/ui/StatusPanelDialog.java
+++ /dev/null
@@ -1,1595 +0,0 @@
-/*
- * 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.statuspanel.ui;
-
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.Toolkit;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseMotionListener;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.io.File;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.Set;
-import java.util.TreeSet;
-
-import javax.swing.BorderFactory;
-import javax.swing.Box;
-import javax.swing.JButton;
-import javax.swing.JComponent;
-import javax.swing.JEditorPane;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTable;
-import javax.swing.JToolTip;
-import javax.swing.Popup;
-import javax.swing.PopupFactory;
-import javax.swing.SwingConstants;
-import javax.swing.ToolTipManager;
-import javax.swing.table.JTableHeader;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumn;
-
-import org.opends.quicksetup.event.MinimumSizeComponentListener;
-import org.opends.quicksetup.ui.UIFactory;
-import org.opends.quicksetup.ui.Utilities;
-import org.opends.quicksetup.util.HtmlProgressMessageFormatter;
-import org.opends.quicksetup.util.Utils;
-
-import org.opends.statuspanel.DatabaseDescriptor;
-import org.opends.statuspanel.BaseDNDescriptor;
-import org.opends.statuspanel.ServerStatusDescriptor;
-import org.opends.statuspanel.event.StatusPanelButtonListener;
-import org.opends.statuspanel.i18n.ResourceProvider;
-
-/**
- * This panel is used to display basic information about the server status.
- *
- */
-public class StatusPanelDialog extends JFrame
-{
- private static final long serialVersionUID = 6832422469078074151L;
-
- private ServerStatusDescriptor lastDescriptor;
- private ServerStatusDescriptor lastPackDescriptor;
-
- private HashSet<StatusPanelButtonListener> listeners =
- new HashSet<StatusPanelButtonListener>();
-
- private JButton quitButton;
- private JButton authenticateButton;
-
- private JLabel lServerStatus;
- private JLabel lCurrentConnections;
- private JLabel lAdministrativeUsers;
- private JLabel lInstallPath;
- private JLabel lOpenDSVersion;
- private JLabel lJavaVersion;
- private JLabel lDbTableEmpty;
- private JLabel lListenersTableEmpty;
- private JEditorPane lError;
-
- private JButton stopButton;
- private JButton startButton;
- private JButton restartButton;
-
- private HtmlProgressMessageFormatter formatter =
- new HtmlProgressMessageFormatter();
-
- private HashSet<JLabel> subsectionLabels = new HashSet<JLabel>();
-
- private DatabasesTableModel dbTableModelWithReplication;
- private DatabasesTableModel dbTableModelWithoutReplication;
- private JTable dbTableWithReplication;
- private JTable dbTableWithoutReplication;
-
- private ListenersTableModel listenersTableModel;
- private JTable listenersTable;
-
- private InstantaneousToolTipManager toolTipManager;
-
- private final String NOT_AVAILABLE = getMsg("not-available-label");
-
- /**
- * ProgressDialog constructor.
- */
- public StatusPanelDialog()
- {
- super();
- setTitle(getMsg("statuspanel-dialog-title"));
- createLayout();
-
- addWindowListener(new WindowAdapter()
- {
- public void windowClosing(WindowEvent e)
- {
- quitClicked();
- }
- });
- setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
- Utilities.setFrameIcon(this);
- }
-
- /**
- * Packs and displays this dialog.
- *
- */
- public void packAndShow()
- {
- pack();
- int packedMinWidth = (int) getPreferredSize().getWidth();
- int packedMinHeight = (int) getPreferredSize().getHeight();
-
- int minWidth = Math.min(packedMinWidth, getMaximalWidth());
- int minHeight = Math.min(packedMinHeight, getMaximalHeight());
-
- addComponentListener(new MinimumSizeComponentListener(this,
- minWidth, minHeight));
- if ((minWidth != packedMinWidth) || (minHeight != packedMinHeight))
- {
- setPreferredSize(new Dimension(minWidth, minHeight));
- pack();
- }
- Utilities.centerOnScreen(this);
-
- lastPackDescriptor = lastDescriptor;
-
- setVisible(true);
- }
-
- /**
- * Updates the contents displaying with what is specified in the provided
- * ServerStatusDescriptor object.
- * This method must be called from the event thread.
- * @param desc the ServerStatusDescriptor object.
- */
- public void updateContents(ServerStatusDescriptor desc)
- {
- lastDescriptor = desc;
-
- updateStatusContents(desc);
-
- updateCurrentConnectionContents(desc);
-
- updateAdministrativeUserContents(desc);
-
- updateInstallPathContents(desc);
-
- updateVersionContents(desc);
-
- updateJavaVersionContents(desc);
-
- updateListenerContents(desc);
-
- updateDatabaseContents(desc);
-
- updateErrorContents(desc);
-
- boolean mustRepack;
- if (lastPackDescriptor == null)
- {
- mustRepack = true;
- }
- else
- {
- boolean lastSmall =
- (lastPackDescriptor.getListeners().size() == 0) &&
- (lastPackDescriptor.getDatabases().size() == 0);
- boolean currentBig =
- (lastDescriptor.getListeners().size() > 0) ||
- (lastDescriptor.getDatabases().size() > 0);
- mustRepack = lastSmall && currentBig;
- }
- if (mustRepack)
- {
- pack();
- int packedMinWidth = (int) getPreferredSize().getWidth();
- int packedMinHeight = (int) getPreferredSize().getHeight();
-
- int minWidth = Math.min(packedMinWidth, getMaximalWidth());
- int minHeight = Math.min(packedMinHeight, getMaximalHeight());
-
- if ((minWidth != packedMinWidth) || (minHeight != packedMinHeight))
- {
- setPreferredSize(new Dimension(minWidth, minHeight));
- pack();
- }
-
- lastPackDescriptor = lastDescriptor;
- }
- }
-
- /**
- * Adds a StatusPanelButtonListener that will be notified of clicks in
- * the control panel dialog.
- * @param l the StatusPanelButtonListener to be added.
- */
- public void addButtonListener(StatusPanelButtonListener l)
- {
- listeners.add(l);
- }
-
- /**
- * Removes a StatusPanelButtonListener.
- * @param l the StatusPanelButtonListener to be removed.
- */
- public void removeButtonListener(StatusPanelButtonListener l)
- {
- listeners.remove(l);
- }
-
- /**
- * Sets the enable state of the authenticate button.
- * @param enable whether to enable or disable the button.
- */
- public void setAuthenticateButtonEnabled(boolean enable)
- {
- authenticateButton.setEnabled(enable);
- }
-
- /**
- * Sets the enable state of the start button.
- * @param enable whether to enable or disable the button.
- */
- public void setStartButtonEnabled(boolean enable)
- {
- startButton.setEnabled(enable);
- }
-
- /**
- * Sets the enable state of the stop button.
- * @param enable whether to enable or disable the button.
- */
- public void setStopButtonEnabled(boolean enable)
- {
- stopButton.setEnabled(enable);
- }
-
- /**
- * Sets the enable state of the restart button.
- * @param enable whether to enable or disable the button.
- */
- public void setRestartButtonEnabled(boolean enable)
- {
- restartButton.setEnabled(enable);
- }
-
- /**
- * Creates the layout of the dialog panel.
- *
- */
- private void createLayout()
- {
- toolTipManager = new InstantaneousToolTipManager();
-
- /* Create input panel. */
- JPanel inputPanel = new JPanel(new GridBagLayout());
- inputPanel.setOpaque(false);
-
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.insets = UIFactory.getEmptyInsets();
- gbc.anchor = GridBagConstraints.NORTHWEST;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.weightx = 1.0;
- gbc.fill = GridBagConstraints.HORIZONTAL;
-
- gbc.insets.bottom = UIFactory.BOTTOM_INSET_PROGRESS_BAR;
- lError = UIFactory.makeHtmlPane("", UIFactory.PROGRESS_FONT);
- lError.setOpaque(false);
- lError.setEditable(false);
- inputPanel.add(lError, gbc);
- gbc.insets.bottom = 0;
- gbc.insets.top = UIFactory.TOP_INSET_CONTROL_PANEL_SUBSECTION -
- UIFactory.getCurrentStepPanelInsets().top;
- inputPanel.add(createServerStatusPanel(), gbc);
-
- inputPanel.add(createServerDetailsPanel(), gbc);
-
- inputPanel.add(createListenersPanel(), gbc);
-
- inputPanel.add(createDatabasesPanel(), gbc);
-
- gbc.weighty = 1.0;
- inputPanel.add(Box.createVerticalGlue(), gbc);
-
- /* Create buttons panel */
- JPanel buttonsPanel = new JPanel(new GridBagLayout());
- buttonsPanel.setOpaque(false);
- gbc.fill = GridBagConstraints.HORIZONTAL;
- gbc.anchor = GridBagConstraints.SOUTH;
- gbc.gridwidth = 4;
- gbc.insets = UIFactory.getEmptyInsets();
- gbc.insets.left = UIFactory.getCurrentStepPanelInsets().left;
- buttonsPanel.add(UIFactory.makeJLabel(UIFactory.IconType.OPENDS_SMALL,
- null, UIFactory.TextStyle.NO_STYLE), gbc);
- gbc.weightx = 1.0;
- gbc.gridwidth--;
- gbc.insets.left = 0;
- buttonsPanel.add(Box.createHorizontalGlue(), gbc);
-
- authenticateButton =
- UIFactory.makeJButton(getMsg("authenticate-button-label"),
- getMsg("authenticate-status-panel-button-tooltip"));
- gbc.fill = GridBagConstraints.NONE;
- gbc.weightx = 0.0;
- gbc.gridwidth = GridBagConstraints.RELATIVE;
- buttonsPanel.add(authenticateButton, gbc);
- authenticateButton.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent ev)
- {
- authenticateClicked();
- }
- });
-
- quitButton =
- UIFactory.makeJButton(getMsg("quit-button-label"),
- getMsg("quit-status-panel-button-tooltip"));
- gbc.fill = GridBagConstraints.NONE;
- gbc.weightx = 0.0;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.insets.left = UIFactory.HORIZONTAL_INSET_BETWEEN_BUTTONS;
- buttonsPanel.add(quitButton, gbc);
- quitButton.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent ev)
- {
- quitClicked();
- }
- });
-
- JPanel p = new JPanel(new GridBagLayout());
- p.setBackground(UIFactory.DEFAULT_BACKGROUND);
- gbc.insets = UIFactory.getEmptyInsets();
- gbc.fill = GridBagConstraints.BOTH;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.weightx = 1.0;
- gbc.weighty = 1.0;
- JPanel p1 = new JPanel(new GridBagLayout());
- p1.setBorder(UIFactory.DIALOG_PANEL_BORDER);
- p1.setBackground(UIFactory.CURRENT_STEP_PANEL_BACKGROUND);
- gbc.insets = UIFactory.getCurrentStepPanelInsets();
- p1.add(inputPanel, gbc);
- gbc.insets = UIFactory.getEmptyInsets();
- p.add(new JScrollPane(p1), gbc);
- gbc.weighty = 0.0;
- gbc.insets = UIFactory.getButtonsPanelInsets();
- p.add(buttonsPanel, gbc);
-
- getContentPane().add(p);
-
- /* Update the preferred sizes of labels */
- int maxWidth = 0;
- for (JLabel l : subsectionLabels)
- {
- int width = (int) l.getPreferredSize().getWidth();
-
- if (maxWidth <= width)
- {
- maxWidth = width;
- }
- }
-
- for (JLabel l : subsectionLabels)
- {
- int height = (int) l.getPreferredSize().getHeight();
-
- l.setPreferredSize(new Dimension(maxWidth, height));
- }
- }
-
-
- /**
- * Method called when start button is clicked.
- */
- private void startClicked()
- {
- for (StatusPanelButtonListener l : listeners)
- {
- l.startClicked();
- }
- }
-
- /**
- * Method called when quit button is clicked.
- */
- private void quitClicked()
- {
- for (StatusPanelButtonListener l : listeners)
- {
- l.quitClicked();
- }
- }
-
- /**
- * Method called when authenticate button is clicked.
- */
- private void authenticateClicked()
- {
- for (StatusPanelButtonListener l : listeners)
- {
- l.authenticateClicked();
- }
- }
-
- /**
- * Method called when stop button is clicked.
- */
- private void stopClicked()
- {
- for (StatusPanelButtonListener l : listeners)
- {
- l.stopClicked();
- }
- }
-
- /**
- * Method called when restart button is clicked.
- */
- private void restartClicked()
- {
- for (StatusPanelButtonListener l : listeners)
- {
- l.restartClicked();
- }
- }
-
- /**
- * Method usedto create the subsection title with two decoration icons
- * surrounding the text.
- * @param title the title of the subsection.
- */
- private JPanel createSubsectionTitle(String title)
- {
- JPanel p = new JPanel(new GridBagLayout());
- p.setOpaque(false);
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.gridwidth = 5;
- gbc.weightx = 0.5;
- p.add(Box.createHorizontalGlue(), gbc);
- gbc.weightx = 0.0;
- gbc.gridwidth--;
- p.add(UIFactory.makeJLabel(UIFactory.IconType.SUBSECTION_LEFT, null,
- UIFactory.TextStyle.NO_STYLE), gbc);
- gbc.weightx = 0.0;
- gbc.gridwidth--;
- gbc.insets.left = UIFactory.HORIZONTAL_INSET_CONTROL_PANEL_SUBSECTION;
- JLabel l = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, title,
- UIFactory.TextStyle.TITLE);
- l.setHorizontalAlignment(SwingConstants.CENTER);
- subsectionLabels.add(l);
- p.add(l, gbc);
- gbc.gridwidth = GridBagConstraints.RELATIVE;
- p.add(UIFactory.makeJLabel(UIFactory.IconType.SUBSECTION_RIGHT, null,
- UIFactory.TextStyle.NO_STYLE), gbc);
- gbc.weightx = 0.5;
- gbc.insets.left = 0;
- p.add(Box.createHorizontalGlue(), gbc);
-
- return p;
- }
-
- /**
- * Creates the server status subsection panel.
- * @return the server status subsection panel.
- */
- private JPanel createServerStatusPanel()
- {
- JPanel p = new JPanel(new GridBagLayout());
- p.setOpaque(false);
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.weightx = 1.0;
- gbc.insets = UIFactory.getEmptyInsets();
-
- p.add(createSubsectionTitle(getMsg("server-status-title")), gbc);
-
- JPanel auxPanel = new JPanel(new GridBagLayout());
- auxPanel.setOpaque(false);
- gbc.anchor = GridBagConstraints.WEST;
- gbc.gridwidth = GridBagConstraints.RELATIVE;
- auxPanel.add(UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
- getMsg("server-status-label"), UIFactory.TextStyle.PRIMARY_FIELD_VALID),
- gbc);
-
- JPanel statusPanel = new JPanel(new GridBagLayout());
- statusPanel.setOpaque(false);
- gbc.gridwidth = 6;
- gbc.weightx = 0.0;
- lServerStatus = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
- NOT_AVAILABLE, UIFactory.TextStyle.READ_ONLY);
- statusPanel.add(lServerStatus, gbc);
- toolTipManager.registerComponent(lServerStatus);
- gbc.gridwidth--;
-
- stopButton = UIFactory.makeJButton(getMsg("stop-button-label"),
- getMsg("stop-button-tooltip"));
- stopButton.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent ev)
- {
- stopClicked();
- }
- });
- gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD;
- statusPanel.add(stopButton, gbc);
-
- gbc.gridwidth--;
- gbc.insets.left = UIFactory.HORIZONTAL_INSET_BETWEEN_BUTTONS;
- startButton = UIFactory.makeJButton(getMsg("start-button-label"),
- getMsg("start-button-tooltip"));
- statusPanel.add(startButton, gbc);
- startButton.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent ev)
- {
- startClicked();
- }
- });
-
- gbc.gridwidth--;
- restartButton = UIFactory.makeJButton(getMsg("restart-button-label"),
- getMsg("restart-button-tooltip"));
- restartButton.addActionListener(new ActionListener()
- {
- public void actionPerformed(ActionEvent ev)
- {
- restartClicked();
- }
- });
- statusPanel.add(restartButton, gbc);
-
- gbc.gridwidth = GridBagConstraints.RELATIVE;
- gbc.weightx = 1.0;
- gbc.insets.left = 0;
- statusPanel.add(Box.createHorizontalGlue(), gbc);
-
- int maxButtonHeight = 0;
- maxButtonHeight = Math.max(maxButtonHeight,
- (int)startButton.getPreferredSize().getHeight());
- maxButtonHeight = Math.max(maxButtonHeight,
- (int)restartButton.getPreferredSize().getHeight());
- maxButtonHeight = Math.max(maxButtonHeight,
- (int)stopButton.getPreferredSize().getHeight());
-
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.weightx = 0.0;
- statusPanel.add(Box.createVerticalStrut(maxButtonHeight), gbc);
-
- gbc.weightx = 1.0;
- gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD;
- auxPanel.add(statusPanel, gbc);
-
- gbc.insets.left = 0;
- gbc.weightx = 0.0;
- gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
- gbc.gridwidth = GridBagConstraints.RELATIVE;
- auxPanel.add(UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
- getMsg("connections-label"), UIFactory.TextStyle.PRIMARY_FIELD_VALID),
- gbc);
- lCurrentConnections = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
- NOT_AVAILABLE, UIFactory.TextStyle.READ_ONLY);
- toolTipManager.registerComponent(lCurrentConnections);
-
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD;
- auxPanel.add(lCurrentConnections, gbc);
-
- gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
- gbc.insets.left = 0;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.weightx = 1.0;
- p.add(auxPanel, gbc);
-
- return p;
- }
-
- /**
- * Creates the server details subsection panel.
- * @return the server details subsection panel.
- */
- private JPanel createServerDetailsPanel()
- {
- JPanel p = new JPanel(new GridBagLayout());
- p.setOpaque(false);
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.insets = UIFactory.getEmptyInsets();
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.weightx = 1.0;
-
- p.add(createSubsectionTitle(getMsg("server-details-title")), gbc);
-
- JPanel auxPanel = new JPanel(new GridBagLayout());
- auxPanel.setOpaque(false);
- gbc.anchor = GridBagConstraints.NORTHWEST;
- gbc.weightx = 0.0;
- JLabel[] leftLabels =
- {
- UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
- getMsg("administrative-users-label"),
- UIFactory.TextStyle.PRIMARY_FIELD_VALID),
- UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
- getMsg("installation-path-label"),
- UIFactory.TextStyle.PRIMARY_FIELD_VALID),
- UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
- getMsg("opends-version-label"),
- UIFactory.TextStyle.PRIMARY_FIELD_VALID),
- UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
- getMsg("java-version-label"),
- UIFactory.TextStyle.PRIMARY_FIELD_VALID)
- };
-
- lAdministrativeUsers = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
- NOT_AVAILABLE, UIFactory.TextStyle.READ_ONLY);
- lInstallPath = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
- NOT_AVAILABLE, UIFactory.TextStyle.READ_ONLY);
- lOpenDSVersion = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
- NOT_AVAILABLE, UIFactory.TextStyle.READ_ONLY);
- lJavaVersion = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON,
- NOT_AVAILABLE, UIFactory.TextStyle.READ_ONLY);
-
- JLabel[] rightLabels =
- {
- lAdministrativeUsers, lInstallPath, lOpenDSVersion, lJavaVersion
- };
-
-
- for (int i=0; i<leftLabels.length; i++)
- {
- gbc.insets.left = 0;
- if (i != 0)
- {
- gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
- }
- gbc.gridwidth = GridBagConstraints.RELATIVE;
- auxPanel.add(leftLabels[i], gbc);
-
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.insets.left = UIFactory.LEFT_INSET_PRIMARY_FIELD;
- auxPanel.add(rightLabels[i], gbc);
- toolTipManager.registerComponent(rightLabels[i]);
- }
-
- gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
- gbc.insets.left = 0;
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.weightx = 1.0;
- p.add(auxPanel, gbc);
-
- return p;
- }
-
- /**
- * Creates the server listeners subsection panel.
- * @return the server listeners subsection panel.
- */
- private JPanel createListenersPanel()
- {
- JPanel p = new JPanel(new GridBagLayout());
- p.setOpaque(false);
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.insets = UIFactory.getEmptyInsets();
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.weightx = 1.0;
- gbc.fill = GridBagConstraints.HORIZONTAL;
-
- p.add(createSubsectionTitle(getMsg("listeners-title")), gbc);
-
- listenersTableModel = new ListenersTableModel();
- listenersTable = UIFactory.makeSortableTable(listenersTableModel,
- new ListenersCellRenderer(),
- UIFactory.makeHeaderRenderer());
- listenersTable.setFocusable(false);
-
- gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
- p.add(listenersTable.getTableHeader(), gbc);
- int height = (int)
- listenersTable.getTableHeader().getPreferredSize().getHeight();
- listenersTable.setRowHeight(height);
- gbc.insets.top = 0;
- p.add(listenersTable, gbc);
-
- lListenersTableEmpty = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, "",
- UIFactory.TextStyle.PRIMARY_FIELD_VALID);
- gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
- p.add(lListenersTableEmpty, gbc);
- lListenersTableEmpty.setVisible(false);
- toolTipManager.registerComponent(lListenersTableEmpty);
- return p;
- }
-
- /**
- * Creates the server databases subsection panel.
- * @return the server databases subsection panel.
- */
- private JPanel createDatabasesPanel()
- {
- JPanel p = new JPanel(new GridBagLayout());
- p.setOpaque(false);
- GridBagConstraints gbc = new GridBagConstraints();
- gbc.insets = UIFactory.getEmptyInsets();
- gbc.gridwidth = GridBagConstraints.REMAINDER;
- gbc.weightx = 1.0;
- gbc.fill = GridBagConstraints.HORIZONTAL;
-
- p.add(createSubsectionTitle(getMsg("databases-title")), gbc);
-
- dbTableModelWithReplication = new DatabasesTableModel(true);
- dbTableModelWithoutReplication = new DatabasesTableModel(false);
- dbTableWithReplication =
- UIFactory.makeSortableTable(dbTableModelWithReplication,
- new DatabasesCellRenderer(),
- UIFactory.makeHeaderRenderer());
- dbTableWithReplication.setFocusable(false);
- toolTipManager.registerComponent(dbTableWithReplication);
- dbTableWithoutReplication =
- UIFactory.makeSortableTable(dbTableModelWithoutReplication,
- new DatabasesCellRenderer(),
- UIFactory.makeHeaderRenderer());
- dbTableWithoutReplication.setFocusable(false);
- toolTipManager.registerComponent(dbTableWithoutReplication);
-
- gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
- p.add(dbTableWithReplication.getTableHeader(), gbc);
- int height = (int)dbTableWithReplication.getTableHeader().
- getPreferredSize().getHeight();
- dbTableWithReplication.setRowHeight(height);
- gbc.insets.top = 0;
- p.add(dbTableWithReplication, gbc);
-
- gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
- p.add(dbTableWithoutReplication.getTableHeader(), gbc);
- height = (int)dbTableWithoutReplication.getTableHeader().
- getPreferredSize().getHeight();
- dbTableWithoutReplication.setRowHeight(height);
- gbc.insets.top = 0;
- p.add(dbTableWithoutReplication, gbc);
- dbTableWithoutReplication.setVisible(false);
-
- gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD;
- lDbTableEmpty = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, "",
- UIFactory.TextStyle.PRIMARY_FIELD_VALID);
- p.add(lDbTableEmpty, gbc);
- lDbTableEmpty.setVisible(false);
- toolTipManager.registerComponent(lDbTableEmpty);
- return p;
- }
-
-
- /**
- * Sets the not available text to a label and associates a help icon and
- * a tooltip explaining that the data is not available because the server is
- * down.
- * @param l the label.
- */
- private void setNotAvailableBecauseServerIsDown(JLabel l)
- {
- l.setText(NOT_AVAILABLE);
- l.setIcon(UIFactory.getImageIcon(UIFactory.IconType.HELP_SMALL));
- l.setToolTipText(getMsg("not-available-server-down-tooltip"));
- l.setHorizontalTextPosition(SwingConstants.LEFT);
- }
-
- /**
- * Sets the not available text to a label and associates a help icon and
- * a tooltip explaining that the data is not available because authentication
- * is required.
- * @param l the label.
- */
- private void setNotAvailableBecauseAuthenticationIsRequired(JLabel l)
- {
- l.setText(NOT_AVAILABLE);
- l.setIcon(UIFactory.getImageIcon(UIFactory.IconType.HELP_SMALL));
- l.setToolTipText(getMsg("not-available-authentication-required-tooltip"));
- l.setHorizontalTextPosition(SwingConstants.LEFT);
- }
-
- /**
- * Sets the not available text to a label with no icon nor tooltip.
- * @param l the label.
- */
- private void setNotAvailable(JLabel l)
- {
- l.setText(NOT_AVAILABLE);
- l.setIcon(null);
- l.setToolTipText(null);
- }
-
- /**
- * Sets the a text to a label with no icon nor tooltip.
- * @param l the label.
- */
- private void setTextValue(JLabel l, String text)
- {
- l.setText(text);
- l.setIcon(null);
- l.setToolTipText(null);
- }
-
- /**
- * Updates the status contents displaying with what is specified in the
- * provided ServerStatusDescriptor object.
- * This method must be called from the event thread.
- * @param desc the ServerStatusDescriptor object.
- */
- private void updateStatusContents(ServerStatusDescriptor desc)
- {
- String status;
- switch (desc.getStatus())
- {
- case STARTED:
- status = getMsg("server-started-label");
- startButton.setVisible(false);
- restartButton.setVisible(true);
- stopButton.setVisible(true);
- break;
-
- case STOPPED:
- status = getMsg("server-stopped-label");
- startButton.setVisible(true);
- restartButton.setVisible(false);
- stopButton.setVisible(false);
- break;
-
- case STARTING:
- status = getMsg("server-starting-label");
- startButton.setVisible(false);
- restartButton.setVisible(false);
- stopButton.setVisible(false);
- break;
-
- case STOPPING:
- status = getMsg("server-stopping-label");
- startButton.setVisible(false);
- restartButton.setVisible(false);
- stopButton.setVisible(false);
- break;
-
- case UNKNOWN:
- status = getMsg("server-unknown-status-label");
- startButton.setVisible(false);
- restartButton.setVisible(true);
- stopButton.setVisible(true);
- break;
-
- default:
- throw new IllegalStateException("Unknown status: "+desc.getStatus());
- }
- lServerStatus.setText(status);
-
- /* Enable authenticate button only if the server is started AND we have
- * no authentication (or the authentication we have does not seem to work
- * because we get an error).
- */
- authenticateButton.setVisible(
- (desc.getStatus() == ServerStatusDescriptor.ServerStatus.STARTED) &&
- (!desc.isAuthenticated() || (desc.getErrorMessage() != null)));
- }
-
- /**
- * Updates the current connection contents displaying with what is specified
- * in the provided ServerStatusDescriptor object.
- * This method must be called from the event thread.
- * @param desc the ServerStatusDescriptor object.
- */
- private void updateCurrentConnectionContents(ServerStatusDescriptor desc)
- {
- if (desc.getStatus() == ServerStatusDescriptor.ServerStatus.STARTED)
- {
- int nConn = desc.getOpenConnections();
- if (nConn >= 0)
- {
- setTextValue(lCurrentConnections, String.valueOf(nConn));
- }
- else
- {
- if (!desc.isAuthenticated())
- {
- setNotAvailableBecauseAuthenticationIsRequired(lCurrentConnections);
- }
- else
- {
- setNotAvailable(lCurrentConnections);
- }
- }
- }
- else
- {
- setNotAvailableBecauseServerIsDown(lCurrentConnections);
- }
- }
-
- /**
- * Updates the admiinistrative user contents displaying with what is specified
- * in the provided ServerStatusDescriptor object.
- * This method must be called from the event thread.
- * @param desc the ServerStatusDescriptor object.
- */
- private void updateAdministrativeUserContents(ServerStatusDescriptor desc)
- {
- Set<String> administrators = desc.getAdministrativeUsers();
- if (administrators.size() > 0)
- {
- TreeSet<String> ordered = new TreeSet<String>();
- for (String name: administrators)
- {
- ordered.add(formatter.getFormattedText(name));
- }
-
- setTextValue(lAdministrativeUsers,"<html>"+
- UIFactory.applyFontToHtml(
- Utils.getStringFromCollection(ordered, "<br>"),
- UIFactory.READ_ONLY_FONT));
- }
- else
- {
- if (desc.getStatus() == ServerStatusDescriptor.ServerStatus.STARTED)
- {
- if (!desc.isAuthenticated())
- {
- setNotAvailableBecauseAuthenticationIsRequired(lAdministrativeUsers);
- }
- else
- {
- setNotAvailable(lAdministrativeUsers);
- }
- }
- else
- {
- setNotAvailable(lAdministrativeUsers);
- }
- }
- }
-
- /**
- * Updates the install path contents displaying with what is specified in the
- * provided ServerStatusDescriptor object.
- * This method must be called from the event thread.
- * @param desc the ServerStatusDescriptor object.
- */
- private void updateInstallPathContents(ServerStatusDescriptor desc)
- {
- File path = desc.getInstallPath();
- lInstallPath.setText(path.toString());
- }
-
- /**
- * Updates the server version contents displaying with what is specified in
- * the provided ServerStatusDescriptor object.
- * This method must be called from the event thread.
- * @param desc the ServerStatusDescriptor object.
- */
- private void updateVersionContents(ServerStatusDescriptor desc)
- {
- String openDSVersion = desc.getOpenDSVersion();
- lOpenDSVersion.setText(openDSVersion);
- }
-
- /**
- * Updates the java version contents displaying with what is specified in
- * the provided ServerStatusDescriptor object.
- * This method must be called from the event thread.
- * @param desc the ServerStatusDescriptor object.
- */
- private void updateJavaVersionContents(ServerStatusDescriptor desc)
- {
- if (desc.getStatus() == ServerStatusDescriptor.ServerStatus.STARTED)
- {
- String javaVersion = desc.getJavaVersion();
- if (javaVersion != null)
- {
- setTextValue(lJavaVersion, javaVersion);
-
- }
- else
- {
- if (!desc.isAuthenticated())
- {
- setNotAvailableBecauseAuthenticationIsRequired(lJavaVersion);
- }
- else
- {
- setNotAvailable(lJavaVersion);
- }
- }
- }
- else
- {
- setNotAvailableBecauseServerIsDown(lJavaVersion);
- }
- }
-
- /**
- * Updates the listeners contents displaying with what is specified in
- * the provided ServerStatusDescriptor object.
- * This method must be called from the event thread.
- * @param desc the ServerStatusDescriptor object.
- */
- private void updateListenerContents(ServerStatusDescriptor desc)
- {
- listenersTableModel.setData(desc.getListeners());
-
- if (listenersTableModel.getRowCount() == 0)
- {
- listenersTable.setVisible(false);
- listenersTable.getTableHeader().setVisible(false);
- lListenersTableEmpty.setVisible(true);
- if (desc.getStatus() == ServerStatusDescriptor.ServerStatus.STARTED)
- {
- if (!desc.isAuthenticated())
- {
- setNotAvailableBecauseAuthenticationIsRequired(lListenersTableEmpty);
- }
- else
- {
- setTextValue(lListenersTableEmpty, getMsg("no-listeners-found"));
- }
- }
- else
- {
- setTextValue(lListenersTableEmpty, getMsg("no-listeners-found"));
- }
- }
- else
- {
- listenersTable.setVisible(true);
- listenersTable.getTableHeader().setVisible(true);
- lListenersTableEmpty.setVisible(false);
- }
- }
-
- /**
- * Updates the databases contents displaying with what is specified in
- * the provided ServerStatusDescriptor object.
- * This method must be called from the event thread.
- * @param desc the ServerStatusDescriptor object.
- */
- private void updateDatabaseContents(ServerStatusDescriptor desc)
- {
- Set<BaseDNDescriptor> replicas = new HashSet<BaseDNDescriptor>();
- Set<DatabaseDescriptor> dbs = desc.getDatabases();
- for (DatabaseDescriptor db: dbs)
- {
- replicas.addAll(db.getBaseDns());
- }
- dbTableModelWithReplication.setData(replicas);
- dbTableModelWithoutReplication.setData(replicas);
-
- if (dbTableModelWithReplication.getRowCount() == 0)
- {
-
- dbTableWithoutReplication.setVisible(false);
- dbTableWithoutReplication.getTableHeader().setVisible(false);
- dbTableWithReplication.setVisible(false);
- dbTableWithReplication.getTableHeader().setVisible(false);
- lDbTableEmpty.setVisible(true);
- if (desc.getStatus() == ServerStatusDescriptor.ServerStatus.STARTED)
- {
- if (!desc.isAuthenticated())
- {
- setNotAvailableBecauseAuthenticationIsRequired(lDbTableEmpty);
- }
- else
- {
- setTextValue(lDbTableEmpty, getMsg("no-dbs-found"));
- }
- }
- else
- {
- setTextValue(lDbTableEmpty, getMsg("no-dbs-found"));
- }
- }
- else
- {
- boolean replicated = false;
- for (BaseDNDescriptor suffix: replicas)
- {
- if (suffix.getType() == BaseDNDescriptor.Type.REPLICATED)
- {
- replicated = true;
- }
- }
-
- updateTableSizes(dbTableWithoutReplication);
- updateTableSizes(dbTableWithReplication);
- dbTableWithoutReplication.setVisible(!replicated);
- dbTableWithoutReplication.getTableHeader().setVisible(!replicated);
- dbTableWithReplication.setVisible(replicated);
- dbTableWithReplication.getTableHeader().setVisible(replicated);
- lDbTableEmpty.setVisible(false);
- }
- }
-
- /**
- * Updates the error label contents displaying with what is specified in
- * the provided ServerStatusDescriptor object.
- * This method must be called from the event thread.
- * @param desc the ServerStatusDescriptor object.
- */
- private void updateErrorContents(ServerStatusDescriptor desc)
- {
- String errorMsg = desc.getErrorMessage();
- if (errorMsg == null)
- {
- lError.setVisible(false);
- }
- else
- {
-
- lError.setVisible(true);
- lError.setText(formatter.getFormattedError(errorMsg, false));
- }
- }
-
- /**
- * The following three methods are just commodity methods to get localized
- * messages.
- */
- private String getMsg(String key)
- {
- return getI18n().getMsg(key);
- }
-
- private ResourceProvider getI18n()
- {
- return ResourceProvider.getInstance();
- }
-
- /**
- * Updates the size of the table rows according to the size of the
- * rendered component.
- * @param table the table to handle.
- */
- private void updateTableSizes(JTable table)
- {
- updateTableColumnWidth(table);
- updateTableRowHeight(table);
-
- /*
- int totalWidth = 0;
- int colMargin = table.getColumnModel().getColumnMargin();
-
- int totalHeight = 0;
-
- TableColumn tcol = table.getColumnModel().getColumn(0);
- TableCellRenderer renderer = tcol.getHeaderRenderer();
- Component comp = renderer.getTableCellRendererComponent(table,
- table.getModel().getColumnName(0), false, false, 0, 0);
- totalHeight = (int)comp.getPreferredSize().getHeight();
- for (int row=0; row<table.getRowCount(); row++)
- {
- totalHeight += table.getRowHeight(row);
- }
-
- for (int col=0; col<table.getColumnCount(); col++)
- {
- tcol = table.getColumnModel().getColumn(col);
- totalWidth += tcol.getPreferredWidth() + colMargin;
- }
-
- table.setPreferredScrollableViewportSize(
- new Dimension(totalWidth, totalHeight));
- */
- }
-
- /**
- * Updates the height of the table rows according to the size of the
- * rendered component.
- * @param table the table to handle.
- */
- private void updateTableRowHeight(JTable table)
- {
- int headerMaxHeight = 0;
-
- for (int col=0; col<table.getColumnCount(); col++)
- {
- TableColumn tcol = table.getColumnModel().getColumn(col);
- TableCellRenderer renderer = tcol.getHeaderRenderer();
- Component comp = renderer.getTableCellRendererComponent(table,
- table.getModel().getColumnName(col), false, false, 0, col);
- int colHeight = (int)comp.getPreferredSize().getHeight();
- headerMaxHeight = Math.max(headerMaxHeight, colHeight);
- }
- JTableHeader header = table.getTableHeader();
- header.setPreferredSize(new Dimension(
- (int)header.getPreferredSize().getWidth(),
- headerMaxHeight));
-
- for (int row=0; row<table.getRowCount(); row++)
- {
- int rowMaxHeight = table.getRowHeight();
- for (int col=0; col<table.getColumnCount(); col++)
- {
- TableCellRenderer renderer = table.getCellRenderer(row, col);
- Component comp = table.prepareRenderer(renderer, row, col);
- int colHeight = (int)comp.getPreferredSize().getHeight();
- rowMaxHeight = Math.max(rowMaxHeight, colHeight);
- }
- table.setRowHeight(row, rowMaxHeight);
- }
- }
-
- /**
- * Updates the height of the table columns according to the size of the
- * rendered component.
- * @param table the table to handle.
- */
- private void updateTableColumnWidth(JTable table)
- {
-
- int margin = table.getIntercellSpacing().width;
- for (int col=0; col<table.getColumnCount(); col++)
- {
- int colMaxWidth;
- TableColumn tcol = table.getColumnModel().getColumn(col);
- TableCellRenderer renderer = tcol.getHeaderRenderer();
- Component comp = renderer.getTableCellRendererComponent(table,
- table.getModel().getColumnName(col), false, false, 0, col);
- colMaxWidth = (int)comp.getPreferredSize().getWidth();
- for (int row=0; row<table.getRowCount(); row++)
- {
- renderer = table.getCellRenderer(row, col);
- comp = table.prepareRenderer(renderer, row, col);
- int colWidth = (int)comp.getPreferredSize().getWidth() + (2 * margin);
- colMaxWidth = Math.max(colMaxWidth, colWidth);
- }
- tcol.setPreferredWidth(colMaxWidth);
- }
- }
-
- private int getMaximalWidth()
- {
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
-
- boolean multipleScreen = screenSize.width / screenSize.height >= 2;
-
- if (multipleScreen)
- {
- return Math.min((screenSize.width/2) - 100, 1000);
- }
- else
- {
- return Math.min(screenSize.width - 100, 1000);
- }
- }
-
- /**
- * Returns the maximum height we allow this dialog to have after pack.
- * @return the maximum height we allow this dialog to have after pack.
- */
- private int getMaximalHeight()
- {
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
-
- return Math.min(screenSize.height - 100, 800);
- }
- /**
- * Method written for testing purposes.
- * @param args the arguments to be passed to the test program.
- */
- public static void main(String[] args)
- {
- try
- {
- UIFactory.initialize();
- StatusPanelDialog dlg = new StatusPanelDialog();
- dlg.packAndShow();
- } catch (Exception ex)
- {
- ex.printStackTrace();
- }
- }
-
- /**
- * Class used to render the databases table cells.
- */
- class DatabasesCellRenderer extends JLabel implements TableCellRenderer
- {
- private static final long serialVersionUID = -256719167426289735L;
-
- /**
- * Default constructor.
- */
- public DatabasesCellRenderer()
- {
- super();
- UIFactory.setTextStyle(this, UIFactory.TextStyle.SECONDARY_FIELD_VALID);
- }
-
- /**
- * {@inheritDoc}
- */
- public Component getTableCellRendererComponent(JTable table, Object value,
- boolean isSelected, boolean hasFocus, int row, int column) {
- if (value instanceof String)
- {
- setTextValue(this, (String)value);
- }
- else if (value instanceof Set)
- {
- LinkedHashSet<String> baseDns = new LinkedHashSet<String>();
- for (Object v : (Set)value)
- {
- baseDns.add((String)v);
- }
- setTextValue(this, "<html>" +
- UIFactory.applyFontToHtml(Utils.getStringFromCollection(
- baseDns, "<br>"),
- UIFactory.SECONDARY_FIELD_VALID_FONT));
- }
- else
- {
- /* Is the number of entries: check if it is available or not */
- if (lastDescriptor.getStatus() ==
- ServerStatusDescriptor.ServerStatus.STARTED)
- {
- int nEntries = (Integer)value;
- if (nEntries >= 0)
- {
- setTextValue(this, String.valueOf(nEntries));
- }
- else
- {
- if (!lastDescriptor.isAuthenticated())
- {
- setNotAvailableBecauseAuthenticationIsRequired(this);
- }
- else
- {
- setNotAvailable(this);
- }
- }
- }
- else
- {
- setNotAvailableBecauseServerIsDown(this);
- }
- }
- if (column == 0)
- {
- setBorder(BorderFactory.createCompoundBorder(
- BorderFactory.createMatteBorder(0, 1, 0, 0,
- UIFactory.PANEL_BORDER_COLOR),
- BorderFactory.createEmptyBorder(4, 4, 4, 4)));
- }
- else
- {
- setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
- }
- return this;
- }
- }
-
- /**
- * Class used to render the listeners table cells.
- */
- class ListenersCellRenderer extends JLabel implements TableCellRenderer
- {
- private static final long serialVersionUID = -256719167426289735L;
-
- /**
- * Default constructor.
- */
- public ListenersCellRenderer()
- {
- super();
- UIFactory.setTextStyle(this, UIFactory.TextStyle.SECONDARY_FIELD_VALID);
- }
-
- /**
- * {@inheritDoc}
- */
- public Component getTableCellRendererComponent(JTable table, Object value,
- boolean isSelected, boolean hasFocus, int row, int column) {
-
- setTextValue(this, (String)value);
- if (column == 0)
- {
- setBorder(BorderFactory.createCompoundBorder(
- BorderFactory.createMatteBorder(0, 1, 0, 0,
- UIFactory.PANEL_BORDER_COLOR),
- BorderFactory.createEmptyBorder(4, 4, 4, 4)));
- }
- else
- {
- setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
- }
- return this;
- }
- }
-}
-
-/**
- * This class is used to be able to have an instantaneous tooltip displayed
- * in the 'not available' labels. It replaces the default ToolTipManager class.
- *
- */
-class InstantaneousToolTipManager extends MouseAdapter
-implements MouseMotionListener
-{
- private ToolTipManager ttipManager = ToolTipManager.sharedInstance();
- private Popup tipWindow;
- private boolean isVisible;
-
- /**
- * The default constructor.
- */
- public InstantaneousToolTipManager()
- {
- }
-
- /**
- * Register a component that will use this tool tip manager to display tool
- * tips.
- * @param comp the component to be registered.
- */
- public void registerComponent(JComponent comp)
- {
- ttipManager.unregisterComponent(comp);
- comp.removeMouseListener(this);
- comp.addMouseListener(this);
- comp.removeMouseMotionListener(this);
- comp.addMouseMotionListener(this);
- }
-
- /**
- * Unregisters a component. Calling this method makes the component to be
- * registered by the default tool tip manager.
- * @param comp the component to be unregistered.
- */
- public void unregisterComponent(JComponent comp)
- {
- ttipManager.registerComponent(comp);
- comp.removeMouseListener(this);
- comp.removeMouseMotionListener(this);
- }
-
- /**
- * {@inheritDoc}
- */
- public void mouseDragged(MouseEvent event)
- {
- }
-
- /**
- * {@inheritDoc}
- */
- public void mouseEntered(MouseEvent event)
- {
- displayToolTip(event);
- }
-
- /**
- * {@inheritDoc}
- */
- public void mouseExited(MouseEvent event)
- {
- hideToolTip(event);
- }
-
- /**
- * {@inheritDoc}
- */
- public void mouseMoved(MouseEvent event)
- {
- hideToolTip(event);
- displayToolTip(event);
- }
-
- /**
- * {@inheritDoc}
- */
- public void mousePressed(MouseEvent event)
- {
- if (isVisible)
- {
- hideToolTip(event);
- }
- else
- {
- hideToolTip(event);
- displayToolTip(event);
- }
- }
-
- /**
- * Displays a tooltip depending on the MouseEvent received.
- * @param event the mouse event.
- */
- private void displayToolTip(MouseEvent event)
- {
- JComponent component = (JComponent)event.getSource();
- String toolTipText = component.getToolTipText(event);
- if (toolTipText != null)
- {
- Point preferredLocation = component.getToolTipLocation(event);
- Rectangle sBounds = component.getGraphicsConfiguration().
- getBounds();
-
- JToolTip tip = component.createToolTip();
- tip.setTipText(toolTipText);
- Dimension size = tip.getPreferredSize();
- Point location = new Point();
-
- Point screenLocation = component.getLocationOnScreen();
- if(preferredLocation != null)
- {
- location.x = screenLocation.x + preferredLocation.x;
- location.y = screenLocation.y + preferredLocation.y;
- }
- else
- {
- location.x = screenLocation.x + event.getX();
- location.y = screenLocation.y + event.getY() + 20;
- }
-
- if (location.x < sBounds.x) {
- location.x = sBounds.x;
- }
- else if (location.x - sBounds.x + size.width > sBounds.width) {
- location.x = sBounds.x + Math.max(0, sBounds.width - size.width);
- }
- if (location.y < sBounds.y) {
- location.y = sBounds.y;
- }
- else if (location.y - sBounds.y + size.height > sBounds.height) {
- location.y = sBounds.y + Math.max(0, sBounds.height - size.height);
- }
-
- PopupFactory popupFactory = PopupFactory.getSharedInstance();
- tipWindow = popupFactory.getPopup(component, tip, location.x, location.y);
- tipWindow.show();
- }
- isVisible = true;
- }
-
- /**
- * Hides the tooltip if we are displaying it.
- * @param event the mouse event.
- */
- private void hideToolTip(MouseEvent event)
- {
- if (tipWindow != null)
- {
- tipWindow.hide();
- tipWindow = null;
- }
- isVisible = false;
- }
-}
diff --git a/opendj-sdk/opends/tests/gui-tests/quickUninstall.xml.stubs b/opendj-sdk/opends/tests/gui-tests/quickUninstall.xml.stubs
index 2767ab2..f77213a 100644
--- a/opendj-sdk/opends/tests/gui-tests/quickUninstall.xml.stubs
+++ b/opendj-sdk/opends/tests/gui-tests/quickUninstall.xml.stubs
@@ -37,7 +37,7 @@
<component class="javax.swing.JButton" id="Quit" index="1" parent="JPanel Instance 2" text="Quit" window="OpenDS QuickSetup" />
<component class="org.opends.quicksetup.installer.ui.ServerSettingsPanel" id="ServerSettingsPanel Instance" index="3" parent="CurrentStepPanel Instance" window="OpenDS QuickSetup" />
<component class="javax.swing.JButton" id="Uninstall" index="3" parent="ButtonsPanel Instance" text="Uninstall" window="OpenDS QuickSetup" />
- <launch args="[]" class="org.opends.quicksetup.uninstaller.UninstallLauncher" classpath=".${path.separator}${instance.path}${file.separator}classes${path.separator}${instance.path}${file.separator}lib${file.separator}activation.jar${path.separator}${instance.path}${file.separator}lib${file.separator}aspectjrt.jar${path.separator}${instance.path}${file.separator}lib${file.separator}je.jar${path.separator}${instance.path}${file.separator}lib${file.separator}mail.jar${path.separator}${instance.path}${file.separator}lib${file.separator}OpenDS.jar${path.separator}${instance.path}${file.separator}lib${file.separator}quicksetup.jar${path.separator}${instance.path}${file.separator}lib${file.separator}statuspanel.jar" desc="Launch org.opends.quicksetup.uninstaller.UninstallLauncher" method="main" />
+ <launch args="[]" class="org.opends.guitools.uninstaller.UninstallLauncher" classpath=".${path.separator}${instance.path}${file.separator}classes${path.separator}${instance.path}${file.separator}lib${file.separator}activation.jar${path.separator}${instance.path}${file.separator}lib${file.separator}aspectjrt.jar${path.separator}${instance.path}${file.separator}lib${file.separator}je.jar${path.separator}${instance.path}${file.separator}lib${file.separator}mail.jar${path.separator}${instance.path}${file.separator}lib${file.separator}OpenDS.jar${path.separator}${instance.path}${file.separator}lib${file.separator}quicksetup.jar${path.separator}${instance.path}${file.separator}lib${file.separator}statuspanel.jar" desc="Launch org.opends.guitools.uninstaller.UninstallLauncher" method="main" />
<sequence>
<action args="Uninstall" class="javax.swing.AbstractButton" method="actionClick" />
<wait args="Confirmation Required" class="abbot.tester.ComponentTester" method="assertComponentShowing" />
--
Gitblit v1.10.0