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

jvergara
09.28.2009 06ec8c88556b02782c7b91a233de91eaf4a1439d
Fix for issue 3550 (Consider making the control panel able to manage remote servers)

The limitations of the control panel when managing a remote server compared to managing the local instance are:

- It cannot start/stop/restart the server
- It cannot manage the server and update the server when it is off-line.
- It cannot update the java settings.
- It cannot update/view the windows service settings.
- It cannot verify indexes.

The main changes at the user interaction level are that the first dialog that is displayed proposes the user to manage the local instance or the remote instance. Moreover the user can choose to change the managed instance by selecting a new menu Item ('File'/'Server to Administer...').
2 files added
55 files modified
3193 ■■■■ changed files
opends/src/guitools/org/opends/guitools/controlpanel/ControlPanel.java 38 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/browser/BrowserController.java 13 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java 245 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java 73 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/task/AddToGroupTask.java 4 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/task/DeleteBaseDNAndBackendTask.java 2 ●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/task/DeleteEntryTask.java 4 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/task/DeleteIndexTask.java 2 ●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/task/ModifyEntryTask.java 4 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/task/NewEntryTask.java 4 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/task/RebuildIndexTask.java 23 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/task/ResetUserPasswordTask.java 4 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/task/StartStopTask.java 2 ●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/task/Task.java 83 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/AbstractBrowseEntriesPanel.java 10 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/BackupListPanel.java 46 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/BackupPanel.java 77 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseGeneralMonitoringPanel.java 17 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/ConnectionHandlerMonitoringPanel.java 10 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/ControlCenterMainPane.java 54 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java 12 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/CustomObjectClassPanel.java 12 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/DeleteBackendPanel.java 8 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/DeleteBaseDNPanel.java 8 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/ExportLDIFPanel.java 37 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/ImportLDIFPanel.java 68 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/IndexPanel.java 14 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java 43 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/LocalOrRemotePanel.java 881 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/MainMenuBar.java 97 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/NewAttributePanel.java 6 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/NewBaseDNPanel.java 121 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/NewIndexPanel.java 5 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/NewObjectClassPanel.java 6 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/NewVLVIndexPanel.java 18 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/RebuildIndexPanel.java 17 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/RestorePanel.java 72 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java 2 ●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/StandardAttributePanel.java 3 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/StandardObjectClassPanel.java 14 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java 113 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusPanel.java 121 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/VLVIndexPanel.java 16 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/VerifyIndexPanel.java 17 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java 5 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ui/WindowsServicePanel.java 33 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java 105 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromFile.java 31 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigReader.java 15 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/util/RemoteSchemaLoader.java 185 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/util/SchemaLoader.java 47 ●●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java 109 ●●●●● patch | view | raw | blame | history
opends/src/messages/messages/admin_tool.properties 80 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/monitors/SystemInfoMonitorProvider.java 13 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tasks/RebuildTask.java 50 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/RebuildIndex.java 90 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/status/StatusCli.java 4 ●●●● patch | view | raw | blame | history
opends/src/guitools/org/opends/guitools/controlpanel/ControlPanel.java
@@ -36,11 +36,12 @@
import javax.swing.WindowConstants;
import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
import org.opends.guitools.controlpanel.ui.ControlCenterMainPane;
import org.opends.guitools.controlpanel.ui.GenericDialog;
import org.opends.guitools.controlpanel.ui.MainMenuBar;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.messages.AdminToolMessages;
import org.opends.quicksetup.Installation;
import org.opends.messages.Message;
import org.opends.quicksetup.util.Utils;
@@ -55,6 +56,7 @@
  private JFrame dlg;
  private ControlPanelInfo info;
  private ControlCenterMainPane controlCenterPane;
  private MainMenuBar menuBar;
  /**
   * Main method that is used for testing purposes.  The control-panel
@@ -83,15 +85,16 @@
  /**
   * Method that creates the ControlCenterInfo object that will be in all the
   * control panel.  Here it basically reads the configuration of the
   * configuration file.
   * control panel.  Nothing is done here: the user must say whether the server
   * is local or remote.
   * @param args the arguments that are passed in the command line.
   */
  public void initialize(String[] args)
  {
    info = ControlPanelInfo.getInstance();
    info.regenerateDescriptor();
    info.startPooling();
    // Call Installation because the LocalOrRemotePanel uses it to check
    // whether the server is running or not and to get the install path.
    Installation.getLocal();
  }
  /**
@@ -99,6 +102,23 @@
   */
  public void createAndDisplayGUI()
  {
    GenericDialog localOrRemote =
      ControlCenterMainPane.getLocalOrRemoteDialog(info);
    Utilities.centerOnScreen(localOrRemote);
    localOrRemote.setVisible(true);
    if (info.getServerDescriptor() == null)
    {
      menuBar = new MainMenuBar(info);
      // Assume that the user decided to quit the application
      menuBar.quitClicked();
    }
    // To be sure that the dlg receives the new configuration event before
    // calling pack.
    SwingUtilities.invokeLater(new Runnable()
    {
      public void run()
      {
//  Create and set up the content pane.
    controlCenterPane = new ControlCenterMainPane(info);
    //  Create and set up the window.
@@ -117,16 +137,12 @@
        Message.class).toString();
    dlg.setTitle(title);
    dlg.setContentPane(controlCenterPane);
    dlg.pack();
    Utilities.centerOnScreen(dlg);
    dlg.setVisible(true);
    if (info.getServerDescriptor().getStatus() ==
      ServerDescriptor.ServerStatus.STARTED)
    {
      controlCenterPane.getLoginDialog().setVisible(true);
      controlCenterPane.getLoginDialog().toFront();
    }
    });
  }
  private static void initLookAndFeel() throws Throwable
opends/src/guitools/org/opends/guitools/controlpanel/browser/BrowserController.java
@@ -36,6 +36,8 @@
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
@@ -133,6 +135,9 @@
  private String filter;
  private static final Logger LOG =
    Logger.getLogger(BrowserController.class.getName());
  /**
   * Constructor of the BrowserController.
   * @param tree the tree that must be updated.
@@ -1540,8 +1545,9 @@
        try {
          refreshTaskDidProgress(task, oldState, newState);
        }
        catch(Exception x) {
          x.printStackTrace();
        catch(Throwable t)
        {
          LOG.log(Level.SEVERE, "Error calling refreshTaskDidProgress: "+t, t);
        }
      }
    };
@@ -1735,7 +1741,8 @@
    if (node.getError() != null) {
      if (node.getError().getException() != null)
      {
        node.getError().getException().printStackTrace();
        LOG.log(Level.SEVERE, "node has error: "+node.getError().getException(),
            node.getError().getException());
      }
      modifiers |= IconPool.MODIFIER_ERROR;
    }
opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ControlPanelInfo.java
@@ -27,6 +27,7 @@
package org.opends.guitools.controlpanel.datamodel;
import java.io.File;
import java.net.InetAddress;
import java.util.Collection;
import java.util.Collections;
@@ -58,7 +59,7 @@
import org.opends.guitools.controlpanel.util.ConfigReader;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.quicksetup.util.UIKeyStore;
import org.opends.server.core.DirectoryServer;
import org.opends.quicksetup.util.Utils;
import org.opends.server.tools.ConfigureWindowsService;
/**
@@ -88,11 +89,16 @@
  private String startTLSURL;
  private String ldapsURL;
  private String adminConnectorURL;
  private String localAdminConnectorURL;
  private String lastWorkingBindDN;
  private String lastWorkingBindPwd;
  private String lastRemoteHostName;
  private String lastRemoteAdministrationURL;
  private static boolean mustDeregisterConfig;
  private boolean isLocal = true;
  private Set<AbstractIndexDescriptor> modifiedIndexes =
    new HashSet<AbstractIndexDescriptor>();
@@ -296,6 +302,8 @@
    {
      lastWorkingBindDN = ConnectionUtils.getBindDN(ctx);
      lastWorkingBindPwd = ConnectionUtils.getBindPassword(ctx);
      lastRemoteHostName = ConnectionUtils.getHostName(ctx);
      lastRemoteAdministrationURL = ConnectionUtils.getLdapUrl(ctx);
    }
  }
@@ -420,7 +428,9 @@
   */
  protected ConfigFromDirContext createNewConfigFromDirContextReader()
  {
    return new ConfigFromDirContext();
    ConfigFromDirContext configFromDirContext = new ConfigFromDirContext();
    configFromDirContext.setIsLocal(isLocal());
    return configFromDirContext;
  }
  /**
@@ -439,14 +449,22 @@
    desc.setSchema(reader.getSchema());
    desc.setSchemaEnabled(reader.isSchemaEnabled());
  }
  private int i=0;
  /**
   * Regenerates the last found ServerDescriptor object.
   *
   */
  public synchronized void regenerateDescriptor()
  {
    boolean isLocal = isLocal();
    ServerDescriptor desc = createNewServerDescriptorInstance();
    desc.setIsLocal(isLocal);
    InitialLdapContext ctx = getDirContext();
    if (isLocal)
    {
      desc.setOpenDSVersion(
        org.opends.server.util.DynamicConstants.FULL_VERSION_STRING);
    desc.setInstallPath(Utilities.getServerRootDirectory());
    desc.setInstancePath(Utilities.getInstanceRootDirectory(
        Utilities.getServerRootDirectory().getAbsolutePath()));
@@ -458,20 +476,28 @@
        result == ConfigureWindowsService.SERVICE_STATE_ENABLED;
    }
    desc.setWindowsServiceEnabled(windowsServiceEnabled);
    desc.setOpenDSVersion(
        org.opends.server.util.DynamicConstants.FULL_VERSION_STRING);
    }
    else
    {
      if (lastRemoteHostName != null)
      {
        desc.setHostname(lastRemoteHostName);
      }
    }
    ConfigReader reader;
    ServerDescriptor.ServerStatus status = null;
    for (Task task : getTasks())
    {
      if ((task.getType() == Task.Type.START_SERVER) &&
          task.getState() == Task.State.RUNNING)
          (task.getState() == Task.State.RUNNING) &&
          isRunningOnServer(desc, task))
      {
        status = ServerDescriptor.ServerStatus.STARTING;
      }
      else if ((task.getType() == Task.Type.STOP_SERVER) &&
          task.getState() == Task.State.RUNNING)
          (task.getState() == Task.State.RUNNING) &&
          isRunningOnServer(desc, task))
      {
        status = ServerDescriptor.ServerStatus.STOPPING;
      }
@@ -514,11 +540,19 @@
          userDataCtx = null;
        }
      }
      if (isLocal)
      {
      reader = createNewConfigFromFileReader();
      ((ConfigFromFile)reader).readConfiguration();
      }
      else
      {
        reader = null;
      }
      desc.setAuthenticated(false);
    }
    else if (Utilities.isServerRunning(
    else if (!isLocal ||
        Utilities.isServerRunning(
        Utilities.getInstanceRootDirectory(
            desc.getInstallPath().getAbsolutePath())))
    {
@@ -529,9 +563,20 @@
        // Try with previous credentials.
        try
        {
          if (isLocal)
          {
          ctx = Utilities.getAdminDirContext(this, lastWorkingBindDN,
              lastWorkingBindPwd);
        }
          else if (lastRemoteAdministrationURL != null)
          {
            ctx = Utils.createLdapsContext(lastRemoteAdministrationURL,
                lastWorkingBindDN,
                lastWorkingBindPwd,
                Utils.getDefaultLDAPTimeout(), null,
                getTrustManager());
          }
        }
        catch (ConfigReadException cre)
        {
//        Ignore: we will ask the user for credentials.
@@ -546,13 +591,20 @@
        }
      }
      if (ctx == null)
      if (isLocal && (ctx == null))
      {
        reader = createNewConfigFromFileReader();
        ((ConfigFromFile)reader).readConfiguration();
      }
      else
      {
        if (!isLocal && (ctx == null))
        {
          desc.setStatus(ServerDescriptor.ServerStatus.NOT_CONNECTED_TO_REMOTE);
          reader = null;
        }
        else
        {
        reader = createNewConfigFromDirContextReader();
        ((ConfigFromDirContext)reader).readConfiguration(ctx);
        if (reader.getExceptions().size() > 0)
@@ -580,9 +632,18 @@
          }
          if (!connectionWorks)
          {
              if (isLocal)
              {
            // Try with offline info
            reader = createNewConfigFromFileReader();
            ((ConfigFromFile)reader).readConfiguration();
              }
              else
              {
                desc.setStatus(
                    ServerDescriptor.ServerStatus.NOT_CONNECTED_TO_REMOTE);
                reader = null;
              }
            try
            {
              ctx.close();
@@ -612,6 +673,9 @@
          }
        }
      }
      }
      if (reader != null)
      {
      desc.setAuthenticated(reader instanceof ConfigFromDirContext);
      desc.setJavaVersion(reader.getJavaVersion());
      desc.setOpenConnections(reader.getOpenConnections());
@@ -623,6 +687,21 @@
        desc.setJvmMemoryUsageMonitor(rCtx.getJvmMemoryUsage());
        desc.setSystemInformationMonitor(rCtx.getSystemInformation());
        desc.setWorkQueueMonitor(rCtx.getWorkQueue());
          desc.setOpenDSVersion((String)Utilities.getFirstMonitoringValue(
              rCtx.getVersionMonitor(), "fullVersion"));
          String installPath = (String)Utilities.getFirstMonitoringValue(
              rCtx.getSystemInformation(), "installPath");
          if (installPath != null)
          {
            desc.setInstallPath(new File(installPath));
          }
          String instancePath = (String)Utilities.getFirstMonitoringValue(
              rCtx.getSystemInformation(), "instancePath");
          if (instancePath != null)
          {
            desc.setInstancePath(new File(instancePath));
          }
        }
      }
    }
    else
@@ -632,24 +711,21 @@
      reader = createNewConfigFromFileReader();
      ((ConfigFromFile)reader).readConfiguration();
    }
    if (reader != null)
    {
    updateServerDescriptor(reader, desc);
    }
    if ((serverDesc == null) || !serverDesc.equals(desc))
    {
      serverDesc = desc;
      // Update the schema: so that when we call the server code the latest
      // schema read is used.
      if (serverDesc.getSchema() != null)
      {
        if (!ServerDescriptor.areSchemasEqual(serverDesc.getSchema(),
            DirectoryServer.getSchema()))
        {
          DirectoryServer.setSchema(desc.getSchema());
        }
      }
      ldapURL = getURL(serverDesc, ConnectionHandlerDescriptor.Protocol.LDAP);
      ldapsURL = getURL(serverDesc, ConnectionHandlerDescriptor.Protocol.LDAPS);
      adminConnectorURL = getAdminConnectorURL(serverDesc);
      if (serverDesc.isLocal())
      {
        localAdminConnectorURL = adminConnectorURL;
      }
      startTLSURL = getURL(serverDesc,
          ConnectionHandlerDescriptor.Protocol.LDAP_STARTTLS);
      ConfigurationChangeEvent ev = new ConfigurationChangeEvent(this, desc);
@@ -766,6 +842,7 @@
            regenerateDescriptor();
            Thread.sleep(poolingPeriod);
          }
        }
        catch (Throwable t)
        {
@@ -861,8 +938,30 @@
   */
  public String getAdminConnectorURL()
  {
    if (isLocal)
    {
      // If the user set isLocal to true, we want to return the
      // localAdminConnectorURL (in particular if regenerateDescriptor has not
      // been called).
      return localAdminConnectorURL;
    }
    else
    {
    return adminConnectorURL;
  }
  }
  /**
   * Gets the Administration Connector URL based in what is read in the local
   * configuration. It returns <CODE>null</CODE> if no Administration
   * Connector URL was found.
   * @return the Administration Connector URL to be used to connect
   * to the local server.
   */
  public String getLocalAdminConnectorURL()
  {
    return localAdminConnectorURL;
  }
  /**
   * Gets the LDAP URL based in what is read in the configuration. It
@@ -958,6 +1057,8 @@
    String url = null;
    ConnectionHandlerDescriptor desc = server.getAdminConnector();
    if (desc != null)
    {
    int port = desc.getPort();
    SortedSet<InetAddress> addresses = desc.getAddresses();
    if (addresses.size() == 0) {
@@ -972,6 +1073,11 @@
          + port;
      }
    }
    }
    else
    {
      url = null;
    }
    return url;
  }
@@ -1081,6 +1187,26 @@
  }
  /**
   * Sets whether the server is local or not.
   * @param isLocal whether the server is local or not.
   */
  public void setIsLocal(boolean isLocal)
  {
    this.isLocal = isLocal;
  }
  /**
   * Returns <CODE>true</CODE> if we are trying to manage the local host and
   * <CODE>false</CODE> otherwise.
   * @return <CODE>true</CODE> if we are trying to manage the local host and
   * <CODE>false</CODE> otherwise.
   */
  public boolean isLocal()
  {
    return isLocal;
  }
  /**
   * Returns the connection pool to be used by the LDAP entry browsers.
   * @return the connection pool to be used by the LDAP entry browsers.
   */
@@ -1115,4 +1241,87 @@
  {
    this.poolingPeriod = poolingPeriod;
  }
  /**
   * Returns whether the provided task is running on the provided server or not.
   * The code takes into account that the server object might not be fully
   * initialized (but at least it contains the host name and the instance
   * path if it is local).
   * @param server the server.
   * @param task the task to be analyzed.
   * @return <CODE>true</CODE> if the provided task is running on the provided
   * server and <CODE>false</CODE> otherwise.
   */
  private boolean isRunningOnServer(ServerDescriptor server, Task task)
  {
    boolean isRunningOnServer;
    if (!server.isLocal() || !task.getServer().isLocal())
    {
      if (!server.isLocal())
      {
        // At this point we only have connection information about the new
        // server.  Use the dir context which corresponds to the server to
        // compare things.
        String host1 = server.getHostname();
        String host2 = task.getServer().getHostname();
        if (host1 == null)
        {
          isRunningOnServer = host2 == null;
        }
        else
        {
          isRunningOnServer = host1.equalsIgnoreCase(host2);
        }
        if (isRunningOnServer)
        {
          // Compare administration port;
          int adminPort1 = -1;
          int adminPort2 = -1;
          if (server.getAdminConnector() != null)
          {
            adminPort1 = server.getAdminConnector().getPort();
          }
          if (getDirContext() != null)
          {
            adminPort2 = ConnectionUtils.getPort(getDirContext());
          }
          isRunningOnServer = adminPort1 == adminPort2;
        }
      }
      else
      {
        // Compare host names and paths
        File f1 = server.getInstancePath();
        File f2 = task.getServer().getInstancePath();
        String host1 = server.getHostname();
        String host2 = task.getServer().getHostname();
        if (host1 == null)
        {
          isRunningOnServer = host2 == null;
        }
        else
        {
          isRunningOnServer = host1.equalsIgnoreCase(host2);
        }
        if (isRunningOnServer)
        {
          if (f1 == null)
          {
            isRunningOnServer = f2 == null;
          }
          else
          {
            isRunningOnServer = f1.equals(f2);
          }
        }
      }
    }
    else
    {
      isRunningOnServer = true;
    }
    return isRunningOnServer;
  }
}
opends/src/guitools/org/opends/guitools/controlpanel/datamodel/ServerDescriptor.java
@@ -83,18 +83,22 @@
  private boolean isAuthenticated;
  private static String hostName = "locahost";
  private static String localHostName = "locahost";
  static
  {
    try
    {
      hostName = java.net.InetAddress.getLocalHost().getHostName();
      localHostName = java.net.InetAddress.getLocalHost().getHostName();
    }
    catch (Throwable t)
    {
    }
  };
  private String hostName = localHostName;
  private boolean isLocal = true;
  /**
   * Enumeration indicating the status of the server.
   *
@@ -118,6 +122,10 @@
     */
    STOPPING,
    /**
     * Not connected to remote.
     */
    NOT_CONNECTED_TO_REMOTE,
    /**
     * Status Unknown.
     */
    UNKNOWN
@@ -295,6 +303,11 @@
        if (equals)
        {
          equals = desc.isLocal() == isLocal();
        }
        if (equals)
        {
          equals = desc.isAuthenticated() == isAuthenticated();
        }
@@ -305,13 +318,27 @@
        if (equals)
        {
          if (desc.getInstallPath() == null)
          {
            equals = getInstallPath() == null;
          }
          else
          {
          equals = desc.getInstallPath().equals(getInstallPath());
        }
        }
        if (equals)
        {
          if (desc.getInstancePath() == null)
          {
            equals = getInstancePath() == null;
          }
          else
          {
          equals = desc.getInstancePath().equals(getInstancePath());
        }
        }
        if (equals)
        {
@@ -327,8 +354,15 @@
        if (equals)
        {
          if (desc.getOpenDSVersion() == null)
          {
            equals = getOpenDSVersion() == null;
          }
          else
          {
          equals = desc.getOpenDSVersion().equals(getOpenDSVersion());
        }
        }
        if (equals)
        {
@@ -484,6 +518,37 @@
  }
  /**
   * Sets the host name of the server.
   * @param hostName the host name of the server.
   */
  public void setHostname(String hostName)
  {
    this.hostName = hostName;
  }
  /**
   * Returns <CODE>true</CODE> if we are trying to manage the local host and
   * <CODE>false</CODE> otherwise.
   * @return <CODE>true</CODE> if we are trying to manage the local host and
   * <CODE>false</CODE> otherwise.
   */
  public boolean isLocal()
  {
    return isLocal;
  }
  /**
   * Sets whether this server represents the local instance or a remote server.
   * @param isLocal whether this server represents the local instance or a
   * remote server (in another machine or in another installation on the same
   * machine).
   */
  public void setIsLocal(boolean isLocal)
  {
    this.isLocal = isLocal;
  }
  /**
   * Returns the exceptions that occurred while reading the configuration.
   * @return the exceptions that occurred while reading the configuration.
   */
@@ -772,7 +837,9 @@
  public void setAdminConnector(ConnectionHandlerDescriptor adminConnector)
  {
    this.adminConnector = adminConnector;
  }/**
  }
  /**
   * Sets the monitoring entry for the entry caches.
   * @param entryCaches the monitoring entry for the entry caches.
   */
opends/src/guitools/org/opends/guitools/controlpanel/task/AddToGroupTask.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.task;
@@ -150,7 +150,7 @@
    boolean canLaunch = true;
    if (!isServerRunning())
    {
      if (state == State.RUNNING)
      if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
      {
        // All the operations are incompatible if they apply to this
        // backend for safety.  This is a short operation so the limitation
opends/src/guitools/org/opends/guitools/controlpanel/task/DeleteBaseDNAndBackendTask.java
@@ -218,7 +218,7 @@
      Collection<Message> incompatibilityReasons)
  {
    boolean canLaunch = true;
    if (state == State.RUNNING)
    if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
    {
      // All the operations are incompatible if they apply to this
      // backend for safety.  This is a short operation so the limitation
opends/src/guitools/org/opends/guitools/controlpanel/task/DeleteEntryTask.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.task;
@@ -182,7 +182,7 @@
    boolean canLaunch = true;
    if (!isServerRunning())
    {
      if (state == State.RUNNING)
      if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
      {
        // All the operations are incompatible if they apply to this
        // backend for safety.
opends/src/guitools/org/opends/guitools/controlpanel/task/DeleteIndexTask.java
@@ -125,7 +125,7 @@
      Collection<Message> incompatibilityReasons)
  {
    boolean canLaunch = true;
    if (state == State.RUNNING)
    if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
    {
      // All the operations are incompatible if they apply to this
      // backend for safety.  This is a short operation so the limitation
opends/src/guitools/org/opends/guitools/controlpanel/task/ModifyEntryTask.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.task;
@@ -203,7 +203,7 @@
    boolean canLaunch = true;
    if (!isServerRunning())
    {
      if (state == State.RUNNING)
      if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
      {
        // All the operations are incompatible if they apply to this
        // backend for safety.  This is a short operation so the limitation
opends/src/guitools/org/opends/guitools/controlpanel/task/NewEntryTask.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.task;
@@ -155,7 +155,7 @@
    boolean canLaunch = true;
    if (!isServerRunning())
    {
      if (state == State.RUNNING)
      if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
      {
        // All the operations are incompatible if they apply to this
        // backend for safety.  This is a short operation so the limitation
opends/src/guitools/org/opends/guitools/controlpanel/task/RebuildIndexTask.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.task;
@@ -50,6 +50,7 @@
import org.opends.server.admin.client.ldap.LDAPManagementContext;
import org.opends.server.admin.std.client.LocalDBBackendCfgClient;
import org.opends.server.admin.std.client.RootCfgClient;
import org.opends.server.tools.RebuildIndex;
import org.opends.server.types.OpenDsException;
import org.opends.server.util.cli.CommandBuilder;
@@ -109,7 +110,7 @@
      Collection<Message> incompatibilityReasons)
  {
    boolean canLaunch = true;
    if (state == State.RUNNING)
    if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
    {
      // All the operations are incompatible if they apply to this
      // backend.
@@ -137,8 +138,9 @@
    {
      boolean mustDisable = false;
      boolean mustEnable = false;
      boolean isLocal = getInfo().getServerDescriptor().isLocal();
      String backendName = backendSet.iterator().next();
      if (isServerRunning())
      if (isServerRunning() && isLocal)
      {
        for (BackendDescriptor backend :
          getInfo().getServerDescriptor().getBackends())
@@ -188,8 +190,16 @@
          }
        });
        if (isLocal)
        {
        returnCode = executeCommandLine(getCommandLinePath("rebuild-index"),
            args);
        }
        else
        {
          returnCode = RebuildIndex.mainRebuildIndex(args, false,
              outPrintStream, errorPrintStream);
        }
        if (returnCode != 0)
        {
@@ -258,6 +268,13 @@
      }
    }
    boolean isLocal = getInfo().getServerDescriptor().isLocal();
    if (!isLocal)
    {
      args.addAll(getConnectionCommandLineArguments());
      args.addAll(getConfigCommandLineArguments());
    }
    return args;
  }
opends/src/guitools/org/opends/guitools/controlpanel/task/ResetUserPasswordTask.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.task;
@@ -190,7 +190,7 @@
    boolean canLaunch = true;
    if (!isServerRunning())
    {
      if (state == State.RUNNING)
      if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
      {
        // All the operations are incompatible if they apply to this
        // backend for safety.  This is a short operation so the limitation
opends/src/guitools/org/opends/guitools/controlpanel/task/StartStopTask.java
@@ -79,7 +79,7 @@
      Collection<Message> incompatibilityReasons)
  {
    boolean canLaunch = true;
    if (state == State.RUNNING)
    if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
    {
      incompatibilityReasons.add(getIncompatibilityMessage(this,
          taskToBeLaunched));
opends/src/guitools/org/opends/guitools/controlpanel/task/Task.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.task;
@@ -53,6 +53,7 @@
import org.opends.guitools.controlpanel.util.ProcessReader;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.messages.Message;
import org.opends.quicksetup.Installation;
import org.opends.server.types.ByteString;
import org.opends.server.types.DN;
import org.opends.server.types.Schema;
@@ -68,6 +69,7 @@
public abstract class Task
{
  private static String localHostName = null;
  private String binDir;
  static
  {
    // Do this since by default the hostname used by the connection is
@@ -275,6 +277,8 @@
  protected Process process;
  private ControlPanelInfo info;
  private ServerDescriptor server;
  private ProgressDialog progressDialog;
  private static int MAX_BINARY_LENGTH_TO_DISPLAY = 1024;
@@ -313,6 +317,7 @@
        logs.append(msg+"\n");
      }
    });
    server = info.getServerDescriptor();
  }
  /**
@@ -600,16 +605,80 @@
   */
  protected String getBinaryDir()
  {
    if (Utilities.isWindows())
    if (binDir == null)
    {
      return getInfo().getServerDescriptor().getInstallPath() +
      File.separator + "bat" + File.separator;
      File f = Installation.getLocal().getBinariesDirectory();
      try
      {
        binDir = f.getCanonicalPath();
      }
      catch (Throwable t)
      {
        binDir = f.getAbsolutePath();
      }
      if (binDir.lastIndexOf(File.separatorChar) != (binDir.length() - 1))
      {
        binDir += File.separatorChar;
      }
    }
    return binDir;
  }
  /**
   * Check whether the provided task and this task run on the same server.
   * @param task the task the task to be analyzed.
   * @return <CODE>true</CODE> if both tasks run on the same server and
   * <CODE>false</CODE> otherwise.
   */
  protected boolean runningOnSameServer(Task task)
  {
    boolean runningOnSameServer = false;
    if (getServer().isLocal() && task.getServer().isLocal())
    {
      runningOnSameServer = true;
    }
    else
    {
      return getInfo().getServerDescriptor().getInstallPath() +
      File.separator + "bin" + File.separator;
      // Compare the host name and the instance path.  This is safer than
      // 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 host1 = getServer().getHostname();
      String host2 = task.getServer().getHostname();
      if (host1 == null)
      {
        runningOnSameServer = host2 == null;
    }
      else
      {
        runningOnSameServer = host1.equalsIgnoreCase(host2);
      }
      if (runningOnSameServer)
      {
        if (f1 == null)
        {
          runningOnSameServer = f2 == null;
        }
        else
        {
          runningOnSameServer = f1.equals(f2);
        }
      }
    }
    return runningOnSameServer;
  }
  /**
   * Returns the server descriptor on which the task was launched.
   * @return the server descriptor on which the task was launched.
   */
  public ServerDescriptor getServer()
  {
    return server;
  }
  /**
@@ -729,7 +798,7 @@
    if (isServerRunning() && (ctx != null))
    {
      String hostName = localHostName;
      if (hostName == null)
      if ((hostName == null) || !getInfo().getServerDescriptor().isLocal())
      {
        hostName = ConnectionUtils.getHostName(ctx);
      }
opends/src/guitools/org/opends/guitools/controlpanel/ui/AbstractBrowseEntriesPanel.java
@@ -1366,6 +1366,16 @@
        }
      }
    }
    else if (status == ServerDescriptor.ServerStatus.NOT_CONNECTED_TO_REMOTE)
    {
      MessageBuilder mb = new MessageBuilder();
      mb.append(INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(
          desc.getHostname()));
      mb.append("<br><br>"+getAuthenticateHTML());
      errorDetails = mb.toMessage();
      errorTitle = INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_SUMMARY.get();
      displayErrorPane = true;
    }
    else
    {
      errorTitle = INFO_CTRL_PANEL_SERVER_NOT_RUNNING_SUMMARY.get();
opends/src/guitools/org/opends/guitools/controlpanel/ui/BackupListPanel.java
@@ -132,6 +132,8 @@
   */
  protected JTable backupList;
  private JLabel lRemoteFileHelp;
  /**
   * Whether the backup parent directory has been initialized with a value or
   * not.
@@ -214,6 +216,15 @@
    gbc.weightx = 0.0;
    add(browse, gbc);
    lRemoteFileHelp = Utilities.createInlineHelpLabel(
        INFO_CTRL_PANEL_REMOTE_SERVER_PATH.get());
    gbc.gridx = 1;
    gbc.gridwidth = 2;
    gbc.insets.top = 3;
    gbc.insets.left = 10;
    gbc.gridy ++;
    add(lRemoteFileHelp, gbc);
    gbc.gridx = 0;
    gbc.gridy ++;
    gbc.insets.top = 10;
@@ -222,6 +233,7 @@
        INFO_CTRL_PANEL_AVAILABLE_BACKUPS_LABEL.get());
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.fill = GridBagConstraints.NONE;
    gbc.gridwidth = 1;
    add(lAvailableBackups, gbc);
    gbc.gridx = 1;
@@ -339,7 +351,7 @@
    verifyBackup.setEnabled(false);
    tableScroll.setVisible(false);
    lRefreshingList.setText(REFRESHING_LIST.toString());
    lRefreshingList.setVisible(true);
    lRefreshingList.setVisible(isLocal());
    final int lastSelectedRow = backupList.getSelectedRow();
    final String parentPath = parentDirectory.getText();
@@ -428,6 +440,7 @@
          {
            model.fireTableDataChanged();
            lRefreshingList.setText(NO_BACKUPS_FOUND.toString());
            lRefreshingList.setVisible(isLocal());
          }
          errorPane.setVisible(false);
          // This is done to perform checks against whether we require to
@@ -522,20 +535,41 @@
    if (!backupDirectoryInitialized &&
        (parentDirectory.getText().length() == 0))
    {
      final String path =
        org.opends.quicksetup.util.Utils.getPath(
            new File(desc.getInstancePath(),
                org.opends.quicksetup.Installation.BACKUPS_PATH_RELATIVE));
      String path;
      File f = new File(desc.getInstancePath(),
          org.opends.quicksetup.Installation.BACKUPS_PATH_RELATIVE);
      try
      {
        path = f.getCanonicalPath();
      }
      catch (Throwable t)
      {
        path = f.getAbsolutePath();
      }
      final String fPath = path;
      SwingUtilities.invokeLater(new Runnable()
      {
        public void run()
        {
          parentDirectory.setText(path);
          parentDirectory.setText(fPath);
          refreshList();
          backupDirectoryInitialized = true;
        }
      });
    }
    SwingUtilities.invokeLater(new Runnable()
    {
      public void run()
      {
        lRemoteFileHelp.setVisible(!isLocal());
        browse.setVisible(isLocal());
        lAvailableBackups.setVisible(isLocal());
        tableScroll.setVisible(isLocal());
        refreshList.setVisible(isLocal());
        verifyBackup.setVisible(isLocal());
      }
    });
  }
  /**
opends/src/guitools/org/opends/guitools/controlpanel/ui/BackupPanel.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.ui;
@@ -81,6 +81,7 @@
  private JComboBox backends;
  private JCheckBox allBackends;
  private JTextField backupID;
  private JTextField parentBackupID;
  private JRadioButton fullBackup;
  private JRadioButton incrementalBackup;
  private JCheckBox compressData;
@@ -91,6 +92,7 @@
  private JLabel lBackend;
  private JLabel lNoBackendsFound;
  private JLabel lBackupID;
  private JLabel lParentID;
  private JLabel lBackupType;
  private JLabel lBackupOptions;
@@ -220,6 +222,7 @@
    gbc.gridx = 0;
    gbc.gridy ++;
    super.createLayout(gbc);
    verifyBackup.setVisible(false);
    lAvailableBackups.setText(
        INFO_CTRL_PANEL_AVAILABLE_PARENT_BACKUPS_LABEL.get().toString());
@@ -229,6 +232,21 @@
    gbc.insets.top = 10;
    gbc.gridwidth = 1;
    gbc.anchor = GridBagConstraints.WEST;
    lParentID = Utilities.createPrimaryLabel(
        INFO_CTRL_PANEL_PARENT_BACKUP_ID_LABEL.get());
    add(lParentID, gbc);
    parentBackupID = Utilities.createMediumTextField();
    gbc.weightx = 0.0;
    gbc.gridx ++;
    gbc.insets.left = 10;
    gbc.fill = GridBagConstraints.NONE;
    gbc.gridwidth = 2;
    add(parentBackupID, gbc);
    gbc.gridy ++;
    gbc.gridx = 0;
    gbc.gridwidth = 1;
    gbc.insets.left = 0;
    lBackupOptions = Utilities.createPrimaryLabel(
        INFO_CTRL_PANEL_BACKUP_OPTIONS_LABEL.get());
    add(lBackupOptions, gbc);
@@ -275,6 +293,11 @@
        refreshList.setEnabled(enable);
        tableScroll.setEnabled(enable);
        backupList.setEnabled(enable);
        lAvailableBackups.setEnabled(enable);
        lRefreshingList.setEnabled(enable);
        lParentID.setEnabled(enable);
        parentBackupID.setEnabled(enable);
        verifyBackup.setEnabled(enable && getSelectedBackup() != null);
      }
    };
    incrementalBackup.addChangeListener(changeListener);
@@ -290,7 +313,7 @@
   */
  public void configurationChanged(ConfigurationChangeEvent ev)
  {
    ServerDescriptor desc = ev.getNewDescriptor();
    final ServerDescriptor desc = ev.getNewDescriptor();
    updateSimpleBackendComboBoxModel(backends, lNoBackendsFound, desc);
    SwingUtilities.invokeLater(new Runnable()
    {
@@ -300,11 +323,23 @@
      public void run()
      {
        allBackends.setVisible(backends.getModel().getSize() > 0);
        lParentID.setVisible(!desc.isLocal());
        parentBackupID.setVisible(!desc.isLocal());
        if (desc.isLocal())
        {
          lPath.setText(INFO_CTRL_PANEL_BACKUP_PATH_LABEL.get().toString());
        }
        else
        {
          lPath.setText(
              INFO_CTRL_PANEL_PARENT_BACKUP_PATH_LABEL.get().toString());
        }
      }
    });
    super.configurationChanged(ev);
    updateErrorPaneAndOKButtonIfAuthRequired(getInfo().getServerDescriptor(),
        INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_BACKUP.get());
    updateErrorPaneAndOKButtonIfAuthRequired(desc,
        isLocal() ? INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_BACKUP.get() :
      INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
  }
  /**
@@ -315,6 +350,7 @@
    setPrimaryValid(lBackend);
    setPrimaryValid(lPath);
    setPrimaryValid(lAvailableBackups);
    setPrimaryValid(lParentID);
    backupIDInitialized = false;
    final LinkedHashSet<Message> errors = new LinkedHashSet<Message>();
@@ -343,7 +379,7 @@
      errors.add(ERR_CTRL_PANEL_NO_BACKUP_PATH_PROVIDED.get());
      setPrimaryInvalid(lPath);
    }
    else
    else if (isLocal())
    {
      File f = new File(parentPath);
      if (f.isFile())
@@ -364,7 +400,7 @@
      setPrimaryInvalid(lBackupID);
    }
    if (errors.isEmpty())
    if (errors.isEmpty() && isLocal())
    {
      File f = new File(parentPath, dir);
      if (f.isFile())
@@ -377,6 +413,8 @@
    if (incrementalBackup.isSelected())
    {
      if (isLocal())
      {
      boolean selected = backupList.isVisible() &&
      (getSelectedBackup() != null);
      if (!selected)
@@ -385,6 +423,16 @@
        setPrimaryInvalid(lAvailableBackups);
      }
    }
      else
      {
        String parentID = parentBackupID.getText();
        if ((parentID == null) || (parentID.trim().equals("")))
        {
          errors.add(ERR_CTRL_PANEL_NO_PARENT_BACKUP_ID_PROVIDED.get());
          setPrimaryInvalid(lParentID);
        }
      }
    }
    // Check that there is not a backup with the provided ID
    final JComponent[] components =
@@ -604,6 +652,8 @@
      }
      if (incrementalBackup.isSelected())
      {
        if (isLocal())
        {
        BackupDescriptor backup = getSelectedBackup();
        dir = backup.getPath().getAbsolutePath();
      }
@@ -612,6 +662,11 @@
        dir = parentDirectory.getText();
      }
    }
      else
      {
        dir = parentDirectory.getText();
      }
    }
    /**
     * {@inheritDoc}
@@ -637,7 +692,7 @@
        Collection<Message> incompatibilityReasons)
    {
      boolean canLaunch = true;
      if (state == State.RUNNING)
      if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
      {
        // All the operations are incompatible if they apply to this
        // backend.
@@ -734,10 +789,18 @@
      if (incrementalBackup.isSelected())
      {
        args.add("--incremental");
        if (isLocal())
        {
        BackupDescriptor backup = getSelectedBackup();
        args.add("--incrementalBaseID");
        args.add(backup.getID());
      }
        else
        {
          args.add("--incrementalBaseID");
          args.add(parentBackupID.getText());
        }
      }
      if (compressData.isSelected())
opends/src/guitools/org/opends/guitools/controlpanel/ui/BrowseGeneralMonitoringPanel.java
@@ -369,6 +369,16 @@
        displayErrorPane = true;
      }
    }
    else if (status == ServerDescriptor.ServerStatus.NOT_CONNECTED_TO_REMOTE)
    {
      MessageBuilder mb = new MessageBuilder();
      mb.append(INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(
          server.getHostname()));
      mb.append("<br><br>"+getAuthenticateHTML());
      errorDetails = mb.toMessage();
      errorTitle = INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_SUMMARY.get();
      displayErrorPane = true;
    }
    else
    {
      errorTitle = INFO_CTRL_PANEL_SERVER_NOT_RUNNING_SUMMARY.get();
@@ -614,8 +624,11 @@
  private String getServerName(ServerDescriptor server)
  {
    String serverName = server.getHostname()+":"+
    server.getAdminConnector().getPort();
    String serverName = server.getHostname();
    if (server.getAdminConnector() != null)
    {
      serverName +=":"+server.getAdminConnector().getPort();
    }
    return serverName;
  }
opends/src/guitools/org/opends/guitools/controlpanel/ui/ConnectionHandlerMonitoringPanel.java
@@ -351,6 +351,16 @@
        displayErrorPane = true;
      }
    }
    else if (status == ServerDescriptor.ServerStatus.NOT_CONNECTED_TO_REMOTE)
    {
      MessageBuilder mb = new MessageBuilder();
      mb.append(INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(
          server.getHostname()));
      mb.append("<br><br>"+getAuthenticateHTML());
      errorDetails = mb.toMessage();
      errorTitle = INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_SUMMARY.get();
      displayErrorPane = true;
    }
    else
    {
      errorTitle = INFO_CTRL_PANEL_SERVER_NOT_RUNNING_SUMMARY.get();
opends/src/guitools/org/opends/guitools/controlpanel/ui/ControlCenterMainPane.java
@@ -178,7 +178,7 @@
   * Returns the login dialog used to ask authentication to the user.
   * @return the login dialog used to ask authentication to the user.
   */
  public GenericDialog getLoginDialog()
  private GenericDialog getLoginDialog()
  {
    return statusPane.getLoginDialog();
  }
@@ -207,10 +207,60 @@
            INFO_CTRL_PANEL_NOT_AUTHENTICATED.get().toString());
      }
    }
    else
    else if (server.isLocal())
    {
      lAuthenticatedAs.setText(
         INFO_CTRL_PANEL_NOT_AUTHENTICATED_SERVER_NOT_RUNNING.get().toString());
    }
    else
    {
      lAuthenticatedAs.setText(
          INFO_CTRL_PANEL_NOT_AUTHENTICATED_SERVER_REMOTE.get(
              server.getHostname()).toString());
    }
  }
  private static GenericDialog localOrRemoteDlg;
  private static GenericDialog loginDlg;
  /**
   * Returns the dialog that is in charge of asking the user the server
   * to be administer.  This method will return always the same dialog.  The
   * dialog will do all the logic of updating the ControlPanelInfo object.
   * @param info the control panel information object.
   * @return the dialog that is in charge of asking the user the server
   * to be administer.
   */
  public static GenericDialog getLocalOrRemoteDialog(ControlPanelInfo info)
  {
    if (localOrRemoteDlg == null)
    {
      LocalOrRemotePanel localOrRemotePanel = new LocalOrRemotePanel();
      localOrRemotePanel.setInfo(info);
      localOrRemoteDlg = new GenericDialog(null, localOrRemotePanel);
      localOrRemoteDlg.setModal(true);
      localOrRemoteDlg.pack();
    }
    return localOrRemoteDlg;
  }
  /**
   * Returns the dialog that is in charge of asking the user the authentication
   * for the local server.  This method will return always the same dialog.
   * @param info the control panel information object.  The
   * dialog will do all the logic of updating the ControlPanelInfo object.
   * @return the dialog that is in charge of asking the user the authentication
   * for the local server.
   */
  public static GenericDialog getLocalServerLoginDialog(ControlPanelInfo info)
  {
    if (loginDlg == null)
    {
      LoginPanel loginPanel = new LoginPanel();
      loginDlg = new GenericDialog(null, loginPanel);
      loginPanel.setInfo(info);
      loginDlg.setModal(true);
    }
    return loginDlg;
  }
}
opends/src/guitools/org/opends/guitools/controlpanel/ui/CustomAttributePanel.java
@@ -41,6 +41,7 @@
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
import org.opends.guitools.controlpanel.event.ScrollPaneBorderListener;
import org.opends.guitools.controlpanel.task.DeleteSchemaElementsTask;
@@ -136,10 +137,13 @@
  /**
   * {@inheritDoc}
   */
  public void configurationChanged(final ConfigurationChangeEvent ev)
  public void configurationChanged(ConfigurationChangeEvent ev)
  {
    updateErrorPaneIfAuthRequired(ev.getNewDescriptor(),
        INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_ATTRIBUTE_DELETE.get());
    final ServerDescriptor desc = ev.getNewDescriptor();
    updateErrorPaneIfAuthRequired(desc,
        isLocal() ?
        INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_ATTRIBUTE_DELETE.get() :
      INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
    SwingUtilities.invokeLater(new Runnable()
    {
      /**
@@ -147,7 +151,7 @@
       */
      public void run()
      {
        delete.setEnabled(!authenticationRequired(ev.getNewDescriptor()));
        delete.setEnabled(!authenticationRequired(desc));
      }
    });
  }
opends/src/guitools/org/opends/guitools/controlpanel/ui/CustomObjectClassPanel.java
@@ -41,6 +41,7 @@
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
import org.opends.guitools.controlpanel.event.ScrollPaneBorderListener;
import org.opends.guitools.controlpanel.task.DeleteSchemaElementsTask;
@@ -116,10 +117,13 @@
  /**
   * {@inheritDoc}
   */
  public void configurationChanged(final ConfigurationChangeEvent ev)
  public void configurationChanged(ConfigurationChangeEvent ev)
  {
    updateErrorPaneIfAuthRequired(ev.getNewDescriptor(),
        INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_OBJECTCLASS_DELETE.get());
    final ServerDescriptor desc = ev.getNewDescriptor();
    updateErrorPaneIfAuthRequired(desc,
       isLocal() ?
          INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_OBJECTCLASS_DELETE.get() :
      INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
    SwingUtilities.invokeLater(new Runnable()
    {
      /**
@@ -127,7 +131,7 @@
       */
      public void run()
      {
        delete.setEnabled(!authenticationRequired(ev.getNewDescriptor()));
        delete.setEnabled(!authenticationRequired(desc));
      }
    });
  }
opends/src/guitools/org/opends/guitools/controlpanel/ui/DeleteBackendPanel.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.ui;
@@ -96,8 +96,10 @@
      }
    }
    updateList(newElements);
    updateErrorPaneAndOKButtonIfAuthRequired(getInfo().getServerDescriptor(),
        INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_BACKEND_DELETE.get());
    updateErrorPaneAndOKButtonIfAuthRequired(desc,
        isLocal() ?
            INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_BACKEND_DELETE.get() :
      INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
  }
  /**
opends/src/guitools/org/opends/guitools/controlpanel/ui/DeleteBaseDNPanel.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.ui;
@@ -362,8 +362,10 @@
      }
    }
    updateList(newElements);
    updateErrorPaneAndOKButtonIfAuthRequired(getInfo().getServerDescriptor(),
        INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_BASE_DN_DELETE.get());
    updateErrorPaneAndOKButtonIfAuthRequired(desc,
        isLocal() ?
            INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_BASE_DN_DELETE.get() :
      INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
  }
  /**
opends/src/guitools/org/opends/guitools/controlpanel/ui/ExportLDIFPanel.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.ui;
@@ -47,12 +47,14 @@
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
import org.opends.guitools.controlpanel.event.BrowseActionListener;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
import org.opends.guitools.controlpanel.task.Task;
@@ -76,11 +78,13 @@
  private JCheckBox generateSignedHash;
  private JCheckBox wrapText;
  private JTextField wrapColumn;
  private JButton bBrowse;
  private JLabel lBackend;
  private JLabel lNoBackendsFound;
  private JLabel lFile;
  private JLabel lExportOptions;
  private JLabel lRemoteFileHelp;
  private JCheckBox excludeOperationalAttrs;
  private DocumentListener documentListener;
@@ -195,7 +199,7 @@
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    add(file, gbc);
    JButton bBrowse = Utilities.createButton(
    bBrowse = Utilities.createButton(
        INFO_CTRL_PANEL_BROWSE_BUTTON_LABEL.get());
    bBrowse.addActionListener(
        new BrowseActionListener(file,
@@ -205,6 +209,16 @@
    gbc.weightx = 0.0;
    bBrowse.setOpaque(false);
    add(bBrowse, gbc);
    lRemoteFileHelp = Utilities.createInlineHelpLabel(
        INFO_CTRL_PANEL_REMOTE_SERVER_PATH.get());
    gbc.gridx = 1;
    gbc.insets.top = 3;
    gbc.insets.left = 10;
    gbc.gridy ++;
    gbc.gridwidth = 3;
    add(lRemoteFileHelp, gbc);
    gbc.gridx = 1;
    gbc.gridy ++;
    gbc.insets.left = 30;
@@ -312,11 +326,22 @@
   */
  public void configurationChanged(ConfigurationChangeEvent ev)
  {
    ServerDescriptor desc = ev.getNewDescriptor();
    updateSimpleBackendComboBoxModel(backends, lNoBackendsFound,
        ev.getNewDescriptor());
    updateErrorPaneAndOKButtonIfAuthRequired(getInfo().getServerDescriptor(),
        INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_EXPORT.get());
    updateErrorPaneAndOKButtonIfAuthRequired(desc,
       isLocal() ? INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_EXPORT.get() :
      INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
    SwingUtilities.invokeLater(new Runnable()
    {
      public void run()
      {
        lRemoteFileHelp.setVisible(!isLocal());
        bBrowse.setVisible(isLocal());
      }
    });
  }
  /**
@@ -350,7 +375,7 @@
      errors.add(INFO_NO_LDIF_PATH.get());
      setPrimaryInvalid(lFile);
    }
    else
    else if (isLocal())
    {
      File f = new File(ldifPath);
      if (f.isDirectory())
@@ -468,7 +493,7 @@
        Collection<Message> incompatibilityReasons)
    {
      boolean canLaunch = true;
      if (state == State.RUNNING)
      if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
      {
        // All the operations are incompatible if they apply to this
        // backend.
opends/src/guitools/org/opends/guitools/controlpanel/ui/ImportLDIFPanel.java
@@ -48,6 +48,7 @@
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
@@ -55,6 +56,7 @@
import org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
import org.opends.guitools.controlpanel.event.BrowseActionListener;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
import org.opends.guitools.controlpanel.task.Task;
@@ -84,6 +86,9 @@
  private JTextField skipsFile;
  private JCheckBox overwriteRejectsFile;
  private JCheckBox overwriteSkipsFile;
  private JButton bBrowse;
  private JButton rejectsBrowse;
  private JButton skipsBrowse;
  private JLabel lBackend;
  private JLabel lNoBackendsFound;
@@ -92,6 +97,9 @@
  private JLabel lSchemaValidation;
  private JLabel lRejectsFile;
  private JLabel lSkipsFile;
  private JLabel lRemoteFileHelp;
  private JLabel lRemoteRejectsHelp;
  private JLabel lRemoteSkipsHelp;
  private DocumentListener documentListener;
@@ -204,7 +212,7 @@
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    add(file, gbc);
    JButton bBrowse = Utilities.createButton(
    bBrowse = Utilities.createButton(
        INFO_CTRL_PANEL_BROWSE_BUTTON_LABEL.get());
    bBrowse.addActionListener(
        new BrowseActionListener(file,
@@ -214,6 +222,16 @@
    gbc.weightx = 0.0;
    bBrowse.setOpaque(false);
    add(bBrowse, gbc);
    lRemoteFileHelp = Utilities.createInlineHelpLabel(
        INFO_CTRL_PANEL_REMOTE_SERVER_PATH.get());
    gbc.gridx = 1;
    gbc.gridwidth = 2;
    gbc.insets.top = 3;
    gbc.insets.left = 10;
    gbc.gridy ++;
    add(lRemoteFileHelp, gbc);
    gbc.gridx = 1;
    gbc.gridy ++;
    gbc.insets.left = 30;
@@ -310,7 +328,7 @@
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    add(rejectsFile, gbc);
    final JButton rejectsBrowse =
    rejectsBrowse =
      Utilities.createButton(INFO_CTRL_PANEL_BROWSE_BUTTON_LABEL.get());
    rejectsBrowse.addActionListener(
        new BrowseActionListener(rejectsFile,
@@ -321,6 +339,16 @@
    gbc.insets.left = 10;
    rejectsBrowse.setOpaque(false);
    add(rejectsBrowse, gbc);
    lRemoteRejectsHelp = Utilities.createInlineHelpLabel(
        INFO_CTRL_PANEL_REMOTE_SERVER_PATH.get());
    gbc.gridx = 1;
    gbc.gridwidth = 2;
    gbc.insets.top = 3;
    gbc.insets.left = 10;
    gbc.gridy ++;
    add(lRemoteRejectsHelp, gbc);
    gbc.gridx = 1;
    gbc.gridy ++;
    gbc.insets.left = 30;
@@ -370,7 +398,7 @@
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    add(skipsFile, gbc);
    final JButton skipsBrowse =
    skipsBrowse =
      Utilities.createButton(INFO_CTRL_PANEL_BROWSE_BUTTON_LABEL.get());
    skipsBrowse.addActionListener(
        new BrowseActionListener(skipsFile,
@@ -382,6 +410,15 @@
    skipsBrowse.setOpaque(false);
    add(skipsBrowse, gbc);
    lRemoteSkipsHelp = Utilities.createInlineHelpLabel(
        INFO_CTRL_PANEL_REMOTE_SERVER_PATH.get());
    gbc.gridx = 1;
    gbc.gridwidth = 2;
    gbc.insets.top = 3;
    gbc.insets.left = 10;
    gbc.gridy ++;
    add(lRemoteSkipsHelp, gbc);
    gbc.gridx = 1;
    gbc.gridy ++;
    gbc.insets.left = 30;
@@ -446,10 +483,23 @@
   */
  public void configurationChanged(ConfigurationChangeEvent ev)
  {
    updateSimpleBackendComboBoxModel(backends, lNoBackendsFound,
        ev.getNewDescriptor());
    updateErrorPaneAndOKButtonIfAuthRequired(getInfo().getServerDescriptor(),
        INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_IMPORT.get());
    ServerDescriptor desc = ev.getNewDescriptor();
    updateSimpleBackendComboBoxModel(backends, lNoBackendsFound, desc);
    updateErrorPaneAndOKButtonIfAuthRequired(desc,
      isLocal() ? INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_IMPORT.get() :
      INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
    SwingUtilities.invokeLater(new Runnable()
    {
      public void run()
      {
        lRemoteFileHelp.setVisible(!isLocal());
        bBrowse.setVisible(isLocal());
        rejectsBrowse.setVisible(isLocal());
        skipsBrowse.setVisible(isLocal());
        lRemoteRejectsHelp.setVisible(!isLocal());
        lRemoteSkipsHelp.setVisible(!isLocal());
      }
    });
  }
  /**
@@ -483,7 +533,7 @@
    {
      errors.add(INFO_NO_LDIF_PATH.get());
      setPrimaryInvalid(lFile);
    } else if (!Utils.fileExists(ldifPath))
    } else if (isLocal() && !Utils.fileExists(ldifPath))
    {
      errors.add(INFO_LDIF_FILE_DOES_NOT_EXIST.get());
      setPrimaryInvalid(lFile);
@@ -622,7 +672,7 @@
        Collection<Message> incompatibilityReasons)
    {
      boolean canLaunch = true;
      if (state == State.RUNNING)
      if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
      {
        // All the operations are incompatible if they apply to this
        // backend.
opends/src/guitools/org/opends/guitools/controlpanel/ui/IndexPanel.java
@@ -60,6 +60,7 @@
import org.opends.guitools.controlpanel.datamodel.AbstractIndexDescriptor;
import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
import org.opends.guitools.controlpanel.datamodel.IndexDescriptor;
import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
import org.opends.guitools.controlpanel.event.ScrollPaneBorderListener;
import org.opends.guitools.controlpanel.task.DeleteIndexTask;
@@ -249,10 +250,13 @@
  /**
   * {@inheritDoc}
   */
  public void configurationChanged(final ConfigurationChangeEvent ev)
  public void configurationChanged(ConfigurationChangeEvent ev)
  {
    updateErrorPaneIfAuthRequired(ev.getNewDescriptor(),
        INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_INDEX_EDITING.get());
    final ServerDescriptor desc = ev.getNewDescriptor();
    updateErrorPaneIfAuthRequired(desc,
        isLocal() ?
            INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_INDEX_EDITING.get() :
      INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
    SwingUtilities.invokeLater(new Runnable()
    {
      /**
@@ -261,7 +265,7 @@
      public void run()
      {
        checkSaveButton();
        deleteIndex.setEnabled(!authenticationRequired(ev.getNewDescriptor()));
        deleteIndex.setEnabled(!authenticationRequired(desc));
      }
    });
  }
@@ -581,7 +585,7 @@
        Collection<Message> incompatibilityReasons)
    {
      boolean canLaunch = true;
      if (state == State.RUNNING)
      if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
      {
        // All the operations are incompatible if they apply to this
        // backend for safety.  This is a short operation so the limitation
opends/src/guitools/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java
@@ -155,7 +155,9 @@
  private boolean readUseOpenDSJavaHome;
  private boolean readUseOpenDSJavaArgs;
  private boolean firstDisplay = true;
  private boolean initialized = false;
  private boolean previousLocal = true;
  private Message READING_JAVA_SETTINGS =
    INFO_CTRL_PANEL_READING_JAVA_SETTINGS_SUMMARY.get();
@@ -240,7 +242,6 @@
    gbc.insets.left = 0;
    add(useOpenDSJavaHomeLabel, gbc);
    gbc.gridx = 1;
    gbc.gridy ++;
    gbc.fill = GridBagConstraints.HORIZONTAL;
@@ -416,7 +417,7 @@
    comps = new JComponent[] {
        javaHome, useOpenDSJavaHome, useSpecifiedJavaHome, browse,
        useOpenDSJavaArgs, useSpecifiedJavaArgs
        useOpenDSJavaArgs, useSpecifiedJavaArgs, showAll
    };
  }
@@ -425,6 +426,31 @@
   */
  public void configurationChanged(ConfigurationChangeEvent ev)
  {
    final boolean isLocal = ev.getNewDescriptor().isLocal();
    if (isLocal != previousLocal)
    {
      previousLocal = isLocal;
      SwingUtilities.invokeLater(new Runnable()
      {
        /**
         * {@inheritDoc}
         */
        public void run()
        {
          if (!isLocal)
          {
            displayErrorMessage(INFO_CTRL_PANEL_SERVER_REMOTE_SUMMARY.get(),
            INFO_CTRL_PANEL_SERVER_MUST_BE_LOCAL_JAVA_PROPERTIES_SUMMARY.get());
            setEnabledOK(false);
          }
          else
          {
            displayMainPanel();
            setEnabledOK(true);
          }
        }
      });
    }
  }
  /**
@@ -433,9 +459,14 @@
  @Override
  public void toBeDisplayed(boolean visible)
  {
    if (visible && (firstDisplay || !updatedByUser()))
    boolean isLocal = true;
    if (getInfo() != null)
    {
      firstDisplay = false;
      isLocal = getInfo().getServerDescriptor().isLocal();
    }
    if (visible && isLocal && (!initialized || !updatedByUser()))
    {
      initialized = true;
      initContents();
    }
  }
@@ -1376,7 +1407,7 @@
      boolean canLaunch = true;
      if (!isServerRunning())
      {
        if (state == State.RUNNING)
        if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
        {
          // All the operations are incompatible if they apply to this
          // backend for safety.  This is a short operation so the limitation
opends/src/guitools/org/opends/guitools/controlpanel/ui/LocalOrRemotePanel.java
New file
@@ -0,0 +1,881 @@
/*
 * 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
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.ui;
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.messages.QuickSetupMessages.*;
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import javax.naming.ldap.InitialLdapContext;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import org.opends.admin.ads.util.ApplicationTrustManager;
import org.opends.admin.ads.util.ConnectionUtils;
import org.opends.guitools.controlpanel.datamodel.ConfigReadException;
import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
import org.opends.guitools.controlpanel.task.OnlineUpdateException;
import org.opends.guitools.controlpanel.util.BackgroundTask;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.messages.Message;
import org.opends.quicksetup.Installation;
import org.opends.quicksetup.UserDataCertificateException;
import org.opends.quicksetup.ui.CertificateDialog;
import org.opends.quicksetup.util.UIKeyStore;
import org.opends.quicksetup.util.Utils;
import org.opends.server.monitors.VersionMonitorProvider;
import org.opends.server.types.DN;
import org.opends.server.types.OpenDsException;
import org.opends.server.util.DynamicConstants;
/**
 * The panel that appears when the user is asked to provide authentication.
 *
 */
public class LocalOrRemotePanel extends StatusGenericPanel
{
  private static final long serialVersionUID = 5051556513294844797L;
  private JComboBox combo;
  private JLabel portLabel;
  private JTextField hostName;
  private JTextField port;
  private JPasswordField pwd;
  private JTextField dn;
  private JLabel pwdLabel;
  private JLabel dnLabel;
  private String usedUrl;
  private JLabel localInstallLabel;
  private JLabel localInstall;
  private JLabel localNotRunning;
  private boolean isLocalServerRunning;
  private static final Logger LOG =
    Logger.getLogger(LocalOrRemotePanel.class.getName());
  /**
   * Default constructor.
   *
   */
  public LocalOrRemotePanel()
  {
    super();
    createLayout();
  }
  /**
   * {@inheritDoc}
   */
  public Message getTitle()
  {
    return INFO_CTRL_PANEL_LOCAL_OR_REMOTE_PANEL_TITLE.get();
  }
  /**
   * {@inheritDoc}
   */
  public GenericDialog.ButtonType getButtonType()
  {
    return GenericDialog.ButtonType.OK_CANCEL;
  }
  /**
   * Creates the layout of the panel (but the contents are not populated here).
   */
  private void createLayout()
  {
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 0.0;
    gbc.weighty = 0.0;
    String localServerInstallPath;
    File instancePath = Installation.getLocal().getInstanceDirectory();
    try
    {
      localServerInstallPath = instancePath.getCanonicalPath();
    }
    catch (IOException ioe)
    {
      localServerInstallPath = instancePath.getAbsolutePath();
    }
    combo = Utilities.createComboBox();
    combo.setModel(new DefaultComboBoxModel(
        new Object[] {INFO_CTRL_PANEL_LOCAL_SERVER.get(),
            INFO_CTRL_PANEL_REMOTE_SERVER.get()}));
    combo.setSelectedIndex(0);
    gbc.gridwidth = 2;
    add(Utilities.createDefaultLabel(INFO_CTRL_PANEL_LOCAL_OR_REMOTE.get()),
        gbc);
    gbc.gridwidth = 1;
    gbc.insets.top = 10;
    gbc.gridy ++;
    add(combo, gbc);
    gbc.gridx = 1;
    localNotRunning = Utilities.createDefaultLabel();
    Utilities.setWarningLabel(localNotRunning,
        INFO_CTRL_PANEL_LOCAL_SERVER_NOT_RUNNING.get());
    gbc.insets.left = 10;
    add(localNotRunning, gbc);
    hostName = Utilities.createMediumTextField();
    add(hostName, gbc);
    gbc.insets.top = 10;
    gbc.gridy ++;
    gbc.insets.left = 0;
    gbc.weightx = 0.0;
    gbc.insets.right = 0;
    gbc.gridx = 0;
    ActionListener actionListener = new ActionListener()
    {
      public void actionPerformed(ActionEvent ev)
      {
        updateComponentState();
      }
    };
    combo.addActionListener(actionListener);
    gbc.gridx = 0;
    gbc.gridwidth = 1;
    localInstallLabel = Utilities.createPrimaryLabel(
        INFO_CTRL_PANEL_INSTANCE_PATH_LABEL.get());
    gbc.insets.left = 0;
    add(localInstallLabel, gbc);
    gbc.gridx = 1;
    gbc.insets.left = 10;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    localInstall = Utilities.createDefaultLabel();
    localInstall.setText(localServerInstallPath);
    add(localInstall, gbc);
    gbc.gridy ++;
    gbc.insets.top = 10;
    gbc.insets.left = 0;
    gbc.gridx = 0;
    gbc.weightx = 0.0;
    portLabel = Utilities.createPrimaryLabel(
        INFO_CTRL_PANEL_ADMINISTRATION_PORT.get());
    add(portLabel, gbc);
    gbc.gridx = 1;
    gbc.insets.left = 10;
    port = Utilities.createMediumTextField();
    port.setText("4444");
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    add(port, gbc);
    gbc.gridy ++;
    gbc.gridx = 0;
    gbc.weightx = 0.0;
    gbc.fill = GridBagConstraints.NONE;
    gbc.insets.left = 0;
    dnLabel = Utilities.createPrimaryLabel(INFO_CTRL_PANEL_BIND_DN_LABEL.get());
    add(dnLabel, gbc);
    gbc.insets.left = 10;
    gbc.gridx = 1;
    dn = Utilities.createTextField("cn=Directory Manager", 20);
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets.left = 10;
    add(dn, gbc);
    gbc.insets.top = 10;
    gbc.insets.left = 0;
    gbc.gridx = 0;
    gbc.gridy ++;
    gbc.weightx = 0.0;
    gbc.fill = GridBagConstraints.NONE;
    pwdLabel = Utilities.createPrimaryLabel(
        INFO_CTRL_PANEL_BIND_PASSWORD_LABEL.get());
    gbc.insets.left = 0;
    add(pwdLabel, gbc);
    gbc.insets.left = 10;
    gbc.gridx = 1;
    pwd = Utilities.createPasswordField();
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    add(pwd, gbc);
    addBottomGlue(gbc);
  }
  /**
   * {@inheritDoc}
   */
  public Component getPreferredFocusComponent()
  {
    return pwd;
  }
  /**
   * {@inheritDoc}
   */
  public void configurationChanged(ConfigurationChangeEvent ev)
  {
  }
  /**
   * {@inheritDoc}
   */
  public void toBeDisplayed(boolean visible)
  {
    super.toBeDisplayed(visible);
    if (visible)
    {
      // Do it outside the event thread if the panel requires it.
      BackgroundTask<Void> worker = new BackgroundTask<Void>()
      {
        public Void processBackgroundTask() throws Throwable
        {
          try
          {
            Thread.sleep(200);
          }
          catch (Throwable t)
          {
          }
          File instancePath = Installation.getLocal().getInstanceDirectory();
          isLocalServerRunning = Utilities.isServerRunning(instancePath);
          return null;
        }
        public void backgroundTaskCompleted(Void returnValue,
            Throwable t)
        {
          updateComponentState();
          displayMainPanel();
        }
      };
      displayMessage(INFO_CTRL_PANEL_LOADING_PANEL_SUMMARY.get());
      worker.startBackgroundTask();
      pwd.setText("");
    }
  }
  /**
   * {@inheritDoc}
   */
  public void okClicked()
  {
    setPrimaryValid(portLabel);
    setPrimaryValid(dnLabel);
    setPrimaryValid(pwdLabel);
    final LinkedHashSet<Message> errors = new LinkedHashSet<Message>();
    boolean dnInvalid = false;
    boolean pwdInvalid = false;
    final boolean isLocal = combo.getSelectedIndex() == 0;
    boolean doChecks = !isLocal || isLocalServerRunning;
    if (doChecks)
    {
      if ("".equals(dn.getText().trim()))
      {
        dnInvalid = true;
        errors.add(INFO_EMPTY_DIRECTORY_MANAGER_DN.get());
      }
      else if (!Utils.isDn(dn.getText()))
      {
        dnInvalid = true;
        errors.add(INFO_NOT_A_DIRECTORY_MANAGER_DN.get());
      }
      if ("".equals(pwd.getPassword().length == 0))
      {
        pwdInvalid = true;
        errors.add(INFO_EMPTY_PWD.get());
      }
      if (dnInvalid)
      {
        setPrimaryInvalid(dnLabel);
      }
      if (pwdInvalid)
      {
        setPrimaryInvalid(pwdLabel);
      }
      if (!isLocal)
      {
        if ("".equals(hostName.getText().trim()))
        {
          errors.add(INFO_EMPTY_REMOTE_HOST_NAME.get());
        }
        try
        {
          int p = Integer.parseInt(port.getText());
          if ((p <= 0) || (p > 65535))
          {
            errors.add(INFO_INVALID_REMOTE_SERVER_PORT.get(0, 65535));
          }
        }
        catch (Throwable t)
        {
          errors.add(INFO_INVALID_REMOTE_SERVER_PORT.get(0, 65535));
        }
      }
    }
    if (errors.isEmpty())
    {
      setEnabledOK(false);
      displayMessage(INFO_CTRL_PANEL_VERIFYING_AUTHENTICATION_SUMMARY.get());
      BackgroundTask<InitialLdapContext> worker =
        new BackgroundTask<InitialLdapContext>()
      {
        /**
         * {@inheritDoc}
         */
        public InitialLdapContext processBackgroundTask() throws Throwable
        {
          getInfo().stopPooling();
          if (isLocal)
          {
            // At least load the local information.
            SwingUtilities.invokeLater(new Runnable()
            {
              public void run()
              {
                displayMessage(
                    INFO_CTRL_PANEL_READING_CONFIGURATION_SUMMARY.get());
              }
            });
            if (getInfo().isLocal() != isLocal)
            {
              closeInfoConnections();
            }
            getInfo().setIsLocal(isLocal);
            getInfo().regenerateDescriptor();
            if (!isLocalServerRunning)
            {
              return null;
            }
          }
          InitialLdapContext ctx = null;
          try
          {
            if (isLocal)
            {
              usedUrl = getInfo().getAdminConnectorURL();
              ctx = Utilities.getAdminDirContext(getInfo(), dn.getText(),
                  String.valueOf(pwd.getPassword()));
            }
            else
            {
              usedUrl =
                "ldaps://"+hostName.getText().trim()+":"+port.getText().trim();
              ctx = Utils.createLdapsContext(usedUrl, dn.getText(),
                  String.valueOf(pwd.getPassword()),
                  Utils.getDefaultLDAPTimeout(), null,
                  getInfo().getTrustManager());
              checkVersion(ctx);
            }
            try
            {
              Thread.sleep(500);
            }
            catch (Throwable t)
            {
            }
            SwingUtilities.invokeLater(new Runnable()
            {
              public void run()
              {
                displayMessage(
                    INFO_CTRL_PANEL_READING_CONFIGURATION_SUMMARY.get());
              }
            });
            closeInfoConnections();
            getInfo().setIsLocal(isLocal);
            getInfo().setDirContext(ctx);
            getInfo().setUserDataDirContext(null);
            getInfo().regenerateDescriptor();
            return ctx;
          } catch (Throwable t)
          {
            if (ctx != null)
            {
              try
              {
                ctx.close();
              }
              catch (Throwable t1)
              {
              }
            }
            throw t;
          }
        }
        /**
         * {@inheritDoc}
         */
        public void backgroundTaskCompleted(InitialLdapContext ctx,
            Throwable throwable)
        {
          boolean handleCertificateException = false;
          boolean localServerErrorConnecting = false;
          if (throwable != null)
          {
            LOG.log(Level.INFO, "Error connecting: " + throwable, throwable);
            if (isVersionException(throwable))
            {
              errors.add(((OpenDsException)throwable).getMessageObject());
            }
            else if (Utils.isCertificateException(throwable))
            {
              ApplicationTrustManager.Cause cause =
                getInfo().getTrustManager().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
              {
                Message msg = Utils.getThrowableMsg(
                    INFO_ERROR_CONNECTING_TO_LOCAL.get(), throwable);
                errors.add(msg);
              }
              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 = INFO_NOT_AVAILABLE_LABEL.get().toString();
                  p = -1;
                }
                UserDataCertificateException udce =
                  new UserDataCertificateException(null,
                      INFO_CERTIFICATE_EXCEPTION.get(h, String.valueOf(p)),
                      throwable, h, p,
                      getInfo().getTrustManager().getLastRefusedChain(),
                      getInfo().getTrustManager().getLastRefusedAuthType(),
                      excType);
                handleCertificateException(udce);
                handleCertificateException = true;
              }
            }
            else if (throwable instanceof NamingException)
            {
              boolean found = false;
              String providedDn = dn.getText();
              if (isLocal)
              {
                Iterator<DN> it = getInfo().getServerDescriptor().
                getAdministrativeUsers().iterator();
                while (it.hasNext() && !found)
                {
                  found = Utils.areDnsEqual(providedDn, it.next().toString());
                }
                if (!found)
                {
                  errors.add(INFO_NOT_A_DIRECTORY_MANAGER_IN_CONFIG.get());
                }
                else
                {
                  errors.add(ERR_CANNOT_CONNECT_TO_LOGIN_WITHOUT_CAUSE.get());
                }
                localServerErrorConnecting = true;
              }
              else
              {
                String msg = throwable.toString();
                errors.add(ERR_CANNOT_CONNECT_TO_REMOTE.get(
                    hostName.getText().trim(),
                    port.getText().trim(),
                    msg));
                setPrimaryInvalid(portLabel);
              }
              setPrimaryInvalid(dnLabel);
              setPrimaryInvalid(pwdLabel);
            }
            else if (throwable instanceof ConfigReadException)
            {
              LOG.log(Level.WARNING,
                  "Error reading configuration: "+throwable, throwable);
              errors.add(((ConfigReadException)throwable).getMessageObject());
            }
            else
            {
              // This is a bug
              LOG.log(Level.SEVERE,
                  "Unexpected error: "+throwable, throwable);
              errors.add(Utils.getThrowableMsg(INFO_BUG_MSG.get(), throwable));
            }
          }
          displayMainPanel();
          setEnabledOK(true);
          if (!errors.isEmpty())
          {
            if (!localServerErrorConnecting)
            {
              displayErrorDialog(errors);
            }
            else
            {
              ArrayList<String> stringErrors = new ArrayList<String>();
              for (Message err : errors)
              {
                stringErrors.add(err.toString());
              }
              String msg = Utilities.getStringFromCollection(stringErrors,
                  "<br>");
              if (displayConfirmationDialog(
                  INFO_CTRL_PANEL_CONFIRMATION_REQUIRED_SUMMARY.get(),
                  INFO_CTRL_PANEL_ERROR_CONNECTING_TO_LOCAL.get(msg)))
              {
                Utilities.getParentDialog(
                    LocalOrRemotePanel.this).setVisible(false);
              }
            }
            pwd.setSelectionStart(0);
            pwd.setSelectionEnd(pwd.getPassword().length);
            pwd.requestFocusInWindow();
          }
          else if (!handleCertificateException)
          {
            Utilities.getParentDialog(
                LocalOrRemotePanel.this).setVisible(false);
          }
          if (!handleCertificateException)
          {
            startPooling();
          }
        }
      };
      worker.startBackgroundTask();
    }
    else
    {
      displayErrorDialog(errors);
      if (dnInvalid)
      {
        dn.setSelectionStart(0);
        dn.setSelectionEnd(dn.getText().length());
        dn.requestFocusInWindow();
      }
      if (pwdInvalid)
      {
        pwd.setSelectionStart(0);
        pwd.setSelectionEnd(pwd.getPassword().length);
        pwd.requestFocusInWindow();
      }
    }
  }
  /**
   * {@inheritDoc}
   */
  public void cancelClicked()
  {
    setPrimaryValid(dnLabel);
    setPrimaryValid(pwdLabel);
    setPrimaryValid(portLabel);
    pwd.setText(null);
    super.cancelClicked();
  }
  /**
   * 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(null, ce);
    dlg.pack();
    Utilities.centerGoldenMean(dlg, Utilities.getParentDialog(this));
    dlg.setVisible(true);
    if (dlg.getUserAnswer() !=
      CertificateDialog.ReturnType.NOT_ACCEPTED)
    {
      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);
        getInfo().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");
        }
      }
    }
    if (dlg.getUserAnswer() ==
      CertificateDialog.ReturnType.ACCEPTED_PERMANENTLY)
    {
      X509Certificate[] chain = ce.getChain();
      if (chain != null)
      {
        try
        {
          UIKeyStore.acceptCertificate(chain);
        }
        catch (Throwable t)
        {
          LOG.log(Level.WARNING, "Error accepting certificate: "+t, t);
        }
      }
    }
  }
  private void updateComponentState()
  {
    boolean isLocal = combo.getSelectedIndex() == 0;
    hostName.setVisible(!isLocal);
    port.setVisible(!isLocal);
    portLabel.setVisible(!isLocal);
    localInstall.setVisible(isLocal);
    localInstallLabel.setVisible(isLocal);
    boolean displayAuthentication = !isLocal || isLocalServerRunning;
    dn.setVisible(displayAuthentication);
    dnLabel.setVisible(displayAuthentication);
    pwd.setVisible(displayAuthentication);
    pwdLabel.setVisible(displayAuthentication);
    localNotRunning.setVisible(isLocal && !isLocalServerRunning);
  }
  private void startPooling()
  {
    // The server descriptor has been already retrieved.
    // startPooling tries to retrieve immediately the server descriptor, so
    // sleep the pooling period before calling it.
    Thread t = new Thread(new Runnable()
    {
      public void run()
      {
        try
        {
          Thread.sleep(getInfo().getPoolingPeriod());
        }
        catch (Throwable t)
        {
        }
        getInfo().startPooling();
      }
    });
    t.start();
  }
  private void checkVersion(InitialLdapContext ctx) throws OpenDsException
  {
    Message msg = null;
    try
    {
      /*
       * Search for the version on the remote server.
       */
      SearchControls searchControls = new SearchControls();
      searchControls.setCountLimit(1);
      searchControls.setSearchScope(
      SearchControls.OBJECT_SCOPE);
      searchControls.setReturningAttributes(
      new String[] {
          VersionMonitorProvider.ATTR_PRODUCT_NAME,
          VersionMonitorProvider.ATTR_MAJOR_VERSION,
          VersionMonitorProvider.ATTR_POINT_VERSION,
          VersionMonitorProvider.ATTR_MINOR_VERSION
          });
      NamingEnumeration<SearchResult> en =
        ctx.search("cn=Version,cn=monitor", "objectclass=*",
          searchControls);
      SearchResult sr = en.next();
      CustomSearchResult csr =
        new CustomSearchResult(sr, "cn=Version,cn=monitor");
      String hostName = ConnectionUtils.getHostName(ctx);
      String productName = String.valueOf(Utilities.getFirstMonitoringValue(csr,
          VersionMonitorProvider.ATTR_PRODUCT_NAME));
      String major = String.valueOf(Utilities.getFirstMonitoringValue(csr,
          VersionMonitorProvider.ATTR_MAJOR_VERSION));
      String point = String.valueOf(Utilities.getFirstMonitoringValue(csr,
          VersionMonitorProvider.ATTR_POINT_VERSION));
      String minor = String.valueOf(Utilities.getFirstMonitoringValue(csr,
          VersionMonitorProvider.ATTR_MINOR_VERSION));
      // Be strict, control panel is only compatible with exactly the same
      // version.
      if (!productName.equalsIgnoreCase(DynamicConstants.PRODUCT_NAME))
      {
        msg = ERR_NOT_SAME_PRODUCT_IN_REMOTE_SERVER_NOT_FOUND.get(hostName,
            productName, DynamicConstants.PRODUCT_NAME);
      }
      else
      {
        if (!String.valueOf(DynamicConstants.MAJOR_VERSION).equals(major) ||
            !String.valueOf(DynamicConstants.MINOR_VERSION).equals(minor) ||
            !String.valueOf(DynamicConstants.POINT_VERSION).equals(point))
        {
          msg = ERR_INCOMPATIBLE_VERSION_IN_REMOTE_SERVER.get(hostName,
              major, minor, point, DynamicConstants.MAJOR_VERSION,
              DynamicConstants.MINOR_VERSION, DynamicConstants.POINT_VERSION);
        }
      }
    }
    catch (Throwable t)
    {
      msg = ERR_VERSION_IN_REMOTE_SERVER_NOT_FOUND.get();
    }
    if (msg != null)
    {
      throw new OnlineUpdateException(msg, null);
    }
  }
  private boolean isVersionException(Throwable t)
  {
    boolean isVersionException = false;
    if (t instanceof OpenDsException)
    {
      OpenDsException oe = (OpenDsException)t;
      if (oe.getMessageObject() != null)
      {
        if (oe.getMessageObject().getDescriptor().equals
            (ERR_INCOMPATIBLE_VERSION_IN_REMOTE_SERVER) ||
            oe.getMessageObject().getDescriptor().equals
            (ERR_VERSION_IN_REMOTE_SERVER_NOT_FOUND) ||
            oe.getMessageObject().getDescriptor().equals
            (ERR_NOT_SAME_PRODUCT_IN_REMOTE_SERVER_NOT_FOUND))
        {
          isVersionException = true;
        }
      }
    }
    return isVersionException;
  }
  private void closeInfoConnections()
  {
    if (getInfo().getDirContext() != null)
    {
      try
      {
        getInfo().getDirContext().close();
      }
      catch (Throwable t)
      {
      }
    }
    if (getInfo().getUserDataDirContext() != null)
    {
      try
      {
        getInfo().getUserDataDirContext().close();
      }
      catch (Throwable t)
      {
      }
    }
  }
}
opends/src/guitools/org/opends/guitools/controlpanel/ui/MainMenuBar.java
@@ -79,29 +79,7 @@
   */
  protected void addMenus()
  {
    JMenu menu;
    JMenuItem menuItem;
    if (!Utilities.isMacOS())
    {
      menu = Utilities.createMenu(INFO_CTRL_PANEL_FILE_MENU.get(),
          INFO_CTRL_PANEL_FILE_MENU_DESCRIPTION.get());
      menu.setMnemonic(KeyEvent.VK_F);
      menuItem = Utilities.createMenuItem(INFO_CTRL_PANEL_EXIT_MENU.get());
      menuItem.addActionListener(new ActionListener()
      {
        /**
         * {@inheritDoc}
         */
        public void actionPerformed(ActionEvent ev)
        {
          quitClicked();
        }
      });
      menu.add(menuItem);
      add(menu);
    }
    add(createFileMenuBar());
    add(createViewMenuBar());
    add(createHelpMenuBar());
  }
@@ -138,7 +116,44 @@
    }
  }
  /**
   * Creates the File menu bar.
   * @return the File menu bar.
   */
  protected JMenu createFileMenuBar()
  {
    JMenu menu = Utilities.createMenu(INFO_CTRL_PANEL_FILE_MENU.get(),
        INFO_CTRL_PANEL_FILE_MENU_DESCRIPTION.get());
    menu.setMnemonic(KeyEvent.VK_F);
    if (!Utilities.isMacOS())
    {
      JMenuItem menuItem =
        Utilities.createMenuItem(INFO_CTRL_PANEL_EXIT_MENU.get());
      menuItem.addActionListener(new ActionListener()
      {
        /**
         * {@inheritDoc}
         */
        public void actionPerformed(ActionEvent ev)
        {
          quitClicked();
        }
      });
      menu.add(menuItem);
    }
    JMenuItem menuItem = Utilities.createMenuItem(
        INFO_CTRL_PANEL_CONNECT_TO_SERVER_MENU.get());
    menu.setMnemonic(KeyEvent.VK_R);
    menuItem.addActionListener(new ActionListener()
    {
      public void actionPerformed(ActionEvent ev)
      {
        connectToServerClicked();
      }
    });
    menu.add(menuItem);
    return menu;
  }
  /**
   * Creates the View menu bar.
@@ -231,4 +246,38 @@
      getInfo().startPooling();
    }
  }
  /**
   * The method called when the user clicks on 'Connect to Server...'.
   */
  protected void connectToServerClicked()
  {
    Set<String> runningTasks = new HashSet<String>();
    for (Task task : getInfo().getTasks())
    {
      if (task.getState() == Task.State.RUNNING)
      {
        runningTasks.add(task.getTaskDescription().toString());
      }
    }
    boolean confirmed = true;
    if (runningTasks.size() > 0)
    {
      String allTasks = Utilities.getStringFromCollection(runningTasks, "<br>");
      Message title = INFO_CTRL_PANEL_CONFIRMATION_REQUIRED_SUMMARY.get();
      Message msg =
        INFO_CTRL_PANEL_RUNNING_TASKS_CHANGE_SERVER_CONFIRMATION_DETAILS.get(
            allTasks);
      confirmed = Utilities.displayConfirmationDialog(
          Utilities.getParentDialog(this), title, msg);
    }
    if (confirmed)
    {
      GenericDialog dlg =
        ControlCenterMainPane.getLocalOrRemoteDialog(getInfo());
      Utilities.centerGoldenMean(dlg,
          Utilities.getFrame(MainMenuBar.this));
      dlg.setVisible(true);
    }
  }
}
opends/src/guitools/org/opends/guitools/controlpanel/ui/NewAttributePanel.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.ui;
@@ -361,7 +361,9 @@
    if (!error[0])
    {
      updateErrorPaneAndOKButtonIfAuthRequired(desc,
     INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_TO_CREATE_ATTRIBUTE_SUMMARY.get());
          isLocal() ?
     INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_TO_CREATE_ATTRIBUTE_SUMMARY.get() :
     INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
    }
  }
opends/src/guitools/org/opends/guitools/controlpanel/ui/NewBaseDNPanel.java
@@ -84,6 +84,7 @@
import org.opends.guitools.controlpanel.util.ConfigReader;
import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.messages.Message;
import org.opends.quicksetup.Installation;
import org.opends.quicksetup.installer.InstallerHelper;
import org.opends.quicksetup.util.Utils;
import org.opends.server.admin.client.ManagementContext;
@@ -98,6 +99,8 @@
import org.opends.server.config.DNConfigAttribute;
import org.opends.server.core.DirectoryServer;
import org.opends.server.tools.ImportLDIF;
import org.opends.server.tools.LDAPModify;
import org.opends.server.tools.makeldif.MakeLDIF;
import org.opends.server.types.AttributeValue;
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
@@ -123,6 +126,7 @@
  private JRadioButton importAutomaticallyGenerated;
  private JTextField path;
  private JTextField numberOfEntries;
  private JLabel lRemoteFileHelp;
  private JButton browseImportPath;
  private JLabel lBackend;
@@ -342,6 +346,7 @@
      {
        browseImportPath.setEnabled(importDataFromLDIF.isSelected());
        lPath.setEnabled(importDataFromLDIF.isSelected());
        lRemoteFileHelp.setEnabled(importDataFromLDIF.isSelected());
        numberOfEntries.setEnabled(importAutomaticallyGenerated.isSelected());
        lNumberOfEntries.setEnabled(importAutomaticallyGenerated.isSelected());
      }
@@ -380,8 +385,18 @@
    newElements.add(NEW_BACKEND);
    super.updateComboBoxModel(newElements,
        ((DefaultComboBoxModel)backends.getModel()));
    updateErrorPaneAndOKButtonIfAuthRequired(getInfo().getServerDescriptor(),
        INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_CREATE_BASE_DN.get());
    updateErrorPaneAndOKButtonIfAuthRequired(desc,
      isLocal() ?
          INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_CREATE_BASE_DN.get() :
      INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
    SwingUtilities.invokeLater(new Runnable()
    {
      public void run()
      {
        lRemoteFileHelp.setVisible(!isLocal());
        browseImportPath.setVisible(isLocal());
      }
    });
  }
  private JPanel createPathPanel()
@@ -390,6 +405,8 @@
    panel.setOpaque(false);
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridwidth = 1;
    gbc.gridy = 0;
    gbc.gridx = 0;
    lPath = Utilities.createDefaultLabel(
        INFO_CTRL_PANEL_IMPORT_LDIF_PATH_LABEL.get());
    panel.add(lPath, gbc);
@@ -409,6 +426,14 @@
    gbc.weightx = 0.0;
    panel.add(browseImportPath, gbc);
    gbc.gridy ++;
    gbc.gridx = 1;
    lRemoteFileHelp = Utilities.createInlineHelpLabel(
        INFO_CTRL_PANEL_REMOTE_SERVER_PATH.get());
    gbc.insets.top = 3;
    gbc.insets.left = 10;
    panel.add(lRemoteFileHelp, gbc);
    return panel;
  }
@@ -573,7 +598,7 @@
      {
        errors.add(INFO_NO_LDIF_PATH.get());
        setSecondaryInvalid(lPath);
      } else if (!Utils.fileExists(ldifPath))
      } else if (isLocal() && !Utils.fileExists(ldifPath))
      {
        errors.add(INFO_LDIF_FILE_DOES_NOT_EXIST.get());
        setSecondaryInvalid(lPath);
@@ -584,7 +609,7 @@
    {
      String nEntries = numberOfEntries.getText();
      int minValue = 1;
      int maxValue = 20000;
      int maxValue = isLocal() ? 20000 : 1000;
      Message errMsg = ERR_NUMBER_OF_ENTRIES_INVALID.get(minValue, maxValue);
      checkIntValue(errors, nEntries, minValue, maxValue, errMsg);
    }
@@ -714,7 +739,7 @@
        Collection<Message> incompatibilityReasons)
    {
      boolean canLaunch = true;
      if (state == State.RUNNING)
      if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
      {
        // All the operations are incompatible if they apply to this
        // backend.
@@ -758,10 +783,17 @@
      String cmdLineName;
      if (!leaveDatabaseEmpty.isSelected())
      {
        if (isLocal())
        {
        cmdLineName = getCommandLinePath("import-ldif");
      }
      else
      {
          cmdLineName = getCommandLinePath("ldapmodify");
        }
      }
      else
      {
        cmdLineName = null;
      }
      return cmdLineName;
@@ -781,6 +813,8 @@
      ArrayList<String> args = new ArrayList<String>();
      if (!leaveDatabaseEmpty.isSelected())
      {
        if (isLocal())
        {
        if (!useTemplate)
        {
          args.add("--ldifFile");
@@ -796,10 +830,16 @@
        args.add("--backendID");
        args.add(getBackendName());
        args.add("--append");
        }
        else
        {
          args.add("-a");
          args.add("-f");
          args.add(ldifFile);
        }
        args.addAll(getConnectionCommandLineArguments(true, !isLocal()));
        args.addAll(getConnectionCommandLineArguments());
        if (isServerRunning())
        if (isServerRunning() && isLocal())
        {
          args.addAll(getConfigCommandLineArguments());
        }
@@ -816,7 +856,6 @@
      {
        if (!isServerRunning())
        {
          configHandlerUpdated = true;
          getInfo().stopPooling();
          if (getInfo().mustDeregisterConfig())
          {
@@ -826,6 +865,7 @@
                org.opends.server.extensions.ConfigFileHandler.class.getName(),
                ConfigReader.configFile);
          getInfo().setMustDeregisterConfig(true);
          configHandlerUpdated = true;
        }
        else
        {
@@ -1009,22 +1049,68 @@
          {
            public void run()
            {
              if (isLocal())
              {
               progressDialog.appendProgressHtml(Utilities.applyFont(
                   INFO_PROGRESS_IMPORT_AUTOMATICALLY_GENERATED.get(nEntries).
                   toString(), ColorAndFontConstants.progressFont)+"<br>");
            }
              else
              {
                getProgressDialog().appendProgressHtml(
                    Utilities.getProgressWithPoints(
              INFO_PROGRESS_IMPORT_AUTOMATICALLY_GENERATED_REMOTE.get(nEntries),
                      ColorAndFontConstants.progressFont));
              }
            }
          });
          File f = SetupUtils.createTemplateFile(newBaseDN,
              Integer.parseInt(nEntries));
          if (!isLocal())
          {
            File tempFile = File.createTempFile("opends-control-panel",
                ".ldif");
            tempFile.deleteOnExit();
            ldifFile = tempFile.getAbsolutePath();
            // Create the LDIF file locally using make-ldif
            ArrayList<String> makeLDIFArgs = new ArrayList<String>();
            makeLDIFArgs.add("--templateFile");
            makeLDIFArgs.add(f.getAbsolutePath());
            makeLDIFArgs.add("--ldifFile");
            makeLDIFArgs.add(ldifFile);
            makeLDIFArgs.add("--randomSeed");
            makeLDIFArgs.add("0");
            makeLDIFArgs.add("--resourcePath");
            File makeLDIFPath =
              new File(Installation.getLocal().getConfigurationDirectory(),
                  "MakeLDIF");
            makeLDIFArgs.add(makeLDIFPath.getAbsolutePath());
            makeLDIFArgs.addAll(getConfigCommandLineArguments());
            MakeLDIF makeLDIF = new MakeLDIF();
            String[] array = new String[makeLDIFArgs.size()];
            makeLDIFArgs.toArray(array);
            returnCode = makeLDIF.makeLDIFMain(array, false, false,
                outPrintStream, errorPrintStream);
            f.delete();
            if (returnCode != 0)
            {
              throw new OnlineUpdateException(
                  ERR_CTRL_PANEL_ERROR_CREATING_NEW_DATA_LDIF.get(returnCode),
                  null);
            }
          }
          else
          {
          ldifFile = f.getAbsolutePath();
        }
        }
        ArrayList<String> arguments = getDataCommandLineArguments(ldifFile,
            generateData);
        String[] args = new String[arguments.size()];
        arguments.toArray(args);
        if (createBaseEntry)
        if (createBaseEntry || !isLocal())
        {
          outPrintStream.setNotifyListeners(false);
          errorPrintStream.setNotifyListeners(false);
@@ -1033,17 +1119,26 @@
        {
          if (isServerRunning())
          {
            returnCode = ImportLDIF.mainImportLDIF(args, false, outPrintStream,
            if (isLocal() || importLDIF)
            {
              returnCode = ImportLDIF.mainImportLDIF(args, false,
                  outPrintStream,
                errorPrintStream);
          }
          else
          {
              returnCode = LDAPModify.mainModify(args,  false,
                  outPrintStream,
                  errorPrintStream);
            }
          }
          else
          {
            returnCode = executeCommandLine(getDataCommandLineName(), args);
          }
        }
        finally
        {
          if (createBaseEntry)
          {
            outPrintStream.setNotifyListeners(true);
            errorPrintStream.setNotifyListeners(true);
@@ -1056,7 +1151,7 @@
        }
        else
        {
          if (createBaseEntry)
          if (createBaseEntry || (!isLocal() && generateData))
          {
            SwingUtilities.invokeLater(new Runnable()
            {
opends/src/guitools/org/opends/guitools/controlpanel/ui/NewIndexPanel.java
@@ -269,7 +269,8 @@
    if (!error[0])
    {
      updateErrorPaneAndOKButtonIfAuthRequired(desc,
          INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_NEW_INDEX.get());
       isLocal() ? INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_NEW_INDEX.get() :
      INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
    }
  }
@@ -448,7 +449,7 @@
        Collection<Message> incompatibilityReasons)
    {
      boolean canLaunch = true;
      if (state == State.RUNNING)
      if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
      {
        // All the operations are incompatible if they apply to this
        // backend for safety.  This is a short operation so the limitation
opends/src/guitools/org/opends/guitools/controlpanel/ui/NewObjectClassPanel.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.ui;
@@ -247,7 +247,9 @@
    if (!error[0])
    {
      updateErrorPaneAndOKButtonIfAuthRequired(desc,
   INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_TO_CREATE_OBJECTCLASS_SUMMARY.get());
          isLocal() ?
   INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_TO_CREATE_OBJECTCLASS_SUMMARY.get() :
     INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
    }
  }
opends/src/guitools/org/opends/guitools/controlpanel/ui/NewVLVIndexPanel.java
@@ -44,6 +44,7 @@
import org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
import org.opends.guitools.controlpanel.datamodel.VLVIndexDescriptor;
import org.opends.guitools.controlpanel.datamodel.VLVSortOrder;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
@@ -91,7 +92,6 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public Message getTitle()
  {
    return INFO_CTRL_PANEL_NEW_VLV_INDEX_TITLE.get();
@@ -100,7 +100,6 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public Component getPreferredFocusComponent()
  {
    return name;
@@ -111,10 +110,12 @@
   */
  public void configurationChanged(ConfigurationChangeEvent ev)
  {
    if (updateLayout(ev.getNewDescriptor()))
    ServerDescriptor desc = ev.getNewDescriptor();
    if (updateLayout(desc))
    {
      updateErrorPaneAndOKButtonIfAuthRequired(ev.getNewDescriptor(),
          INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_NEW_VLV.get());
      updateErrorPaneAndOKButtonIfAuthRequired(desc,
         isLocal() ? INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_NEW_VLV.get() :
      INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
    }
  }
@@ -131,7 +132,6 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void okClicked()
  {
    List<Message> errors = checkErrors(true);
@@ -214,7 +214,6 @@
    /**
     * {@inheritDoc}
     */
    @Override
    public Type getType()
    {
      return Type.NEW_INDEX;
@@ -223,7 +222,6 @@
    /**
     * {@inheritDoc}
     */
    @Override
    public Set<String> getBackends()
    {
      return backendSet;
@@ -232,7 +230,6 @@
    /**
     * {@inheritDoc}
     */
    @Override
    public Message getTaskDescription()
    {
      return INFO_CTRL_PANEL_NEW_VLV_INDEX_TASK_DESCRIPTION.get(
@@ -242,12 +239,11 @@
    /**
     * {@inheritDoc}
     */
    @Override
    public boolean canLaunch(Task taskToBeLaunched,
        Collection<Message> incompatibilityReasons)
    {
      boolean canLaunch = true;
      if (state == State.RUNNING)
      if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
      {
        // All the operations are incompatible if they apply to this
        // backend for safety.  This is a short operation so the limitation
opends/src/guitools/org/opends/guitools/controlpanel/ui/RebuildIndexPanel.java
@@ -228,7 +228,7 @@
   * Refresh the contents of the panel with the provided server descriptor.
   * @param desc the server descriptor.
   */
  private void refreshContents(ServerDescriptor desc)
  private void refreshContents(final ServerDescriptor desc)
  {
    updateIndexMap(desc, hmIndexes);
    updateBaseDNComboBoxModel((DefaultComboBoxModel)baseDNs.getModel(), desc);
@@ -249,7 +249,9 @@
    if (!allDisabled)
    {
      updateErrorPaneAndOKButtonIfAuthRequired(desc,
          INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_DISABLE_BACKEND.get());
        isLocal() ?
            INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_DISABLE_BACKEND.get() :
      INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
    }
    SwingUtilities.invokeLater(new Runnable()
    {
@@ -277,6 +279,17 @@
        addRemove.getSelectedList().repaint();
        Utilities.updateViewPositions(pos);
        if (!desc.isLocal() && false)
        {
          displayErrorMessage(INFO_CTRL_PANEL_SERVER_REMOTE_SUMMARY.get(),
          INFO_CTRL_PANEL_SERVER_MUST_BE_LOCAL_REBUILD_INDEX_SUMMARY.get());
          setEnabledOK(false);
        }
        else
        {
          displayMainPanel();
          setEnabledOK(true);
        }
      }
    });
  }
opends/src/guitools/org/opends/guitools/controlpanel/ui/RestorePanel.java
@@ -38,6 +38,8 @@
import java.util.Set;
import java.util.TreeSet;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
@@ -45,6 +47,7 @@
import org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
import org.opends.guitools.controlpanel.datamodel.BackupDescriptor;
import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
import org.opends.guitools.controlpanel.event.BackupCreatedEvent;
import org.opends.guitools.controlpanel.event.BackupCreatedListener;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
@@ -62,6 +65,8 @@
{
  private static final long serialVersionUID = -205585323128518051L;
  private ListSelectionListener listener;
  private JLabel lBackupID;
  private JTextField backupID;
  /**
   * Constructor of the panel.
@@ -140,9 +145,22 @@
   */
  public void configurationChanged(ConfigurationChangeEvent ev)
  {
    final ServerDescriptor desc = ev.getNewDescriptor();
    SwingUtilities.invokeLater(new Runnable()
    {
      /**
       * {@inheritDoc}
       */
      public void run()
      {
        lBackupID.setVisible(!desc.isLocal());
        backupID.setVisible(!desc.isLocal());
      }
    });
    super.configurationChanged(ev);
    updateErrorPaneAndOKButtonIfAuthRequired(getInfo().getServerDescriptor(),
        INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_RESTORE.get());
    updateErrorPaneAndOKButtonIfAuthRequired(desc,
        isLocal() ? INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_RESTORE.get() :
      INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
  }
  /**
@@ -194,6 +212,24 @@
    super.createLayout(gbc);
    gbc.insets.top = 10;
    gbc.gridx = 0;
    gbc.gridy ++;
    gbc.insets.left = 0;
    gbc.gridwidth = 1;
    lBackupID = Utilities.createPrimaryLabel(
        INFO_CTRL_PANEL_BACKUP_ID_LABEL.get());
    add(lBackupID, gbc);
    backupID = Utilities.createMediumTextField();
    gbc.weightx = 0.0;
    gbc.gridx = 1;
    gbc.insets.left = 10;
    gbc.insets.right = 40;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.gridwidth = 2;
    add(backupID, gbc);
    listener = new ListSelectionListener()
    {
      public void valueChanged(ListSelectionEvent ev)
@@ -203,6 +239,8 @@
      }
    };
    backupList.getSelectionModel().addListSelectionListener(listener);
    addBottomGlue(gbc);
  }
  /**
@@ -220,11 +258,14 @@
  {
    setPrimaryValid(lPath);
    setPrimaryValid(lAvailableBackups);
    setPrimaryValid(lBackupID);
    final LinkedHashSet<Message> errors = new LinkedHashSet<Message>();
    BackupDescriptor backup = getSelectedBackup();
    if (isLocal())
    {
    boolean selected = backupList.isVisible() && (backup != null);
    if (!selected)
    {
@@ -239,6 +280,23 @@
      }
      setPrimaryInvalid(lAvailableBackups);
    }
    }
    else
    {
      String parentPath = parentDirectory.getText();
      if ((parentPath == null) || (parentPath.trim().equals("")))
      {
        errors.add(ERR_CTRL_PANEL_NO_BACKUP_PATH_PROVIDED.get());
        setPrimaryInvalid(lPath);
      }
      String id = backupID.getText();
      if ((id == null) || (id.trim().equals("")))
      {
        errors.add(ERR_CTRL_PANEL_NO_BACKUP_ID_PROVIDED.get());
        setPrimaryInvalid(lBackupID);
      }
    }
    if (errors.isEmpty())
    {
@@ -312,9 +370,17 @@
    {
      super(info, dlg);
      this.verify = verify;
      if (isLocal())
      {
      BackupDescriptor backup = getSelectedBackup();
      dir = backup.getPath().getAbsolutePath();
      backupID = backup.getID();
      }
      else
      {
        dir = parentDirectory.getText();
        backupID = RestorePanel.this.backupID.getText();
      }
      backendSet = new HashSet<String>();
      for (BackendDescriptor backend : info.getServerDescriptor().getBackends())
      {
@@ -355,7 +421,7 @@
        Collection<Message> incompatibilityReasons)
    {
      boolean canLaunch = true;
      if (state == State.RUNNING)
      if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
      {
        // All the operations are incompatible if they apply to this
        // backend.
opends/src/guitools/org/opends/guitools/controlpanel/ui/SimplifiedViewEntryPanel.java
@@ -2024,7 +2024,7 @@
        }
        values.addAll(ocDesc.getAuxiliary());
        Schema schema = getInfo().getServerDescriptor().getSchema();
        if (schema != null)
        if ((schema != null) && (structural != null))
        {
          ObjectClass oc = schema.getObjectClass(structural.toLowerCase());
          if (oc != null)
opends/src/guitools/org/opends/guitools/controlpanel/ui/StandardAttributePanel.java
@@ -149,13 +149,14 @@
        INFO_CTRL_PANEL_ATTRIBUTE_DESCRIPTION_LABEL.get(),
        INFO_CTRL_PANEL_ATTRIBUTE_USAGE_LABEL.get(),
        INFO_CTRL_PANEL_ATTRIBUTE_SYNTAX_LABEL.get(),
        INFO_CTRL_PANEL_ATTRIBUTE_TYPE_LABEL.get(),
        INFO_CTRL_PANEL_ATTRIBUTE_APPROXIMATE_MATCHING_RULE_LABEL.get(),
        INFO_CTRL_PANEL_ATTRIBUTE_EQUALITY_MATCHING_RULE_LABEL.get(),
        INFO_CTRL_PANEL_ATTRIBUTE_ORDERING_MATCHING_RULE_LABEL.get(),
        INFO_CTRL_PANEL_ATTRIBUTE_SUBSTRING_MATCHING_RULE_LABEL.get()
    };
    JLabel[] values = {name, parent, oid, aliases, origin, description, usage,
        syntax, approximate, equality, ordering, substring, type};
        syntax, type, approximate, equality, ordering, substring};
    gbc.gridy = 0;
    gbc.gridwidth = 2;
    addErrorPane(c, gbc);
opends/src/guitools/org/opends/guitools/controlpanel/ui/StandardObjectClassPanel.java
@@ -40,7 +40,6 @@
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
@@ -60,7 +59,6 @@
import org.opends.server.types.CommonSchemaElements;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.Schema;
import org.opends.server.util.ServerConstants;
/**
 * The panel that displays a standard object class definition.
@@ -269,17 +267,7 @@
  {
    MessageBuilder returnValue = new MessageBuilder();
    String fileName = element.getSchemaFile();
    String xOrigin = null;
    Iterable<String> it =
      element.getExtraProperty(ServerConstants.SCHEMA_PROPERTY_ORIGIN);
    if (it != null)
    {
      Iterator<String> iterator = it.iterator();
      if (iterator.hasNext())
      {
        xOrigin = iterator.next();
      }
    }
    String xOrigin = Utilities.getOrigin(element);
    if (xOrigin != null)
    {
      returnValue.append(xOrigin);
opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusGenericPanel.java
@@ -91,6 +91,7 @@
import org.opends.messages.MessageBuilder;
import org.opends.messages.MessageDescriptor;
import org.opends.quicksetup.ui.CustomHTMLEditorKit;
import org.opends.server.types.OpenDsException;
import org.opends.server.util.ServerConstants;
/**
@@ -128,9 +129,7 @@
  private boolean disposeOnClose = false;
  private JPanel mainPanel;
  private JLabel message;
  private GenericDialog loginDialog;
  private JEditorPane message;
  /**
   * The error pane.
@@ -238,7 +237,7 @@
    mainPanel = new JPanel(new GridBagLayout());
    mainPanel.setOpaque(false);
    message = Utilities.createDefaultLabel();
    message = Utilities.makeHtmlPane("", ColorAndFontConstants.progressFont);
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
@@ -627,11 +626,22 @@
    }
    else
    {
      if (isLocal() || true)
      {
      rebuildIndexes = Utilities.displayConfirmationDialog(progressDialog,
          INFO_CTRL_PANEL_INDEX_REBUILD_REQUIRED_SUMMARY.get(),
          INFO_CTRL_PANEL_INDEX_REBUILD_REQUIRED_ONLINE_DETAILS.get(
              index.getName(), backendName, backendName));
    }
      else
      {
        Utilities.displayWarningDialog(progressDialog,
            INFO_CTRL_PANEL_INDEX_REBUILD_REQUIRED_SUMMARY.get(),
            INFO_CTRL_PANEL_INDEX_REBUILD_REQUIRED_REMOTE_DETAILS.get(
                index.getName(), backendName));
        rebuildIndexes = false;
      }
    }
    if (rebuildIndexes)
    {
      SortedSet<AbstractIndexDescriptor> indexes =
@@ -824,8 +834,9 @@
  {
    boolean returnValue;
    ServerDescriptor.ServerStatus status = desc.getStatus();
    if ((status == ServerDescriptor.ServerStatus.STARTED) &&
        !desc.isAuthenticated())
    if (((status == ServerDescriptor.ServerStatus.STARTED) &&
        !desc.isAuthenticated()) ||
        (status == ServerDescriptor.ServerStatus.NOT_CONNECTED_TO_REMOTE))
    {
      returnValue = true;
    }
@@ -896,7 +907,8 @@
      Message authRequired)
  {
    ServerDescriptor.ServerStatus status = desc.getStatus();
    if (status != ServerDescriptor.ServerStatus.STARTED)
    if ((status != ServerDescriptor.ServerStatus.STARTED) &&
        (status != ServerDescriptor.ServerStatus.NOT_CONNECTED_TO_REMOTE))
    {
      Message title = INFO_CTRL_PANEL_SERVER_NOT_RUNNING_SUMMARY.get();
      MessageBuilder mb = new MessageBuilder();
@@ -1051,7 +1063,7 @@
        displayMessage(INFO_CTRL_PANEL_LOADING_PANEL_SUMMARY.get());
        worker.startBackgroundTask();
      }
      else
      else if (info.getServerDescriptor() != null)
      {
        configurationChanged(new ConfigurationChangeEvent(
          this.info, this.info.getServerDescriptor()));
@@ -1070,17 +1082,49 @@
  }
  /**
   * Returns whether the main panel is visible or not.
   * @return whether the main panel is visible or not.
   */
  protected boolean isMainPanelVisible()
  {
    return mainPanel.isVisible();
  }
  /**
   * Displays a message and hides the main panel.
   * @param msg the message to be displayed.
   */
  protected void displayMessage(Message msg)
  {
    message.setText(msg.toString());
    message.setText(Utilities.applyFont(msg.toString(),
        ColorAndFontConstants.progressFont));
    mainPanel.setVisible(false);
    message.setVisible(true);
  }
  /**
   * Displays an error message and hides the main panel.
   * @param title the title of the message to be displayed.
   * @param msg the message to be displayed.
   */
  protected void displayErrorMessage(Message title, Message msg)
  {
    updateErrorPane(message, title, ColorAndFontConstants.errorTitleFont,
        msg, ColorAndFontConstants.defaultFont);
    mainPanel.setVisible(false);
    message.setVisible(true);
  }
  /**
   * Returns whether the message is visible or not.
   * @return whether the message is visible or not.
   */
  protected boolean isMessageVisible()
  {
    return message.isVisible();
  }
  /**
   * Updates the contents of an editor pane using the error format.
   * @param pane the editor pane to be updated.
   * @param title the title.
@@ -1156,7 +1200,7 @@
   * @param detailsFont the font to be used for the details.
   * @param type the type of panel.
   */
  private void updatePane(JEditorPane pane, Message title,
  private void updatePane(final JEditorPane pane, Message title,
      Font titleFont, Message details, Font detailsFont, PanelType type)
  {
    String text;
@@ -1202,11 +1246,11 @@
          ServerConstants.EOL);
      Utilities.updatePreferredSize(pane2, 100, plainText, detailsFont, true);
      Dimension d2 = pane2.getPreferredSize();
      pane.setText(text);
      pane.setPreferredSize(new Dimension(Math.max(d1.width, d2.width),
          d1.height + d2.height));
      lastDisplayedError = text;
      pane.setText(text);
    }
    final Window window =
      Utilities.getParentDialog(StatusGenericPanel.this);
@@ -1219,6 +1263,7 @@
         */
        public void run()
        {
          pane.invalidate();
          window.validate();
        }
      });
@@ -1563,6 +1608,17 @@
  }
  /**
   * Returns <CODE>true</CODE> if the managed server is the local installation
   * (where the control panel is installed) <CODE>false</CODE> otherwise.
   * @return <CODE>true</CODE> if the managed server is the local installation
   * (where the control panel is installed) <CODE>false</CODE> otherwise.
   */
  protected boolean isLocal()
  {
    return getInfo().getServerDescriptor().isLocal();
  }
  /**
   * Launch an task.
   * @param task the task to be launched.
   * @param initialSummary the initial summary to be displayed in the progress
@@ -1715,10 +1771,26 @@
            if ((task.getReturnCode() != null) &&
                (errorDetailCode != null))
            {
              String sThrowable;
              if (t instanceof OpenDsException)
              {
                sThrowable = ((OpenDsException)t).getMessageObject().toString();
              }
              else
              {
                if (t.getMessage() != null)
                {
                  sThrowable = t.getMessage();
                }
                else
                {
                  sThrowable = t.toString();
                }
              }
              MessageBuilder mb = new MessageBuilder();
              mb.append(errorDetailCode.get(task.getReturnCode()));
              mb.append(
                  "  "+INFO_CTRL_PANEL_DETAILS_THROWABLE.get(t.toString()));
                  "  "+INFO_CTRL_PANEL_DETAILS_THROWABLE.get(sThrowable));
              summaryMsg = Utilities.getFormattedError(errorSummary,
                  ColorAndFontConstants.errorTitleFont,
                  mb.toMessage(), ColorAndFontConstants.defaultFont);
@@ -1943,16 +2015,23 @@
   */
  protected GenericDialog getLoginDialog()
  {
    if (loginDialog == null)
    if (isLocal())
    {
      LoginPanel loginPanel = new LoginPanel();
      loginDialog = new GenericDialog(Utilities.getFrame(this), loginPanel);
      loginPanel.setInfo(getInfo());
      GenericDialog loginDialog =
        ControlCenterMainPane.getLocalServerLoginDialog(getInfo());
      Utilities.centerGoldenMean(loginDialog, Utilities.getFrame(this));
      loginDialog.setModal(true);
    }
    return loginDialog;
  }
    else
    {
      GenericDialog localOrRemoteDialog =
        ControlCenterMainPane.getLocalOrRemoteDialog(getInfo());
      Utilities.centerGoldenMean(localOrRemoteDialog, Utilities.getFrame(this));
      localOrRemoteDialog.setModal(true);
      return localOrRemoteDialog;
    }
  }
  /**
   * Tells whether an entry exists or not.  Actually it tells if we could find
opends/src/guitools/org/opends/guitools/controlpanel/ui/StatusPanel.java
@@ -266,6 +266,20 @@
              mb.toMessage(), ColorAndFontConstants.defaultFont);
        }
      }
      else if (desc.getStatus() ==
        ServerDescriptor.ServerStatus.NOT_CONNECTED_TO_REMOTE)
      {
        errorPaneVisible = true;
        MessageBuilder mb = new MessageBuilder();
        mb.append(INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(
            desc.getHostname()));
        mb.append("<br><br>"+getAuthenticateHTML());
        Message title =
          INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_SUMMARY.get();
        updateErrorPane(errorPane, title,
            ColorAndFontConstants.errorTitleFont,
            mb.toMessage(), ColorAndFontConstants.defaultFont);
      }
      if (errorPane.isVisible() != errorPaneVisible)
      {
        errorPane.setVisible(errorPaneVisible);
@@ -292,12 +306,20 @@
      {
        if (!desc.isAuthenticated())
        {
          mb.append("<br>");
          mb.append(
     INFO_CTRL_PANEL_AUTH_REQUIRED_TO_BROWSE_MONITORING_SUMMARY.
     get());
          mb.append("<br><br>"+getAuthenticateHTML());
        }
      }
      else if (desc.getStatus() == ServerDescriptor.ServerStatus.STARTED)
      {
        mb.append("<br>");
        mb.append(INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(
          desc.getHostname()));
        mb.append("<br><br>"+getAuthenticateHTML());
      }
      updateErrorPane(errorPane, title, ColorAndFontConstants.errorTitleFont,
          mb.toMessage(), ColorAndFontConstants.defaultFont);
@@ -307,21 +329,30 @@
      }
    }
    serverStatus.setText(desc.getStatus().toString().toLowerCase());
    serverStatus.setText(getStatusLabel(desc));
    boolean isRunning = desc.getStatus() ==
      ServerDescriptor.ServerStatus.STARTED;
    boolean isAuthenticated = desc.isAuthenticated();
    boolean isLocal = desc.isLocal();
    startButton.setVisible(desc.getStatus() ==
      ServerDescriptor.ServerStatus.STOPPED);
    restartButton.setVisible(isRunning);
    stopButton.setVisible(isRunning);
      ServerDescriptor.ServerStatus.STOPPED  && isLocal);
    restartButton.setVisible(isRunning  && isLocal);
    stopButton.setVisible(isRunning && isLocal);
    if (!isRunning)
    {
      if (isLocal)
      {
      Utilities.setNotAvailableBecauseServerIsDown(currentConnections);
    }
      else
      {
        Utilities.setTextValue(currentConnections,
            INFO_NOT_AVAILABLE_SHORT_LABEL.get().toString());
      }
    }
    else if (!isAuthenticated)
    {
      Utilities.setNotAvailableBecauseAuthenticationIsRequired(
@@ -358,23 +389,51 @@
      }
    }
    if (rootUsers.size() > 0)
    {
    String htmlString = "<html>"+Utilities.applyFont(
        Utilities.getStringFromCollection(sortedRootUsers, "<br>"),
        administrativeUsers.getFont());
    administrativeUsers.setText(htmlString);
    }
    else
    {
      administrativeUsers.setText(
          INFO_NOT_AVAILABLE_SHORT_LABEL.get().toString());
    }
    File install = desc.getInstallPath();
    if (install != null)
    {
    installPath.setText(install.getAbsolutePath());
    }
    else
    {
      installPath.setText(INFO_NOT_AVAILABLE_SHORT_LABEL.get().toString());
    }
    File instance = desc.getInstancePath();
    if (instance != null)
    {
    instancePath.setText(instance.getAbsolutePath());
    }
    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
@@ -383,12 +442,27 @@
    instancePath.setVisible(!sameInstallAndInstance);
    lInstancePath.setVisible(!sameInstallAndInstance);
    if (desc.getOpenDSVersion() != null)
    {
    opendsVersion.setText(desc.getOpenDSVersion());
    }
    else
    {
      opendsVersion.setText(INFO_NOT_AVAILABLE_SHORT_LABEL.get().toString());
    }
    if (!isRunning)
    {
      if (isLocal)
      {
      Utilities.setNotAvailableBecauseServerIsDown(javaVersion);
    }
      else
      {
        Utilities.setTextValue(javaVersion,
            INFO_NOT_AVAILABLE_SHORT_LABEL.get().toString());
      }
    }
    else if (!isAuthenticated)
    {
      Utilities.setNotAvailableBecauseAuthenticationIsRequired(javaVersion);
@@ -642,7 +716,7 @@
      gbc.insets.left = 0;
      if (i != 0)
      {
        gbc.insets.top = 5;
        gbc.insets.top = 10;
      }
      gbc.gridwidth = GridBagConstraints.RELATIVE;
      auxPanel.add(leftLabels[i], gbc);
@@ -772,5 +846,40 @@
      return INFO_NOT_AVAILABLE_SHORT_LABEL.get().toString();
    }
  }
  private String getStatusLabel(ServerDescriptor desc)
  {
    Message status;
    switch (desc.getStatus())
    {
    case STARTED:
      status = INFO_SERVER_STARTED_LABEL.get();
      break;
    case STOPPED:
      status = INFO_SERVER_STOPPED_LABEL.get();
      break;
    case STARTING:
      status = INFO_SERVER_STARTING_LABEL.get();
      break;
    case STOPPING:
      status = INFO_SERVER_STOPPING_LABEL.get();
      break;
    case NOT_CONNECTED_TO_REMOTE:
      status = INFO_SERVER_NOT_CONNECTED_TO_REMOTE_STATUS_LABEL.get();
      break;
    case UNKNOWN:
      status = INFO_SERVER_UNKNOWN_STATUS_LABEL.get();
      break;
    default:
      throw new IllegalStateException("Unknown status: "+desc.getStatus());
    }
    return status.toString();
  }
}
opends/src/guitools/org/opends/guitools/controlpanel/ui/VLVIndexPanel.java
@@ -62,6 +62,7 @@
import org.opends.guitools.controlpanel.datamodel.AbstractIndexDescriptor;
import org.opends.guitools.controlpanel.datamodel.CategorizedComboBoxElement;
import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
import org.opends.guitools.controlpanel.datamodel.ServerDescriptor;
import org.opends.guitools.controlpanel.datamodel.VLVIndexDescriptor;
import org.opends.guitools.controlpanel.datamodel.VLVSortOrder;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
@@ -142,12 +143,15 @@
  /**
   * {@inheritDoc}
   */
  public void configurationChanged(final ConfigurationChangeEvent ev)
  public void configurationChanged(ConfigurationChangeEvent ev)
  {
    if (updateLayout(ev.getNewDescriptor()))
    final ServerDescriptor desc = ev.getNewDescriptor();
    if (updateLayout(desc))
    {
      updateErrorPaneIfAuthRequired(ev.getNewDescriptor(),
          INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_VLV_INDEX_EDITING.get());
      updateErrorPaneIfAuthRequired(desc,
          isLocal() ?
          INFO_CTRL_PANEL_AUTHENTICATION_REQUIRED_FOR_VLV_INDEX_EDITING.get() :
      INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS.get(desc.getHostname()));
      SwingUtilities.invokeLater(new Runnable()
      {
        /**
@@ -157,7 +161,7 @@
        {
          checkSaveButton();
          deleteIndex.setEnabled(
              !authenticationRequired(ev.getNewDescriptor()));
              !authenticationRequired(desc));
        }
      });
    }
@@ -668,7 +672,7 @@
        Collection<Message> incompatibilityReasons)
    {
      boolean canLaunch = true;
      if (state == State.RUNNING)
      if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
      {
        // All the operations are incompatible if they apply to this
        // backend for safety.  This is a short operation so the limitation
opends/src/guitools/org/opends/guitools/controlpanel/ui/VerifyIndexPanel.java
@@ -295,7 +295,7 @@
    refreshContents(ev.getNewDescriptor());
  }
  private void refreshContents(ServerDescriptor desc)
  private void refreshContents(final ServerDescriptor desc)
  {
    updateIndexMap(desc, hmIndexes);
    updateBaseDNComboBoxModel((DefaultComboBoxModel)baseDNs.getModel(), desc);
@@ -327,6 +327,19 @@
        baseDNs.setVisible(comboVisible);
        lNoBaseDNsFound.setVisible(!comboVisible);
        Utilities.updateViewPositions(pos);
        if (!desc.isLocal())
        {
          displayErrorMessage(INFO_CTRL_PANEL_SERVER_REMOTE_SUMMARY.get(),
          INFO_CTRL_PANEL_SERVER_MUST_BE_LOCAL_VERIFY_INDEX_SUMMARY.get());
          setEnabledOK(false);
        }
        else
        {
          displayMainPanel();
          setEnabledOK(true);
        }
      }
    });
  }
@@ -572,7 +585,7 @@
        Collection<Message> incompatibilityReasons)
    {
      boolean canLaunch = true;
      if (state == State.RUNNING)
      if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
      {
        // All the operations are incompatible if they apply to this
        // backend.
opends/src/guitools/org/opends/guitools/controlpanel/ui/ViewEntryPanel.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.ui;
@@ -647,11 +647,14 @@
  {
    boolean isOperational = false;
    attrName = Utilities.getAttributeNameWithoutOptions(attrName);
    if (schema != null)
    {
    AttributeType attrType = schema.getAttributeType(attrName.toLowerCase());
    if (attrType != null)
    {
      isOperational = attrType.isOperational();
    }
    }
    return !isOperational || isEditableOperationalAttribute(attrName);
  }
}
opends/src/guitools/org/opends/guitools/controlpanel/ui/WindowsServicePanel.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.ui;
@@ -44,6 +44,7 @@
import javax.swing.JButton;
import javax.swing.JEditorPane;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
import org.opends.guitools.controlpanel.datamodel.ControlPanelInfo;
import org.opends.guitools.controlpanel.event.ConfigurationChangeEvent;
@@ -64,6 +65,8 @@
  private JButton bEnable;
  private JButton bDisable;
  private boolean previousLocal = true;
  private boolean isWindowsServiceEnabled;
  /**
@@ -193,13 +196,37 @@
  {
    boolean previousValue = isWindowsServiceEnabled;
    isWindowsServiceEnabled = ev.getNewDescriptor().isWindowsServiceEnabled();
    if (isWindowsServiceEnabled != previousValue)
    final boolean isLocal = ev.getNewDescriptor().isLocal();
    if ((isLocal != previousLocal) ||
        (isWindowsServiceEnabled != previousValue))
    {
      previousLocal = isLocal;
      SwingUtilities.invokeLater(new Runnable()
      {
        /**
         * {@inheritDoc}
         */
        public void run()
    {
      lState.setText(isWindowsServiceEnabled ?
          INFO_ENABLED_LABEL.get().toString() :
            INFO_DISABLED_LABEL.get().toString());
      bEnable.setVisible(!isWindowsServiceEnabled);
      bDisable.setVisible(isWindowsServiceEnabled);
          if (!isLocal)
          {
            displayErrorMessage(INFO_CTRL_PANEL_SERVER_REMOTE_SUMMARY.get(),
            INFO_CTRL_PANEL_SERVER_MUST_BE_LOCAL_WINDOWS_SERVICE_SUMMARY.get());
            packParentDialog();
          }
          else
          {
            displayMainPanel();
          }
        }
      });
    }
  }
@@ -314,7 +341,7 @@
        Collection<Message> incompatibilityReasons)
    {
      boolean canLaunch = true;
      if (state == State.RUNNING)
      if (state == State.RUNNING && runningOnSameServer(taskToBeLaunched))
      {
        if ((taskToBeLaunched.getType() == Type.ENABLE_WINDOWS_SERVICE) ||
            (taskToBeLaunched.getType() == Type.DISABLE_WINDOWS_SERVICE))
opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromDirContext.java
@@ -67,6 +67,7 @@
import org.opends.server.admin.client.ldap.LDAPManagementContext;
import org.opends.server.admin.std.client.*;
import org.opends.server.admin.std.meta.LocalDBIndexCfgDefn.IndexType;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.DN;
import org.opends.server.types.OpenDsException;
import org.opends.server.util.ServerConstants;
@@ -88,6 +89,9 @@
  private CustomSearchResult systemInformation;
  private CustomSearchResult entryCaches;
  private CustomSearchResult workQueue;
  private CustomSearchResult versionMonitor;
  private boolean isLocal = true;
  private Map<String, CustomSearchResult> hmConnectionHandlersMonitor =
    new HashMap<String, CustomSearchResult>();
@@ -112,6 +116,10 @@
   * The work queue monitoring entry DN.
   */
  protected DN workQueueDN = DN.nullDN();
  /**
   * The version monitoring entry DN.
   */
  protected DN versionDN = DN.nullDN();
  {
    try
@@ -121,6 +129,7 @@
      systemInformationDN = DN.decode("cn=System Information,cn=monitor");
      entryCachesDN = DN.decode("cn=Entry Caches,cn=monitor");
      workQueueDN = DN.decode("cn=Work Queue,cn=monitor");
      versionDN = DN.decode("cn=Version,cn=monitor");
    }
    catch (Throwable t)
    {
@@ -169,6 +178,15 @@
  }
  /**
   * Returns the version entry of the monitoring tree.
   * @return the version entry of the monitoring tree.
   */
  public CustomSearchResult getVersionMonitor()
  {
    return versionMonitor;
  }
  /**
   * Returns the monitoring entry for the system information.
   * @return the monitoring entry for the system information.
   */
@@ -187,6 +205,28 @@
  }
  /**
   * Sets whether this server represents the local instance or a remote server.
   * @param isLocal whether this server represents the local instance or a
   * remote server (in another machine or in another installation on the same
   * machine).
   */
  public void setIsLocal(boolean isLocal)
  {
    this.isLocal = isLocal;
  }
  /**
   * Returns <CODE>true</CODE> if we are trying to manage the local host and
   * <CODE>false</CODE> otherwise.
   * @return <CODE>true</CODE> if we are trying to manage the local host and
   * <CODE>false</CODE> otherwise.
   */
  public boolean isLocal()
  {
    return isLocal;
  }
  /**
   * Reads configuration and monitoring information using the provided
   * connection.
   * @param ctx the connection to be used to read the information.
@@ -204,9 +244,28 @@
    systemInformation = null;
    entryCaches = null;
    workQueue = null;
    versionMonitor = null;
    hmConnectionHandlersMonitor.clear();
    if (mustReadSchema())
    {
      try
      {
        readSchema(ctx);
        if (getSchema() != null)
        {
          // Update the schema: so that when we call the server code the
          // latest schema read on the server we are managing is used.
          DirectoryServer.setSchema(getSchema());
        }
      }
      catch (OpenDsException oe)
      {
        ex.add(oe);
      }
    }
    try
    {
      // Get the Directory Server configuration handler and use it.
@@ -449,15 +508,6 @@
      {
        ex.add(oe);
      }
      try
      {
        readSchema();
      }
      catch (OpenDsException oe)
      {
        ex.add(oe);
      }
    }
    catch (final Throwable t)
    {
@@ -506,6 +556,33 @@
  }
  /**
   * Reads the schema from the files.
   * @param ctx the connection to be used to load the schema.
   * @throws OpenDsException if an error occurs reading the schema.
   */
  private void readSchema(InitialLdapContext ctx) throws OpenDsException
  {
    if (isLocal)
    {
      super.readSchema();
    }
    else
    {
      RemoteSchemaLoader loader = new RemoteSchemaLoader();
      try
      {
        loader.readSchema(ctx);
      }
      catch (NamingException ne)
      {
        throw new OnlineUpdateException(
            ERR_READING_SCHEMA_LDAP.get(ne.toString()), ne);
      }
      schema = loader.getSchema();
    }
  }
  /**
   * Takes the provided search result and updates the monitoring information
   * accordingly.
   * @param sr the search result.
@@ -662,6 +739,10 @@
        {
          systemInformation = csr;
        }
        else if ((versionMonitor == null) && isVersionMonitor(csr))
        {
          versionMonitor = csr;
        }
        else if (isConnectionHandler(csr))
        {
          String statistics = " Statistics";
@@ -829,6 +910,12 @@
    return monitorDN.equals(DN.decode(csr.getDN()));
  }
  private boolean isVersionMonitor(CustomSearchResult csr)
  throws OpenDsException
  {
    return versionDN.equals(DN.decode(csr.getDN()));
  }
  private boolean isSystemInformation(CustomSearchResult csr)
  throws OpenDsException
  {
opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigFromFile.java
@@ -110,6 +110,25 @@
    try
    {
      DirectoryServer.getInstance().initializeConfiguration();
      if (mustReadSchema())
      {
        try
        {
          readSchema();
          if (getSchema() != null)
          {
            // Update the schema: so that when we call the server code the
            // latest schema read on the server we are managing is used.
            DirectoryServer.setSchema(getSchema());
          }
        }
        catch (OpenDsException oe)
        {
          ex.add(oe);
        }
      }
      // Get the Directory Server configuration handler and use it.
      RootCfg root =
        ServerManagementContext.getInstance().getRootConfiguration();
@@ -343,18 +362,6 @@
      {
        ex.add(oe);
      }
      if (mustReadSchema())
      {
        try
        {
          readSchema();
        }
        catch (OpenDsException oe)
        {
          ex.add(oe);
        }
      }
    }
    catch (OpenDsException oe)
    {
opends/src/guitools/org/opends/guitools/controlpanel/util/ConfigReader.java
@@ -36,6 +36,8 @@
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.opends.guitools.controlpanel.datamodel.BackendDescriptor;
import org.opends.guitools.controlpanel.datamodel.ConnectionHandlerDescriptor;
@@ -58,14 +60,18 @@
 */
public abstract class ConfigReader
{
  private static final Logger LOG =
    Logger.getLogger(ConfigReader.class.getName());
  /**
   * The class used to read the configuration from a file.
   */
  public static String configClassName;
  /**
   * The configuration file full path (-INSTANCE_ROOT-/config/config.ldif).
   * of the installation of the control panel.
   */
  public static String configFile;
  /**
   * The error that occurred when setting the environment (null if no error
   * occurred).
@@ -89,9 +95,9 @@
    {
      DirectoryEnvironmentConfig env = DirectoryServer.getEnvironmentConfig();
      env.setServerRoot(new File(installRoot));
      DirectoryServer instance = DirectoryServer.getInstance();
      DirectoryServer.bootstrapClient();
      DirectoryServer.initializeJMX();
      DirectoryServer instance = DirectoryServer.getInstance();
      instance.initializeConfiguration(configClassName, configFile);
      instance.initializeSchema();
    }
@@ -100,6 +106,7 @@
      environmentSettingException = new OfflineUpdateException(
          ERR_CTRL_PANEL_SETTING_ENVIRONMENT.get(t.getMessage().toString()), t);
    }
    LOG.log(Level.INFO, "Environment initialized.");
  }
  /**
@@ -275,8 +282,8 @@
  /**
   * Reads the schema from the files.
   * @throws ConfigException if an error occurs reading the schema.
   * @throws InitializationException if an error occurs trying to find out
   * the schema files.
   * @throws InitializationException if an error occurs initializing
   * configuration to read schema.
   * @throws DirectoryException if there is an error registering the minimal
   * objectclasses.
   */
@@ -285,7 +292,7 @@
  {
    SchemaLoader loader = new SchemaLoader();
    loader.readSchema();
    schema = loader.getSchema().duplicate();
    schema = loader.getSchema();
  }
  /**
opends/src/guitools/org/opends/guitools/controlpanel/util/RemoteSchemaLoader.java
New file
@@ -0,0 +1,185 @@
/*
 * 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
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 */
package org.opends.guitools.controlpanel.util;
import java.util.HashSet;
import java.util.Set;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import javax.naming.ldap.InitialLdapContext;
import org.opends.guitools.controlpanel.browser.BrowserController;
import org.opends.guitools.controlpanel.datamodel.CustomSearchResult;
import org.opends.server.config.ConfigConstants;
import org.opends.server.config.ConfigException;
import org.opends.server.schema.AttributeTypeSyntax;
import org.opends.server.schema.ObjectClassSyntax;
import org.opends.server.types.AttributeType;
import org.opends.server.types.ByteStringBuilder;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.InitializationException;
import org.opends.server.types.ObjectClass;
import org.opends.server.types.Schema;
/**
 * Class used to retrieve the schema from the schema files.
 *
 */
public class RemoteSchemaLoader extends SchemaLoader
{
  private Schema schema;
  /**
   * Constructor.
   *
   */
  public RemoteSchemaLoader()
  {
    super();
  }
  /**
   * Reads the schema.
   * @param ctx the connection to be used to load the schema.
   * @throws NamingException if an error occurs reading the schema.
   * @throws DirectoryException if an error occurs parsing the schema.
   * @throws InitializationException if an error occurs finding the base
   * schema.
   * @throws ConfigException if an error occurs loading the configuration
   * required to use the schema classes.
   */
  public void readSchema(InitialLdapContext ctx) throws NamingException,
  DirectoryException, InitializationException, ConfigException
  {
    SearchControls searchControls = new SearchControls();
    searchControls.setSearchScope(SearchControls.OBJECT_SCOPE);
    String[] schemaAttrs =
    {
        ConfigConstants.ATTR_OBJECTCLASSES_LC,
        ConfigConstants.ATTR_ATTRIBUTE_TYPES_LC
    };
    searchControls.setReturningAttributes(schemaAttrs);
    String filter = BrowserController.ALL_OBJECTS_FILTER;
    NamingEnumeration<SearchResult> srs =
      ctx.search(ConfigConstants.DN_DEFAULT_SCHEMA_ROOT,
          filter,
          searchControls);
    SearchResult sr = srs.next();
    CustomSearchResult csr = new CustomSearchResult(sr,
        ConfigConstants.DN_DEFAULT_SCHEMA_ROOT);
    schema = getBaseSchema();
    Set<Object> attrs =
      csr.getAttributeValues(ConfigConstants.ATTR_ATTRIBUTE_TYPES_LC);
    Set<String> remainingAttrs = new HashSet<String>();
    for (Object o : attrs)
    {
      remainingAttrs.add((String)o);
    }
    while (!remainingAttrs.isEmpty())
    {
      DirectoryException lastException = null;
      boolean oneRegistered = false;
      Set<String> registeredAttrs = new HashSet<String>();
      for (String attrDefinition : remainingAttrs)
      {
        ByteStringBuilder sb = new ByteStringBuilder();
        sb.append(attrDefinition);
        try
        {
          AttributeType attrType =
            AttributeTypeSyntax.decodeAttributeType(sb, schema, false);
          schema.registerAttributeType(attrType, true);
          oneRegistered = true;
          registeredAttrs.add(attrDefinition);
        }
        catch (DirectoryException de)
        {
          lastException = de;
        }
      }
      if (!oneRegistered)
      {
        throw lastException;
      }
      remainingAttrs.removeAll(registeredAttrs);
    }
    Set<Object> objectClasses =
      csr.getAttributeValues(ConfigConstants.ATTR_OBJECTCLASSES_LC);
    Set<String> remainingOcs = new HashSet<String>();
    for (Object o : objectClasses)
    {
      remainingOcs.add((String)o);
    }
    while (!remainingOcs.isEmpty())
    {
      DirectoryException lastException = null;
      boolean oneRegistered = false;
      Set<String> registeredOcs = new HashSet<String>();
      for (String ocDefinition : remainingOcs)
      {
        ByteStringBuilder sb = new ByteStringBuilder();
        sb.append(ocDefinition);
        try
        {
          ObjectClass oc =
            ObjectClassSyntax.decodeObjectClass(sb, schema, false);
          schema.registerObjectClass(oc, true);
          oneRegistered = true;
          registeredOcs.add(ocDefinition);
        }
        catch (DirectoryException de)
        {
          lastException = de;
        }
      }
      if (!oneRegistered)
      {
        throw lastException;
      }
      remainingOcs.removeAll(registeredOcs);
    }
  }
  /**
   * Returns the schema that was read.
   * @return the schema that was read.
   */
  public Schema getSchema()
  {
    return schema;
  }
}
opends/src/guitools/org/opends/guitools/controlpanel/util/SchemaLoader.java
@@ -128,23 +128,7 @@
  public void readSchema() throws DirectoryException,
  ConfigException, InitializationException
  {
    schema = new Schema();
    for (MatchingRule mr : matchingRulesToKeep)
    {
      schema.registerMatchingRule(mr, true);
    }
    for (AttributeSyntax syntax : syntaxesToKeep)
    {
      schema.registerSyntax(syntax, true);
    }
    for (AttributeType attr : attributesToKeep)
    {
      schema.registerAttributeType(attr, true);
    }
    for (ObjectClass oc : objectclassesToKeep)
    {
      schema.registerObjectClass(oc, true);
    }
    schema = getBaseSchema();
    String[] fileNames = null;
    try
@@ -263,6 +247,35 @@
  }
  /**
   * Returns a basic version of the schema.  The schema is created and contains
   * enough definitions for the schema to be loaded.
   * @return a basic version of the schema.
   * @throws DirectoryException if there is an error registering the minimal
   * objectclasses.
   */
  protected Schema getBaseSchema() throws DirectoryException
  {
    Schema schema = new Schema();
    for (MatchingRule mr : matchingRulesToKeep)
    {
      schema.registerMatchingRule(mr, true);
    }
    for (AttributeSyntax syntax : syntaxesToKeep)
    {
      schema.registerSyntax(syntax, true);
    }
    for (AttributeType attr : attributesToKeep)
    {
      schema.registerAttributeType(attr, true);
    }
    for (ObjectClass oc : objectclassesToKeep)
    {
      schema.registerObjectClass(oc, true);
    }
    return schema;
  }
  /**
   * Returns the schema that was read.
   * @return the schema that was read.
   */
opends/src/guitools/org/opends/guitools/controlpanel/util/Utilities.java
@@ -48,6 +48,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.Set;
import javax.naming.CompositeName;
@@ -292,6 +293,25 @@
        null); // default button title
  }
  /**
   * Displays a warning dialog.
   * @param parentComponent the parent component relative to which the dialog
   * will be displayed.
   * @param title the title of the dialog.
   * @param msg the message to be displayed.
   */
  public static void displayWarningDialog(Component parentComponent,
      Message title, Message msg)
  {
    String plainText = msg.toString().replaceAll("<br>", ServerConstants.EOL);
    String wrappedText = StaticUtils.wrapText(plainText, 70);
    wrappedText = wrappedText.replaceAll(ServerConstants.EOL, "<br>");
    JOptionPane.showMessageDialog(
        parentComponent, "<html>"+wrappedText,
        title.toString(),
        JOptionPane.WARNING_MESSAGE);
  }
  /**
   * Creates a JEditorPane that displays a message.
@@ -1734,6 +1754,16 @@
      "03-uddiv3.ldif", "05-solaris.ldif"
  };
  private final static String[] configurationSchemaOrigins =
  {
      "OpenDS Directory Server", "Sun Directory Server"
  };
  private final static String[] standardSchemaOrigins =
  {
      "Sun Java System Directory Server", "Solaris Specific", "X.501"
  };
  private final static String[] configurationSchemaFileNames =
  {
      "02-config.ldif", "06-compat.ldif"
@@ -1765,6 +1795,27 @@
        isStandard = fileName.toLowerCase().indexOf("-rfc") != -1;
      }
    }
    else if (fileElement instanceof CommonSchemaElements)
    {
      CommonSchemaElements element = (CommonSchemaElements)fileElement;
      String xOrigin = getOrigin(element);
      if (xOrigin != null)
      {
        for (String name : standardSchemaOrigins)
        {
          isStandard = xOrigin.equals(name);
          if (isStandard)
          {
            break;
          }
        }
        if (!isStandard)
        {
          isStandard = xOrigin.startsWith("RFC ") ||
          xOrigin.startsWith("draft-");
        }
      }
    }
    return isStandard;
  }
@@ -1790,10 +1841,47 @@
        }
      }
    }
    else if (fileElement instanceof CommonSchemaElements)
    {
      CommonSchemaElements element = (CommonSchemaElements)fileElement;
      String xOrigin = getOrigin(element);
      if (xOrigin != null)
      {
        for (String name : configurationSchemaOrigins)
        {
          isConfiguration = xOrigin.equals(name);
          if (isConfiguration)
          {
            break;
          }
        }
      }
    }
    return isConfiguration;
  }
  /**
   * Returns the origin of the provided schema element.
   * @param element the schema element.
   * @return the origin of the provided schema element.
   */
  public static String getOrigin(CommonSchemaElements element)
  {
    String xOrigin = null;
    Iterable<String> it =
      element.getExtraProperty(ServerConstants.SCHEMA_PROPERTY_ORIGIN);
    if (it != null)
    {
      Iterator<String> iterator = it.iterator();
      if (iterator.hasNext())
      {
        xOrigin = iterator.next();
      }
    }
    return xOrigin;
  }
  /**
   * Returns the string representation of an attribute syntax.
   * @param syntax the attribute syntax.
   * @return the string representation of an attribute syntax.
@@ -1976,13 +2064,7 @@
    /*
     * 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);
    checkCanReadConfig(ctx);
    return ctx;
  }
@@ -2042,6 +2124,18 @@
          bindDN, pwd, Utils.getDefaultLDAPTimeout(), null);
    }
    checkCanReadConfig(ctx);
    return ctx;
  }
  /**
   * Checks that the provided connection can read cn=config.
   * @param ctx the connection to be tested.
   * @throws NamingException if an error occurs while reading cn=config.
   */
  public static void checkCanReadConfig(InitialLdapContext ctx)
  throws NamingException
  {
    /*
     * Search for the config to check that it is the directory manager.
     */
@@ -2052,7 +2146,6 @@
    searchControls.setReturningAttributes(
    new String[] {"dn"});
    ctx.search("cn=config", "objectclass=*", searchControls);
    return ctx;
  }
  /**
opends/src/messages/messages/admin_tool.properties
@@ -199,6 +199,8 @@
MILD_ERR_READING_CONFIG_FILE=Error reading the configuration file.
MILD_ERR_READING_CONFIG_LDAP=Error reading data from server.  Verify the \
 authentication information provided.%nDetails: %s
MILD_ERR_READING_SCHEMA_LDAP=Error reading schema from the remote server.\
 %nDetails: %s
SEVERE_ERR_STARTING_SERVER_GENERIC=Could not Start server.
INFO_FINISH_BUTTON_UNINSTALL_LABEL=Uninstall
INFO_FINISH_BUTTON_UNINSTALL_TOOLTIP=Finish Uninstall
@@ -279,6 +281,7 @@
INFO_SERVER_STOPPED_LABEL=Stopped
INFO_SERVER_STOPPING_LABEL=Stopping
INFO_SERVER_UNKNOWN_STATUS_LABEL=Unknown
INFO_SERVER_NOT_CONNECTED_TO_REMOTE_STATUS_LABEL=Not Connected to Remote
INFO_START_BUTTON_LABEL=Start
INFO_START_BUTTON_TOOLTIP=Starts the Directory Server
INFO_STATE_COLUMN=State
@@ -1814,6 +1817,27 @@
INFO_CTRL_OBJECTCLASS_DESCRIPTOR=Objectclass: %s
INFO_CTRL_AUXILIARY_OBJECTCLASS_DESCRIPTOR=Auxiliary objectclasses: %s
INFO_CTRL_PANEL_LOCAL_OR_REMOTE_LABEL=Choose the server to be administered:
INFO_CTRL_PANEL_REMOTE_SERVER=Remote Server:
INFO_CTRL_PANEL_LOCAL_SERVER=Local Server
INFO_CTRL_PANEL_ADMINISTRATION_PORT=Administration Port:
INFO_CTRL_PANEL_LOCAL_SERVER_NOT_RUNNING=Not Running
INFO_EMPTY_REMOTE_HOST_NAME=You must provide the name of the remote host name.
INFO_INVALID_REMOTE_SERVER_PORT=The value of the remote server administrative \
 port must be an integer value between %d and %d.
INFO_CTRL_PANEL_LOCAL_OR_REMOTE_PANEL_TITLE=Server to Administer
#
# Note that the following two properties contain line breaks in HTML format
# (<br>)
#
INFO_CTRL_PANEL_ERROR_CONNECTING_TO_LOCAL=The following errors occurred \
 connecting to the local server:<br>%s<br>If you continue without providing \
 authentication no monitoring information will be displayed.<br><br>Do you \
 want to continue?
MILD_ERR_CANNOT_CONNECT_TO_REMOTE=Could not connect to server '%s' on port \
 '%s'.  Verify that the provided information is valid and that the server is \
 running.  Details: %s
INFO_CTRL_PANEL_LOGIN_PANEL_TITLE=Authentication Required
INFO_CTRL_PANEL_BIND_DN_LABEL=Bind DN:
INFO_CTRL_PANEL_BIND_PASSWORD_LABEL=Password:
@@ -1824,8 +1848,12 @@
#
INFO_CTRL_PANEL_RUNNING_TASKS_CONFIRMATION_DETAILS=The following tasks are \
 running:<br>%s<br><br>If you exit the tasks will continue but you will have \
 to check the error logs to see if they complete successfully.<br><br>Do you \
 to check the log files to see if they complete successfully.<br><br>Do you \
 want to continue?
INFO_CTRL_PANEL_RUNNING_TASKS_CHANGE_SERVER_CONFIRMATION_DETAILS=The following \
 tasks are running:<br>%s<br><br>If you connect to another server the tasks \
 will continue but you will have to check the log files to see if they \
 complete successfully.<br><br>Do you want to continue?
INFO_CTRL_PANEL_MATCHING_RULE_PANEL_TITLE=Matching Rule
INFO_CTRL_PANEL_MATCHING_RULE_DETAILS=Matching Rule Details
@@ -1895,6 +1923,7 @@
INFO_CTRL_PANEL_ATTRIBUTE_DESCRIPTION_LABEL=Description:
INFO_CTRL_PANEL_ATTRIBUTE_USAGE_LABEL=Usage:
INFO_CTRL_PANEL_ATTRIBUTE_SYNTAX_LABEL=Syntax:
INFO_CTRL_PANEL_ATTRIBUTE_TYPE_LABEL=Type:
INFO_CTRL_PANEL_ATTRIBUTE_APPROXIMATE_MATCHING_RULE_LABEL=Approximate \
 Matching Rule:
INFO_CTRL_PANEL_ATTRIBUTE_EQUALITY_MATCHING_RULE_LABEL=Equality \
@@ -2476,6 +2505,49 @@
INFO_CTRL_PANEL_AVERAGE_HEADER=%s Avg per second
INFO_CTRL_PANEL_AUTHENTICATED_AS=Authenticated as '%s'
INFO_CTRL_PANEL_NOT_AUTHENTICATED=User Not Authenticated
INFO_CTRL_PANEL_NOT_AUTHENTICATED_SERVER_NOT_RUNNING=User Not Authenticated \
 (Server not Running)
INFO_CTRL_PANEL_NOT_AUTHENTICATED_SERVER_NOT_RUNNING=User not authenticated \
 (server not running)
INFO_CTRL_PANEL_NOT_AUTHENTICATED_SERVER_REMOTE=User not authenticated \
 (could not connect to server '%s')
INFO_CTRL_PANEL_LOCAL_OR_REMOTE=Select the server that you want to administer:
INFO_CTRL_PANEL_SERVER_REMOTE_SUMMARY=Server is Remote
INFO_CTRL_PANEL_SERVER_MUST_BE_LOCAL_JAVA_PROPERTIES_SUMMARY=The Java Settings \
 can only be updated when the managed server is the local server.
INFO_CTRL_PANEL_SERVER_MUST_BE_LOCAL_VERIFY_INDEX_SUMMARY=The indexes can only \
 be verified when the managed server is the local server.
INFO_CTRL_PANEL_SERVER_MUST_BE_LOCAL_REBUILD_INDEX_SUMMARY=The indexes can \
 only be rebuilt when the managed server is the local server.
INFO_CTRL_PANEL_REMOTE_SERVER_PATH=The path must be accessible by the remote \
 server.
INFO_CTRL_PANEL_SERVER_MUST_BE_LOCAL_WINDOWS_SERVICE_SUMMARY=The Windows \
 Service configuration can only be viewed and updated when the managed server \
 is the local server.
SEVERE_ERR_CTRL_PANEL_ERROR_CREATING_NEW_DATA_LDIF=Could not created local \
 LDIF to populate new base DN with automatically generated data.  Error code: \
 %d.
INFO_CTRL_PANEL_PARENT_BACKUP_ID_LABEL=Parent Backup ID:
INFO_CTRL_PANEL_PARENT_BACKUP_PATH_LABEL=Parent Backup Path:
MILD_ERR_CTRL_PANEL_NO_PARENT_BACKUP_ID_PROVIDED=No parent backup ID provided.
INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_SUMMARY=Could not connect to remote \
 server
INFO_CTRL_PANEL_CANNOT_CONNECT_TO_REMOTE_DETAILS=The remote server '%s' might \
 be down or the provided authentication is no longer valid.  To be able to \
 manage a server remotely it must be running and you must provide \
 authentication.
INFO_CTRL_PANEL_CONNECT_TO_SERVER_MENU=Server to Administer...
INFO_CTRL_PANEL_INDEX_REBUILD_REQUIRED_REMOTE_DETAILS=The index configuration \
 for '%s' was successfully modified.  For the configuration to be taken into \
 account the database index files must be regenerated.  This can be done by \
 using the 'rebuild-index' command-line on the remote server or re-importing \
 the contents of the backend '%s'.
INFO_PROGRESS_IMPORT_AUTOMATICALLY_GENERATED_REMOTE=Importing \
 Automatically-Generated Data (%s Entries)
SEVERE_ERR_NOT_SAME_PRODUCT_IN_REMOTE_SERVER_NOT_FOUND=The remote server in \
 '%s' is cannot be managed by this control panel.  The remote server product \
 name is '%s' and the control panel product name is '%s'.
SEVERE_ERR_INCOMPATIBLE_VERSION_IN_REMOTE_SERVER=The remote server in '%s' has \
 not the same version as the control panel.  The remote server version is \
 '%s.%s.%s' and the control panel version is '%d.%d.%d'.
SEVERE_ERR_VERSION_IN_REMOTE_SERVER_NOT_FOUND=Could not find version \
 information in the remote server.  The remote LDAP server does not seem to be \
 manageable remotely by the control panel.
opends/src/server/org/opends/server/monitors/SystemInfoMonitorProvider.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 */
package org.opends.server.monitors;
@@ -196,7 +196,16 @@
                              String.valueOf(runtime.totalMemory())));
    attrs.add(createAttribute("freeUsedMemory",
                              String.valueOf(runtime.freeMemory())));
    String installPath = DirectoryServer.getServerRoot();
    if (installPath != null)
    {
      attrs.add(createAttribute("installPath", installPath));
    }
    String instancePath = DirectoryServer.getInstanceRoot();
    if (instancePath != null)
    {
      attrs.add(createAttribute("instancePath", instancePath));
    }
    // Get the JVM input arguments.
    RuntimeMXBean rtBean = ManagementFactory.getRuntimeMXBean();
opends/src/server/org/opends/server/tasks/RebuildTask.java
@@ -22,7 +22,7 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 */
package org.opends.server.tasks;
import org.opends.messages.Message;
@@ -65,8 +65,6 @@
import static org.opends.messages.ToolMessages.
    ERR_REBUILDINDEX_CANNOT_EXCLUSIVE_LOCK_BACKEND;
import static org.opends.messages.ToolMessages.
    ERR_REBUILDINDEX_CANNOT_SHARED_LOCK_BACKEND;
import static org.opends.messages.ToolMessages.
    WARN_REBUILDINDEX_CANNOT_UNLOCK_BACKEND;
import static org.opends.server.config.ConfigConstants.
    ATTR_REBUILD_BASE_DN;
@@ -195,8 +193,7 @@
    // to aquire exclusive lock.
    String lockFile = LockFileManager.getBackendLockFileName(backend);
    StringBuilder failureReason = new StringBuilder();
    if(rebuildConfig.includesSystemIndex())
    {
      // Disable the backend.
      try
      {
@@ -230,30 +227,9 @@
        logError(message);
        return TaskState.STOPPED_BY_ERROR;
      }
    }
    else
    {
      try
      {
        if(! LockFileManager.acquireSharedLock(lockFile, failureReason))
        {
          Message message = ERR_REBUILDINDEX_CANNOT_SHARED_LOCK_BACKEND.get(
              backend.getBackendID(), String.valueOf(failureReason));
          logError(message);
          return TaskState.STOPPED_BY_ERROR;
        }
      }
      catch (Exception e)
      {
        Message message = ERR_REBUILDINDEX_CANNOT_SHARED_LOCK_BACKEND.get(
            backend.getBackendID(), getExceptionMessage(e));
        logError(message);
        return TaskState.STOPPED_BY_ERROR;
      }
    }
    TaskState returnCode = TaskState.COMPLETED_SUCCESSFULLY;
    // Launch the rebuild process.
    try
    {
@@ -270,10 +246,11 @@
      Message message =
          ERR_REBUILDINDEX_ERROR_DURING_REBUILD.get(e.getMessage());
      logError(message);
      return TaskState.STOPPED_BY_ERROR;
      returnCode = TaskState.STOPPED_BY_ERROR;
    }
    // Release the lock on the backend.
    finally
    {
    try
    {
      lockFile = LockFileManager.getBackendLockFileName(backend);
@@ -283,18 +260,19 @@
        Message message = WARN_REBUILDINDEX_CANNOT_UNLOCK_BACKEND.get(
            backend.getBackendID(), String.valueOf(failureReason));
        logError(message);
        return TaskState.COMPLETED_WITH_ERRORS;
          returnCode = TaskState.COMPLETED_WITH_ERRORS;
      }
    }
    catch (Exception e)
      catch (Throwable t)
    {
      Message message = WARN_REBUILDINDEX_CANNOT_UNLOCK_BACKEND.get(
          backend.getBackendID(), getExceptionMessage(e));
            backend.getBackendID(), getExceptionMessage(t));
      logError(message);
      return TaskState.COMPLETED_WITH_ERRORS;
        returnCode = TaskState.COMPLETED_WITH_ERRORS;
      }
    }
    if(rebuildConfig.includesSystemIndex())
    if(returnCode == TaskState.COMPLETED_SUCCESSFULLY)
    {
      // Enable the backend.
      try
@@ -309,10 +287,10 @@
        }
        logError(e.getMessageObject());
        return TaskState.STOPPED_BY_ERROR;
        returnCode = TaskState.STOPPED_BY_ERROR;
      }
    }
    return TaskState.COMPLETED_SUCCESSFULLY;
    return returnCode;
  }
}
opends/src/server/org/opends/server/tools/RebuildIndex.java
@@ -22,31 +22,38 @@
 * CDDL HEADER END
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 */
package org.opends.server.tools;
import org.opends.messages.Message;
import static org.opends.server.util.StaticUtils.wrapText;
import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.ArgumentParser;
import org.opends.server.util.args.BooleanArgument;
import org.opends.server.util.args.LDAPConnectionArgumentParser;
import org.opends.server.util.args.StringArgument;
import org.opends.server.extensions.ConfigFileHandler;
import static org.opends.messages.ToolMessages.*;
import org.opends.server.config.ConfigException;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.loggers.ErrorLogger.logError;
import org.opends.server.loggers.TextWriter;
import org.opends.server.loggers.ErrorLogger;
import org.opends.server.loggers.TextErrorLogPublisher;
import org.opends.server.loggers.debug.TextDebugLogPublisher;
import org.opends.server.loggers.debug.DebugLogger;
import org.opends.server.protocols.ldap.LDAPAttribute;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.LockFileManager;
import org.opends.server.tasks.RebuildTask;
import org.opends.server.tools.tasks.TaskTool;
import org.opends.server.types.*;
import org.opends.server.api.Backend;
import org.opends.server.api.ErrorLogPublisher;
@@ -67,8 +74,12 @@
 * intended to run separate from Directory Server and not internally within the
 * server process (e.g., via the tasks interface).
 */
public class RebuildIndex
public class RebuildIndex extends TaskTool
{
  private StringArgument  configClass             = null;
  private StringArgument  configFile              = null;
  private StringArgument  baseDNString            = null;
  private StringArgument  indexList               = null;
  /**
   * Processes the command-line arguments and invokes the rebuild process.
@@ -102,6 +113,12 @@
                                     OutputStream outStream,
                                     OutputStream errStream)
  {
    RebuildIndex tool = new RebuildIndex();
    return tool.process(args, initializeServer, outStream, errStream);
  }
  private int process(String[] args, boolean initializeServer,
      OutputStream outStream, OutputStream errStream) {
    PrintStream out;
    if (outStream == null)
    {
@@ -123,18 +140,14 @@
    }
    // Define the command-line arguments that may be used with this program.
    StringArgument  configClass             = null;
    StringArgument  configFile              = null;
    StringArgument  baseDNString            = null;
    StringArgument  indexList               = null;
    BooleanArgument displayUsage            = null;
    // Create the command-line argument parser for use with this program.
    Message toolDescription = INFO_REBUILDINDEX_TOOL_DESCRIPTION.get();
    ArgumentParser argParser =
         new ArgumentParser("org.opends.server.tools.RebuildIndex",
                            toolDescription, false);
    LDAPConnectionArgumentParser argParser =
      createArgParser("org.opends.server.tools.RebuildIndex",
                            toolDescription);
    // Initialize all the command-line argument types and register them with the
@@ -232,6 +245,17 @@
      return 1;
    }
    return process(argParser, initializeServer, out, err);
  }
  /**
   * {@inheritDoc}
   */
  @Override
  protected int processLocal(boolean initializeServer,
                           PrintStream out,
                           PrintStream err) {
    // Perform the initial bootstrap of the Directory Server and process the
    // configuration.
    DirectoryServer directoryServer = DirectoryServer.getInstance();
@@ -512,4 +536,50 @@
    return returnCode;
  }
  /**
   * {@inheritDoc}
   */
  public String getTaskId() {
    // NYI.
    return null;
  }
  /**
   * {@inheritDoc}
   */
  public void addTaskAttributes(List<RawAttribute> attributes)
  {
    //
    // Required attributes
    //
    ArrayList<ByteString> values;
    String baseDN = baseDNString.getValue();
    values = new ArrayList<ByteString>(1);
    values.add(ByteString.valueOf(baseDN));
    attributes.add(new LDAPAttribute(ATTR_REBUILD_BASE_DN, values));
    List<String> indexes = indexList.getValues();
    values = new ArrayList<ByteString>(indexes.size());
    for (String s : indexes)
    {
      values.add(ByteString.valueOf(s));
    }
    attributes.add(new LDAPAttribute(ATTR_REBUILD_INDEX, values));
  }
  /**
   * {@inheritDoc}
   */
  public String getTaskObjectclass() {
    return "ds-task-rebuild";
  }
  /**
   * {@inheritDoc}
   */
  public Class getTaskClass() {
    return RebuildTask.class;
  }
}
opends/src/server/org/opends/server/tools/status/StatusCli.java
@@ -575,6 +575,10 @@
      status = INFO_SERVER_STOPPING_LABEL.get();
      break;
    case NOT_CONNECTED_TO_REMOTE:
      status = INFO_SERVER_NOT_CONNECTED_TO_REMOTE_STATUS_LABEL.get();
      break;
    case UNKNOWN:
      status = INFO_SERVER_UNKNOWN_STATUS_LABEL.get();
      break;