From db3ffddbfab6dc0d5219247d432ef36c1a3a2055 Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Tue, 01 Mar 2016 09:43:01 +0000
Subject: [PATCH] Code cleanup
---
opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/ConnectionFactoryProvider.java | 54 +++++++-----------------------------------------------
1 files changed, 7 insertions(+), 47 deletions(-)
diff --git a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/ConnectionFactoryProvider.java b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/ConnectionFactoryProvider.java
index 39cf434..7a3c7c4 100644
--- a/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/ConnectionFactoryProvider.java
+++ b/opendj-sdk/opendj-cli/src/main/java/com/forgerock/opendj/cli/ConnectionFactoryProvider.java
@@ -20,6 +20,7 @@
import static com.forgerock.opendj.cli.CliConstants.DEFAULT_LDAP_PORT;
import static com.forgerock.opendj.cli.CliMessages.*;
import static com.forgerock.opendj.cli.Utils.getHostNameForLdapUrl;
+import static com.forgerock.opendj.cli.Utils.throwIfArgumentsConflict;
import static org.forgerock.opendj.ldap.LDAPConnectionFactory.AUTHN_BIND_REQUEST;
import static org.forgerock.opendj.ldap.LDAPConnectionFactory.CONNECT_TIMEOUT;
import static org.forgerock.opendj.ldap.LDAPConnectionFactory.SSL_CONTEXT;
@@ -447,45 +448,12 @@
* an argument exception is thrown.
*/
private void checkForConflictingArguments() throws ArgumentException {
- // Couldn't have at the same time bindPassword and bindPasswordFile
- if (bindPasswordArg.isPresent() && bindPasswordFileArg.isPresent()) {
- final LocalizableMessage message =
- ERR_TOOL_CONFLICTING_ARGS.get(bindPasswordArg.getLongIdentifier(),
- bindPasswordFileArg.getLongIdentifier());
- throw new ArgumentException(message);
- }
-
- /*
- * 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(),
- trustStorePathArg.getLongIdentifier());
- throw new ArgumentException(message);
- }
- if (trustAllArg.isPresent() && trustStorePasswordArg.isPresent()) {
- final LocalizableMessage message =
- ERR_TOOL_CONFLICTING_ARGS.get(trustAllArg.getLongIdentifier(),
- trustStorePasswordArg.getLongIdentifier());
- throw new ArgumentException(message);
- }
- if (trustAllArg.isPresent() && trustStorePasswordFileArg.isPresent()) {
- final LocalizableMessage message =
- ERR_TOOL_CONFLICTING_ARGS.get(trustAllArg.getLongIdentifier(),
- trustStorePasswordFileArg.getLongIdentifier());
- throw new ArgumentException(message);
- }
-
- /*
- * 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(),
- trustStorePasswordFileArg.getLongIdentifier());
- throw new ArgumentException(message);
- }
+ throwIfArgumentsConflict(bindPasswordArg, bindPasswordFileArg);
+ throwIfArgumentsConflict(trustAllArg, trustStorePathArg);
+ throwIfArgumentsConflict(trustAllArg, trustStorePasswordArg);
+ throwIfArgumentsConflict(trustAllArg, trustStorePasswordFileArg);
+ throwIfArgumentsConflict(trustStorePasswordArg, trustStorePasswordFileArg);
+ throwIfArgumentsConflict(useStartTLSArg, useSSLArg);
if (trustStorePathArg.isPresent()) {
// Check that the path exists and is readable
@@ -504,14 +472,6 @@
throw new ArgumentException(message);
}
}
-
- // Couldn't have at the same time startTLSArg and useSSLArg
- if (useStartTLSArg.isPresent() && useSSLArg.isPresent()) {
- final LocalizableMessage message =
- ERR_TOOL_CONFLICTING_ARGS.get(useStartTLSArg.getLongIdentifier(), useSSLArg
- .getLongIdentifier());
- throw new ArgumentException(message);
- }
}
/**
--
Gitblit v1.10.0