From 4e4b322332130bf466e3bdbd9cd7c4ca832d1049 Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Fri, 17 Jul 2015 13:29:00 +0000
Subject: [PATCH] OPENDJ-2027 (CR-7617) Code cleanup
---
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPModify.java | 63 ++++++++++---------------------
1 files changed, 21 insertions(+), 42 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPModify.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPModify.java
index 2338dde..2cc1d4d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPModify.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPModify.java
@@ -199,9 +199,7 @@
}
else
{
- LocalizableMessage message = ERR_LDIF_FILE_INVALID_LDIF_ENTRY.get(
- le.getLineNumber(), fileNameValue, le);
- err.println(wrapText(message, MAX_LINE_WIDTH));
+ printWrappedText(err, ERR_LDIF_FILE_INVALID_LDIF_ENTRY.get(le.getLineNumber(), fileNameValue, le));
continue;
}
} catch (Exception e)
@@ -224,8 +222,7 @@
}
else
{
- LocalizableMessage message = ERR_LDIF_FILE_READ_ERROR.get(fileNameValue, e);
- err.println(wrapText(message, MAX_LINE_WIDTH));
+ printWrappedText(err, ERR_LDIF_FILE_READ_ERROR.get(fileNameValue, e));
continue;
}
}
@@ -313,9 +310,8 @@
} catch(DecodeException ae)
{
logger.traceException(ae);
- LocalizableMessage message = INFO_OPERATION_FAILED.get(operationType);
- err.println(wrapText(message, MAX_LINE_WIDTH));
- err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
+ printWrappedText(err, INFO_OPERATION_FAILED.get(operationType));
+ printWrappedText(err, ae.getMessage());
if (!modifyOptions.continueOnError())
{
String msg = LDAPToolUtils.getMessageForConnectionException(ae);
@@ -412,7 +408,7 @@
if (errorMessage != null)
{
- out.println(wrapText(errorMessage, MAX_LINE_WIDTH));
+ printWrappedText(out, errorMessage);
}
if (referralURLs != null)
@@ -445,10 +441,7 @@
}
catch (DirectoryException de)
{
- err.println(wrapText(
- ERR_LDAPMODIFY_PREREAD_CANNOT_DECODE_VALUE.get(
- de.getMessage()),
- MAX_LINE_WIDTH));
+ printWrappedText(err, ERR_LDAPMODIFY_PREREAD_CANNOT_DECODE_VALUE.get(de.getMessage()));
continue;
}
@@ -477,10 +470,7 @@
}
catch (DirectoryException de)
{
- err.println(wrapText(
- ERR_LDAPMODIFY_POSTREAD_CANNOT_DECODE_VALUE.get(
- de.getMessage()),
- MAX_LINE_WIDTH));
+ printWrappedText(err, ERR_LDAPMODIFY_POSTREAD_CANNOT_DECODE_VALUE.get(de.getMessage()));
continue;
}
@@ -878,9 +868,7 @@
argParser.setUsageArgument(showUsage, out);
} catch (ArgumentException ae)
{
- LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
-
- err.println(wrapText(message, MAX_LINE_WIDTH));
+ printWrappedText(err, ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage()));
return CLIENT_SIDE_PARAM_ERROR;
}
@@ -891,9 +879,7 @@
}
catch (ArgumentException ae)
{
- LocalizableMessage message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
-
- err.println(wrapText(message, MAX_LINE_WIDTH));
+ printWrappedText(err, ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
err.println(argParser.getUsage());
return CLIENT_SIDE_PARAM_ERROR;
}
@@ -907,10 +893,8 @@
if(bindPassword.isPresent() && bindPasswordFile.isPresent())
{
- LocalizableMessage message = ERR_TOOL_CONFLICTING_ARGS.get(
- bindPassword.getLongIdentifier(),
- bindPasswordFile.getLongIdentifier());
- err.println(wrapText(message, MAX_LINE_WIDTH));
+ printWrappedText(
+ err, ERR_TOOL_CONFLICTING_ARGS.get(bindPassword.getLongIdentifier(), bindPasswordFile.getLongIdentifier()));
return CLIENT_SIDE_PARAM_ERROR;
}
@@ -922,7 +906,7 @@
} catch(ArgumentException ae)
{
logger.traceException(ae);
- err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
+ printWrappedText(err, ae.getMessage());
return CLIENT_SIDE_PARAM_ERROR;
}
@@ -931,14 +915,14 @@
int versionNumber = version.getIntValue();
if(versionNumber != 2 && versionNumber != 3)
{
- err.println(wrapText(ERR_DESCRIPTION_INVALID_VERSION.get(versionNumber), MAX_LINE_WIDTH));
+ printWrappedText(err, ERR_DESCRIPTION_INVALID_VERSION.get(versionNumber));
return CLIENT_SIDE_PARAM_ERROR;
}
connectionOptions.setVersionNumber(versionNumber);
} catch(ArgumentException ae)
{
logger.traceException(ae);
- err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
+ printWrappedText(err, ae.getMessage());
return CLIENT_SIDE_PARAM_ERROR;
}
@@ -953,7 +937,7 @@
catch (Exception ex)
{
logger.traceException(ex);
- err.println(wrapText(ex.getMessage(), MAX_LINE_WIDTH));
+ printWrappedText(err, ex.getMessage());
return CLIENT_SIDE_PARAM_ERROR;
}
@@ -993,8 +977,7 @@
Control ctrl = LDAPToolUtils.getControl(ctrlString, err);
if(ctrl == null)
{
- LocalizableMessage message = ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString);
- err.println(wrapText(message, MAX_LINE_WIDTH));
+ printWrappedText(err, ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString));
err.println(argParser.getUsage());
return CLIENT_SIDE_PARAM_ERROR;
}
@@ -1024,9 +1007,7 @@
}
catch (LDAPException le)
{
- LocalizableMessage message = ERR_LDAP_ASSERTION_INVALID_FILTER.get(
- le.getMessage());
- err.println(wrapText(message, MAX_LINE_WIDTH));
+ printWrappedText(err, ERR_LDAP_ASSERTION_INVALID_FILTER.get(le.getMessage()));
return CLIENT_SIDE_PARAM_ERROR;
}
}
@@ -1085,14 +1066,12 @@
{
if(!connectionOptions.useSSL() && !connectionOptions.useStartTLS())
{
- LocalizableMessage message = ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get();
- err.println(wrapText(message, MAX_LINE_WIDTH));
+ printWrappedText(err, ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get());
return CLIENT_SIDE_PARAM_ERROR;
}
if(keyStorePathValue == null)
{
- LocalizableMessage message = ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get();
- err.println(wrapText(message, MAX_LINE_WIDTH));
+ printWrappedText(err, ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get());
return CLIENT_SIDE_PARAM_ERROR;
}
}
@@ -1156,12 +1135,12 @@
} catch (FileNotFoundException fe)
{
logger.traceException(fe);
- err.println(wrapText(fe.getMessage(), MAX_LINE_WIDTH));
+ printWrappedText(err, fe.getMessage());
return CLIENT_SIDE_PARAM_ERROR;
} catch(Exception e)
{
logger.traceException(e);
- err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
+ printWrappedText(err, e.getMessage());
return OPERATIONS_ERROR;
} finally
{
--
Gitblit v1.10.0