mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jvergara
07.43.2009 b471bc6b9f2a087e8bb8e3adc6e5d1b32e80db8d
Fix for issue 4271 (control-panel: in remote mode, "Installation Path" is incorrect)
Since using File when you have different OS in the control panel and in the managed server can be really problematic, use String instead in the ServerDescriptor object.
11 files modified
195 ■■■■■ changed files
opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java 18 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java 87 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/task/Task.java 4 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/BackupListPanel.java 22 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/ControlCenterMainPane.java 5 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/GenericDialog.java 2 ●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/GenericFrame.java 1 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java 4 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusPanel.java 31 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java 1 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/status/StatusCli.java 20 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
@@ -465,9 +465,9 @@
    {
      desc.setOpenDSVersion(
        org.opends.server.util.DynamicConstants.FULL_VERSION_STRING);
      desc.setInstallPath(Utilities.getServerRootDirectory());
      desc.setInstancePath(Utilities.getInstanceRootDirectory(
          Utilities.getServerRootDirectory().getAbsolutePath()));
      String installPath = Utilities.getInstallPathFromClasspath();
      desc.setInstallPath(installPath);
      desc.setInstancePath(Utils.getInstancePathFromClasspath(installPath));
      boolean windowsServiceEnabled = false;
      if (Utilities.isWindows())
      {
@@ -552,9 +552,7 @@
      desc.setAuthenticated(false);
    }
    else if (!isLocal ||
        Utilities.isServerRunning(
        Utilities.getInstanceRootDirectory(
            desc.getInstallPath().getAbsolutePath())))
        Utilities.isServerRunning(new File(desc.getInstancePath())))
    {
      desc.setStatus(ServerDescriptor.ServerStatus.STARTED);
@@ -694,13 +692,13 @@
              rCtx.getSystemInformation(), "installPath");
          if (installPath != null)
          {
            desc.setInstallPath(new File(installPath));
            desc.setInstallPath(installPath);
          }
          String instancePath = (String)Utilities.getFirstMonitoringValue(
              rCtx.getSystemInformation(), "instancePath");
          if (instancePath != null)
          {
            desc.setInstancePath(new File(instancePath));
            desc.setInstancePath(instancePath);
          }
        }
      }
@@ -1311,8 +1309,8 @@
      else
      {
        // Compare host names and paths
        File f1 = server.getInstancePath();
        File f2 = task.getServer().getInstancePath();
        String f1 = server.getInstancePath();
        String f2 = task.getServer().getInstancePath();
        String host1 = server.getHostname();
        String host2 = task.getServer().getHostname();
opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java
@@ -28,6 +28,7 @@
package org.opends.guitools.controlpanel.datamodel;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -45,6 +46,7 @@
import org.opends.server.types.DN;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.OpenDsException;
import org.opends.server.types.OperatingSystem;
import org.opends.server.types.Schema;
/**
@@ -60,8 +62,8 @@
    new HashSet<ConnectionHandlerDescriptor>();
  private ConnectionHandlerDescriptor adminConnector;
  private Set<DN> administrativeUsers = new HashSet<DN>();
  private File installPath;
  private File instancePath;
  private String installPath;
  private String instancePath;
  private String openDSVersion;
  private String javaVersion;
  private ArrayList<OpenDsException> exceptions =
@@ -185,7 +187,7 @@
   * @return the instance path where the server databases and configuration is
   * located
   */
  public File getInstancePath()
  public String getInstancePath()
  {
    return instancePath;
  }
@@ -196,7 +198,7 @@
   * @param instancePath the instance path where the server databases and
   * configuration is located.
   */
  public void setInstancePath(File instancePath)
  public void setInstancePath(String instancePath)
  {
    this.instancePath = instancePath;
  }
@@ -205,7 +207,7 @@
   * Return the install path where the server is installed.
   * @return the install path where the server is installed.
   */
  public File getInstallPath()
  public String getInstallPath()
  {
    return installPath;
  }
@@ -214,12 +216,49 @@
   * Sets the install path where the server is installed.
   * @param installPath the install path where the server is installed.
   */
  public void setInstallPath(File installPath)
  public void setInstallPath(String installPath)
  {
    this.installPath = installPath;
  }
  /**
   * Returns whether the install and the instance are on the same server
   * or not.
   * @return whether the install and the instance are on the same server
   * or not.
   */
  public boolean sameInstallAndInstance()
  {
    boolean sameInstallAndInstance;
    String instance = getInstancePath();
    String install = getInstallPath();
    try
    {
      if (instance != null)
      {
        sameInstallAndInstance = instance.equals(install);
        if (!sameInstallAndInstance &&
            (isLocal() || (isWindows() == Utilities.isWindows())))
        {
          File f1 = new File(instance);
          File f2 = new File(install);
          sameInstallAndInstance =
            f1.getCanonicalFile().equals(f2.getCanonicalFile());
        }
      }
      else
      {
        sameInstallAndInstance = install == null;
      }
    }
    catch (IOException ioe)
    {
      sameInstallAndInstance = false;
    }
    return sameInstallAndInstance;
  }
  /**
   * Return the java version used to run the server.
   * @return the java version used to run the server.
   */
@@ -615,6 +654,42 @@
  }
  /**
   * Returns whether the server is running under a windows system or not.
   * @return whether the server is running under a windows system or not.
   */
  public boolean isWindows()
  {
    boolean isWindows;
    if (isLocal())
    {
      isWindows = Utilities.isWindows();
    }
    else
    {
      CustomSearchResult sr = getSystemInformationMonitor();
      if (sr == null)
      {
        isWindows = false;
      }
      else
      {
        String os =
          (String)Utilities.getFirstMonitoringValue(sr, "operatingSystem");
        if (os == null)
        {
          isWindows = false;
        }
        else
        {
          OperatingSystem oSystem = OperatingSystem.forName(os);
          isWindows = OperatingSystem.WINDOWS == oSystem;
        }
      }
    }
    return isWindows;
  }
  /**
   * Method used to compare schemas.
   * Returns <CODE>true</CODE> if the two schemas are equal and
   * <CODE>false</CODE> otherwise.
opends/src/guitools/org/opends/guitools/controlpanel/task/Task.java
@@ -644,8 +644,8 @@
      // comparing ports: we might be running locally on a stopped instance with
      // the same configuration as a "remote" (though located on the same
      // machine) server.
      File f1 = getServer().getInstancePath();
      File f2 = task.getServer().getInstancePath();
      String f1 = getServer().getInstancePath();
      String f2 = task.getServer().getInstancePath();
      String host1 = getServer().getHostname();
      String host2 = task.getServer().getHostname();
opends/src/guitools/org/opends/guitools/controlpanel/ui/BackupListPanel.java
@@ -537,16 +537,26 @@
    {
      String path;
      File f = new File(desc.getInstancePath(),
          org.opends.quicksetup.Installation.BACKUPS_PATH_RELATIVE);
      try
      if (desc.isLocal() || (desc.isWindows() == Utilities.isWindows()))
      {
        path = f.getCanonicalPath();
        File f = new File(desc.getInstancePath(),
            org.opends.quicksetup.Installation.BACKUPS_PATH_RELATIVE);
        try
        {
          path = f.getCanonicalPath();
        }
        catch (Throwable t)
        {
          path = f.getAbsolutePath();
        }
      }
      catch (Throwable t)
      else
      {
        path = f.getAbsolutePath();
        String separator = desc.isWindows() ? "\\" : "/";
        path = desc.getInstancePath() + separator +
        org.opends.quicksetup.Installation.BACKUPS_PATH_RELATIVE;
      }
      final String fPath = path;
      SwingUtilities.invokeLater(new Runnable()
      {
opends/src/guitools/org/opends/guitools/controlpanel/ui/ControlCenterMainPane.java
@@ -237,7 +237,8 @@
    {
      LocalOrRemotePanel localOrRemotePanel = new LocalOrRemotePanel();
      localOrRemotePanel.setInfo(info);
      localOrRemoteDlg = new GenericDialog(null, localOrRemotePanel);
      localOrRemoteDlg = new GenericDialog(Utilities.createFrame(),
          localOrRemotePanel);
      localOrRemoteDlg.setModal(true);
      localOrRemoteDlg.pack();
    }
@@ -257,7 +258,7 @@
    if (loginDlg == null)
    {
      LoginPanel loginPanel = new LoginPanel();
      loginDlg = new GenericDialog(null, loginPanel);
      loginDlg = new GenericDialog(Utilities.createFrame(), loginPanel);
      loginPanel.setInfo(info);
      loginDlg.setModal(true);
    }
opends/src/guitools/org/opends/guitools/controlpanel/ui/GenericDialog.java
@@ -122,7 +122,7 @@
   */
  public GenericDialog(JFrame parentFrame, StatusGenericPanel panel)
  {
    super();
    super(parentFrame);
    this.panel = panel;
    if (panel.requiresBorder())
    {
opends/src/guitools/org/opends/guitools/controlpanel/ui/GenericFrame.java
@@ -168,6 +168,7 @@
      }
    });
    org.opends.quicksetup.ui.Utilities.setFrameIcon(this);
    pack();
    if (!SwingUtilities.isEventDispatchThread())
    {
opends/src/guitools/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java
@@ -818,7 +818,7 @@
            Set<String> notWorkingArgs = new HashSet<String>();
            String installPath = getInfo().getServerDescriptor().
            getInstallPath().getAbsolutePath();
            getInstallPath();
            if (!Utils.supportsOption("", jvm, installPath))
            {
              if (jvm == userJVM && !useSpecifiedJavaHome.isSelected())
@@ -1014,7 +1014,7 @@
  private String getPropertiesFile()
  {
    String installPath = getInfo().getServerDescriptor().
      getInstancePath().getAbsolutePath();
      getInstancePath();
    String propertiesFile =  Utils.getPath(
      Utilities.getInstanceRootDirectory(installPath).getAbsolutePath(),
      Installation.RELATIVE_JAVA_PROPERTIES_FILE);
opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusPanel.java
@@ -35,8 +35,6 @@
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;
@@ -402,46 +400,29 @@
      administrativeUsers.setText(
          INFO_NOT_AVAILABLE_SHORT_LABEL.get().toString());
    }
    File install = desc.getInstallPath();
    String install = desc.getInstallPath();
    if (install != null)
    {
      installPath.setText(install.getAbsolutePath());
      installPath.setText(install);
    }
    else
    {
      installPath.setText(INFO_NOT_AVAILABLE_SHORT_LABEL.get().toString());
    }
    File instance = desc.getInstancePath();
    String instance = desc.getInstancePath();
    if (instance != null)
    {
      instancePath.setText(instance.getAbsolutePath());
      instancePath.setText(instance);
    }
    else
    {
      instancePath.setText(INFO_NOT_AVAILABLE_SHORT_LABEL.get().toString());
    }
    boolean sameInstallAndInstance;
    try
    {
      if (instance != null)
      {
        sameInstallAndInstance = instance.getCanonicalFile().equals(install);
      }
      else
      {
        sameInstallAndInstance = install == null;
      }
    }
    catch (IOException ioe)
    {
      // Best effort
      sameInstallAndInstance = instance.getAbsoluteFile().equals(install);
    }
    instancePath.setVisible(!sameInstallAndInstance);
    lInstancePath.setVisible(!sameInstallAndInstance);
    instancePath.setVisible(!desc.sameInstallAndInstance());
    lInstancePath.setVisible(!desc.sameInstallAndInstance());
    if (desc.getOpenDSVersion() != null)
    {
opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java
@@ -176,6 +176,7 @@
  {
    JFrame frame = new JFrame();
    frame.setResizable(true);
    org.opends.quicksetup.ui.Utilities.setFrameIcon(frame);
    return frame;
  }
opends/src/server/org/opends/server/tools/status/StatusCli.java
@@ -28,7 +28,6 @@
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;
@@ -495,18 +494,7 @@
    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());
    }
    boolean sameInstallAndInstance = desc.sameInstallAndInstance();
    if (!sameInstallAndInstance)
    {
      writeInstancePathContents(desc, labelWidth);
@@ -702,9 +690,8 @@
  private void writeInstallPathContents(ServerDescriptor desc,
      int maxLabelWidth)
  {
    File path = desc.getInstallPath();
    writeLabelValue(INFO_INSTALLATION_PATH_LABEL.get(),
            Message.raw(path.toString()),
            Message.raw(desc.getInstallPath()),
            maxLabelWidth);
  }
@@ -717,9 +704,8 @@
  private void writeInstancePathContents(ServerDescriptor desc,
      int maxLabelWidth)
  {
    File path = desc.getInstancePath();
    writeLabelValue(INFO_CTRL_PANEL_INSTANCE_PATH_LABEL.get(),
            Message.raw(path.toString()),
            Message.raw(desc.getInstancePath()),
            maxLabelWidth);
  }