From 3a457ac64c4d051a8f80fdc8ef807bf614bddafb Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Sat, 19 Aug 2006 22:24:30 +0000
Subject: [PATCH] Make the following updates to the OpenDS code:
---
opendj-sdk/opends/resource/setup.bat | 2
opendj-sdk/opends/resource/setup.sh | 3
opendj-sdk/opends/src/server/org/opends/server/messages/ToolMessages.java | 27 ++++++
opendj-sdk/opends/src/server/org/opends/server/tools/ImportLDIF.java | 19 +++-
opendj-sdk/opends/src/server/org/opends/server/tools/InstallDS.java | 142 ++++++++++++++++++++--------------
5 files changed, 125 insertions(+), 68 deletions(-)
diff --git a/opendj-sdk/opends/resource/setup.bat b/opendj-sdk/opends/resource/setup.bat
index aab2ee2..8bc6272 100644
--- a/opendj-sdk/opends/resource/setup.bat
+++ b/opendj-sdk/opends/resource/setup.bat
@@ -49,7 +49,7 @@
cd %DIR_HOME%
-%JAVA_BIN% %JAVA_ARGS% -classpath "%CLASSPATH%" org.opends.server.tools.InstallDS --configClass org.opends.server.config.ConfigFileHandler --configFile %DIR_HOME%\config\config.ldif %*
+%JAVA_BIN% %JAVA_ARGS% -classpath "%CLASSPATH%" org.opends.server.tools.InstallDS --configClass org.opends.server.config.ConfigFileHandler --configFile %DIR_HOME%\config\config.ldif -P setup.bat %*
:end
diff --git a/opendj-sdk/opends/resource/setup.sh b/opendj-sdk/opends/resource/setup.sh
index 1d817b2..b478561 100755
--- a/opendj-sdk/opends/resource/setup.sh
+++ b/opendj-sdk/opends/resource/setup.sh
@@ -80,4 +80,5 @@
${JAVA_BIN} ${JAVA_ARGS} org.opends.server.tools.InstallDS \
--configClass org.opends.server.config.ConfigFileHandler \
- --configFile ${INSTANCE_ROOT}/config/config.ldif "${@}"
+ --configFile ${INSTANCE_ROOT}/config/config.ldif -P ${0} "${@}"
+
diff --git a/opendj-sdk/opends/src/server/org/opends/server/messages/ToolMessages.java b/opendj-sdk/opends/src/server/org/opends/server/messages/ToolMessages.java
index 73f0eb1..d1a52e0 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/messages/ToolMessages.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/messages/ToolMessages.java
@@ -32,6 +32,7 @@
import static org.opends.server.messages.MessageHandler.*;
import static org.opends.server.tools.ToolConstants.*;
+import static org.opends.server.util.DynamicConstants.*;
@@ -5203,6 +5204,24 @@
/**
+ * The message ID for the message that will be used as the description of the
+ * quiet argument. This does not take any arguments.
+ */
+ public static final int MSGID_LDIFIMPORT_DESCRIPTION_QUIET =
+ CATEGORY_MASK_TOOLS | SEVERITY_MASK_INFORMATIONAL | 532;
+
+
+
+ /**
+ * The message ID for the message that will be used to indicate that the
+ * LDIF import was successful. This does not take any arguments.
+ */
+ public static final int MSGID_INSTALLDS_IMPORT_SUCCESSFUL =
+ CATEGORY_MASK_TOOLS | SEVERITY_MASK_INFORMATIONAL | 533;
+
+
+
+ /**
* Associates a set of generic messages with the message IDs defined in this
* class.
*/
@@ -5545,6 +5564,8 @@
registerMessage(MSGID_LDIFIMPORT_DESCRIPTION_IS_ENCRYPTED,
"Indicates whether the LDIF file containing the data to " +
"import is encrypted.");
+ registerMessage(MSGID_LDIFIMPORT_DESCRIPTION_QUIET,
+ "Use quiet mode (no output).");
registerMessage(MSGID_LDIFIMPORT_DESCRIPTION_USAGE,
"Displays this usage information.");
registerMessage(MSGID_LDIFIMPORT_CANNOT_INITIALIZE_ARGS,
@@ -6895,9 +6916,11 @@
registerMessage(MSGID_INSTALLDS_STATUS_IMPORTING_LDIF,
"Importing the LDIF data into the Directory Server " +
"database....");
+ registerMessage(MSGID_INSTALLDS_IMPORT_SUCCESSFUL,
+ "Import complete.");
registerMessage(MSGID_INSTALLDS_STATUS_SUCCESS,
- "The OpenDS Directory Service setup process has " +
- "completed successfully.");
+ "The " + SHORT_NAME + " setup process has completed " +
+ "successfully.");
registerMessage(MSGID_INSTALLDS_PROMPT_VALUE_YES, "yes");
registerMessage(MSGID_INSTALLDS_PROMPT_VALUE_NO, "no");
registerMessage(MSGID_INSTALLDS_INVALID_YESNO_RESPONSE,
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/ImportLDIF.java b/opendj-sdk/opends/src/server/org/opends/server/tools/ImportLDIF.java
index c5e8424..186d248 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/ImportLDIF.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/ImportLDIF.java
@@ -113,6 +113,7 @@
BooleanArgument isCompressed = null;
BooleanArgument isEncrypted = null;
BooleanArgument overwriteRejects = null;
+ BooleanArgument quietMode = null;
BooleanArgument replaceExisting = null;
BooleanArgument skipSchemaValidation = null;
StringArgument backendID = null;
@@ -251,6 +252,11 @@
argParser.addArgument(isEncrypted);
+ quietMode = new BooleanArgument("quietmode", 'q', "quiet",
+ MSGID_LDIFIMPORT_DESCRIPTION_QUIET);
+ argParser.addArgument(quietMode);
+
+
displayUsage =
new BooleanArgument("help", 'H', "help",
MSGID_LDIFIMPORT_DESCRIPTION_USAGE);
@@ -414,11 +420,14 @@
}
- // FIXME -- Install a custom logger to capture information about the state
- // of the import.
- StartupErrorLogger startupLogger = new StartupErrorLogger();
- startupLogger.initializeErrorLogger(null);
- addErrorLogger(startupLogger);
+ if (! quietMode.isPresent())
+ {
+ // FIXME -- Install a custom logger to capture information about the state
+ // of the import.
+ StartupErrorLogger startupLogger = new StartupErrorLogger();
+ startupLogger.initializeErrorLogger(null);
+ addErrorLogger(startupLogger);
+ }
// Initialize all the password policy information.
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/InstallDS.java b/opendj-sdk/opends/src/server/org/opends/server/tools/InstallDS.java
index 7723fef..b131cd4 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/InstallDS.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/InstallDS.java
@@ -78,6 +78,13 @@
/**
+ * The position at which to wrap long lines.
+ */
+ public static final int MAX_LINE_WIDTH = 79;
+
+
+
+ /**
* Indicates whether we think we're running on a Windows system.
*/
private static boolean isWindows = false;
@@ -247,7 +254,7 @@
}
catch (ArgumentException ae)
{
- System.err.println(ae.getMessage());
+ System.err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
System.err.println(argParser.getUsage());
return 1;
}
@@ -260,7 +267,7 @@
}
catch (ArgumentException ae)
{
- System.err.println(ae.getMessage());
+ System.err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
System.err.println(argParser.getUsage());
return 1;
}
@@ -284,7 +291,7 @@
{
int msgID = MSGID_INSTALLDS_NO_CONFIG_FILE;
String message = getMessage(msgID, configFile.getLongIdentifier());
- System.err.println(message);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
return 1;
}
@@ -315,7 +322,7 @@
String message = getMessage(msgID,
String.valueOf(configFile.getValue()),
e.getMessage());
- System.err.println(message);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
return 1;
}
@@ -330,7 +337,7 @@
String message = getMessage(msgID,
String.valueOf(configFile.getValue()),
e.getMessage());
- System.err.println(message);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
return 1;
}
@@ -344,7 +351,7 @@
String message = getMessage(msgID,
String.valueOf(configFile.getValue()),
e.getMessage());
- System.err.println(message);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
return 1;
}
@@ -364,7 +371,7 @@
{
int msgID = MSGID_INSTALLDS_CANNOT_PARSE_DN;
String message = getMessage(msgID, s, e.getMessage());
- System.err.println(message);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
return 1;
}
}
@@ -381,7 +388,7 @@
int msgID = MSGID_INSTALLDS_CANNOT_PARSE_DN;
String message = getMessage(msgID, baseDN.getDefaultValue(),
e.getMessage());
- System.err.println(message);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
return 1;
}
}
@@ -449,7 +456,7 @@
int msgID = MSGID_INSTALLDS_TWO_CONFLICTING_ARGUMENTS;
String message = getMessage(msgID, addBaseEntry.getLongIdentifier(),
importLDIF.getLongIdentifier());
- System.err.println(message);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
return 1;
}
}
@@ -480,7 +487,7 @@
}
catch (ArgumentException ae)
{
- System.err.println(ae.getMessage());
+ System.err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
return 1;
}
}
@@ -510,15 +517,13 @@
{
msgID = MSGID_INSTALLDS_CANNOT_BIND_TO_PRIVILEGED_PORT;
message = getMessage(msgID, ldapPortNumber, e.getMessage());
- System.err.println(message);
- return 1;
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
}
else
{
msgID = MSGID_INSTALLDS_CANNOT_BIND_TO_PORT;
message = getMessage(msgID, ldapPortNumber, e.getMessage());
- System.err.println(message);
- return 1;
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
}
}
}
@@ -541,7 +546,7 @@
{
int msgID = MSGID_INSTALLDS_CANNOT_PARSE_DN;
String message = getMessage(msgID, s, e.getMessage());
- System.err.println(message);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
return 1;
}
}
@@ -558,7 +563,7 @@
int msgID = MSGID_INSTALLDS_CANNOT_PARSE_DN;
String message = getMessage(msgID, rootDN.getDefaultValue(),
e.getMessage());
- System.err.println(message);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
return 1;
}
}
@@ -583,7 +588,7 @@
int msgID = MSGID_INSTALLDS_TWO_CONFLICTING_ARGUMENTS;
String message = getMessage(msgID, rootPWString.getLongIdentifier(),
rootPWFile.getLongIdentifier());
- System.err.println(message);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
return 1;
}
}
@@ -596,7 +601,7 @@
int msgID = MSGID_INSTALLDS_NO_ROOT_PASSWORD;
String message = getMessage(msgID, rootPWString.getLongIdentifier(),
rootPWFile.getLongIdentifier());
- System.err.println(message);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
return 1;
}
else
@@ -643,7 +648,9 @@
if (! silentInstall.isPresent())
{
System.out.println();
- System.out.println(getMessage(MSGID_INSTALLDS_STATUS_CONFIGURING_DS));
+
+ String message = getMessage(MSGID_INSTALLDS_STATUS_CONFIGURING_DS);
+ System.out.println(wrapText(message, MAX_LINE_WIDTH));
}
int returnValue = ConfigureDS.configMain(configureDSArguments);
@@ -659,9 +666,8 @@
// Create a temporary LDIF file that will hold the entry to add.
if (! silentInstall.isPresent())
{
- System.out.println();
- System.out.println(getMessage(
- MSGID_INSTALLDS_STATUS_CREATING_BASE_LDIF));
+ String message = getMessage(MSGID_INSTALLDS_STATUS_CREATING_BASE_LDIF);
+ System.out.println(wrapText(message, MAX_LINE_WIDTH));
}
try
@@ -689,8 +695,10 @@
}
catch (Exception e)
{
- int msgID = MSGID_INSTALLDS_CANNOT_CREATE_BASE_ENTRY_LDIF;
- System.err.println(getMessage(msgID, String.valueOf(e)));
+ int msgID = MSGID_INSTALLDS_CANNOT_CREATE_BASE_ENTRY_LDIF;
+ String message = getMessage(msgID, String.valueOf(e));
+
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
return 1;
}
}
@@ -699,8 +707,8 @@
{
if (! silentInstall.isPresent())
{
- System.out.println();
- System.out.println(getMessage(MSGID_INSTALLDS_STATUS_IMPORTING_LDIF));
+ String message = getMessage(MSGID_INSTALLDS_STATUS_IMPORTING_LDIF);
+ System.out.println(wrapText(message, MAX_LINE_WIDTH));
}
// Use the ImportLDIF tool to perform the import.
@@ -718,6 +726,11 @@
argList.add(s);
}
+ if (addBase)
+ {
+ argList.add("-q");
+ }
+
String[] importLDIFArguments = new String[argList.size()];
argList.toArray(importLDIFArguments);
@@ -726,14 +739,19 @@
{
return returnValue;
}
+ else
+ {
+ String message = getMessage(MSGID_INSTALLDS_IMPORT_SUCCESSFUL);
+ System.out.println(wrapText(message, MAX_LINE_WIDTH));
+ }
}
// If we've gotten here, then everything seems to have gone smoothly.
if (! silentInstall.isPresent())
{
- System.out.println();
- System.out.println(getMessage(MSGID_INSTALLDS_STATUS_SUCCESS));
+ String message = getMessage(MSGID_INSTALLDS_STATUS_SUCCESS);
+ System.out.println(wrapText(message, MAX_LINE_WIDTH));
}
return 0;
@@ -757,7 +775,7 @@
*/
private static boolean promptForBoolean(String prompt, Boolean defaultValue)
{
- String wrappedPrompt = wrapText(prompt, 79);
+ String wrappedPrompt = wrapText(prompt, MAX_LINE_WIDTH);
while (true)
{
@@ -801,8 +819,8 @@
{
if (defaultValue == null)
{
- System.err.println(getMessage(
- MSGID_INSTALLDS_INVALID_YESNO_RESPONSE));
+ String message = getMessage(MSGID_INSTALLDS_INVALID_YESNO_RESPONSE);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
}
else
{
@@ -811,7 +829,8 @@
}
else
{
- System.err.println(getMessage(MSGID_INSTALLDS_INVALID_YESNO_RESPONSE));
+ String message = getMessage(MSGID_INSTALLDS_INVALID_YESNO_RESPONSE);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
}
}
}
@@ -839,7 +858,7 @@
private static int promptForInteger(String prompt, Integer defaultValue,
Integer lowerBound, Integer upperBound)
{
- String wrappedPrompt = wrapText(prompt, 79);
+ String wrappedPrompt = wrapText(prompt, MAX_LINE_WIDTH);
while (true)
{
@@ -864,8 +883,8 @@
{
if (defaultValue == null)
{
- int msgID = MSGID_INSTALLDS_INVALID_INTEGER_RESPONSE;
- System.err.println(getMessage(msgID));
+ String message = getMessage(MSGID_INSTALLDS_INVALID_INTEGER_RESPONSE);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
}
else
{
@@ -879,13 +898,17 @@
int intValue = Integer.parseInt(response);
if ((lowerBound != null) && (intValue < lowerBound))
{
- int msgID = MSGID_INSTALLDS_INTEGER_BELOW_LOWER_BOUND;
- System.err.println(getMessage(msgID, lowerBound));
+ String message =
+ getMessage(MSGID_INSTALLDS_INTEGER_BELOW_LOWER_BOUND,
+ lowerBound);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
}
else if ((upperBound != null) && (intValue > upperBound))
{
- int msgID = MSGID_INSTALLDS_INTEGER_ABOVE_UPPER_BOUND;
- System.err.println(getMessage(msgID, upperBound));
+ String message =
+ getMessage(MSGID_INSTALLDS_INTEGER_ABOVE_UPPER_BOUND,
+ upperBound);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
}
else
{
@@ -894,8 +917,8 @@
}
catch (NumberFormatException nfe)
{
- int msgID = MSGID_INSTALLDS_INVALID_INTEGER_RESPONSE;
- System.err.println(getMessage(msgID));
+ String message = getMessage(MSGID_INSTALLDS_INVALID_INTEGER_RESPONSE);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
}
}
}
@@ -919,7 +942,7 @@
*/
private static DN promptForDN(String prompt, String defaultValue)
{
- String wrappedPrompt = wrapText(prompt, 79);
+ String wrappedPrompt = wrapText(prompt, MAX_LINE_WIDTH);
while (true)
{
@@ -944,8 +967,8 @@
{
if (defaultValue == null)
{
- int msgID = MSGID_INSTALLDS_INVALID_DN_RESPONSE;
- System.err.println(getMessage(msgID));
+ String message = getMessage(MSGID_INSTALLDS_INVALID_DN_RESPONSE);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
}
else
{
@@ -955,8 +978,8 @@
}
catch (Exception e)
{
- int msgID = MSGID_INSTALLDS_INVALID_DN_RESPONSE;
- System.err.println(getMessage(msgID));
+ String message = getMessage(MSGID_INSTALLDS_INVALID_DN_RESPONSE);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
}
}
}
@@ -968,8 +991,8 @@
}
catch (Exception e)
{
- int msgID = MSGID_INSTALLDS_INVALID_DN_RESPONSE;
- System.err.println(getMessage(msgID));
+ String message = getMessage(MSGID_INSTALLDS_INVALID_DN_RESPONSE);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
}
}
}
@@ -993,7 +1016,7 @@
private static String promptForString(String prompt, String defaultValue)
{
System.out.println();
- String wrappedPrompt = wrapText(prompt, 79);
+ String wrappedPrompt = wrapText(prompt, MAX_LINE_WIDTH);
while (true)
{
@@ -1017,8 +1040,8 @@
{
if (defaultValue == null)
{
- int msgID = MSGID_INSTALLDS_INVALID_STRING_RESPONSE;
- System.err.println(getMessage(msgID));
+ String message = getMessage(MSGID_INSTALLDS_INVALID_STRING_RESPONSE);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
}
else
{
@@ -1049,8 +1072,8 @@
private static char[] promptForPassword(String initialPrompt,
String reEntryPrompt)
{
- String wrappedInitialPrompt = wrapText(initialPrompt, 79);
- String wrappedReEntryPrompt = wrapText(reEntryPrompt, 79);
+ String wrappedInitialPrompt = wrapText(initialPrompt, MAX_LINE_WIDTH);
+ String wrappedReEntryPrompt = wrapText(reEntryPrompt, MAX_LINE_WIDTH);
while (true)
{
@@ -1062,8 +1085,8 @@
char[] password = PasswordReader.readPassword();
if ((password == null) || (password.length == 0))
{
- int msgID = MSGID_INSTALLDS_INVALID_PASSWORD_RESPONSE;
- System.err.println(getMessage(msgID));
+ String message = getMessage(MSGID_INSTALLDS_INVALID_PASSWORD_RESPONSE);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
}
else
{
@@ -1074,8 +1097,8 @@
if ((confirmedPassword == null) ||
(! Arrays.equals(password, confirmedPassword)))
{
- int msgID = MSGID_INSTALLDS_PASSWORDS_DONT_MATCH;
- System.err.println(getMessage(msgID));
+ String message = getMessage(MSGID_INSTALLDS_PASSWORDS_DONT_MATCH);
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
}
else
{
@@ -1130,8 +1153,9 @@
}
catch (Exception e)
{
- int msgID = MSGID_INSTALLDS_ERROR_READING_FROM_STDIN;
- System.err.println(getMessage(msgID, String.valueOf(e)));
+ String message = getMessage(MSGID_INSTALLDS_ERROR_READING_FROM_STDIN,
+ String.valueOf(e));
+ System.err.println(wrapText(message, MAX_LINE_WIDTH));
return null;
}
--
Gitblit v1.10.0