From eddcb644c79477295162f81d76151f41208c7e27 Mon Sep 17 00:00:00 2001
From: fguigues <fguigues@localhost>
Date: Thu, 16 Apr 2009 12:37:36 +0000
Subject: [PATCH] Fix ServiceTag URN for 2.0 Fix ServiceTag Registration adding debug message in case of error Fix 2619 : ldap tools always return 1 in case of argument parsing error Fix 3690 : SNMP: incorrect value for dsServerDescription entry Fix an error in the util script when the install dir is != instance dir
---
opendj-sdk/opends/src/server/org/opends/server/tools/LDAPSearch.java | 68 +++++-----
opendj-sdk/opends/src/server/org/opends/server/tools/LDAPModify.java | 35 +++--
opendj-sdk/opends/resource/bin/_script-util.sh | 2
opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/DsTableEntryImpl.java | 14 --
opendj-sdk/opends/src/server/org/opends/server/tools/LDAPCompare.java | 40 +++---
opendj-sdk/opends/src/server/org/opends/server/tools/LDAPDelete.java | 35 +++--
opendj-sdk/opends/src/server/org/opends/server/tools/LDAPPasswordModify.java | 33 ++--
opendj-sdk/opends/src/server/org/opends/server/servicetag/Registry.java | 25 +--
opendj-sdk/opends/src/server/org/opends/server/servicetag/ServiceTagRegistration.java | 51 +++++---
opendj-sdk/opends/src/messages/messages/servicetag.properties | 4
10 files changed, 160 insertions(+), 147 deletions(-)
diff --git a/opendj-sdk/opends/resource/bin/_script-util.sh b/opendj-sdk/opends/resource/bin/_script-util.sh
index b10b277..47a58b4 100644
--- a/opendj-sdk/opends/resource/bin/_script-util.sh
+++ b/opendj-sdk/opends/resource/bin/_script-util.sh
@@ -154,7 +154,7 @@
do
CLASSPATH=${CLASSPATH}:${JAR}
done
- if [ "${INSTANCE_ROOT}" != "${INSTANCE_ROOT}" ]
+ if [ "${INSTALL_ROOT}" != "${INSTANCE_ROOT}" ]
then
for JAR in ${INSTANCE_ROOT}/lib/*.jar
do
diff --git a/opendj-sdk/opends/src/messages/messages/servicetag.properties b/opendj-sdk/opends/src/messages/messages/servicetag.properties
index bcf6d2a..8a3838a 100644
--- a/opendj-sdk/opends/src/messages/messages/servicetag.properties
+++ b/opendj-sdk/opends/src/messages/messages/servicetag.properties
@@ -51,11 +51,13 @@
SEVERE_WARN_SERVICETAG_DOESNOT_EXIST_2=ServiceTag does not exist
SEVERE_WARN_REGISTRY_NOT_SUPPORTED_3=Common Registration is not supported
SEVERE_WARN_PARAMETER_CANNOT_BE_NULL_4=Parameter %s cannot be null or empty
-SEVERE_WARN_SERVICETAG_CANNOT_BE_REGISTERED_5=ServiceTag cannot be registered
+SEVERE_WARN_SERVICETAG_CANNOT_BE_REGISTERED_5=ServiceTag cannot be registered \
+for product name %s, product urn %s, installed location %s
SEVERE_WARN_SERVICETAG_CANNOT_BE_REMOVED_6=ServiceTag cannot be removed
SEVERE_WARN_NO_SERVICETAG_TO_REMOVE_7=No ServiceTag to remove
SEVERE_WARN_NO_SERVICETAG_TO_REGISTER_8=No ServiceTag to register
SEVERE_WARN_BAD_PROPERTIES_9=Properties parameter does not contain %s
+SEVERE_WARN_SERVICETAG_REGISTRATION_10=ServiceTag cannot be registered : %s
diff --git a/opendj-sdk/opends/src/server/org/opends/server/servicetag/Registry.java b/opendj-sdk/opends/src/server/org/opends/server/servicetag/Registry.java
index 697bcf3..98aec6e 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/servicetag/Registry.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/servicetag/Registry.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2008 Sun Microsystems, Inc.
+ * Copyright 2008-2009 Sun Microsystems, Inc.
*/
package org.opends.server.servicetag;
@@ -96,26 +96,21 @@
* @param installedLocation identifying the installed product.
* @return true if at least corresponding ServiceTag exists, otherwise
* return false.
+ * @throws IOException if an error occurred in the stclient call.
*/
public boolean existServiceTag(String productUrn,
- String installedLocation) {
+ String installedLocation) throws IOException {
boolean found = false;
Set<ServiceTag> tags;
- try {
- tags = this.findServiceTags(productUrn);
- for (ServiceTag svcTag : tags) {
- if (svcTag.getProductDefinedInstanceID().equals
- (installedLocation)) {
- found = true;
- break;
- }
- }
- } catch (IOException ex) {
- if (debugEnabled()) {
- TRACER.debugCaught(DebugLogLevel.WARNING, ex);
- }
+ tags = this.findServiceTags(productUrn);
+ for (ServiceTag svcTag : tags) {
+ if (svcTag.getProductDefinedInstanceID().equals
+ (installedLocation)) {
+ found = true;
+ break;
+ }
}
return found;
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/servicetag/ServiceTagRegistration.java b/opendj-sdk/opends/src/server/org/opends/server/servicetag/ServiceTagRegistration.java
index 2853466..2fbee4e 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/servicetag/ServiceTagRegistration.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/servicetag/ServiceTagRegistration.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2008 Sun Microsystems, Inc.
+ * Copyright 2008-2009 Sun Microsystems, Inc.
*/
package org.opends.server.servicetag;
@@ -31,6 +31,7 @@
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
+import org.opends.messages.Message;
import org.opends.server.core.DirectoryServer;
import org.opends.server.loggers.debug.DebugTracer;
@@ -127,21 +128,24 @@
throw new IllegalArgumentException(
WARN_PARAMETER_CANNOT_BE_NULL.get("svcTag").toString());
}
-
- // Add the ServiceTag if it does not exist
- if (this.registry.existServiceTag(
- svcTag.getProductURN(),
- svcTag.getProductDefinedInstanceID())) {
- throw new ServiceTagAlreadyExistsException
- (WARN_SERVICETAG_ALREADY_EXIST.get());
- }
-
- // Add the ServiceTag in the common registry
try {
+ // Add the ServiceTag if it does not exist
+ if (this.registry.existServiceTag(
+ svcTag.getProductURN(),
+ svcTag.getProductDefinedInstanceID())) {
+ throw new ServiceTagAlreadyExistsException
+ (WARN_SERVICETAG_ALREADY_EXIST.get());
+ }
+
+ // Add the ServiceTag in the common registry
this.registry.addServiceTag(svcTag);
+
} catch (IOException ex) {
throw new ServiceTagException(
- WARN_SERVICETAG_CANNOT_BE_REGISTERED.get());
+ WARN_SERVICETAG_CANNOT_BE_REGISTERED.get(
+ svcTag.getProductName(),
+ svcTag.getProductURN(),
+ svcTag.getProductDefinedInstanceID()));
}
}
@@ -200,7 +204,14 @@
try {
registerServiceTag(svcTag);
} catch (Exception ex) {
- errors.add(svcTag);
+ if (debugEnabled()) {
+ Message message =
+ WARN_SERVICETAG_CANNOT_BE_REGISTERED.get(
+ svcTag.getProductName(),
+ svcTag.getProductURN(),
+ svcTag.getProductDefinedInstanceID());
+ TRACER.debugWarning(message.toString());
+ }
}
}
return errors;
@@ -230,15 +241,13 @@
throw new IllegalArgumentException(
WARN_PARAMETER_CANNOT_BE_NULL.get("svcTag").toString());
}
-
- if (!this.registry.existServiceTag(
- svcTag.getProductURN(),
- svcTag.getProductDefinedInstanceID())) {
- throw new ServiceTagDoesNotExistException(
- WARN_SERVICETAG_DOESNOT_EXIST.get());
- }
-
try {
+ if (!this.registry.existServiceTag(
+ svcTag.getProductURN(),
+ svcTag.getProductDefinedInstanceID())) {
+ throw new ServiceTagDoesNotExistException(
+ WARN_SERVICETAG_DOESNOT_EXIST.get());
+ }
this.registry.removeServiceTag(svcTag.getInstanceURN());
} catch (IOException ex) {
throw new ServiceTagException(
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 97dfa96..35b6d14 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
@@ -600,7 +600,7 @@
Message message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
// Parse the command-line arguments provided to this program.
@@ -614,7 +614,7 @@
err.println(wrapText(message, MAX_LINE_WIDTH));
err.println(argParser.getUsage());
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
// If we should just display usage or version information,
@@ -630,7 +630,7 @@
bindPassword.getLongIdentifier(),
bindPasswordFile.getLongIdentifier());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
ArrayList<String> attrAndDNStrings = argParser.getTrailingArguments();
@@ -639,7 +639,7 @@
{
Message message = ERR_LDAPCOMPARE_NO_ATTR.get();
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
// First element should be an attribute string.
@@ -656,7 +656,7 @@
{
err.println(wrapText(ERR_LDAPCOMPARE_NO_DNS.get(), MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
// If trailing DNs were provided and the filename argument was also
@@ -665,7 +665,7 @@
{
err.println(wrapText(ERR_LDAPCOMPARE_FILENAME_AND_DNS.get(),
MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
// parse the attribute string
@@ -675,7 +675,7 @@
Message message =
ERR_LDAPCOMPARE_INVALID_ATTR_STRING.get(attributeString);
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
attributeType = attributeString.substring(0, idx);
String remainder = attributeString.substring(idx+1,
@@ -700,7 +700,7 @@
err.println(wrapText(
INFO_COMPARE_CANNOT_BASE64_DECODE_ASSERTION_VALUE.get(),
MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
} else if(nextChar == '<')
{
@@ -715,7 +715,7 @@
INFO_COMPARE_CANNOT_READ_ASSERTION_VALUE_FROM_FILE.get(
String.valueOf(e)),
MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
} else
{
@@ -739,7 +739,7 @@
TRACER.debugCaught(DebugLogLevel.ERROR, ae);
}
err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
try
@@ -750,7 +750,7 @@
err.println(wrapText(ERR_DESCRIPTION_INVALID_VERSION.get(
String.valueOf(versionNumber)), MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
connectionOptions.setVersionNumber(versionNumber);
} catch(ArgumentException ae)
@@ -760,7 +760,7 @@
TRACER.debugCaught(DebugLogLevel.ERROR, ae);
}
err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
@@ -784,7 +784,7 @@
TRACER.debugCaught(DebugLogLevel.ERROR, ex);
}
err.println(wrapText(ex.getMessage(), MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
} else if(bindPasswordValue == null)
{
@@ -830,7 +830,7 @@
Message message = ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString);
err.println(wrapText(message, MAX_LINE_WIDTH));
err.println(argParser.getUsage());
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
compareOptions.getControls().add(ctrl);
}
@@ -853,7 +853,7 @@
Message message = ERR_LDAP_ASSERTION_INVALID_FILTER.get(
le.getMessage());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
@@ -870,14 +870,14 @@
boolean val = connectionOptions.setSASLMechanism(saslOption);
if(val == false)
{
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
} else
{
boolean val = connectionOptions.addSASLProperty(saslOption);
if(val == false)
{
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
}
@@ -891,13 +891,13 @@
{
Message message = ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get();
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
if(keyStorePathValue == null)
{
Message message = ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get();
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
@@ -961,7 +961,7 @@
}
err.println(wrapText(ERR_LDAPCOMPARE_ERROR_READING_FILE.get(
fileNameValue, details), MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
if(rdr != null)
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 2fe8f9f..b94683f 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
@@ -570,9 +570,8 @@
} catch (ArgumentException ae)
{
Message message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
-
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
// Parse the command-line arguments provided to this program.
@@ -583,10 +582,9 @@
catch (ArgumentException ae)
{
Message message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
-
err.println(wrapText(message, MAX_LINE_WIDTH));
err.println(argParser.getUsage());
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
// If we should just display usage or version information,
@@ -602,7 +600,16 @@
bindPassword.getLongIdentifier(),
bindPasswordFile.getLongIdentifier());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
+ }
+
+ if ((!filename.isPresent() &&
+ (argParser.getTrailingArguments().size()==0)))
+ {
+ Message message = ERR_ERROR_PARSING_ARGS.get(filename.getValue());
+ err.println(wrapText(message, MAX_LINE_WIDTH));
+ err.println(argParser.getUsage());
+ return CLIENT_SIDE_PARAM_ERROR;
}
String hostNameValue = hostName.getValue();
@@ -617,7 +624,7 @@
TRACER.debugCaught(DebugLogLevel.ERROR, ae);
}
err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
try
@@ -628,7 +635,7 @@
err.println(wrapText(ERR_DESCRIPTION_INVALID_VERSION.get(
String.valueOf(versionNumber)), MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
connectionOptions.setVersionNumber(versionNumber);
} catch(ArgumentException ae)
@@ -638,7 +645,7 @@
TRACER.debugCaught(DebugLogLevel.ERROR, ae);
}
err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
String bindDNValue = bindDN.getValue();
@@ -661,7 +668,7 @@
TRACER.debugCaught(DebugLogLevel.ERROR, ex);
}
err.println(wrapText(ex.getMessage(), MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
} else if(bindPasswordValue == null)
{
@@ -708,7 +715,7 @@
Message message = ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString);
err.println(wrapText(message, MAX_LINE_WIDTH));
err.println(argParser.getUsage());
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
deleteOptions.getControls().add(ctrl);
}
@@ -739,14 +746,14 @@
boolean val = connectionOptions.setSASLMechanism(saslOption);
if(val == false)
{
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
} else
{
boolean val = connectionOptions.addSASLProperty(saslOption);
if(val == false)
{
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
}
@@ -760,13 +767,13 @@
{
Message message = ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get();
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
if(keyStorePathValue == null)
{
Message message = ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get();
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
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 2760dd6..b324dd3 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
@@ -900,7 +900,7 @@
Message message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
// Parse the command-line arguments provided to this program.
@@ -914,7 +914,7 @@
err.println(wrapText(message, MAX_LINE_WIDTH));
err.println(argParser.getUsage());
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
// If we should just display usage or version information,
@@ -930,7 +930,16 @@
bindPassword.getLongIdentifier(),
bindPasswordFile.getLongIdentifier());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
+ }
+
+ if ((!filename.isPresent() &&
+ (argParser.getTrailingArguments().size()==0)))
+ {
+ Message message = ERR_ERROR_PARSING_ARGS.get(filename.getValue());
+ err.println(wrapText(message, MAX_LINE_WIDTH));
+ err.println(argParser.getUsage());
+ return CLIENT_SIDE_PARAM_ERROR;
}
String hostNameValue = hostName.getValue();
@@ -945,7 +954,7 @@
TRACER.debugCaught(DebugLogLevel.ERROR, ae);
}
err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
try
@@ -956,7 +965,7 @@
err.println(wrapText(ERR_DESCRIPTION_INVALID_VERSION.get(
String.valueOf(versionNumber)), MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
connectionOptions.setVersionNumber(versionNumber);
} catch(ArgumentException ae)
@@ -966,7 +975,7 @@
TRACER.debugCaught(DebugLogLevel.ERROR, ae);
}
err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
String bindDNValue = bindDN.getValue();
@@ -989,7 +998,7 @@
TRACER.debugCaught(DebugLogLevel.ERROR, ex);
}
err.println(wrapText(ex.getMessage(), MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
} else if(bindPasswordValue == null)
{
@@ -1036,7 +1045,7 @@
Message message = ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString);
err.println(wrapText(message, MAX_LINE_WIDTH));
err.println(argParser.getUsage());
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
modifyOptions.getControls().add(ctrl);
}
@@ -1067,7 +1076,7 @@
Message message = ERR_LDAP_ASSERTION_INVALID_FILTER.get(
le.getMessage());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
@@ -1113,14 +1122,14 @@
boolean val = connectionOptions.setSASLMechanism(saslOption);
if(val == false)
{
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
} else
{
boolean val = connectionOptions.addSASLProperty(saslOption);
if(val == false)
{
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
}
@@ -1136,13 +1145,13 @@
{
Message message = ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get();
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
if(keyStorePathValue == null)
{
Message message = ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get();
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
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 9ee5d04..da82045 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
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Copyright 2006-2008 Sun Microsystems, Inc.
+ * Copyright 2006-2009 Sun Microsystems, Inc.
*/
package org.opends.server.tools;
import org.opends.messages.Message;
@@ -59,6 +59,7 @@
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.protocols.ldap.LDAPResultCode.*;
@@ -416,7 +417,7 @@
Message message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
@@ -431,7 +432,7 @@
err.println(wrapText(message, MAX_LINE_WIDTH));
err.println(argParser.getUsage());
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
@@ -450,7 +451,7 @@
bindPW.getLongIdentifier(),
bindPWFile.getLongIdentifier());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
if (newPW.isPresent() && newPWFile.isPresent())
@@ -459,7 +460,7 @@
newPW.getLongIdentifier(),
newPWFile.getLongIdentifier());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
if (currentPW.isPresent() && currentPWFile.isPresent())
@@ -468,7 +469,7 @@
currentPW.getLongIdentifier(),
currentPWFile.getLongIdentifier());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
if (useSSL.isPresent() && useStartTLS.isPresent())
@@ -477,7 +478,7 @@
useSSL.getLongIdentifier(),
useStartTLS.getLongIdentifier());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
if (sslKeyStorePIN.isPresent() && sslKeyStorePINFile.isPresent())
@@ -486,7 +487,7 @@
sslKeyStorePIN.getLongIdentifier(),
sslKeyStorePINFile.getLongIdentifier());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
if (sslTrustStorePIN.isPresent() && sslTrustStorePINFile.isPresent())
@@ -495,7 +496,7 @@
sslTrustStorePIN.getLongIdentifier(),
sslTrustStorePINFile.getLongIdentifier());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
@@ -511,7 +512,7 @@
err.println(wrapText(message, MAX_LINE_WIDTH));
err.println(argParser.getUsage());
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
else if (bindPW.isPresent() || bindPWFile.isPresent())
@@ -520,7 +521,7 @@
err.println(wrapText(message, MAX_LINE_WIDTH));
err.println(argParser.getUsage());
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
else
{
@@ -532,7 +533,7 @@
bindDN.getLongIdentifier());
err.println(wrapText(message, MAX_LINE_WIDTH));
err.println(argParser.getUsage());
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
if (! (authzID.isPresent() &&
@@ -542,7 +543,7 @@
ERR_LDAPPWMOD_ANON_REQUIRES_AUTHZID_AND_CURRENTPW.get();
err.println(wrapText(message, MAX_LINE_WIDTH));
err.println(argParser.getUsage());
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
@@ -558,7 +559,7 @@
{
// This should never happen.
err.println(e);
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
@@ -574,7 +575,7 @@
Message message = ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString);
err.println(wrapText(message, MAX_LINE_WIDTH));
err.println(argParser.getUsage());
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
controls.add(ctrl);
}
@@ -638,7 +639,7 @@
Message message =
ERR_LDAPPWMOD_ERROR_INITIALIZING_SSL.get(String.valueOf(e));
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
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 2d029e8..65b6d7e 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
@@ -1067,7 +1067,7 @@
Message message = ERR_CANNOT_INITIALIZE_ARGS.get(ae.getMessage());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
// Parse the command-line arguments provided to this program.
@@ -1081,7 +1081,7 @@
err.println(wrapText(message, MAX_LINE_WIDTH));
err.println(argParser.getUsage());
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
// If we should just display usage or version information,
@@ -1114,7 +1114,7 @@
TRACER.debugCaught(DebugLogLevel.ERROR, le);
}
err.println(wrapText(le.getMessage(), MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
// The rest are attributes
@@ -1132,7 +1132,7 @@
bindPassword.getLongIdentifier(),
bindPasswordFile.getLongIdentifier());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
if (useSSL.isPresent() && startTLS.isPresent())
@@ -1141,7 +1141,7 @@
useSSL.getLongIdentifier(),
startTLS.getLongIdentifier());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
if (keyStorePassword.isPresent() && keyStorePasswordFile.isPresent())
@@ -1150,7 +1150,7 @@
keyStorePassword.getLongIdentifier(),
keyStorePasswordFile.getLongIdentifier());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
if (trustStorePassword.isPresent() && trustStorePasswordFile.isPresent())
@@ -1159,7 +1159,7 @@
trustStorePassword.getLongIdentifier(),
trustStorePasswordFile.getLongIdentifier());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
String hostNameValue = hostName.getValue();
@@ -1174,7 +1174,7 @@
TRACER.debugCaught(DebugLogLevel.ERROR, ae);
}
err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
// Read the LDAP version number.
@@ -1186,7 +1186,7 @@
err.println(wrapText(ERR_DESCRIPTION_INVALID_VERSION.get(
String.valueOf(versionNumber)), MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
connectionOptions.setVersionNumber(versionNumber);
} catch(ArgumentException ae)
@@ -1196,7 +1196,7 @@
TRACER.debugCaught(DebugLogLevel.ERROR, ae);
}
err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
@@ -1228,7 +1228,7 @@
TRACER.debugCaught(DebugLogLevel.ERROR, ex);
}
err.println(wrapText(ex.getMessage(), MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
else if(bindPasswordValue == null)
@@ -1273,17 +1273,17 @@
} catch(ArgumentException ex1)
{
err.println(wrapText(ex1.getMessage(), MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
boolean val = searchOptions.setSearchScope(searchScope.getValue(), err);
if(val == false)
{
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
val = searchOptions.setDereferencePolicy(dereferencePolicy.getValue(), err);
if(val == false)
{
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
if(controlStr.isPresent())
@@ -1296,7 +1296,7 @@
Message message = ERR_TOOL_INVALID_CONTROL_STRING.get(ctrlString);
err.println(wrapText(message, MAX_LINE_WIDTH));
err.println(argParser.getUsage());
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
searchOptions.getControls().add(ctrl);
}
@@ -1308,7 +1308,7 @@
Message message = ERR_EFFECTIVERIGHTS_INVALID_AUTHZID.get(authzID);
err.println(wrapText(message, MAX_LINE_WIDTH));
err.println(argParser.getUsage());
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
Control effectiveRightsControl =
new GetEffectiveRightsRequestControl(false, authzID.substring(3),
@@ -1338,7 +1338,7 @@
{
Message message = ERR_PSEARCH_MISSING_DESCRIPTOR.get();
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
else
{
@@ -1348,7 +1348,7 @@
Message message = ERR_PSEARCH_DOESNT_START_WITH_PS.get(
String.valueOf(infoString));
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
@@ -1387,7 +1387,7 @@
Message message =
ERR_PSEARCH_INVALID_CHANGE_TYPE.get(String.valueOf(token));
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
}
@@ -1417,7 +1417,7 @@
Message message = ERR_PSEARCH_INVALID_CHANGESONLY.get(
String.valueOf(token));
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
@@ -1438,7 +1438,7 @@
Message message = ERR_PSEARCH_INVALID_RETURN_ECS.get(
String.valueOf(token));
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
@@ -1466,7 +1466,7 @@
Message message = ERR_LDAP_ASSERTION_INVALID_FILTER.get(
le.getMessage());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
@@ -1487,7 +1487,7 @@
Message message = ERR_LDAP_MATCHEDVALUES_INVALID_FILTER.get(
le.getMessage());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
@@ -1507,7 +1507,7 @@
Message message = ERR_LDAP_SORTCONTROL_INVALID_ORDER.get(
le.getErrorMessage());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
@@ -1519,7 +1519,7 @@
vlvDescriptor.getLongIdentifier(),
sortOrder.getLongIdentifier());
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
StringTokenizer tokenizer =
@@ -1539,7 +1539,7 @@
{
Message message = ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get();
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
else if (numTokens == 4)
@@ -1558,14 +1558,14 @@
{
Message message = ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get();
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
else
{
Message message = ERR_LDAPSEARCH_VLV_INVALID_DESCRIPTOR.get();
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
@@ -1581,14 +1581,14 @@
boolean mechValue = connectionOptions.setSASLMechanism(saslOption);
if(mechValue == false)
{
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
} else
{
boolean propValue = connectionOptions.addSASLProperty(saslOption);
if(propValue == false)
{
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
}
@@ -1602,13 +1602,13 @@
{
Message message = ERR_TOOL_SASLEXTERNAL_NEEDS_SSL_OR_TLS.get();
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
if(keyStorePathValue == null)
{
Message message = ERR_TOOL_SASLEXTERNAL_NEEDS_KEYSTORE.get();
err.println(wrapText(message, MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
}
@@ -1640,7 +1640,7 @@
TRACER.debugCaught(DebugLogLevel.ERROR, e);
}
err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
finally
{
@@ -1660,7 +1660,7 @@
err.println(wrapText(ERR_SEARCH_NO_FILTERS.get(), MAX_LINE_WIDTH));
err.println(argParser.getUsage());
- return 1;
+ return CLIENT_SIDE_PARAM_ERROR;
}
int wrapColumn = 80;
diff --git a/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/DsTableEntryImpl.java b/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/DsTableEntryImpl.java
index 7d6503b..9f08604 100644
--- a/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/DsTableEntryImpl.java
+++ b/opendj-sdk/opends/src/snmp/src/org/opends/server/snmp/DsTableEntryImpl.java
@@ -27,12 +27,11 @@
package org.opends.server.snmp;
import com.sun.management.snmp.agent.SnmpMib;
-import java.io.File;
import java.util.Iterator;
import java.util.Set;
import javax.management.MBeanServer;
import javax.management.ObjectName;
-import org.opends.server.core.DirectoryServer;
+import org.opends.guitools.controlpanel.util.Utilities;
import org.opends.server.loggers.debug.DebugLogger;
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.types.DebugLogLevel;
@@ -178,16 +177,7 @@
*/
@Override
public String getDsServerDescription() {
- String result = null;
- try {
- result = DirectoryServer.getServerRoot() +
- File.separatorChar;
- } catch (Exception ex) {
- if (DebugLogger.debugEnabled()) {
- TRACER.debugCaught(DebugLogLevel.ERROR, ex);
- }
- }
- return result;
+ return Utilities.getServerRootDirectory().getAbsolutePath();
}
/**
--
Gitblit v1.10.0