From cfc513043c5830b5a967733066068c7097b42e3c Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Wed, 15 Aug 2007 21:34:53 +0000
Subject: [PATCH] This commit is a step toward getting OpenDS internationalized. There are still issues to be resolved before we can declare that we are internationalized but this commit covers the bulk of changes needed at this time.
---
opendj-sdk/opends/src/server/org/opends/server/config/StringConfigAttribute.java | 184 +++++++++++++++++++++-------------------------
1 files changed, 84 insertions(+), 100 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/config/StringConfigAttribute.java b/opendj-sdk/opends/src/server/org/opends/server/config/StringConfigAttribute.java
index d346cd4..7d092f7 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/config/StringConfigAttribute.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/config/StringConfigAttribute.java
@@ -25,6 +25,7 @@
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
package org.opends.server.config;
+import org.opends.messages.Message;
@@ -41,19 +42,13 @@
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeValue;
-import org.opends.server.types.ErrorLogCategory;
-import org.opends.server.types.ErrorLogSeverity;
import org.opends.server.types.DebugLogLevel;
import static org.opends.server.config.ConfigConstants.*;
-import static org.opends.server.loggers.ErrorLogger.*;
import static org.opends.server.loggers.debug.DebugLogger.*;
import org.opends.server.loggers.debug.DebugTracer;
-import static org.opends.server.messages.ConfigMessages.*;
-import static org.opends.server.messages.MessageHandler.*;
-
-
-
+import org.opends.server.loggers.ErrorLogger;
+import static org.opends.messages.ConfigMessages.*;
/**
* This class defines a string configuration attribute, which can hold zero or
* more string values.
@@ -93,7 +88,7 @@
* configuration attribute require administrative
* action before they will take effect.
*/
- public StringConfigAttribute(String name, String description,
+ public StringConfigAttribute(String name, Message description,
boolean isRequired, boolean isMultiValued,
boolean requiresAdminAction)
{
@@ -123,7 +118,7 @@
* @param value The value for this string configuration
* attribute.
*/
- public StringConfigAttribute(String name, String description,
+ public StringConfigAttribute(String name, Message description,
boolean isRequired, boolean isMultiValued,
boolean requiresAdminAction, String value)
{
@@ -163,7 +158,7 @@
* @param values The set of values for this configuration
* attribute.
*/
- public StringConfigAttribute(String name, String description,
+ public StringConfigAttribute(String name, Message description,
boolean isRequired, boolean isMultiValued,
boolean requiresAdminAction, List<String> values)
{
@@ -204,7 +199,7 @@
* @param pendingValues The set of pending values for this
* configuration attribute.
*/
- public StringConfigAttribute(String name, String description,
+ public StringConfigAttribute(String name, Message description,
boolean isRequired, boolean isMultiValued,
boolean requiresAdminAction,
List<String> activeValues,
@@ -277,16 +272,14 @@
{
if ((activeValues == null) || activeValues.isEmpty())
{
- int msgID = MSGID_CONFIG_ATTR_NO_STRING_VALUE;
- String message = getMessage(msgID, getName());
- throw new ConfigException(msgID, message);
+ Message message = ERR_CONFIG_ATTR_NO_STRING_VALUE.get(getName());
+ throw new ConfigException(message);
}
if (activeValues.size() > 1)
{
- int msgID = MSGID_CONFIG_ATTR_MULTIPLE_STRING_VALUES;
- String message = getMessage(msgID, getName());
- throw new ConfigException(msgID, message);
+ Message message = ERR_CONFIG_ATTR_MULTIPLE_STRING_VALUES.get(getName());
+ throw new ConfigException(message);
}
return activeValues.get(0);
@@ -327,16 +320,14 @@
if ((pendingValues == null) || pendingValues.isEmpty())
{
- int msgID = MSGID_CONFIG_ATTR_NO_STRING_VALUE;
- String message = getMessage(msgID, getName());
- throw new ConfigException(msgID, message);
+ Message message = ERR_CONFIG_ATTR_NO_STRING_VALUE.get(getName());
+ throw new ConfigException(message);
}
if (pendingValues.size() > 1)
{
- int msgID = MSGID_CONFIG_ATTR_MULTIPLE_STRING_VALUES;
- String message = getMessage(msgID, getName());
- throw new ConfigException(msgID, message);
+ Message message = ERR_CONFIG_ATTR_MULTIPLE_STRING_VALUES.get(getName());
+ throw new ConfigException(message);
}
return pendingValues.get(0);
@@ -375,9 +366,8 @@
{
if ((value == null) || (value.length() == 0))
{
- int msgID = MSGID_CONFIG_ATTR_EMPTY_STRING_VALUE;
- String message = getMessage(msgID, getName());
- throw new ConfigException(msgID, message);
+ Message message = ERR_CONFIG_ATTR_EMPTY_STRING_VALUE.get(getName());
+ throw new ConfigException(message);
}
if (requiresAdminAction())
@@ -413,9 +403,8 @@
{
if (isRequired())
{
- int msgID = MSGID_CONFIG_ATTR_IS_REQUIRED;
- String message = getMessage(msgID, getName());
- throw new ConfigException(msgID, message);
+ Message message = ERR_CONFIG_ATTR_IS_REQUIRED.get(getName());
+ throw new ConfigException(message);
}
else
{
@@ -437,9 +426,9 @@
int numValues = values.size();
if ((! isMultiValued()) && (numValues > 1))
{
- int msgID = MSGID_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED;
- String message = getMessage(msgID, getName());
- throw new ConfigException(msgID, message);
+ Message message =
+ ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(getName());
+ throw new ConfigException(message);
}
@@ -451,9 +440,8 @@
{
if ((value == null) || (value.length() == 0))
{
- int msgID = MSGID_CONFIG_ATTR_EMPTY_STRING_VALUE;
- String message = getMessage(msgID, getName());
- throw new ConfigException(msgID, message);
+ Message message = ERR_CONFIG_ATTR_EMPTY_STRING_VALUE.get(getName());
+ throw new ConfigException(message);
}
AttributeValue attrValue =
@@ -462,9 +450,9 @@
if (valueSet.contains(attrValue))
{
- int msgID = MSGID_CONFIG_ATTR_ADD_VALUES_ALREADY_EXISTS;
- String message = getMessage(msgID, getName(), value);
- throw new ConfigException(msgID, message);
+ Message message =
+ ERR_CONFIG_ATTR_ADD_VALUES_ALREADY_EXISTS.get(getName(), value);
+ throw new ConfigException(message);
}
valueSet.add(attrValue);
@@ -571,8 +559,7 @@
// The only requirement is that the value is not null or empty.
if ((value == null) || (value.getStringValue().length() == 0))
{
- rejectReason.append(getMessage(MSGID_CONFIG_ATTR_EMPTY_STRING_VALUE,
- getName()));
+ rejectReason.append(ERR_CONFIG_ATTR_EMPTY_STRING_VALUE.get(getName()));
return false;
}
@@ -610,9 +597,8 @@
{
if (isRequired())
{
- int msgID = MSGID_CONFIG_ATTR_IS_REQUIRED;
- String message = getMessage(msgID, getName());
- throw new ConfigException(msgID, message);
+ Message message = ERR_CONFIG_ATTR_IS_REQUIRED.get(getName());
+ throw new ConfigException(message);
}
else
{
@@ -624,9 +610,9 @@
int numValues = valueStrings.size();
if ((! isMultiValued()) && (numValues > 1))
{
- int msgID = MSGID_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED;
- String message = getMessage(msgID, getName());
- throw new ConfigException(msgID, message);
+ Message message =
+ ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(getName());
+ throw new ConfigException(message);
}
@@ -636,18 +622,16 @@
{
if ((valueString == null) || (valueString.length() == 0))
{
- int msgID = MSGID_CONFIG_ATTR_EMPTY_STRING_VALUE;
- String message = getMessage(msgID, getName());
+ Message message = ERR_CONFIG_ATTR_EMPTY_STRING_VALUE.get(getName());
if (allowFailures)
{
- logError(ErrorLogCategory.CONFIGURATION, ErrorLogSeverity.MILD_ERROR,
- message, msgID);
+ ErrorLogger.logError(message);
continue;
}
else
{
- throw new ConfigException(msgID, message);
+ throw new ConfigException(message);
}
}
@@ -661,9 +645,8 @@
// attribute and if so deal with it accordingly.
if ((isRequired()) && valueSet.isEmpty())
{
- int msgID = MSGID_CONFIG_ATTR_IS_REQUIRED;
- String message = getMessage(msgID, getName());
- throw new ConfigException(msgID, message);
+ Message message = ERR_CONFIG_ATTR_IS_REQUIRED.get(getName());
+ throw new ConfigException(message);
}
@@ -751,9 +734,9 @@
if (pendingValues != null)
{
// We cannot have multiple pending value sets.
- int msgID = MSGID_CONFIG_ATTR_MULTIPLE_PENDING_VALUE_SETS;
- String message = getMessage(msgID, a.getName());
- throw new ConfigException(msgID, message);
+ Message message =
+ ERR_CONFIG_ATTR_MULTIPLE_PENDING_VALUE_SETS.get(a.getName());
+ throw new ConfigException(message);
}
@@ -763,9 +746,8 @@
if (isRequired())
{
// This is illegal -- it must have a value.
- int msgID = MSGID_CONFIG_ATTR_IS_REQUIRED;
- String message = getMessage(msgID, a.getName());
- throw new ConfigException(msgID, message);
+ Message message = ERR_CONFIG_ATTR_IS_REQUIRED.get(a.getName());
+ throw new ConfigException(message);
}
else
{
@@ -779,9 +761,9 @@
if ((numValues > 1) && (! isMultiValued()))
{
// This is illegal -- the attribute is single-valued.
- int msgID = MSGID_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED;
- String message = getMessage(msgID, a.getName());
- throw new ConfigException(msgID, message);
+ Message message =
+ ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(a.getName());
+ throw new ConfigException(message);
}
pendingValues = new ArrayList<String>(numValues);
@@ -795,9 +777,9 @@
{
// This is illegal -- only the pending option is allowed for
// configuration attributes.
- int msgID = MSGID_CONFIG_ATTR_OPTIONS_NOT_ALLOWED;
- String message = getMessage(msgID, a.getName());
- throw new ConfigException(msgID, message);
+ Message message =
+ ERR_CONFIG_ATTR_OPTIONS_NOT_ALLOWED.get(a.getName());
+ throw new ConfigException(message);
}
}
else
@@ -806,9 +788,9 @@
if (activeValues!= null)
{
// We cannot have multiple active value sets.
- int msgID = MSGID_CONFIG_ATTR_MULTIPLE_ACTIVE_VALUE_SETS;
- String message = getMessage(msgID, a.getName());
- throw new ConfigException(msgID, message);
+ Message message =
+ ERR_CONFIG_ATTR_MULTIPLE_ACTIVE_VALUE_SETS.get(a.getName());
+ throw new ConfigException(message);
}
@@ -818,9 +800,8 @@
if (isRequired())
{
// This is illegal -- it must have a value.
- int msgID = MSGID_CONFIG_ATTR_IS_REQUIRED;
- String message = getMessage(msgID, a.getName());
- throw new ConfigException(msgID, message);
+ Message message = ERR_CONFIG_ATTR_IS_REQUIRED.get(a.getName());
+ throw new ConfigException(message);
}
else
{
@@ -834,9 +815,9 @@
if ((numValues > 1) && (! isMultiValued()))
{
// This is illegal -- the attribute is single-valued.
- int msgID = MSGID_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED;
- String message = getMessage(msgID, a.getName());
- throw new ConfigException(msgID, message);
+ Message message =
+ ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(a.getName());
+ throw new ConfigException(message);
}
activeValues = new ArrayList<String>(numValues);
@@ -851,9 +832,8 @@
if (activeValues == null)
{
// This is not OK. The value set must contain an active value.
- int msgID = MSGID_CONFIG_ATTR_NO_ACTIVE_VALUE_SET;
- String message = getMessage(msgID, getName());
- throw new ConfigException(msgID, message);
+ Message message = ERR_CONFIG_ATTR_NO_ACTIVE_VALUE_SET.get(getName());
+ throw new ConfigException(message);
}
if (pendingValues == null)
@@ -1023,15 +1003,17 @@
{
attributeInfoList.add(new MBeanAttributeInfo(getName(),
JMX_TYPE_STRING_ARRAY,
- getDescription(), true, true,
- false));
+ String.valueOf(
+ getDescription()),
+ true, true, false));
}
else
{
attributeInfoList.add(new MBeanAttributeInfo(getName(),
String.class.getName(),
- getDescription(), true, true,
- false));
+ String.valueOf(
+ getDescription()),
+ true, true, false));
}
@@ -1043,15 +1025,17 @@
{
attributeInfoList.add(new MBeanAttributeInfo(name,
JMX_TYPE_STRING_ARRAY,
- getDescription(), true,
- false, false));
+ String.valueOf(
+ getDescription()),
+ true, false, false));
}
else
{
attributeInfoList.add(new MBeanAttributeInfo(name,
String.class.getName(),
- getDescription(), true,
- false, false));
+ String.valueOf(
+ getDescription()),
+ true, false, false));
}
}
}
@@ -1070,12 +1054,12 @@
if (isMultiValued())
{
return new MBeanParameterInfo(getName(), JMX_TYPE_STRING_ARRAY,
- getDescription());
+ String.valueOf(getDescription()));
}
else
{
return new MBeanParameterInfo(getName(), String.class.getName(),
- getDescription());
+ String.valueOf(getDescription()));
}
}
@@ -1134,25 +1118,25 @@
TRACER.debugCaught(DebugLogLevel.ERROR, e);
}
- int msgID = MSGID_CONFIG_ATTR_INVALID_STRING_VALUE;
- String message = getMessage(msgID, getName(), String.valueOf(value),
- String.valueOf(e));
- throw new ConfigException(msgID, message, e);
+ Message message = ERR_CONFIG_ATTR_INVALID_STRING_VALUE.get(
+ getName(), String.valueOf(value), String.valueOf(e));
+ throw new ConfigException(message, e);
}
}
else
{
- int msgID = MSGID_CONFIG_ATTR_STRING_INVALID_ARRAY_TYPE;
- String message = getMessage(msgID, componentType);
- throw new ConfigException(msgID, message);
+ Message message =
+ ERR_CONFIG_ATTR_STRING_INVALID_ARRAY_TYPE.get(
+ String.valueOf(jmxAttribute),
+ String.valueOf(componentType));
+ throw new ConfigException(message);
}
}
else
{
- int msgID = MSGID_CONFIG_ATTR_STRING_INVALID_TYPE;
- String message = getMessage(msgID, String.valueOf(value), getName(),
- value.getClass().getName());
- throw new ConfigException(msgID, message);
+ Message message = ERR_CONFIG_ATTR_STRING_INVALID_TYPE.get(
+ String.valueOf(value), getName(), value.getClass().getName());
+ throw new ConfigException(message);
}
}
--
Gitblit v1.10.0