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

jvergara
02.04.2007 cd7ddcc30ed1b2cedf327e3c45185f815bf7ca29
opends/src/server/org/opends/server/tools/ConfigureDS.java
@@ -42,6 +42,7 @@
import org.opends.server.protocols.ldap.LDAPResultCode;
import org.opends.server.types.DirectoryException;
import org.opends.server.types.DN;
import org.opends.server.util.SetupUtils;
import org.opends.server.util.args.ArgumentException;
import org.opends.server.util.args.ArgumentParser;
import org.opends.server.util.args.BooleanArgument;
@@ -99,6 +100,12 @@
       "cn=LDAP Connection Handler," + DN_CONNHANDLER_BASE;
  /**
   * The DN of the configuration entry defining the JMX connection handler.
   */
  private static final String DN_JMX_CONNECTION_HANDLER =
       "cn=JMX Connection Handler," + DN_CONNHANDLER_BASE;
  /**
   * The DN of the configuration entry defining the initial root user.
@@ -140,6 +147,7 @@
    BooleanArgument   showUsage;
    FileBasedArgument rootPasswordFile;
    IntegerArgument   ldapPort;
    IntegerArgument   jmxPort;
    StringArgument    baseDNString;
    StringArgument    configClass;
    StringArgument    configFile;
@@ -171,6 +179,12 @@
                                     MSGID_CONFIGDS_DESCRIPTION_LDAP_PORT);
      argParser.addArgument(ldapPort);
      jmxPort = new IntegerArgument("jmxport", 'j', "jmxPort", false, false,
          true, "{jmxPort}", SetupUtils.getDefaultJMXPort(), null, true, 1,
          true, 65535,
          MSGID_CONFIGDS_DESCRIPTION_JMX_PORT);
      argParser.addArgument(jmxPort);
      baseDNString = new StringArgument("basedn", 'b', "baseDN", false, true,
                                        true, "{baseDN}", "dc=example,dc=com",
                                        null,
@@ -233,7 +247,7 @@
    // Make sure that the user actually tried to configure something.
    if (! (baseDNString.isPresent() || ldapPort.isPresent() ||
           rootDNString.isPresent()))
        jmxPort.isPresent() || rootDNString.isPresent()))
    {
      int    msgID   = MSGID_CONFIGDS_NO_CONFIG_CHANGES;
      String message = getMessage(msgID);
@@ -426,6 +440,31 @@
        }
      }
//    If an JMX port was specified, then update the config accordingly.
      if (jmxPort.isPresent())
      {
        try
        {
          DN jmxListenerDN = DN.decode(DN_JMX_CONNECTION_HANDLER);
          ConfigEntry configEntry =
               configHandler.getConfigEntry(jmxListenerDN);
          int msgID = MSGID_JMX_CONNHANDLER_DESCRIPTION_LISTEN_PORT;
          IntegerConfigAttribute portAttr =
               new IntegerConfigAttribute(ATTR_LISTEN_PORT, getMessage(msgID),
                                          true, false, true, true, 1, true,
                                          65535, jmxPort.getIntValue());
          configEntry.putConfigAttribute(portAttr);
        }
        catch (Exception e)
        {
          int    msgID   = MSGID_CONFIGDS_CANNOT_UPDATE_JMX_PORT;
          String message = getMessage(msgID, String.valueOf(e));
          System.err.println(wrapText(message, MAX_LINE_WIDTH));
          return 1;
        }
      }
      // If a root user DN and password were specified, then update the config
      // accordingly.