From 9f0eb1a26745e51dc39184882d542583ba4ab7e5 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Wed, 14 Mar 2007 20:32:37 +0000
Subject: [PATCH] Update the LDAP client tools so that they provide error messages in a more readable format. They can now generate up to four lines of output in the following order:
---
opends/src/server/org/opends/server/tools/LDAPToolUtils.java | 43 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/opends/src/server/org/opends/server/tools/LDAPToolUtils.java b/opends/src/server/org/opends/server/tools/LDAPToolUtils.java
index c8725c6..81b8c43 100644
--- a/opends/src/server/org/opends/server/tools/LDAPToolUtils.java
+++ b/opends/src/server/org/opends/server/tools/LDAPToolUtils.java
@@ -33,7 +33,11 @@
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.protocols.ldap.LDAPControl;
+import org.opends.server.protocols.ldap.LDAPResultCode;
+import org.opends.server.types.DN;
+import static org.opends.server.messages.MessageHandler.*;
+import static org.opends.server.messages.ToolMessages.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
@@ -223,5 +227,44 @@
}
}
+ /**
+ * Prints a multi-line error message with the provided information to the
+ * given print stream.
+ *
+ * @param err The print stream to use to write the error message.
+ * @param explanation The general explanation to provide to the user, or
+ * {@code null} if there is none.
+ * @param resultCode The result code returned from the server, or -1 if
+ * there is none.
+ * @param errorMessage The additional information / error message returned
+ * from the server, or {@code null} if there was none.
+ * @param matchedDN The matched DN returned from the server, or
+ * {@code null} if there was none.
+ */
+ public static void printErrorMessage(PrintStream err, String explanation,
+ int resultCode, String errorMessage,
+ DN matchedDN)
+ {
+ if ((explanation != null) && (explanation.length() > 0))
+ {
+ err.println(explanation);
+ }
+
+ if (resultCode >= 0)
+ {
+ err.println(getMessage(MSGID_TOOL_RESULT_CODE, resultCode,
+ LDAPResultCode.toString(resultCode)));
+ }
+
+ if ((errorMessage != null) && (errorMessage.length() > 0))
+ {
+ err.println(getMessage(MSGID_TOOL_ERROR_MESSAGE, errorMessage));
+ }
+
+ if (matchedDN != null)
+ {
+ err.println(getMessage(MSGID_TOOL_MATCHED_DN, matchedDN.toString()));
+ }
+ }
}
--
Gitblit v1.10.0