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

Violette Roche-Montane
26.54.2014 1a9b0c4c35b0fbcc2cf09db1f40a17fc76cb4a90
Minor code cleanup.
4 files modified
104 ■■■■ changed files
opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java 30 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java 68 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java 4 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java 2 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/guitools/org/opends/guitools/uninstaller/UninstallerArgumentParser.java
@@ -27,6 +27,11 @@
package org.opends.guitools.uninstaller;
import static com.forgerock.opendj.cli.ArgumentConstants.OPTION_LONG_REFERENCED_HOST_NAME;
import static com.forgerock.opendj.cli.ArgumentConstants.OPTION_SHORT_HOST;
import static com.forgerock.opendj.cli.Utils.LINE_SEPARATOR;
import static com.forgerock.opendj.cli.CliMessages.*;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.LinkedHashSet;
@@ -36,20 +41,14 @@
import org.opends.quicksetup.UserData;
import org.opends.server.admin.client.cli.SecureConnectionCliArgs;
import org.opends.server.admin.client.cli.SecureConnectionCliParser;
import org.opends.server.tools.JavaPropertiesTool.ErrorReturnCode;
import com.forgerock.opendj.cli.Argument;
import com.forgerock.opendj.cli.ArgumentException;
import com.forgerock.opendj.cli.BooleanArgument;
import com.forgerock.opendj.cli.CommonArguments;
import com.forgerock.opendj.cli.ReturnCode;
import com.forgerock.opendj.cli.StringArgument;
import static org.opends.messages.AdminToolMessages.*;
import static org.opends.messages.ToolMessages.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.LINE_SEPARATOR;
/**
 * Class used to parse and populate the arguments of the Uninstaller.
 *
@@ -70,7 +69,7 @@
  private StringArgument referencedHostNameArg;
  // This CLI is always using the administration connector with SSL
  /** This CLI is always using the administration connector with SSL. */
  private final boolean alwaysSSL = true;
  /**
@@ -372,12 +371,11 @@
  @Override
  public int validateGlobalOptions(LocalizableMessageBuilder buf)
  {
    int returnValue;
    if (!noPromptArg.isPresent() && forceOnErrorArg.isPresent())
    {
      LocalizableMessage message = ERR_UNINSTALL_FORCE_REQUIRES_NO_PROMPT.get(
          "--"+forceOnErrorArg.getLongIdentifier(),
          "--"+noPromptArg.getLongIdentifier());
      final LocalizableMessage message =
          ERR_TOOL_CONFLICTING_ARGS.get(forceOnErrorArg.getLongIdentifier(),
              noPromptArg.getLongIdentifier());
      if (buf.length() > 0)
      {
        buf.append(LINE_SEPARATOR);
@@ -412,13 +410,9 @@
    super.validateGlobalOptions(buf);
    if (buf.length() > 0)
    {
      returnValue = ErrorReturnCode.CONFLICTING_ARGS.getReturnCode();
      return ReturnCode.CONFLICTING_ARGS.get();
    }
    else
    {
      returnValue = ErrorReturnCode.SUCCESSFUL_NOP.getReturnCode();
    }
    return returnValue;
    return ReturnCode.SUCCESS.get();
  }
  /**
opendj3-server-dev/src/server/org/opends/server/admin/client/cli/SecureConnectionCliArgs.java
@@ -68,11 +68,10 @@
import com.forgerock.opendj.cli.StringArgument;
/**
 * This is a commodity class that can be used to check the arguments required
 * to establish a secure connection in the command line.  It can be used
 * to generate an ApplicationTrustManager object based on the options provided
 * by the user in the command line.
 *
 * This is a commodity class that can be used to check the arguments required to
 * establish a secure connection in the command line. It can be used to generate
 * an ApplicationTrustManager object based on the options provided by the user
 * in the command line.
 */
public final class SecureConnectionCliArgs
{
@@ -228,10 +227,11 @@
  }
  /**
   * Tells whether this parser uses the Administrator UID (instead of the
   * bind DN) or not.
   * @return <CODE>true</CODE> if this parser uses the Administrator UID and
   * <CODE>false</CODE> otherwise.
   * Tells whether this parser uses the Administrator UID (instead of the bind
   * DN) or not.
   *
   * @return {@code true} if this parser uses the Administrator UID and
   *         {@code false} otherwise.
   */
  public boolean useAdminUID()
  {
@@ -600,30 +600,29 @@
  /**
   * Returns <CODE>true</CODE> if we can read on the provided path and
   * <CODE>false</CODE> otherwise.
   * @param path the path.
   * @return <CODE>true</CODE> if we can read on the provided path and
   * <CODE>false</CODE> otherwise.
   * Returns {@code true} if we can read on the provided path and
   * {@code false} otherwise.
   *
   * @param path
   *          the path.
   * @return {@code true} if we can read on the provided path and
   *         {@code false} otherwise.
   */
  private boolean canRead(String path)
  {
    final File file = new File(path);
    if (file.exists())
    {
      return file.canRead();
    }
    return false;
    return file.exists() && file.canRead();
  }
  /**
   *  Returns the absolute path of the trust store file that appears on the
   *  config.  Returns <CODE>null</CODE> if the trust store is not defined or
   *  it does not exist.
   * Returns the absolute path of the trust store file that appears on the
   * config. Returns {@code null} if the trust store is not defined or it
   * does not exist.
   *
   *  @return the absolute path of the trust store file that appears on the
   *  config.
   *  @throws ConfigException if there is an error reading the configuration.
   * @return the absolute path of the trust store file that appears on the
   *         config.
   * @throws ConfigException
   *           if there is an error reading the configuration.
   */
  public String getTruststoreFileFromConfig() throws ConfigException
  {
@@ -681,8 +680,10 @@
  /**
   * Returns the admin port from the configuration.
   *
   * @return the admin port from the configuration.
   * @throws ConfigException if an error occurs reading the configuration.
   * @throws ConfigException
   *           if an error occurs reading the configuration.
   */
  public int getAdminPortFromConfig() throws ConfigException
  {
@@ -726,10 +727,11 @@
  /**
   * Returns the port to be used according to the configuration and the
   * arguments provided by the user.
   * This method should be called after the arguments have been parsed.
   * arguments provided by the user. This method should be called after the
   * arguments have been parsed.
   *
   * @return the port to be used according to the configuration and the
   * arguments provided by the user.
   *         arguments provided by the user.
   */
  public int getPortFromConfig()
  {
@@ -742,10 +744,10 @@
      {
        portNumber = getAdminPortFromConfig();
      } catch (ConfigException ex) {
        // nothing to do
        // Nothing to do
      }
    } else {
      portNumber = 636;
      portNumber = CliConstants.DEFAULT_SSL_PORT;
    }
    return portNumber;
  }
@@ -753,7 +755,9 @@
  /**
   * Updates the default values of the port and the trust store with what is
   * read in the configuration.
   * @throws ConfigException if there is an error reading the configuration.
   *
   * @throws ConfigException
   *           if there is an error reading the configuration.
   */
  public void initArgumentsWithConfiguration() throws ConfigException
  {
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java
@@ -61,7 +61,6 @@
import org.opends.admin.ads.util.ApplicationTrustManager;
import org.opends.admin.ads.util.ConnectionUtils;
import org.opends.server.admin.client.cli.SecureConnectionCliArgs;
import org.opends.server.tools.JavaPropertiesTool.ErrorReturnCode;
import org.opends.server.util.cli.LDAPConnectionConsoleInteraction;
import com.forgerock.opendj.cli.Argument;
@@ -202,7 +201,6 @@
          {
            if (app.isInteractive()
                && ci.isTrustStoreInMemory()
                && e.getCause() != null
                && e.getCause() instanceof SSLException
                && e.getCause().getCause() instanceof CertificateException)
            {
@@ -354,7 +352,7 @@
    // arguments.
    LocalizableMessageBuilder buf = new LocalizableMessageBuilder();
    int v = secureArgsList.validateGlobalOptions(buf);
    if (v != ErrorReturnCode.SUCCESSFUL_NOP.getReturnCode())
    if (v != ReturnCode.SUCCESS.get())
    {
      throw new ArgumentException(buf.toMessage());
    }
opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java
@@ -827,8 +827,6 @@
   *           parsed successfully.
   * @throws ClientException
   *           If the management context could not be created.
   * @throws ClientException
   *           If a CLI exception occurred.
   */
  public abstract MenuResult<Integer> run(ConsoleApplication app,
      ManagementContextFactory factory) throws ArgumentException,