From 0b4d509011ee8f909711a31d9c1823d00bb368fd Mon Sep 17 00:00:00 2001
From: Violette Roche-Montane <violette.roche-montane@forgerock.com>
Date: Tue, 01 Apr 2014 09:07:24 +0000
Subject: [PATCH] Minor code cleanup
---
opendj-server/src/main/java/org/forgerock/opendj/server/setup/cli/SetupCli.java | 2 +-
opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java | 10 +++++-----
opendj-cli/src/main/java/com/forgerock/opendj/cli/ConnectionFactoryProvider.java | 28 +++++++++++++---------------
3 files changed, 19 insertions(+), 21 deletions(-)
diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java
index 72bf4f9..9e4a9a3 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java
@@ -27,6 +27,7 @@
import static com.forgerock.opendj.cli.CliMessages.*;
import static com.forgerock.opendj.cli.ArgumentConstants.*;
+import static com.forgerock.opendj.cli.CliConstants.DEFAULT_LDAP_CONNECT_TIMEOUT;
import org.forgerock.i18n.LocalizableMessage;
@@ -400,16 +401,15 @@
/**
* Returns the "connectTimeout" integer argument.
*
- * @param defaultTimeout
- * The default timeout.
* @return The "connectTimeout" argument.
* @throws ArgumentException
* If there is a problem with any of the parameters used to create this argument.
*/
- public static IntegerArgument getConnectTimeOut(final int defaultTimeout) throws ArgumentException {
+ public static IntegerArgument getConnectTimeOut() throws ArgumentException {
final IntegerArgument connectTimeout = new IntegerArgument(OPTION_LONG_CONNECT_TIMEOUT, null,
- OPTION_LONG_CONNECT_TIMEOUT, false, false, true, INFO_TIMEOUT_PLACEHOLDER.get(), defaultTimeout, null,
- true, 0, false, Integer.MAX_VALUE, INFO_DESCRIPTION_CONNECTION_TIMEOUT.get());
+ OPTION_LONG_CONNECT_TIMEOUT, false, false, true, INFO_TIMEOUT_PLACEHOLDER.get(),
+ DEFAULT_LDAP_CONNECT_TIMEOUT, null, true, 0, false, Integer.MAX_VALUE,
+ INFO_DESCRIPTION_CONNECTION_TIMEOUT.get());
connectTimeout.setPropertyName(OPTION_LONG_CONNECT_TIMEOUT);
connectTimeout.setHidden(true);
return connectTimeout;
diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/ConnectionFactoryProvider.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/ConnectionFactoryProvider.java
index 2c84378..be4754b 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/ConnectionFactoryProvider.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/ConnectionFactoryProvider.java
@@ -330,8 +330,9 @@
throw new ArgumentException(message);
}
- /* Couldn't have at the same time trustAll and
- trustStore related arg*/
+ /*
+ * Couldn't have at the same time trustAll and trustStore related arg
+ */
if (trustAllArg.isPresent() && trustStorePathArg.isPresent()) {
final LocalizableMessage message =
ERR_TOOL_CONFLICTING_ARGS.get(trustAllArg.getLongIdentifier(),
@@ -351,8 +352,9 @@
throw new ArgumentException(message);
}
- /* Couldn't have at the same time trustStorePasswordArg and
- trustStorePasswordFileArg*/
+ /*
+ * Couldn't have at the same time trustStorePasswordArg and trustStorePasswordFileArg
+ */
if (trustStorePasswordArg.isPresent() && trustStorePasswordFileArg.isPresent()) {
final LocalizableMessage message =
ERR_TOOL_CONFLICTING_ARGS.get(trustStorePasswordArg.getLongIdentifier(),
@@ -451,10 +453,8 @@
* <CODE>false</CODE> otherwise.
*/
private boolean canReadPath(final String path) {
- boolean canRead;
final File file = new File(path);
- canRead = file.exists() && file.canRead();
- return canRead;
+ return file.exists() && file.canRead();
}
private String getAuthID(final String mech) throws ArgumentException {
@@ -536,24 +536,24 @@
|| bindPasswordArg.isPresent()) {
bindRequest = Requests.newSimpleBindRequest(getBindName(), getPassword());
}
- } else if (mech.equals(DigestMD5SASLBindRequest.SASL_MECHANISM_NAME)) {
+ } else if (DigestMD5SASLBindRequest.SASL_MECHANISM_NAME.equals(mech)) {
bindRequest =
Requests.newDigestMD5SASLBindRequest(
getAuthID(DigestMD5SASLBindRequest.SASL_MECHANISM_NAME),
getPassword()).setAuthorizationID(getAuthzID())
.setRealm(getRealm());
- } else if (mech.equals(CRAMMD5SASLBindRequest.SASL_MECHANISM_NAME)) {
+ } else if (CRAMMD5SASLBindRequest.SASL_MECHANISM_NAME.equals(mech)) {
bindRequest =
Requests.newCRAMMD5SASLBindRequest(
getAuthID(CRAMMD5SASLBindRequest.SASL_MECHANISM_NAME),
getPassword());
- } else if (mech.equals(GSSAPISASLBindRequest.SASL_MECHANISM_NAME)) {
+ } else if (GSSAPISASLBindRequest.SASL_MECHANISM_NAME.equals(mech)) {
bindRequest =
Requests.newGSSAPISASLBindRequest(
getAuthID(GSSAPISASLBindRequest.SASL_MECHANISM_NAME), getPassword())
.setKDCAddress(getKDC()).setRealm(getRealm()).setAuthorizationID(
getAuthzID());
- } else if (mech.equals(ExternalSASLBindRequest.SASL_MECHANISM_NAME)) {
+ } else if (ExternalSASLBindRequest.SASL_MECHANISM_NAME.equals(mech)) {
if (sslContext == null) {
final LocalizableMessage message = ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get();
throw new ArgumentException(message);
@@ -564,7 +564,7 @@
}
bindRequest =
Requests.newExternalSASLBindRequest().setAuthorizationID(getAuthzID());
- } else if (mech.equals(PlainSASLBindRequest.SASL_MECHANISM_NAME)) {
+ } else if (PlainSASLBindRequest.SASL_MECHANISM_NAME.equals(mech)) {
bindRequest =
Requests.newPlainSASLBindRequest(
getAuthID(PlainSASLBindRequest.SASL_MECHANISM_NAME), getPassword())
@@ -584,9 +584,7 @@
return bindRequest;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public String toString() {
return connFactory.toString();
diff --git a/opendj-server/src/main/java/org/forgerock/opendj/server/setup/cli/SetupCli.java b/opendj-server/src/main/java/org/forgerock/opendj/server/setup/cli/SetupCli.java
index 4d0e2e2..98e61dc 100644
--- a/opendj-server/src/main/java/org/forgerock/opendj/server/setup/cli/SetupCli.java
+++ b/opendj-server/src/main/java/org/forgerock/opendj/server/setup/cli/SetupCli.java
@@ -249,7 +249,7 @@
keyStorePassword = addGlobal(CommonArguments.getKeyStorePassword());
keyStorePasswordFile = addGlobal(CommonArguments.getKeyStorePasswordFile());
certNickname = addGlobal(CommonArguments.getCertNickName());
- connectTimeout = CommonArguments.getConnectTimeOut(DEFAULT_LDAP_CONNECT_TIMEOUT);
+ connectTimeout = CommonArguments.getConnectTimeOut();
// Utility Input Output Options.
noPrompt = addGlobal(CommonArguments.getNoPrompt());
--
Gitblit v1.10.0