From 412d2a37f5783a4946bcf2a22ca0e79f95047f04 Mon Sep 17 00:00:00 2001
From: lutoff <lutoff@localhost>
Date: Tue, 15 May 2007 08:10:13 +0000
Subject: [PATCH] issue 1430 fix (all utilities should provide as standard option -V/--version) to specify the LDAP protocol version number, we should use now -V/--ldapVersion to get the 'product' version --version
---
opendj-sdk/opends/src/server/org/opends/server/tools/LDAPSearch.java | 12 +
opendj-sdk/opends/src/server/org/opends/server/tools/ConfigureDS.java | 5
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusPanelLauncher.java | 24 +++
opendj-sdk/opends/src/server/org/opends/server/tools/StopDS.java | 6
opendj-sdk/opends/src/server/org/opends/server/tools/BackUpDB.java | 5
opendj-sdk/opends/src/server/org/opends/server/tools/ListBackends.java | 6
opendj-sdk/opends/src/server/org/opends/server/tools/EncodePassword.java | 6
opendj-sdk/opends/src/server/org/opends/server/tools/ConfigureWindowsService.java | 7
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusCli.java | 19 ++
opendj-sdk/opends/src/server/org/opends/server/tools/LDAPModify.java | 11 +
opendj-sdk/opends/src/server/org/opends/server/tools/LDAPCompare.java | 13 +
opendj-sdk/opends/src/server/org/opends/server/tools/LDIFSearch.java | 5
opendj-sdk/opends/src/server/org/opends/server/tools/ImportLDIF.java | 5
opendj-sdk/opends/src/server/org/opends/server/tools/LDAPPasswordModify.java | 6
opendj-sdk/opends/src/server/org/opends/server/tools/makeldif/MakeLDIF.java | 5
opendj-sdk/opends/src/server/org/opends/server/util/args/SubCommandArgumentParser.java | 49 +++++++
opendj-sdk/opends/src/server/org/opends/server/plugins/profiler/ProfileViewer.java | 5
opendj-sdk/opends/src/server/org/opends/server/tools/LDIFModify.java | 5
opendj-sdk/opends/src/server/org/opends/server/util/args/ArgumentParser.java | 69 ++++++++-
opendj-sdk/opends/src/server/org/opends/server/core/DirectoryServer.java | 53 ++++---
opendj-sdk/opends/src/server/org/opends/server/tools/VerifyIndex.java | 5
opendj-sdk/opends/src/server/org/opends/server/tools/ExportLDIF.java | 5
opendj-sdk/opends/src/server/org/opends/server/tools/ToolConstants.java | 29 ++++
opendj-sdk/opends/src/server/org/opends/server/tools/LDIFDiff.java | 5
opendj-sdk/opends/src/server/org/opends/server/tools/WaitForFileDelete.java | 5
opendj-sdk/opends/src/server/org/opends/server/tools/RebuildIndex.java | 5
opendj-sdk/opends/src/server/org/opends/server/tools/LDAPDelete.java | 13 +
opendj-sdk/opends/src/server/org/opends/server/tools/RestoreDB.java | 5
opendj-sdk/opends/src/server/org/opends/server/messages/ToolMessages.java | 10 +
opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/resources/Resources.properties | 2
opendj-sdk/opends/src/server/org/opends/server/tools/InstallDS.java | 6
31 files changed, 308 insertions(+), 98 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/core/DirectoryServer.java b/opendj-sdk/opends/src/server/org/opends/server/core/DirectoryServer.java
index 7724359..a4bcc88 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/core/DirectoryServer.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/core/DirectoryServer.java
@@ -29,6 +29,8 @@
import java.io.File;
import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
import java.io.PrintStream;
import java.net.InetAddress;
import java.util.Collections;
@@ -8327,6 +8329,33 @@
return buffer.toString();
}
+ /**
+ * Prints out the version string for the Directory Server.
+ *
+ *
+ * @param outputStream The output stream to which the version information
+ * should be written.
+ *
+ * @throws IOException If a problem occurs while attempting to write the
+ * version information to the provided output stream.
+ */
+ public static void printVersion(OutputStream outputStream)
+ throws IOException
+ {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append(getVersionString());
+ buffer.append(EOL);
+ buffer.append("Build " + BUILD_ID);
+ buffer.append(EOL);
+
+ if ((FIX_IDS != null) && (FIX_IDS.length() > 0))
+ {
+ buffer.append("Fix IDs: " + FIX_IDS);
+ buffer.append(EOL);
+ }
+ outputStream.write(getBytes(buffer.toString()));
+ return;
+ }
/**
@@ -8613,7 +8642,6 @@
BooleanArgument fullVersion = null;
BooleanArgument noDetach = null;
BooleanArgument systemInfo = null;
- BooleanArgument version = null;
StringArgument configClass = null;
StringArgument configFile = null;
@@ -8658,11 +8686,6 @@
argParser.addArgument(windowsNetStart);
- version = new BooleanArgument("version", 'V', "version",
- MSGID_DSCORE_DESCRIPTION_VERSION);
- argParser.addArgument(version);
-
-
fullVersion = new BooleanArgument("fullversion", 'F', "fullVersion",
MSGID_DSCORE_DESCRIPTION_FULLVERSION);
fullVersion.setHidden(true);
@@ -8738,13 +8761,13 @@
// that is something other than NOTHING_TO_DO, SERVER_ALREADY_STARTED,
// START_AS_DETACH, START_AS_NON_DETACH, START_AS_WINDOWS_SERVICE to
// indicate that a problem occurred.
- if (argParser.usageDisplayed())
+ if (argParser.usageOrVersionDisplayed())
{
// We're just trying to display usage, and that's already been done so
// exit with a code of zero.
System.exit(NOTHING_TO_DO);
}
- else if (fullVersion.isPresent() || version.isPresent() ||
+ else if (fullVersion.isPresent() ||
systemInfo.isPresent() || dumpMessages.isPresent())
{
// We're not really trying to start, so rebuild the argument list
@@ -8768,7 +8791,7 @@
System.exit(checkStartability(argParser));
}
}
- else if (argParser.usageDisplayed())
+ else if (argParser.usageOrVersionDisplayed())
{
System.exit(0);
}
@@ -8792,18 +8815,6 @@
return;
}
- else if (version.isPresent())
- {
- System.out.println(getVersionString());
- System.out.println("Build " + BUILD_ID);
-
- if ((FIX_IDS != null) && (FIX_IDS.length() > 0))
- {
- System.out.println("Fix IDs: " + FIX_IDS);
- }
-
- return;
- }
else if (systemInfo.isPresent())
{
System.out.println(getVersionString());
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 eaf42e8..d9c4338 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
@@ -7093,6 +7093,13 @@
public static final int MSGID_EFFECTIVERIGHTS_INVALID_AUTHZID =
CATEGORY_MASK_TOOLS | SEVERITY_MASK_MILD_ERROR | 890;
+ /**
+ * The message ID for the message that will be used as the description of the
+ * version argument. This does not take any arguments.
+ */
+ public static final int MSGID_DESCRIPTION_PRODUCT_VERSION =
+ CATEGORY_MASK_TOOLS | SEVERITY_MASK_INFORMATIONAL | 891;
+
/**
* Associates a set of generic messages with the message IDs defined in this
@@ -9332,6 +9339,9 @@
"The authorization ID \"%s\" contained in the " +
"geteffectiverights control is invalid because it does" +
" not start with \"dn:\" to indicate a user DN");
+
+ registerMessage(MSGID_DESCRIPTION_PRODUCT_VERSION,
+ "Display Directory Server version information");
}
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/plugins/profiler/ProfileViewer.java b/opendj-sdk/opends/src/server/org/opends/server/plugins/profiler/ProfileViewer.java
index fc7c49d..2fddb30 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/plugins/profiler/ProfileViewer.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/plugins/profiler/ProfileViewer.java
@@ -159,8 +159,9 @@
}
- // If we should just display usage information, then print it and exit.
- if (argParser.usageDisplayed())
+ // If we should just display usage or versionn information,
+ // then print it and exit.
+ if (argParser.usageOrVersionDisplayed())
{
System.exit(0);
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/BackUpDB.java b/opendj-sdk/opends/src/server/org/opends/server/tools/BackUpDB.java
index e72074d..042364a 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/BackUpDB.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/BackUpDB.java
@@ -260,8 +260,9 @@
}
- // If we should just display usage information, then print it and exit.
- if (argParser.usageDisplayed())
+ // If we should just display usage or version information,
+ // then print it and exit.
+ if (argParser.usageOrVersionDisplayed())
{
return 0;
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/ConfigureDS.java b/opendj-sdk/opends/src/server/org/opends/server/tools/ConfigureDS.java
index 517d0ac..01ab56a 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/ConfigureDS.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/ConfigureDS.java
@@ -310,8 +310,9 @@
}
- // If we should just display usage information, then print it and exit.
- if (argParser.usageDisplayed())
+ // If we should just display usage or version information,
+ // then print it and exit.
+ if (argParser.usageOrVersionDisplayed())
{
return 0;
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/ConfigureWindowsService.java b/opendj-sdk/opends/src/server/org/opends/server/tools/ConfigureWindowsService.java
index 9a5988a..fe137cc 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/ConfigureWindowsService.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/ConfigureWindowsService.java
@@ -256,8 +256,9 @@
}
}
- // If we should just display usage information, then it is already done
- if ((returnValue == 0) && !argParser.usageDisplayed())
+ // If we should just display usage or version information,
+ // then it is already done
+ if ((returnValue == 0) && !argParser.usageOrVersionDisplayed())
{
/* Check that the user only asked for one argument */
int nArgs = 0;
@@ -295,7 +296,7 @@
}
}
- if ((returnValue == 0) && !argParser.usageDisplayed())
+ if ((returnValue == 0) && !argParser.usageOrVersionDisplayed())
{
if (enableService.isPresent())
{
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/EncodePassword.java b/opendj-sdk/opends/src/server/org/opends/server/tools/EncodePassword.java
index 7987633..b74fc80 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/EncodePassword.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/EncodePassword.java
@@ -267,9 +267,9 @@
}
- // If we should just display usage information, then we've already done it
- // so just return without doing anything else.
- if (argParser.usageDisplayed())
+ // If we should just display usage or version information,
+ // then we've already done it so just return without doing anything else.
+ if (argParser.usageOrVersionDisplayed())
{
return 0;
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/ExportLDIF.java b/opendj-sdk/opends/src/server/org/opends/server/tools/ExportLDIF.java
index b4bf59a..4913bf3 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/ExportLDIF.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/ExportLDIF.java
@@ -297,8 +297,9 @@
}
- // If we should just display usage information, then print it and exit.
- if (argParser.usageDisplayed())
+ // If we should just display usage or version information,
+ // then print it and exit.
+ if (argParser.usageOrVersionDisplayed())
{
return 0;
}
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 5eb0586..f84dabe 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
@@ -338,8 +338,9 @@
}
- // If we should just display usage information, then print it and exit.
- if (argParser.usageDisplayed())
+ // If we should just display usage or version information,
+ // then print it and exit.
+ if (argParser.usageOrVersionDisplayed())
{
return 0;
}
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 2a77f2c..814411f 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
@@ -327,9 +327,9 @@
}
- // If either the showUsage or testOnly arguments were provided, then we're
- // done.
- if (argParser.usageDisplayed() || testOnly.isPresent())
+ // If either the showUsage or testOnly or version arguments were provided,
+ // then we're done.
+ if (argParser.usageOrVersionDisplayed() || testOnly.isPresent())
{
return 0;
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPCompare.java b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPCompare.java
index d0c4faf..eb6d6c3 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPCompare.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPCompare.java
@@ -511,9 +511,11 @@
null, null, MSGID_DESCRIPTION_CONTROLS);
argParser.addArgument(controlStr);
- version = new IntegerArgument("version", 'V', "version",
- false, false, true, "{version}", 3, null,
- MSGID_DESCRIPTION_VERSION);
+ version = new IntegerArgument("version", OPTION_SHORT_PROTOCOL_VERSION,
+ OPTION_LONG_PROTOCOL_VERSION,
+ false, false, true,
+ OPTION_VALUE_PROTOCOL_VERSION,
+ 3, null, MSGID_DESCRIPTION_VERSION);
argParser.addArgument(version);
encodingStr = new StringArgument("encoding", 'i', "encoding",
@@ -565,8 +567,9 @@
return 1;
}
- // If we should just display usage information, then print it and exit.
- if (argParser.usageDisplayed())
+ // If we should just display usage or version information,
+ // then print it and exit.
+ if (argParser.usageOrVersionDisplayed())
{
return 0;
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPDelete.java b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPDelete.java
index f4f1e2e..9f4d160 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPDelete.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPDelete.java
@@ -488,9 +488,10 @@
null, null, MSGID_DESCRIPTION_CONTROLS);
argParser.addArgument(controlStr);
- version = new IntegerArgument("version", 'V', "version", false, false,
- true, "{version}", 3, null,
- MSGID_DESCRIPTION_VERSION);
+ version = new IntegerArgument("version", OPTION_SHORT_PROTOCOL_VERSION,
+ OPTION_LONG_PROTOCOL_VERSION, false, false,
+ true, OPTION_VALUE_PROTOCOL_VERSION, 3,
+ null, MSGID_DESCRIPTION_VERSION);
argParser.addArgument(version);
encodingStr = new StringArgument("encoding", 'i', "encoding", false,
@@ -540,9 +541,9 @@
return 1;
}
- // If we should just display usage information, then it has already been
- // done so just exit.
- if (argParser.usageDisplayed())
+ // If we should just display usage or version information,
+ // then it has already been done so just exit.
+ if (argParser.usageOrVersionDisplayed())
{
return 0;
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPModify.java b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPModify.java
index 5c0c1f2..f103a20 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPModify.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPModify.java
@@ -802,8 +802,10 @@
null, null, MSGID_DESCRIPTION_CONTROLS);
argParser.addArgument(controlStr);
- version = new IntegerArgument("version", 'V', "version",
- false, false, true, "{version}", 3, null,
+ version = new IntegerArgument("version", OPTION_SHORT_PROTOCOL_VERSION,
+ OPTION_LONG_PROTOCOL_VERSION,
+ false, false, true,
+ OPTION_VALUE_PROTOCOL_VERSION, 3, null,
MSGID_DESCRIPTION_VERSION);
argParser.addArgument(version);
@@ -856,8 +858,9 @@
return 1;
}
- // If we should just display usage information, then print it and exit.
- if (argParser.usageDisplayed())
+ // If we should just display usage or version information,
+ // then print it and exit.
+ if (argParser.usageOrVersionDisplayed())
{
return 0;
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPPasswordModify.java b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPPasswordModify.java
index 3825dd1..9b7f993 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPPasswordModify.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPPasswordModify.java
@@ -386,9 +386,9 @@
}
- // If the usage argument was provided, then we don't need to do anything
- // else.
- if (argParser.usageDisplayed())
+ // If the usage or version argument was provided,
+ // then we don't need to do anything else.
+ if (argParser.usageOrVersionDisplayed())
{
return 0;
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPSearch.java b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPSearch.java
index bffff7d..c54aaf0 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPSearch.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/LDAPSearch.java
@@ -887,9 +887,10 @@
MSGID_DESCRIPTION_EFFECTIVERIGHTS_ATTR );
argParser.addArgument(effectiveRightsAttrs);
- version = new IntegerArgument("version", 'V', "version", false, false,
- true, "{version}", 3, null,
- MSGID_DESCRIPTION_VERSION);
+ version = new IntegerArgument("version", OPTION_SHORT_PROTOCOL_VERSION,
+ OPTION_LONG_PROTOCOL_VERSION, false, false,
+ true, OPTION_VALUE_PROTOCOL_VERSION, 3,
+ null, MSGID_DESCRIPTION_VERSION);
argParser.addArgument(version);
encodingStr = new StringArgument("encoding", 'i', "encoding", false,
@@ -967,8 +968,9 @@
return 1;
}
- // If we should just display usage information, then print it and exit.
- if (argParser.usageDisplayed())
+ // If we should just display usage or version information,
+ // then print it and exit.
+ if (argParser.usageOrVersionDisplayed())
{
return 0;
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/LDIFDiff.java b/opendj-sdk/opends/src/server/org/opends/server/tools/LDIFDiff.java
index dd878e5..b5be8d9 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/LDIFDiff.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/LDIFDiff.java
@@ -215,8 +215,9 @@
}
- // If we should just display usage information, then print it and exit.
- if (argParser.usageDisplayed())
+ // If we should just display usage or version information,
+ // then print it and exit.
+ if (argParser.usageOrVersionDisplayed())
{
return 0;
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/LDIFModify.java b/opendj-sdk/opends/src/server/org/opends/server/tools/LDIFModify.java
index df59346..bab2dbc 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/LDIFModify.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/LDIFModify.java
@@ -498,8 +498,9 @@
}
- // If we should just display usage information, then print it and exit.
- if (argParser.usageDisplayed())
+ // If we should just display usage or version information,
+ // then print it and exit.
+ if (argParser.usageOrVersionDisplayed())
{
return 0;
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/LDIFSearch.java b/opendj-sdk/opends/src/server/org/opends/server/tools/LDIFSearch.java
index c20a889..4fe4ddb 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/LDIFSearch.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/LDIFSearch.java
@@ -259,8 +259,9 @@
}
- // If we should just display usage information, then print it and exit.
- if (argParser.usageDisplayed())
+ // If we should just display usage or version information,
+ // then print it and exit.
+ if (argParser.usageOrVersionDisplayed())
{
return 0;
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/ListBackends.java b/opendj-sdk/opends/src/server/org/opends/server/tools/ListBackends.java
index f87fbb8..0ca1552 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/ListBackends.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/ListBackends.java
@@ -221,9 +221,9 @@
}
- // If we should just display usage information, then it's already been done
- // so just return.
- if (argParser.usageDisplayed())
+ // If we should just display usage or version information,
+ // then it's already been done so just return.
+ if (argParser.usageOrVersionDisplayed())
{
return 0;
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/RebuildIndex.java b/opendj-sdk/opends/src/server/org/opends/server/tools/RebuildIndex.java
index e609d96..5d27702 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/RebuildIndex.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/RebuildIndex.java
@@ -178,8 +178,9 @@
}
- // If we should just display usage information, then print it and exit.
- if (argParser.usageDisplayed())
+ // If we should just display usage or version information,
+ // then print it and exit.
+ if (argParser.usageOrVersionDisplayed())
{
return 0;
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/RestoreDB.java b/opendj-sdk/opends/src/server/org/opends/server/tools/RestoreDB.java
index a8f0d6d..a0d753e 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/RestoreDB.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/RestoreDB.java
@@ -216,8 +216,9 @@
}
- // If we should just display usage information, then print it and exit.
- if (argParser.usageDisplayed())
+ // If we should just display usage or version information,
+ // then print it and exit.
+ if (argParser.usageOrVersionDisplayed())
{
return 0;
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/StopDS.java b/opendj-sdk/opends/src/server/org/opends/server/tools/StopDS.java
index 47c0182..a366bdf 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/StopDS.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/StopDS.java
@@ -403,9 +403,9 @@
}
- // If we should just display usage information, then exit because it will
- // have already been done.
- if (argParser.usageDisplayed())
+ // If we should just display usage or version information,
+ // then exit because it will have already been done.
+ if (argParser.usageOrVersionDisplayed())
{
return LDAPResultCode.SUCCESS;
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/ToolConstants.java b/opendj-sdk/opends/src/server/org/opends/server/tools/ToolConstants.java
index 92ba45a..3b2e64a 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/ToolConstants.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/ToolConstants.java
@@ -480,5 +480,34 @@
*/
public static final String OPTION_LONG_EFFECTIVERIGHTSATTR =
"getEffectiveRightsAttribute";
+
+ /**
+ * The value for the short option protocol version attributes.
+ */
+ public static final char OPTION_SHORT_PROTOCOL_VERSION = 'V';
+
+ /**
+ * The value for the long option protocol version
+ * attribute.
+ */
+ public static final String OPTION_LONG_PROTOCOL_VERSION =
+ "ldapVersion";
+
+ /**
+ * The placeholder value of protocol version that will be
+ * displayed in usage information.
+ */
+ public static final String OPTION_VALUE_PROTOCOL_VERSION = "{version}";
+
+ /**
+ * The value for the long option version.
+ */
+ public static final char OPTION_SHORT_PRODUCT_VERSION = 'V';
+
+ /**
+ * The value for the long option version.
+ */
+ public static final String OPTION_LONG_PRODUCT_VERSION = "version";
+
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/VerifyIndex.java b/opendj-sdk/opends/src/server/org/opends/server/tools/VerifyIndex.java
index 4359a78..b9511c8 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/VerifyIndex.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/VerifyIndex.java
@@ -190,8 +190,9 @@
}
- // If we should just display usage information, then print it and exit.
- if (argParser.usageDisplayed())
+ // If we should just display usage or version information,
+ // then print it and exit.
+ if (argParser.usageOrVersionDisplayed())
{
return 0;
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/WaitForFileDelete.java b/opendj-sdk/opends/src/server/org/opends/server/tools/WaitForFileDelete.java
index 7d1785f..6c450d5 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/WaitForFileDelete.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/WaitForFileDelete.java
@@ -188,8 +188,9 @@
}
- // If we should just display usage information, then print it and exit.
- if (argParser.usageDisplayed())
+ // If we should just display usage or version information,
+ // then print it and exit.
+ if (argParser.usageOrVersionDisplayed())
{
return EXIT_CODE_SUCCESS;
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/makeldif/MakeLDIF.java b/opendj-sdk/opends/src/server/org/opends/server/tools/makeldif/MakeLDIF.java
index 9fc3ff0..0d3dcd3 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/makeldif/MakeLDIF.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/makeldif/MakeLDIF.java
@@ -204,8 +204,9 @@
}
- // If we should just display usage information, then print it and exit.
- if (argParser.usageDisplayed())
+ // If we should just display usage or version information,
+ // then print it and exit.
+ if (argParser.usageOrVersionDisplayed())
{
return 0;
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/util/args/ArgumentParser.java b/opendj-sdk/opends/src/server/org/opends/server/util/args/ArgumentParser.java
index 9608bd2..5428335 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/util/args/ArgumentParser.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/util/args/ArgumentParser.java
@@ -36,11 +36,14 @@
import java.util.LinkedList;
import java.util.Properties;
+import org.opends.server.core.DirectoryServer;
+
import static org.opends.server.messages.MessageHandler.*;
import static org.opends.server.messages.UtilityMessages.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
-
+import static org.opends.server.tools.ToolConstants.*;
+import static org.opends.server.messages.ToolMessages.*;
/**
@@ -69,8 +72,8 @@
// manner.
private boolean longArgumentsCaseSensitive;
- // Indicates whether the usage information has been displayed.
- private boolean usageDisplayed;
+ // Indicates whether the usage or version information has been displayed.
+ private boolean usageOrVersionDisplayed;
// The set of arguments defined for this parser, referenced by short ID.
private HashMap<Character,Argument> shortIDMap;
@@ -136,7 +139,7 @@
shortIDMap = new HashMap<Character,Argument>();
longIDMap = new HashMap<String,Argument>();
allowsTrailingArguments = false;
- usageDisplayed = false;
+ usageOrVersionDisplayed = false;
trailingArgsDisplayName = null;
maxTrailingArguments = 0;
minTrailingArguments = 0;
@@ -198,7 +201,7 @@
shortIDMap = new HashMap<Character,Argument>();
longIDMap = new HashMap<String,Argument>();
trailingArguments = new ArrayList<String>();
- usageDisplayed = false;
+ usageOrVersionDisplayed = false;
rawArguments = null;
usageArgument = null;
usageOutputStream = System.out;
@@ -663,6 +666,19 @@
return;
}
else
+ if (argName.equals(OPTION_LONG_PRODUCT_VERSION))
+ {
+ // "--version" will always be interpreted as requesting version
+ // information.
+ usageOrVersionDisplayed = true;
+ try
+ {
+ DirectoryServer.printVersion(usageOutputStream);
+ } catch (Exception e) {}
+
+ return;
+ }
+ else
{
// There is no such argument registered.
int msgID = MSGID_ARGPARSER_NO_ARGUMENT_WITH_LONG_ID;
@@ -775,6 +791,21 @@
return;
}
else
+ if ( (argCharacter == OPTION_SHORT_PRODUCT_VERSION)
+ &&
+ ( ! shortIDMap.containsKey(OPTION_SHORT_PRODUCT_VERSION)))
+ {
+ // "-V" will always be interpreted as requesting
+ // version information except if it's already defined (e.g in
+ // lpda tools).
+ usageOrVersionDisplayed = true ;
+ try
+ {
+ DirectoryServer.printVersion(usageOutputStream);
+ } catch (Exception e) {}
+ return;
+ }
+ else
{
// There is no such argument registered.
int msgID = MSGID_ARGPARSER_NO_ARGUMENT_WITH_SHORT_ID;
@@ -970,7 +1001,7 @@
*/
public void getUsage(StringBuilder buffer)
{
- usageDisplayed = true;
+ usageOrVersionDisplayed = true;
if ((toolDescription != null) && (toolDescription.length() > 0))
{
buffer.append(wrapText(toolDescription, 79));
@@ -1008,6 +1039,17 @@
buffer.append(" where {options} include:");
buffer.append(EOL);
+ // --version is a builtin option
+ if (! shortIDMap.containsKey(OPTION_SHORT_PRODUCT_VERSION))
+ {
+ buffer.append("-" + OPTION_SHORT_PRODUCT_VERSION + ", ");
+ }
+ buffer.append("--" + OPTION_LONG_PRODUCT_VERSION);
+ buffer.append(EOL);
+ buffer.append(" ");
+ buffer.append( getMessage(MSGID_DESCRIPTION_PRODUCT_VERSION));
+ buffer.append(EOL);
+
for (Argument a : argumentList)
{
// If this argument is hidden, then skip it.
@@ -1191,16 +1233,17 @@
/**
- * Indicates whether the usage information has been displayed to the end user
- * either by an explicit argument like "-H" or "--help", or by a built-in
- * argument like "-?".
+ * Indicates whether the version or the usage information has been
+ * displayed to the end user either by an explicit argument like
+ * "-H" or "--help", or by a built-in argument like "-?".
*
- * @return {@code true} if the usage information has been displayed, or
- * {@code false} if not.
+ * @return {@code true} if the usage information has been displayed,
+ * or {@code false} if not.
*/
- public boolean usageDisplayed()
+ public boolean usageOrVersionDisplayed()
{
- return usageDisplayed;
+ return usageOrVersionDisplayed;
}
+
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/util/args/SubCommandArgumentParser.java b/opendj-sdk/opends/src/server/org/opends/server/util/args/SubCommandArgumentParser.java
index 83ac61e..2f0f862 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/util/args/SubCommandArgumentParser.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/util/args/SubCommandArgumentParser.java
@@ -35,10 +35,13 @@
import java.util.LinkedList;
import java.util.Properties;
+import org.opends.server.core.DirectoryServer;
+
import static org.opends.server.messages.MessageHandler.*;
import static org.opends.server.messages.UtilityMessages.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
+import static org.opends.server.tools.ToolConstants.*;
@@ -714,6 +717,18 @@
return;
}
else
+ if (argName.equals(OPTION_LONG_PRODUCT_VERSION))
+ {
+ // "--version" will always be interpreted as requesting usage
+ // information.
+ try
+ {
+ DirectoryServer.printVersion(usageOutputStream);
+ } catch (Exception e) {}
+
+ return;
+ }
+ else
{
// There is no such global argument.
int msgID = MSGID_SUBCMDPARSER_NO_GLOBAL_ARGUMENT_FOR_LONG_ID;
@@ -738,6 +753,18 @@
return;
}
else
+ if (argName.equals(OPTION_LONG_PRODUCT_VERSION))
+ {
+ // "--version" will always be interpreted as requesting usage
+ // information.
+ try
+ {
+ DirectoryServer.printVersion(usageOutputStream);
+ } catch (Exception e) {}
+
+ return;
+ }
+ else
{
// There is no such global or subcommand argument.
int msgID = MSGID_SUBCMDPARSER_NO_ARGUMENT_FOR_LONG_ID;
@@ -853,6 +880,17 @@
return;
}
else
+ if (argCharacter == OPTION_SHORT_PRODUCT_VERSION)
+ {
+ // "-V" will always be interpreted as requesting
+ // version information.
+ try
+ {
+ getUsage(usageOutputStream);
+ } catch (Exception e) {}
+ return;
+ }
+ else
{
// There is no such argument registered.
int msgID = MSGID_SUBCMDPARSER_NO_GLOBAL_ARGUMENT_FOR_SHORT_ID;
@@ -876,6 +914,17 @@
return;
}
else
+ if (argCharacter == OPTION_SHORT_PRODUCT_VERSION)
+ {
+ // "-V" will always be interpreted as requesting
+ // version information.
+ try
+ {
+ getUsage(usageOutputStream);
+ } catch (Exception e) {}
+ return;
+ }
+ else
{
// There is no such argument registered.
int msgID = MSGID_SUBCMDPARSER_NO_ARGUMENT_FOR_SHORT_ID;
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusCli.java b/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusCli.java
index a34d80f..c3729ef 100644
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusCli.java
+++ b/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusCli.java
@@ -30,6 +30,7 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
+import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashSet;
@@ -128,6 +129,7 @@
ArrayList<String> errors = new ArrayList<String>();
boolean printUsage = false;
+ boolean printVersion = false;
String directoryManagerPwd = null;
String directoryManagerPwdFile = null;
@@ -141,6 +143,12 @@
{
printUsage = true;
}
+ else
+ if (args[i].equalsIgnoreCase("-" + OPTION_SHORT_PRODUCT_VERSION) ||
+ args[i].equalsIgnoreCase("--" + OPTION_LONG_PRODUCT_VERSION))
+ {
+ printVersion = true;
+ }
else if (args[i].equalsIgnoreCase("-D") ||
args[i].equalsIgnoreCase("--bindDN"))
{
@@ -245,6 +253,17 @@
{
printUsage(System.out);
}
+ else if(printVersion)
+ {
+ try
+ {
+ DirectoryServer.printVersion(System.out);
+ }
+ catch (IOException e)
+ {
+ // TODO Auto-generated catch block
+ }
+ }
else if (errors.size() > 0)
{
System.err.println(Utils.getStringFromCollection(errors,
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusPanelLauncher.java b/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusPanelLauncher.java
index 3c19010..d502668 100644
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusPanelLauncher.java
+++ b/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/StatusPanelLauncher.java
@@ -28,13 +28,16 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.IOException;
import java.io.PrintStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.opends.quicksetup.util.Utils;
import org.opends.quicksetup.Installation;
+import org.opends.server.core.DirectoryServer;
import org.opends.statuspanel.i18n.ResourceProvider;
+import static org.opends.server.tools.ToolConstants.*;
/**
* This class is called by the control panel command lines to launch the
@@ -66,6 +69,7 @@
t.printStackTrace();
}
boolean printUsage = false;
+ boolean printVersion = false;
if ((args != null) && (args.length > 4))
{
printUsage = true;
@@ -78,7 +82,27 @@
{
printUsage = true;
}
+ else
+ if (args[i].equalsIgnoreCase("-" + OPTION_SHORT_PRODUCT_VERSION) ||
+ args[i].equalsIgnoreCase("--" + OPTION_LONG_PRODUCT_VERSION))
+ {
+ printVersion = true;
+ }
}
+ // We first check if we have to pribt the version
+ if(printVersion)
+ {
+ try
+ {
+ DirectoryServer.printVersion(System.out);
+ }
+ catch (IOException e)
+ {
+ // TODO Auto-generated catch block
+ }
+ System.exit(1);
+ }
+ else
if (printUsage)
{
printUsage(System.out);
diff --git a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/resources/Resources.properties b/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/resources/Resources.properties
index 9a01405..ccdd7b6 100644
--- a/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/resources/Resources.properties
+++ b/opendj-sdk/opends/src/statuspanel/org/opends/statuspanel/resources/Resources.properties
@@ -35,6 +35,7 @@
Panel window which displays basic server information and allows to \
start, stop and restart the server.\n\
Usage: {0} {options}\n where {options} include:\n\
+-V, --version\n Display Directory Server version information.\n\
-?, -H, --help\n Display this usage information.
status-panel-launcher-gui-launch-failed=Could not launch Status Panel. Check \
that you have access to the display.
@@ -175,6 +176,7 @@
status-cli-usage=This utility may be used to display basic server \
information\n\n\
Usage: {0} {options}\n where {options} include:\n\
+-V, --version\n Display Directory Server version information\n\
-D {bindDN}, --bindDN {bindDN}\n Bind DN\n\
-w {bindPassword}, --bindPassword {bindPassword}\n Bind password\n\
-j {bindPasswordFile}, --bindPasswordFile {bindPasswordFile}\n Bind \
--
Gitblit v1.10.0