From 6ea56ecde3d05b84f42a7338d7c2c159817d00d0 Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Tue, 01 Mar 2016 09:44:57 +0000
Subject: [PATCH] Code cleanup
---
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPPasswordModify.java | 51 +++++++++++----------------------------------------
1 files changed, 11 insertions(+), 40 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPPasswordModify.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPPasswordModify.java
index fded94b..c29eeaa 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPPasswordModify.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPPasswordModify.java
@@ -24,7 +24,6 @@
import static com.forgerock.opendj.cli.ArgumentConstants.*;
import static com.forgerock.opendj.cli.Utils.*;
-import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS;
import static com.forgerock.opendj.cli.CommonArguments.*;
import java.io.OutputStream;
@@ -365,49 +364,21 @@
// Make sure that the user didn't specify any conflicting arguments.
- if (bindPW.isPresent() && bindPWFile.isPresent())
+ try
{
- printWrappedText(
- err, ERR_TOOL_CONFLICTING_ARGS.get(bindPW.getLongIdentifier(), bindPWFile.getLongIdentifier()));
+ throwIfArgumentsConflict(bindPW, bindPWFile);
+ throwIfArgumentsConflict(newPW, newPWFile);
+ throwIfArgumentsConflict(currentPW, currentPWFile);
+ throwIfArgumentsConflict(useSSL, useStartTLS);
+ throwIfArgumentsConflict(sslKeyStorePIN, sslKeyStorePINFile);
+ throwIfArgumentsConflict(sslTrustStorePIN, sslTrustStorePINFile);
+ }
+ catch(final ArgumentException conflict)
+ {
+ printWrappedText(err, conflict.getMessageObject());
return CLIENT_SIDE_PARAM_ERROR;
}
- if (newPW.isPresent() && newPWFile.isPresent())
- {
- printWrappedText(
- err, ERR_TOOL_CONFLICTING_ARGS.get(newPW.getLongIdentifier(), newPWFile.getLongIdentifier()));
- return CLIENT_SIDE_PARAM_ERROR;
- }
-
- if (currentPW.isPresent() && currentPWFile.isPresent())
- {
- printWrappedText(err,
- ERR_TOOL_CONFLICTING_ARGS.get(currentPW.getLongIdentifier(), currentPWFile.getLongIdentifier()));
- return CLIENT_SIDE_PARAM_ERROR;
- }
-
- if (useSSL.isPresent() && useStartTLS.isPresent())
- {
- printWrappedText(
- err, ERR_TOOL_CONFLICTING_ARGS.get(useSSL.getLongIdentifier(), useStartTLS.getLongIdentifier()));
- return CLIENT_SIDE_PARAM_ERROR;
- }
-
- if (sslKeyStorePIN.isPresent() && sslKeyStorePINFile.isPresent())
- {
- printWrappedText(err,
- ERR_TOOL_CONFLICTING_ARGS.get(sslKeyStorePIN.getLongIdentifier(), sslKeyStorePINFile.getLongIdentifier()));
- return CLIENT_SIDE_PARAM_ERROR;
- }
-
- if (sslTrustStorePIN.isPresent() && sslTrustStorePINFile.isPresent())
- {
- printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get(sslTrustStorePIN.getLongIdentifier(),
- sslTrustStorePINFile.getLongIdentifier()));
- return CLIENT_SIDE_PARAM_ERROR;
- }
-
-
// If a bind DN was provided, make sure that a password was given. If a
// password was given, make sure a bind DN was provided. If neither were
// given, then make sure that an authorization ID and the current password
--
Gitblit v1.10.0