From 9c88e7e8be7dde117ada9ae483d535b99c6c11dc Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Tue, 25 Feb 2014 10:35:48 +0000
Subject: [PATCH] Checkpoint OPENDJ-1343 Migrate dsconfig - Code cleanup. Thanks to AutoRefactor ;)

---
 opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java |  104 +++++++++++++++++++++------------------------------
 1 files changed, 43 insertions(+), 61 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java
index e6061bb..ae71217 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsconfig/LDAPManagementContextFactory.java
@@ -73,19 +73,19 @@
 public final class LDAPManagementContextFactory implements
     ManagementContextFactory {
 
-  // The SecureConnectionCliArgsList object.
+  /** The SecureConnectionCliArgsList object. */
   private SecureConnectionCliArgs secureArgsList = null;
 
-  // The management context.
+  /** The management context. */
   private ManagementContext context = null;
 
-  // The connection parameters command builder.
+  /** The connection parameters command builder. */
   private CommandBuilder contextCommandBuilder;
 
-  // This CLI is always using the administration connector with SSL
+  /** This CLI is always using the administration connector with SSL. */
   private boolean alwaysSSL = false;
 
-  // Raw arguments
+  /** Raw arguments. */
   private String[] rawArgs = null;
 
   /**
@@ -98,9 +98,7 @@
     this.alwaysSSL = alwaysSSL;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public ManagementContext getManagementContext(ConsoleApplication app)
       throws ArgumentException, ClientException
@@ -117,9 +115,7 @@
     return context;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void close()
   {
@@ -129,9 +125,7 @@
     }
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public CommandBuilder getContextCommandBuilder()
   {
@@ -190,51 +184,47 @@
           }
           catch (NamingException e)
           {
-            if ( app.isInteractive() && ci.isTrustStoreInMemory())
+            if (app.isInteractive()
+                && ci.isTrustStoreInMemory()
+                && e.getRootCause() != null
+                && e.getRootCause().getCause() instanceof OpendsCertificateException)
             {
-              if ((e.getRootCause() != null)
-                  && (e.getRootCause().getCause()
-                      instanceof OpendsCertificateException))
-              {
-                OpendsCertificateException oce =
+              OpendsCertificateException oce =
                   (OpendsCertificateException) e.getRootCause().getCause();
-                String authType = null;
-                if (trustManager instanceof ApplicationTrustManager)
-                {
-                  ApplicationTrustManager appTrustManager =
-                    (ApplicationTrustManager)trustManager;
-                  authType = appTrustManager.getLastRefusedAuthType();
-                }
-                  if (ci.checkServerCertificate(oce.getChain(), authType,
-                      hostName))
-                  {
-                    // If the certificate is trusted, update the trust manager.
-                    trustManager = ci.getTrustManager();
-
-                    // Try to connect again.
-                    continue ;
-                  }
+              String authType = null;
+              if (trustManager instanceof ApplicationTrustManager)
+              {
+                ApplicationTrustManager appTrustManager =
+                    (ApplicationTrustManager) trustManager;
+                authType = appTrustManager.getLastRefusedAuthType();
+              }
+              if (ci.checkServerCertificate(oce.getChain(), authType, hostName))
+              {
+                // If the certificate is trusted, update the trust manager.
+                trustManager = ci.getTrustManager();
+                // Try to connect again.
+                continue;
               }
             }
             if (e.getRootCause() != null) {
-              if (e.getRootCause().getCause() != null) {
-                if (((e.getRootCause().getCause()
-                  instanceof OpendsCertificateException)) ||
-                  (e.getRootCause() instanceof SSLHandshakeException)) {
-                  LocalizableMessage message =
-                    ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_NOT_TRUSTED.get(hostName, portNumber);
-                  throw new ClientException(
-                    ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message);
-                }
+              if (e.getRootCause().getCause() != null
+                  && (e.getRootCause().getCause() instanceof OpendsCertificateException
+                  || e.getRootCause() instanceof SSLHandshakeException))
+              {
+                final LocalizableMessage message =
+                    ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_NOT_TRUSTED.get(
+                        hostName, portNumber);
+                throw new ClientException(ReturnCode.CLIENT_SIDE_CONNECT_ERROR,
+                    message);
               }
               if (e.getRootCause() instanceof SSLException) {
-                LocalizableMessage message =
+                final LocalizableMessage message =
                   ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_WRONG_PORT.get(hostName, portNumber);
                 throw new ClientException(
                     ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message);
               }
             }
-            LocalizableMessage message = ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get(hostName, portNumber);
+            final LocalizableMessage message = ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT.get(hostName, portNumber);
             throw new ClientException(
                 ReturnCode.CLIENT_SIDE_CONNECT_ERROR, message);
           }
@@ -259,9 +249,8 @@
           {
             if ( app.isInteractive() && ci.isTrustStoreInMemory())
             {
-              if ((e.getRootCause() != null)
-                  && (e.getRootCause().getCause()
-                      instanceof OpendsCertificateException))
+              if (e.getRootCause() != null
+                  && e.getRootCause().getCause() instanceof OpendsCertificateException)
               {
                 String authType = null;
                 if (trustManager instanceof ApplicationTrustManager)
@@ -332,18 +321,14 @@
     return context;
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void setRawArguments(String[] args) {
     this.rawArgs = args;
 
   }
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void registerGlobalArguments(SubCommandArgumentParser parser)
       throws ArgumentException {
@@ -367,8 +352,7 @@
             continue;
           }
           if (rawArg.contains(OPTION_LONG_HELP) ||
-            (rawArg.charAt(1) == OPTION_SHORT_HELP) || (rawArg.
-            charAt(1) == '?')) {
+            rawArg.charAt(1) == OPTION_SHORT_HELP || rawArg.charAt(1) == '?') {
             // used for usage help default values only
             secureArgsList.initArgumentsWithConfiguration();
           }
@@ -383,9 +367,7 @@
 
 
 
-  /**
-   * {@inheritDoc}
-   */
+  /** {@inheritDoc} */
   @Override
   public void validateGlobalArguments() throws ArgumentException {
     // Make sure that the user didn't specify any conflicting

--
Gitblit v1.10.0