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

jvergara
28.20.2007 beb0fcc101626f90436e0670b30e8164e57bf17a
Complete fix for issue 1613 applying the fix also to the status-panel and status command lines.
3 files modified
138 ■■■■■ changed files
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusCli.java 71 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusPanelLauncher.java 47 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/resources/Resources.properties 20 ●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusCli.java
@@ -50,8 +50,15 @@
import org.opends.statuspanel.ui.DatabasesTableModel;
import org.opends.statuspanel.ui.ListenersTableModel;
import static org.opends.server.messages.ToolMessages.*;
import static org.opends.server.tools.ToolConstants.*;
import org.opends.server.util.PasswordReader;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.args.ArgumentParser;
import org.opends.server.util.args.BooleanArgument;
import org.opends.server.util.args.FileBasedArgument;
import org.opends.server.util.args.StringArgument;
/**
 * The class used to provide some CLI interface to display status.
@@ -374,21 +381,57 @@
  private void printUsage(PrintStream stream)
  {
    String arg;
    if (Utils.isWindows())
    {
      arg = Installation.WINDOWS_STATUSCLI_FILE_NAME;
    } else
    {
      arg = Installation.UNIX_STATUSCLI_FILE_NAME;
    ArgumentParser argParser =
      new ArgumentParser(StatusPanelLauncher.class.getName(),
        getI18n().getMsg("status-cli-usage-description"), false);
    BooleanArgument showUsage;
    StringArgument bindDN;
    StringArgument bindPW;
    FileBasedArgument bindPWFile;
    String scriptName;
    if (Utils.isWindows()) {
      scriptName = Installation.WINDOWS_STATUSCLI_FILE_NAME;
    } else {
      scriptName = Installation.UNIX_STATUSCLI_FILE_NAME;
    }
    /*
     * This is required because the usage message contains '{' characters that
     * mess up the MessageFormat.format method.
     */
    String msg = getMsg("status-cli-usage", true);
    msg = msg.replace("{0}", arg);
    stream.println(msg);
    System.setProperty(ServerConstants.PROPERTY_SCRIPT_NAME, scriptName);
    try
    {
      bindDN = new StringArgument("binddn", OPTION_SHORT_BINDDN,
          OPTION_LONG_BINDDN, false, false, true,
          OPTION_VALUE_BINDDN, null, null,
          MSGID_STOPDS_DESCRIPTION_BINDDN);
      argParser.addArgument(bindDN);
      bindPW = new StringArgument("bindpw", OPTION_SHORT_BINDPWD,
          OPTION_LONG_BINDPWD, false, false,
          true,
          OPTION_VALUE_BINDPWD, null, null,
          MSGID_STOPDS_DESCRIPTION_BINDPW);
      argParser.addArgument(bindPW);
      bindPWFile = new FileBasedArgument("bindpwfile",
          OPTION_SHORT_BINDPWD_FILE,
          OPTION_LONG_BINDPWD_FILE,
          false, false,
          OPTION_VALUE_BINDPWD_FILE,
          null, null,
          MSGID_STOPDS_DESCRIPTION_BINDPWFILE);
      argParser.addArgument(bindPWFile);
      showUsage = new BooleanArgument("showusage", OPTION_SHORT_HELP,
        OPTION_LONG_HELP,
        MSGID_DESCRIPTION_USAGE);
      argParser.addArgument(showUsage);
      argParser.setUsageArgument(showUsage);
      String msg = argParser.getUsage();
      stream.println(msg);
    }
    catch (Throwable t)
    {
      System.out.println("ERROR: "+t);
      t.printStackTrace();
    }
  }
  private ServerStatusDescriptor createServerStatusDescriptor(String dn,
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusPanelLauncher.java
@@ -36,7 +36,12 @@
import org.opends.quicksetup.util.Utils;
import org.opends.quicksetup.Installation;
import org.opends.server.core.DirectoryServer;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.args.ArgumentParser;
import org.opends.server.util.args.BooleanArgument;
import org.opends.statuspanel.i18n.ResourceProvider;
import static org.opends.server.messages.ToolMessages.*;
import static org.opends.server.tools.ToolConstants.*;
/**
@@ -89,7 +94,7 @@
        printVersion = true;
      }
    }
    // We first check if we have to pribt the version
    // We first check if we have to print the version
    if(printVersion)
    {
      try
@@ -209,21 +214,33 @@
  private static void printUsage(PrintStream stream)
  {
    String arg;
    if (Utils.isWindows())
    {
      arg = Installation.WINDOWS_STATUSPANEL_FILE_NAME;
    } else
    {
      arg = Installation.UNIX_STATUSPANEL_FILE_NAME;
    ArgumentParser argParser =
      new ArgumentParser(StatusPanelLauncher.class.getName(),
        getI18n().getMsg("status-panel-launcher-usage-description"), false);
    BooleanArgument showUsage;
    String scriptName;
    if (Utils.isWindows()) {
      scriptName = Installation.WINDOWS_STATUSPANEL_FILE_NAME;
    } else {
      scriptName = Installation.UNIX_STATUSPANEL_FILE_NAME;
    }
    /*
     * This is required because the usage message contains '{' characters that
     * mess up the MessageFormat.format method.
     */
    String msg = getMsg("status-panel-launcher-usage");
    msg = msg.replace("{0}", arg);
    stream.println(msg);
    System.setProperty(ServerConstants.PROPERTY_SCRIPT_NAME, scriptName);
    try
    {
      showUsage = new BooleanArgument("showusage", OPTION_SHORT_HELP,
        OPTION_LONG_HELP,
        MSGID_DESCRIPTION_USAGE);
      argParser.addArgument(showUsage);
      argParser.setUsageArgument(showUsage);
      String msg = argParser.getUsage();
      stream.println(msg);
    }
    catch (Throwable t)
    {
      System.out.println("ERROR: "+t);
      t.printStackTrace();
    }
  }
  /**
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/resources/Resources.properties
@@ -31,12 +31,9 @@
#
# StatusPanel launcher
#
status-panel-launcher-usage=This utility may be used to display the Status \
Panel window which displays basic server information and allows to \
start, stop and restart the server.\n\
Usage:  {0} {options}\n        where {options} include:\n\
-V, --version\n    Display Directory Server version information.\n\
-?, -H, --help\n    Display this usage information.
status-panel-launcher-usage-description=This utility may be used to display \
the Status Panel window which displays basic server information and allows to \
start, stop and restart the server.
status-panel-launcher-gui-launch-failed=Could not launch Status Panel.  Check \
that you have access to the display.
status-panel-launcher-gui-launch-failed-details=Could not launch Status \
@@ -172,15 +169,8 @@
file {0}.  Check that the file path is correct, that you have access rights to \
it and that it contains a password.
cli-status-ldapauth-password-prompt=Password for user {0}:  
status-cli-usage=This utility may be used to display basic server \
information\n\n\
Usage:  {0} {options}\n        where {options} include:\n\
-V, --version\n    Display Directory Server version information\n\
-D {bindDN}, --bindDN {bindDN}\n    Bind DN\n\
-w {bindPassword}, --bindPassword {bindPassword}\n    Bind password\n\
-j {bindPasswordFile}, --bindPasswordFile {bindPasswordFile}\n    Bind \
password file\n\
-?, -H , --help\n    Display this usage information.
status-cli-usage-description=This utility may be used to display basic server \
information
not-available-authentication-required-cli-label=<not available> (*)
not-available-authentication-required-cli-legend=* Information only available \
if you provide authentication information when launching the status \