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/EncodePassword.java |   35 +++++++++--------------------------
 1 files changed, 9 insertions(+), 26 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/EncodePassword.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/EncodePassword.java
index c40214c..7f28f83 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/EncodePassword.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/EncodePassword.java
@@ -18,7 +18,6 @@
 
 import static com.forgerock.opendj.cli.ArgumentConstants.*;
 import static com.forgerock.opendj.cli.CliMessages.INFO_FILE_PLACEHOLDER;
-import static com.forgerock.opendj.cli.CliMessages.ERR_TOOL_CONFLICTING_ARGS;
 import static com.forgerock.opendj.cli.Utils.*;
 import static com.forgerock.opendj.cli.CommonArguments.*;
 
@@ -264,35 +263,19 @@
     }
 
     // Check for conflicting arguments.
-    if (clearPassword.isPresent() && clearPasswordFile.isPresent())
+    try
     {
-      printWrappedText(err,
-          ERR_TOOL_CONFLICTING_ARGS.get(clearPassword.getLongIdentifier(), clearPasswordFile.getLongIdentifier()));
+      throwIfArgumentsConflict(clearPassword, clearPasswordFile);
+      throwIfArgumentsConflict(clearPassword, interactivePassword);
+      throwIfArgumentsConflict(clearPasswordFile, interactivePassword);
+      throwIfArgumentsConflict(encodedPassword, encodedPasswordFile);
+    }
+    catch (final ArgumentException conflict)
+    {
+      printWrappedText(err, conflict.getMessageObject());
       return OPERATIONS_ERROR;
     }
 
-    if (clearPassword.isPresent() && interactivePassword.isPresent())
-    {
-      printWrappedText(err,
-          ERR_TOOL_CONFLICTING_ARGS.get(clearPassword.getLongIdentifier(), interactivePassword.getLongIdentifier()));
-      return OPERATIONS_ERROR;
-    }
-
-    if (clearPasswordFile.isPresent() && interactivePassword.isPresent())
-    {
-      printWrappedText(err, ERR_TOOL_CONFLICTING_ARGS.get(clearPasswordFile.getLongIdentifier(),
-                                                          interactivePassword.getLongIdentifier()));
-      return OPERATIONS_ERROR;
-    }
-
-    if (encodedPassword.isPresent() && encodedPasswordFile.isPresent())
-    {
-      printWrappedText(err,
-          ERR_TOOL_CONFLICTING_ARGS.get(encodedPassword.getLongIdentifier(), encodedPasswordFile.getLongIdentifier()));
-      return OPERATIONS_ERROR;
-    }
-
-
     // If we are not going to just list the storage schemes, then the clear-text
     // password must have been provided.  If we're going to encode a password,
     // then the scheme must have also been provided.

--
Gitblit v1.10.0