From 0fd845d18cfaf23fc9f54e92775c735955e4e859 Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Mon, 27 Jul 2015 09:02:08 +0000
Subject: [PATCH] OPENDJ-2027 CR-7646 Change tools message on error
---
opendj-server-legacy/src/main/java/org/opends/server/util/args/LDAPConnectionArgumentParser.java | 28 +++++++++++++++-------------
1 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/util/args/LDAPConnectionArgumentParser.java b/opendj-server-legacy/src/main/java/org/opends/server/util/args/LDAPConnectionArgumentParser.java
index 7557485..d3ec150 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/util/args/LDAPConnectionArgumentParser.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/util/args/LDAPConnectionArgumentParser.java
@@ -297,11 +297,12 @@
* stream to write error messages
* @return LDAPConnection created by this class from parsed arguments
* @throws LDAPConnectionException
- * if there was a problem connecting to the server indicated by the
- * input arguments
+ * if there was a problem connecting to the server
+ * @throws ArgumentException
+ * if there was a problem indicated by the input arguments
*/
public LDAPConnection connect(LDAPConnectionConsoleInteraction ui, PrintStream out, PrintStream err)
- throws LDAPConnectionException
+ throws LDAPConnectionException, ArgumentException
{
try
{
@@ -311,18 +312,19 @@
return connect(ui.getHostName(), ui.getPortNumber(), ui.getBindDN(),
ui.getBindPassword(), ui.populateLDAPOptions(options), ui.getConnectTimeout(), out, err);
}
- catch (ArgumentException | OpenDsException e)
+ catch (OpenDsException e)
{
- if (e.getCause() != null && e.getCause().getCause() != null && e.getCause().getCause() instanceof SSLException)
- {
- err.println(ERR_TASKINFO_LDAP_EXCEPTION_SSL.get(ui.getHostName(), ui.getPortNumber()));
- }
- else
- {
- err.println(e.getMessageObject());
- }
+ err.println(isSSLException(e) ?
+ ERR_TASKINFO_LDAP_EXCEPTION_SSL.get(ui.getHostName(), ui.getPortNumber()) : e.getMessageObject());
+ return null;
}
- return null;
+ }
+
+ private boolean isSSLException(Exception e)
+ {
+ return e.getCause() != null
+ && e.getCause().getCause() != null
+ && e.getCause().getCause() instanceof SSLException;
}
/**
--
Gitblit v1.10.0