From 5bf6f768ae8b392564ac427810cac9790b1c7705 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Mon, 12 Jan 2009 01:03:11 +0000
Subject: [PATCH] Fix for issue 3709 (control-panel: value of "Backup Path" field should be the instance path and not the installation path in the Backup/Restore panels) The code has been update to use the instance path instead of the install path in different places (the default backup directory, the path to be used to retrieve the java properties file, etc.). If we are dealing with a package installation (install and instance paths are different), the control panel and the status command-line will display two paths: one for the install and the other for the instance.
---
opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java | 28 ++++++++++++++
opends/src/guitools/org/opends/guitools/controlpanel/ui/BackupListPanel.java | 2
opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusPanel.java | 30 ++++++++++++++-
opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java | 2 +
opends/src/guitools/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java | 2
opends/src/server/org/opends/server/tools/status/StatusCli.java | 32 ++++++++++++++++
6 files changed, 92 insertions(+), 4 deletions(-)
diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java b/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
index 24af7be..f280d3b 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
@@ -432,6 +432,8 @@
ServerDescriptor desc = createNewServerDescriptorInstance();
InitialLdapContext ctx = getDirContext();
desc.setInstallPath(Utilities.getServerRootDirectory());
+ desc.setInstancePath(Utilities.getInstanceRootDirectory(
+ Utilities.getServerRootDirectory().getAbsolutePath()));
boolean windowsServiceEnabled = false;
if (Utilities.isWindows())
{
diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java b/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java
index a71b7e1..3a80912 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java
@@ -58,6 +58,7 @@
private ConnectionHandlerDescriptor adminConnector;
private Set<DN> administrativeUsers = new HashSet<DN>();
private File installPath;
+ private File instancePath;
private String openDSVersion;
private String javaVersion;
private ArrayList<OpenDsException> exceptions =
@@ -154,6 +155,28 @@
}
/**
+ * Return the instance path where the server databases and configuration is
+ * located.
+ * @return the instance path where the server databases and configuration is
+ * located
+ */
+ public File getInstancePath()
+ {
+ return instancePath;
+ }
+
+ /**
+ * Sets the instance path where the server databases and configuration is
+ * located.
+ * @param instancePath the instance path where the server databases and
+ * configuration is located.
+ */
+ public void setInstancePath(File instancePath)
+ {
+ this.instancePath = instancePath;
+ }
+
+ /**
* Return the install path where the server is installed.
* @return the install path where the server is installed.
*/
@@ -273,6 +296,11 @@
if (equals)
{
+ equals = desc.getInstancePath().equals(getInstancePath());
+ }
+
+ if (equals)
+ {
if (desc.getJavaVersion() == null)
{
equals = getJavaVersion() == null;
diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/ui/BackupListPanel.java b/opends/src/guitools/org/opends/guitools/controlpanel/ui/BackupListPanel.java
index ac6a741..11a5c19 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/ui/BackupListPanel.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/ui/BackupListPanel.java
@@ -523,7 +523,7 @@
if (!backupDirectoryInitialized &&
(parentDirectory.getText().length() == 0))
{
- final String path = new File(desc.getInstallPath(),
+ final String path = new File(desc.getInstancePath(),
org.opends.quicksetup.Installation.BACKUPS_PATH_RELATIVE).
getAbsolutePath();
SwingUtilities.invokeLater(new Runnable()
diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java b/opends/src/guitools/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java
index a40ccd7..4e67671 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java
@@ -764,7 +764,7 @@
private String getPropertiesFile()
{
String installPath = getInfo().getServerDescriptor().
- getInstallPath().getAbsolutePath();
+ getInstancePath().getAbsolutePath();
String propertiesFile = Utils.getPath(
Utilities.getInstanceRootDirectory(installPath).getAbsolutePath(),
Installation.RELATIVE_JAVA_PROPERTIES_FILE);
diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusPanel.java b/opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusPanel.java
index 0035917..2b8aab8 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusPanel.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusPanel.java
@@ -35,6 +35,8 @@
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@@ -82,11 +84,13 @@
private JLabel hostName;
private JLabel administrativeUsers;
private JLabel installPath;
+ private JLabel instancePath;
private JLabel opendsVersion;
private LabelWithHelpIcon javaVersion;
private JLabel adminConnector;
private JLabel dbTableEmpty;
private JLabel connectionHandlerTableEmpty;
+ private JLabel lInstancePath;
private JButton stopButton;
private JButton startButton;
private JButton restartButton;
@@ -315,7 +319,25 @@
administrativeUsers.getFont());
administrativeUsers.setText(htmlString);
- installPath.setText(desc.getInstallPath().getAbsolutePath());
+ File install = desc.getInstallPath();
+ installPath.setText(install.getAbsolutePath());
+
+ File instance = desc.getInstancePath();
+
+ instancePath.setText(instance.getAbsolutePath());
+
+ boolean sameInstallAndInstance;
+ try
+ {
+ sameInstallAndInstance = instance.getCanonicalFile().equals(install);
+ }
+ catch (IOException ioe)
+ {
+ // Best effort
+ sameInstallAndInstance = instance.getAbsoluteFile().equals(install);
+ }
+ instancePath.setVisible(!sameInstallAndInstance);
+ lInstancePath.setVisible(!sameInstallAndInstance);
opendsVersion.setText(desc.getOpenDSVersion());
@@ -546,23 +568,27 @@
Utilities.createPrimaryLabel(
INFO_CTRL_PANEL_INSTALLATION_PATH_LABEL.get()),
Utilities.createPrimaryLabel(
+ INFO_CTRL_PANEL_INSTANCE_PATH_LABEL.get()),
+ Utilities.createPrimaryLabel(
INFO_CTRL_PANEL_OPENDS_VERSION_LABEL.get()),
Utilities.createPrimaryLabel(
INFO_CTRL_PANEL_JAVA_VERSION_LABEL.get()),
Utilities.createPrimaryLabel(
INFO_CTRL_PANEL_ADMIN_CONNECTOR_LABEL.get())
};
+ lInstancePath = leftLabels[3];
hostName = Utilities.createDefaultLabel();
administrativeUsers = Utilities.createDefaultLabel();
installPath = Utilities.createDefaultLabel();
+ instancePath = Utilities.createDefaultLabel();
opendsVersion = Utilities.createDefaultLabel();
javaVersion = new LabelWithHelpIcon(Message.EMPTY, null);
adminConnector = Utilities.createDefaultLabel();
JComponent[] rightLabels =
{
- hostName, administrativeUsers, installPath, opendsVersion,
+ hostName, administrativeUsers, installPath, instancePath, opendsVersion,
javaVersion, adminConnector
};
diff --git a/opends/src/server/org/opends/server/tools/status/StatusCli.java b/opends/src/server/org/opends/server/tools/status/StatusCli.java
index 272108f..fdba154 100644
--- a/opends/src/server/org/opends/server/tools/status/StatusCli.java
+++ b/opends/src/server/org/opends/server/tools/status/StatusCli.java
@@ -28,6 +28,7 @@
package org.opends.server.tools.status;
import java.io.File;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
@@ -486,6 +487,22 @@
writeHostnameContents(desc, labelWidth);
writeAdministrativeUserContents(desc, labelWidth);
writeInstallPathContents(desc, labelWidth);
+ boolean sameInstallAndInstance = true;
+ try
+ {
+ sameInstallAndInstance = desc.getInstancePath().getCanonicalFile().equals(
+ desc.getInstallPath().getCanonicalFile());
+ }
+ catch (IOException ioe)
+ {
+ // Best effort
+ sameInstallAndInstance = desc.getInstancePath().getAbsoluteFile().equals(
+ desc.getInstallPath().getAbsoluteFile());
+ }
+ if (!sameInstallAndInstance)
+ {
+ writeInstancePathContents(desc, labelWidth);
+ }
writeVersionContents(desc, labelWidth);
writeJavaVersionContents(desc, labelWidth);
writeAdminConnectorContents(desc, labelWidth);
@@ -680,6 +697,21 @@
}
/**
+ * Writes the instance path contents displaying with what is specified in the
+ * provided ServerDescriptor object.
+ * @param desc the ServerDescriptor object.
+ * @param maxLabelWidth the maximum label width of the left label.
+ */
+ private void writeInstancePathContents(ServerDescriptor desc,
+ int maxLabelWidth)
+ {
+ File path = desc.getInstallPath();
+ writeLabelValue(INFO_CTRL_PANEL_INSTANCE_PATH_LABEL.get(),
+ Message.raw(path.toString()),
+ maxLabelWidth);
+ }
+
+ /**
* Updates the server version contents displaying with what is specified in
* the provided ServerDescriptor object.
* This method must be called from the event thread.
--
Gitblit v1.10.0