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

jvergara
20.11.2007 7008381ae6c2eb1fd67a1cc50b8e78dbc2fc78c6
Fix for issue 2006.

Compare the values provided by the user for the different ports. If they match, display an error message.
3 files modified
94 ■■■■■ changed files
opends/src/server/org/opends/server/messages/ToolMessages.java 11 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/ConfigureDS.java 50 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/InstallDS.java 33 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/messages/ToolMessages.java
@@ -9143,7 +9143,13 @@
  public static final int MSGID_DSCFG_ERROR_UNABLE_TO_SET_NAMING_PROPERTY =
       CATEGORY_MASK_TOOLS | SEVERITY_MASK_SEVERE_ERROR | 1210;
  /**
   * The message ID for the message that will be used if the user specifies
   * the same port for different protocols.  This takes as argument the value of
   * the culprit port.
   */
  public static final int MSGID_CONFIGDS_PORT_ALREADY_SPECIFIED  =
    CATEGORY_MASK_TOOLS | SEVERITY_MASK_SEVERE_ERROR | 1211;
  /**
   * Associates a set of generic messages with the message IDs defined in this
@@ -10476,6 +10482,9 @@
                    "Server configuration:  %s");
    registerMessage(MSGID_CONFIGDS_NO_CONFIG_CHANGES,
                    "ERROR:  No configuration changes were specified");
    registerMessage(MSGID_CONFIGDS_PORT_ALREADY_SPECIFIED,
                    "ERROR:  You have specified the value %s for different " +
                    "ports.");
    registerMessage(MSGID_CONFIGDS_WROTE_UPDATED_CONFIG,
                    "Successfully wrote the updated Directory Server " +
                    "configuration");
opends/src/server/org/opends/server/tools/ConfigureDS.java
@@ -28,7 +28,9 @@
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import org.opends.server.api.ConfigHandler;
import org.opends.server.config.BooleanConfigAttribute;
@@ -329,6 +331,54 @@
      return 1;
    }
    try
    {
      Set<Integer> ports = new HashSet<Integer>();
      if (ldapPort.isPresent())
      {
        ports.add(ldapPort.getIntValue());
      }
      if (ldapsPort.isPresent())
      {
        if (ports.contains(ldapsPort.getIntValue()))
        {
          int    msgID   = MSGID_CONFIGDS_PORT_ALREADY_SPECIFIED;
          String message = getMessage(msgID,
              String.valueOf(ldapsPort.getIntValue()));
          System.err.println(wrapText(message, MAX_LINE_WIDTH));
          System.err.println(argParser.getUsage());
          return 1;
        }
        else
        {
          ports.add(ldapsPort.getIntValue());
        }
      }
      if (jmxPort.isPresent())
      {
        if (ports.contains(jmxPort.getIntValue()))
        {
          int    msgID   = MSGID_CONFIGDS_PORT_ALREADY_SPECIFIED;
          String message = getMessage(msgID,
              String.valueOf(jmxPort.getIntValue()));
          System.err.println(wrapText(message, MAX_LINE_WIDTH));
          System.err.println(argParser.getUsage());
          return 1;
        }
        else
        {
          ports.add(jmxPort.getIntValue());
        }
      }
    }
    catch (ArgumentException ae)
    {
      int    msgID   = MSGID_CANNOT_INITIALIZE_ARGS;
      String message = getMessage(msgID, ae.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
    // Initialize the Directory Server configuration handler using the
    // information that was provided.
opends/src/server/org/opends/server/tools/InstallDS.java
@@ -32,7 +32,9 @@
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import org.opends.server.core.DirectoryServer;
import org.opends.server.extensions.ConfigFileHandler;
@@ -334,6 +336,37 @@
      return 0;
    }
    try
    {
      Set<Integer> ports = new HashSet<Integer>();
      if (ldapPort.isPresent())
      {
        ports.add(ldapPort.getIntValue());
      }
      if (jmxPort.isPresent())
      {
        if (ports.contains(jmxPort.getIntValue()))
        {
          int    msgID   = MSGID_CONFIGDS_PORT_ALREADY_SPECIFIED;
          String message = getMessage(msgID,
              String.valueOf(jmxPort.getIntValue()));
          System.err.println(wrapText(message, MAX_LINE_WIDTH));
          System.err.println(argParser.getUsage());
          return 1;
        }
        else
        {
          ports.add(jmxPort.getIntValue());
        }
      }
    }
    catch (ArgumentException ae)
    {
      int    msgID   = MSGID_CANNOT_INITIALIZE_ARGS;
      String message = getMessage(msgID, ae.getMessage());
      System.err.println(wrapText(message, MAX_LINE_WIDTH));
      return 1;
    }
    // Make sure that the user didn't provide conflicting arguments.
    if (addBaseEntry.isPresent())