From de19fe2956d5a4b3817834191c51989664f8c47c Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Mon, 03 Sep 2007 20:36:20 +0000
Subject: [PATCH] Fix issue 1443: Admin framework: improve error logging in server
---
opends/src/server/org/opends/server/admin/PropertyIsMandatoryException.java | 21
opends/src/server/org/opends/server/admin/AdminException.java | 25 -
opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java | 6
opends/src/server/org/opends/server/admin/PropertyIsSingleValuedException.java | 26
opends/src/server/org/opends/server/admin/IllegalPropertyValueException.java | 30
opends/src/server/org/opends/server/admin/client/ConcurrentModificationException.java | 18
opends/src/server/org/opends/server/admin/IllegalPropertyValueStringException.java | 29
opends/src/server/org/opends/server/admin/DefaultBehaviorException.java | 31 -
opends/src/server/org/opends/server/admin/client/IllegalManagedObjectNameException.java | 64 +-
opends/src/server/org/opends/server/admin/OperationsException.java | 34 -
opends/src/server/org/opends/server/admin/server/ServerManagedObjectDecodingException.java | 91 +++-
opends/src/server/org/opends/server/admin/PropertyException.java | 66 ++-
opends/src/server/org/opends/server/admin/PropertyIsReadOnlyException.java | 21
opends/src/server/org/opends/server/admin/client/spi/Driver.java | 5
opends/src/server/org/opends/server/admin/client/AuthenticationException.java | 15
opends/src/server/org/opends/server/admin/client/CommunicationException.java | 15
opends/src/server/org/opends/server/admin/client/OperationRejectedException.java | 26
opends/src/server/org/opends/server/admin/server/ServerManagedObject.java | 5
opends/src/server/org/opends/server/admin/AdminRuntimeException.java | 41 +-
opends/src/server/org/opends/server/admin/client/ManagedObjectDecodingException.java | 92 +++-
opends/src/server/org/opends/server/admin/client/MissingMandatoryPropertiesException.java | 56 +-
opends/src/server/org/opends/server/admin/client/AdminSecurityException.java | 25 -
opends/src/server/org/opends/server/admin/client/AdminClientException.java | 32 -
opends/src/server/org/opends/server/admin/ManagedObjectAlreadyExistsException.java | 12
opends/src/server/org/opends/server/admin/DefinitionDecodingException.java | 111 +++--
opends/src/server/org/opends/server/admin/PropertyNotFoundException.java | 6
opends/src/server/org/opends/server/admin/client/ldap/LDAPDriver.java | 4
opends/src/server/org/opends/server/admin/ManagedObjectNotFoundException.java | 17
opends/src/messages/messages/admin.properties | 69 +++
opends/src/server/org/opends/server/admin/DecodingException.java | 21
opends/src/server/org/opends/server/admin/UnknownPropertyDefinitionException.java | 28
opends/src/server/org/opends/server/admin/client/AuthorizationException.java | 15
opends/src/server/org/opends/server/admin/client/AuthenticationNotSupportedException.java | 16
33 files changed, 571 insertions(+), 502 deletions(-)
diff --git a/opends/src/messages/messages/admin.properties b/opends/src/messages/messages/admin.properties
index 79bf72f..6ab5d73 100644
--- a/opends/src/messages/messages/admin.properties
+++ b/opends/src/messages/messages/admin.properties
@@ -186,5 +186,70 @@
administrator's properties
INFO_ADMIN_ARG_USERID_DESCRIPTION_73=The administrator's unique identifier. \
This is a required argument
-SEVERE_ERR_OPERATION_REJECTED_DEFAULT_74=The operation was rejected for an \
- unspecified reason
+SEVERE_ERR_OPERATION_REJECTED_DEFAULT_74=Reason unknown
+SEVERE_ERR_SERVER_CONSTRAINT_EXCEPTION_75=A configuration exception \
+ occurred while evaluating a constraint: %s
+SEVERE_ERR_DECODING_EXCEPTION_NO_TYPE_INFO_82=The %s could \
+ be found but did not contain any type information (e.g. missing object \
+ classes in LDAP)
+SEVERE_ERR_DECODING_EXCEPTION_WRONG_TYPE_INFO_83=The %s could \
+ be found but did not contain the expected type information (e.g. incorrect \
+ object classes in LDAP)
+SEVERE_ERR_DECODING_EXCEPTION_ABSTRACT_TYPE_INFO_84=The %s \
+ could be found but its type resolved to an abstract managed object \
+ definition
+SEVERE_ERR_DECODING_EXCEPTION_UNKNOWN_85=The managed object could not \
+ be decoded due to an unspecified reason
+SEVERE_ERR_DEFAULT_BEHAVIOR_PROPERTY_EXCEPTION_86=The default values \
+ for the "%s" property could not be determined
+SEVERE_ERR_ILLEGAL_PROPERTY_VALUE_EXCEPTION_87=The value "%s" is not \
+ a valid value for the "%s" property, which must have the following \
+ syntax: %s
+SEVERE_ERR_ILLEGAL_PROPERTY_VALUE_STRING_EXCEPTION_88=The string value \
+ "%s" is not a valid value for the "%s" property, which must have the \
+ following syntax: %s
+SEVERE_ERR_PROPERTY_IS_MANDATORY_EXCEPTION_89=The "%s" property must be \
+ specified as it is mandatory
+SEVERE_ERR_PROPERTY_IS_READ_ONLY_EXCEPTION_90=The "%s" property must not \
+ be modified as it is read-only
+SEVERE_ERR_PROPERTY_IS_SINGLE_VALUED_EXCEPTION_91=The "%s" property \
+ must not contain more than one value
+SEVERE_ERR_UNKNOWN_PROPERTY_DEFINITION_EXCEPTION_92=An internal error \
+ occurred while processing property "%s": unknown property type "%s"
+SEVERE_ERR_AUTHENTICATION_EXCEPTION_DEFAULT_93=Authentication failure
+SEVERE_ERR_AUTHENTICATION_NOT_SUPPORTED_EXCEPTION_DEFAULT_94=The \
+ requested authentication mechanism is not supported by the server
+SEVERE_ERR_AUTHORIZATION_EXCEPTION_DEFAULT_95=Authorization failure
+SEVERE_ERR_COMMUNICATION_EXCEPTION_DEFAULT_96=A communication problem \
+ occurred while contacting the server
+SEVERE_ERR_OPERATION_REJECTED_EXCEPTION_SINGLE_97=The operation was rejected \
+ for the following reason: %s
+SEVERE_ERR_OPERATION_REJECTED_EXCEPTION_PLURAL_98=The operation was rejected \
+ for the following reasons: %s
+SEVERE_ERR_CONCURRENT_MODIFICATION_EXCEPTION_DEFAULT_99=The operation could \
+ not be performed because a conflicting change has already occurred. There \
+ may be another client administration tool in use
+SEVERE_ERR_MANAGED_OBJECT_DECODING_EXCEPTION_SINGLE_100=The %s could not \
+ be decoded due to the following property exception: %s
+SEVERE_ERR_MANAGED_OBJECT_DECODING_EXCEPTION_PLURAL_101=The %s could not \
+ be decoded due to the following property exceptions: %s
+SEVERE_ERR_ILLEGAL_MANAGED_OBJECT_NAME_EXCEPTION_EMPTY_102=Empty managed \
+ object names are not permitted
+SEVERE_ERR_ILLEGAL_MANAGED_OBJECT_NAME_EXCEPTION_BLANK_103=Blank managed \
+ object names are not permitted
+SEVERE_ERR_ILLEGAL_MANAGED_OBJECT_NAME_EXCEPTION_SYNTAX_104=The managed \
+ object name "%s" is not a valid value for the naming property "%s", \
+ which must have the following syntax: %s
+SEVERE_ERR_ILLEGAL_MANAGED_OBJECT_NAME_EXCEPTION_OTHER_105=The managed \
+ object name "%s" is not permitted
+SEVERE_ERR_MANAGED_OBJECT_ALREADY_EXISTS_EXCEPTION_106=The managed object \
+ could not be created because there is an existing managed object with \
+ the same name
+SEVERE_ERR_MANAGED_OBJECT_NOT_FOUND_EXCEPTION_107=The requested managed \
+ object could not be found
+SEVERE_ERR_MISSING_MANDATORY_PROPERTIES_EXCEPTION_SINGLE_108=The "%s" \
+ property is mandatory
+SEVERE_ERR_MISSING_MANDATORY_PROPERTIES_EXCEPTION_PLURAL_109=The following \
+ properties are mandatory: %s
+SEVERE_ERR_PROPERTY_NOT_FOUND_EXCEPTION_110=The property "%s" was not \
+ recognized
diff --git a/opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java b/opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java
index 8d6c75e..881e140 100644
--- a/opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java
+++ b/opends/src/server/org/opends/server/admin/AbstractManagedObjectDefinition.java
@@ -637,12 +637,14 @@
rd = resolveManagedObjectDefinitionAux(this, r);
if (rd == null) {
// Unable to resolve the definition.
- throw new DefinitionDecodingException(Reason.WRONG_TYPE_INFORMATION);
+ throw new DefinitionDecodingException(this,
+ Reason.WRONG_TYPE_INFORMATION);
} else if (rd instanceof ManagedObjectDefinition) {
return (ManagedObjectDefinition<? extends C, ? extends S>) rd;
} else {
// Resolved definition was abstract.
- throw new DefinitionDecodingException(Reason.ABSTRACT_TYPE_INFORMATION);
+ throw new DefinitionDecodingException(this,
+ Reason.ABSTRACT_TYPE_INFORMATION);
}
}
diff --git a/opends/src/server/org/opends/server/admin/AdminException.java b/opends/src/server/org/opends/server/admin/AdminException.java
index 20937f1..bdb8eda 100644
--- a/opends/src/server/org/opends/server/admin/AdminException.java
+++ b/opends/src/server/org/opends/server/admin/AdminException.java
@@ -26,38 +26,21 @@
*/
package org.opends.server.admin;
+
+
+
import org.opends.messages.Message;
import org.opends.server.types.OpenDsException;
+
/**
* Exceptions thrown when interacting with administration framework.
*/
public abstract class AdminException extends OpenDsException {
/**
- * Create an admin exception.
- */
- protected AdminException() {
- // No implementation required.
- }
-
-
-
- /**
- * Create an admin exception with a cause.
- *
- * @param cause
- * The cause.
- */
- protected AdminException(Throwable cause) {
- super(cause);
- }
-
-
-
- /**
* Create an admin exception with a message and cause.
*
* @param message
diff --git a/opends/src/server/org/opends/server/admin/AdminRuntimeException.java b/opends/src/server/org/opends/server/admin/AdminRuntimeException.java
index 15a2be7..304124c 100644
--- a/opends/src/server/org/opends/server/admin/AdminRuntimeException.java
+++ b/opends/src/server/org/opends/server/admin/AdminRuntimeException.java
@@ -26,34 +26,21 @@
*/
package org.opends.server.admin;
+
+
+
import org.opends.messages.Message;
/**
- * Exceptions thrown when interacting with administration framework that
- * applications are not expected to catch.
+ * Exceptions thrown when interacting with administration framework
+ * that applications are not expected to catch.
*/
public abstract class AdminRuntimeException extends RuntimeException {
- /**
- * Create an admin runtime exception.
- */
- protected AdminRuntimeException() {
- // No implementation required.
- }
-
-
-
- /**
- * Create an admin runtime exception with a cause.
- *
- * @param cause
- * The cause.
- */
- protected AdminRuntimeException(Throwable cause) {
- super(cause);
- }
+ // Message that explains the problem.
+ private final Message message;
@@ -67,6 +54,7 @@
*/
protected AdminRuntimeException(Message message, Throwable cause) {
super(message.toString(), cause);
+ this.message = message;
}
@@ -79,5 +67,18 @@
*/
protected AdminRuntimeException(Message message) {
super(message.toString());
+ this.message = message;
+ }
+
+
+
+ /**
+ * Returns the message that explains the problem that occurred.
+ *
+ * @return Returns the message describing the problem that occurred
+ * (never <code>null</code>).
+ */
+ public Message getMessageObject() {
+ return this.message;
}
}
diff --git a/opends/src/server/org/opends/server/admin/DecodingException.java b/opends/src/server/org/opends/server/admin/DecodingException.java
index 1fcd1e7..645f499 100644
--- a/opends/src/server/org/opends/server/admin/DecodingException.java
+++ b/opends/src/server/org/opends/server/admin/DecodingException.java
@@ -26,27 +26,26 @@
*/
package org.opends.server.admin;
+
+
+
import org.opends.messages.Message;
+
/**
* The requested managed object was found but it could not be decoded.
*/
public abstract class DecodingException extends OperationsException {
/**
- * Create a decoding exception.
+ * Create a decoding exception with a message.
+ *
+ * @param message
+ * The message.
*/
- protected DecodingException() {
- // No implementation required.
+ protected DecodingException(Message message) {
+ super(message);
}
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public abstract Message getMessageObject();
-
}
diff --git a/opends/src/server/org/opends/server/admin/DefaultBehaviorException.java b/opends/src/server/org/opends/server/admin/DefaultBehaviorException.java
index 55ed90d..cadf390 100644
--- a/opends/src/server/org/opends/server/admin/DefaultBehaviorException.java
+++ b/opends/src/server/org/opends/server/admin/DefaultBehaviorException.java
@@ -29,6 +29,10 @@
+import static org.opends.messages.AdminMessages.*;
+
+
+
/**
* This exception is thrown when a property's default values cannot be
* determined. This can occur in the following situations:
@@ -47,9 +51,6 @@
*/
private static final long serialVersionUID = -2542117466747573053L;
- // The cause of this exception.
- private final Throwable cause;
-
/**
@@ -63,28 +64,6 @@
* being determined.
*/
public DefaultBehaviorException(PropertyDefinition<?> pd, Throwable cause) {
- super(pd);
- this.cause = cause;
- }
-
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Throwable getCause() {
- return cause;
- }
-
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getMessage() {
- return "The default values could not be determined "
- + "for the property \"" + getPropertyDefinition().getName() + "\"";
+ super(pd, ERR_DEFAULT_BEHAVIOR_PROPERTY_EXCEPTION.get(pd.getName()), cause);
}
}
diff --git a/opends/src/server/org/opends/server/admin/DefinitionDecodingException.java b/opends/src/server/org/opends/server/admin/DefinitionDecodingException.java
index 7644f99..3f60689 100644
--- a/opends/src/server/org/opends/server/admin/DefinitionDecodingException.java
+++ b/opends/src/server/org/opends/server/admin/DefinitionDecodingException.java
@@ -26,9 +26,15 @@
*/
package org.opends.server.admin;
+
+
+
+import static org.opends.messages.AdminMessages.*;
+
import org.opends.messages.Message;
+
/**
* The requested managed object was found but its type could not be
* determined.
@@ -36,55 +42,54 @@
public class DefinitionDecodingException extends DecodingException {
/**
+ * An enumeration defining the reasons why the definition could not
+ * be resolved.
+ */
+ public static enum Reason {
+ /**
+ * The managed object could be found but its type resolved to an
+ * abstract managed object definition.
+ */
+ ABSTRACT_TYPE_INFORMATION(),
+
+ /**
+ * The managed object could be found but did not contain any type
+ * information (eg missing object classes in LDAP).
+ */
+ NO_TYPE_INFORMATION(),
+
+ /**
+ * The managed object could be found but did not contain the
+ * expected type information (eg incorrect object classes in
+ * LDAP).
+ */
+ WRONG_TYPE_INFORMATION();
+
+ }
+
+ /**
* Version ID required by serializable classes.
*/
private static final long serialVersionUID = 3459033551415663416L;
- /**
- * An enumeration defining the reasons why the definition could not be
- * resolved.
- */
- public static enum Reason {
- /**
- * The managed object could be found but did not contain any type
- * information (eg missing object classes in LDAP).
- */
- NO_TYPE_INFORMATION(Message.raw( // TODO: i18n?
- "The managed object could be found but did not contain any"
- + " type information (e.g. missing object classes in LDAP).")),
-
- /**
- * The managed object could be found but did not contain the expected type
- * information (eg incorrect object classes in LDAP).
- */
- WRONG_TYPE_INFORMATION(Message.raw( // TODO: i18n?
- "The managed object could be found but did not contain the"
- + " expected type information (e.g. incorrect object"
- + " classes in LDAP).")),
-
- /**
- * The managed object could be found but its type resolved to an abstract
- * managed object definition.
- */
- ABSTRACT_TYPE_INFORMATION(Message.raw( // TODO: i18n?
- "The managed object could be found but its type resolved to an"
- + " abstract managed object definition."));
-
- // Simple description of this reason for debugging.
- private Message msg;
-
-
-
- // Private constructor.
- private Reason(Message msg) {
- this.msg = msg;
+ // Create the message.
+ private static Message createMessage(AbstractManagedObjectDefinition<?, ?> d,
+ Reason reason) {
+ Message ufn = d.getUserFriendlyName();
+ switch (reason) {
+ case NO_TYPE_INFORMATION:
+ return ERR_DECODING_EXCEPTION_NO_TYPE_INFO.get(ufn);
+ case WRONG_TYPE_INFORMATION:
+ return ERR_DECODING_EXCEPTION_WRONG_TYPE_INFO.get(ufn);
+ default:
+ return ERR_DECODING_EXCEPTION_ABSTRACT_TYPE_INFO.get(ufn);
}
-
}
-
+ // The expected type of managed object.
+ private final AbstractManagedObjectDefinition<?, ?> d;
// The reason why the definition could not be determined.
private final Reason reason;
@@ -94,32 +99,38 @@
/**
* Create a new definition decoding exception.
*
+ * @param d
+ * The expected type of managed object.
* @param reason
* The reason why the definition could not be determined.
*/
- public DefinitionDecodingException(Reason reason) {
+ public DefinitionDecodingException(AbstractManagedObjectDefinition<?, ?> d,
+ Reason reason) {
+ super(createMessage(d, reason));
+ this.d = d;
this.reason = reason;
}
/**
- * Get the reason why the definition could not be determined.
+ * Gets the expected managed object definition.
*
- * @return Returns the reason why the definition could not be determined.
+ * @return Returns the expected managed object definition.
*/
- public Reason getReason() {
- return reason;
+ public AbstractManagedObjectDefinition<?, ?> getManagedObjectDefinition() {
+ return d;
}
/**
- * {@inheritDoc}
+ * Gets the reason why the definition could not be determined.
+ *
+ * @return Returns the reason why the definition could not be
+ * determined.
*/
- @Override
- public Message getMessageObject() {
- return reason.msg;
+ public Reason getReason() {
+ return reason;
}
-
}
diff --git a/opends/src/server/org/opends/server/admin/IllegalPropertyValueException.java b/opends/src/server/org/opends/server/admin/IllegalPropertyValueException.java
index 591252c..ef0cd5d 100644
--- a/opends/src/server/org/opends/server/admin/IllegalPropertyValueException.java
+++ b/opends/src/server/org/opends/server/admin/IllegalPropertyValueException.java
@@ -29,9 +29,15 @@
+import static org.opends.messages.AdminMessages.*;
+
+import org.opends.messages.Message;
+
+
+
/**
- * Thrown to indicate that a property value was invalid according to its
- * associated property definition.
+ * Thrown to indicate that a property value was invalid according to
+ * its associated property definition.
*/
public class IllegalPropertyValueException extends PropertyException {
@@ -48,13 +54,13 @@
/**
* Create a new illegal property value exception.
*
- * @param d
+ * @param pd
* The property definition.
* @param value
* The illegal property value.
*/
- public IllegalPropertyValueException(PropertyDefinition<?> d, Object value) {
- super(d);
+ public IllegalPropertyValueException(PropertyDefinition<?> pd, Object value) {
+ super(pd, createMessage(pd, value));
this.value = value;
}
@@ -71,18 +77,12 @@
- /**
- * {@inheritDoc}
- */
- @Override
- public String getMessage() {
- String msg = "The value \"%s\" is not a valid value for the "
- + "property \"%s\", which must have the following syntax: %s";
- PropertyDefinition<?> pd = getPropertyDefinition();
+ // Create the message.
+ private static Message createMessage(PropertyDefinition<?> pd, Object value) {
PropertyDefinitionUsageBuilder builder = new PropertyDefinitionUsageBuilder(
true);
- return String.format(msg, String.valueOf(value), pd.getName(), builder
- .getUsage(pd));
+ return ERR_ILLEGAL_PROPERTY_VALUE_EXCEPTION.get(String.valueOf(value), pd
+ .getName(), builder.getUsage(pd));
}
}
diff --git a/opends/src/server/org/opends/server/admin/IllegalPropertyValueStringException.java b/opends/src/server/org/opends/server/admin/IllegalPropertyValueStringException.java
index 6c062ea..bf8db42 100644
--- a/opends/src/server/org/opends/server/admin/IllegalPropertyValueStringException.java
+++ b/opends/src/server/org/opends/server/admin/IllegalPropertyValueStringException.java
@@ -29,9 +29,15 @@
+import static org.opends.messages.AdminMessages.*;
+
+import org.opends.messages.Message;
+
+
+
/**
- * Thrown to indicate that a property value string was invalid according to its
- * associated property definition.
+ * Thrown to indicate that a property value string was invalid
+ * according to its associated property definition.
*/
public class IllegalPropertyValueStringException extends PropertyException {
@@ -48,14 +54,14 @@
/**
* Create a new illegal property value string exception.
*
- * @param d
+ * @param pd
* The property definition.
* @param value
* The illegal property value string.
*/
- public IllegalPropertyValueStringException(PropertyDefinition<?> d,
+ public IllegalPropertyValueStringException(PropertyDefinition<?> pd,
String value) {
- super(d);
+ super(pd, createMessage(pd, value));
this.value = value;
}
@@ -72,17 +78,12 @@
- /**
- * {@inheritDoc}
- */
- @Override
- public String getMessage() {
- String msg = "The string value \"%s\" is not a valid value for the "
- + "property \"%s\", which must have the following syntax: %s";
- PropertyDefinition<?> pd = getPropertyDefinition();
+ // Create the message.
+ private static Message createMessage(PropertyDefinition<?> pd, String value) {
PropertyDefinitionUsageBuilder builder = new PropertyDefinitionUsageBuilder(
true);
- return String.format(msg, value, pd.getName(), builder.getUsage(pd));
+ return ERR_ILLEGAL_PROPERTY_VALUE_STRING_EXCEPTION.get(value, pd.getName(),
+ builder.getUsage(pd));
}
}
diff --git a/opends/src/server/org/opends/server/admin/ManagedObjectAlreadyExistsException.java b/opends/src/server/org/opends/server/admin/ManagedObjectAlreadyExistsException.java
index 9ba2004..77e5643 100644
--- a/opends/src/server/org/opends/server/admin/ManagedObjectAlreadyExistsException.java
+++ b/opends/src/server/org/opends/server/admin/ManagedObjectAlreadyExistsException.java
@@ -26,7 +26,11 @@
*/
package org.opends.server.admin;
-import org.opends.messages.Message;
+
+
+
+import static org.opends.messages.AdminMessages.*;
+
/**
@@ -41,16 +45,12 @@
*/
private static final long serialVersionUID = -2344653674171609366L;
- // Simple description of this exception for debugging.
- private static final String MSG = "A managed object could not be created"
- + " because there is an existing managed object with the same name";
-
/**
* Create a managed object already exists exception.
*/
public ManagedObjectAlreadyExistsException() {
- super(Message.raw(MSG));
+ super(ERR_MANAGED_OBJECT_ALREADY_EXISTS_EXCEPTION.get());
}
}
diff --git a/opends/src/server/org/opends/server/admin/ManagedObjectNotFoundException.java b/opends/src/server/org/opends/server/admin/ManagedObjectNotFoundException.java
index da465f4..d2ab214 100644
--- a/opends/src/server/org/opends/server/admin/ManagedObjectNotFoundException.java
+++ b/opends/src/server/org/opends/server/admin/ManagedObjectNotFoundException.java
@@ -26,7 +26,11 @@
*/
package org.opends.server.admin;
-import org.opends.messages.Message;
+
+
+
+import static org.opends.messages.AdminMessages.*;
+
/**
@@ -39,28 +43,25 @@
*/
private static final long serialVersionUID = -477551786551892978L;
- // Simple description of this exception for debugging.
- private static final String MSG = // TODO: i18n
- "The requested managed object could not be found";
-
/**
* Create a managed object not found exception.
*/
public ManagedObjectNotFoundException() {
- super(Message.raw(MSG));
+ super(ERR_MANAGED_OBJECT_NOT_FOUND_EXCEPTION.get());
}
/**
- * Create a managed object not found exception with the specified cause.
+ * Create a managed object not found exception with the specified
+ * cause.
*
* @param cause
* The cause of this exception.
*/
public ManagedObjectNotFoundException(Throwable cause) {
- super(Message.raw(MSG), cause);
+ super(ERR_MANAGED_OBJECT_NOT_FOUND_EXCEPTION.get(), cause);
}
}
diff --git a/opends/src/server/org/opends/server/admin/OperationsException.java b/opends/src/server/org/opends/server/admin/OperationsException.java
index 90710b5..f3a2e7e 100644
--- a/opends/src/server/org/opends/server/admin/OperationsException.java
+++ b/opends/src/server/org/opends/server/admin/OperationsException.java
@@ -27,14 +27,17 @@
package org.opends.server.admin;
+
+
import org.opends.messages.Message;
+
/**
- * Exceptions thrown as a result of errors that occurred when reading, listing,
- * and modifying managed objects.
+ * Exceptions thrown as a result of errors that occurred when reading,
+ * listing, and modifying managed objects.
*/
-public class OperationsException extends AdminException {
+public abstract class OperationsException extends AdminException {
/**
* Serialization ID.
@@ -44,27 +47,6 @@
/**
- * Create an operations exception.
- */
- public OperationsException() {
- // No implementation required.
- }
-
-
-
- /**
- * Create an operations exception with a cause.
- *
- * @param cause
- * The cause.
- */
- public OperationsException(Throwable cause) {
- super(cause);
- }
-
-
-
- /**
* Create an operations exception with a message and cause.
*
* @param message
@@ -72,7 +54,7 @@
* @param cause
* The cause.
*/
- public OperationsException(Message message, Throwable cause) {
+ protected OperationsException(Message message, Throwable cause) {
super(message, cause);
}
@@ -84,7 +66,7 @@
* @param message
* The message.
*/
- public OperationsException(Message message) {
+ protected OperationsException(Message message) {
super(message);
}
}
diff --git a/opends/src/server/org/opends/server/admin/PropertyException.java b/opends/src/server/org/opends/server/admin/PropertyException.java
index beb5246..17d282d 100644
--- a/opends/src/server/org/opends/server/admin/PropertyException.java
+++ b/opends/src/server/org/opends/server/admin/PropertyException.java
@@ -29,9 +29,13 @@
+import org.opends.messages.Message;
+
+
+
/**
- * Exceptions thrown as a result of errors that occurred when decoding and
- * modifying property values.
+ * Exceptions thrown as a result of errors that occurred when decoding
+ * and modifying property values.
*/
public abstract class PropertyException extends AdminRuntimeException {
@@ -40,42 +44,56 @@
*/
private static final long serialVersionUID = -8465109598081914482L;
- // The property definition associated with the property that caused the
- // exception.
- private final PropertyDefinition<?> definition;
+ // The property definition associated with the property that caused
+ // the exception.
+ private final PropertyDefinition<?> pd;
/**
- * Create an operations exception with a cause.
+ * Creates property exception without a cause.
*
- * @param definition
- * The property definition associated with the property that caused
- * the exception.
+ * @param pd
+ * The property definition associated with the property
+ * that caused the exception.
+ * @param message
+ * The message.
*/
- protected PropertyException(PropertyDefinition<?> definition) {
- this.definition = definition;
+ protected PropertyException(PropertyDefinition<?> pd, Message message) {
+ super(message);
+ this.pd = pd;
}
/**
- * Get the property definition associated with the property that caused the
- * exception.
+ * Creates property exception with a cause.
*
- * @return Returns the property definition associated with the property that
- * caused the exception.
+ * @param pd
+ * The property definition associated with the property
+ * that caused the exception.
+ * @param message
+ * The message.
+ * @param cause
+ * The cause.
+ */
+ protected PropertyException(PropertyDefinition<?> pd, Message message,
+ Throwable cause) {
+ super(message, cause);
+ this.pd = pd;
+ }
+
+
+
+ /**
+ * Get the property definition associated with the property that
+ * caused the exception.
+ *
+ * @return Returns the property definition associated with the
+ * property that caused the exception.
*/
public final PropertyDefinition<?> getPropertyDefinition() {
- return definition;
+ return pd;
}
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public abstract String getMessage();
-
}
diff --git a/opends/src/server/org/opends/server/admin/PropertyIsMandatoryException.java b/opends/src/server/org/opends/server/admin/PropertyIsMandatoryException.java
index 8277da5..3f78033 100644
--- a/opends/src/server/org/opends/server/admin/PropertyIsMandatoryException.java
+++ b/opends/src/server/org/opends/server/admin/PropertyIsMandatoryException.java
@@ -29,6 +29,10 @@
+import static org.opends.messages.AdminMessages.*;
+
+
+
/**
* Thrown when an attempt is made to remove a mandatory property.
*/
@@ -44,22 +48,11 @@
/**
* Create a new property is mandatory exception.
*
- * @param d
+ * @param pd
* The property definition.
*/
- public PropertyIsMandatoryException(PropertyDefinition<?> d) {
- super(d);
- }
-
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getMessage() {
- return "The property \"" + getPropertyDefinition().getName()
- + "\" must be specified as it is mandatory";
+ public PropertyIsMandatoryException(PropertyDefinition<?> pd) {
+ super(pd, ERR_PROPERTY_IS_MANDATORY_EXCEPTION.get(pd.getName()));
}
}
diff --git a/opends/src/server/org/opends/server/admin/PropertyIsReadOnlyException.java b/opends/src/server/org/opends/server/admin/PropertyIsReadOnlyException.java
index bec4e26..96607e7 100644
--- a/opends/src/server/org/opends/server/admin/PropertyIsReadOnlyException.java
+++ b/opends/src/server/org/opends/server/admin/PropertyIsReadOnlyException.java
@@ -29,6 +29,10 @@
+import static org.opends.messages.AdminMessages.*;
+
+
+
/**
* Thrown when an attempt is made to modify a read-only property.
*/
@@ -44,22 +48,11 @@
/**
* Create a new property is read-only exception.
*
- * @param d
+ * @param pd
* The property definition.
*/
- public PropertyIsReadOnlyException(PropertyDefinition<?> d) {
- super(d);
- }
-
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getMessage() {
- return "The property \"" + getPropertyDefinition().getName()
- + "\" must not be modified as it is read-only";
+ public PropertyIsReadOnlyException(PropertyDefinition<?> pd) {
+ super(pd, ERR_PROPERTY_IS_READ_ONLY_EXCEPTION.get(pd.getName()));
}
}
diff --git a/opends/src/server/org/opends/server/admin/PropertyIsSingleValuedException.java b/opends/src/server/org/opends/server/admin/PropertyIsSingleValuedException.java
index c268b8f..249f757 100644
--- a/opends/src/server/org/opends/server/admin/PropertyIsSingleValuedException.java
+++ b/opends/src/server/org/opends/server/admin/PropertyIsSingleValuedException.java
@@ -29,9 +29,13 @@
+import static org.opends.messages.AdminMessages.*;
+
+
+
/**
- * Thrown when an attempt is made to add more than value to a single-valued
- * property.
+ * Thrown when an attempt is made to add more than value to a
+ * single-valued property.
*/
public class PropertyIsSingleValuedException extends PropertyException {
@@ -45,22 +49,10 @@
/**
* Create a new property is single valued exception.
*
- * @param d
+ * @param pd
* The property definition.
*/
- public PropertyIsSingleValuedException(PropertyDefinition<?> d) {
- super(d);
+ public PropertyIsSingleValuedException(PropertyDefinition<?> pd) {
+ super(pd, ERR_PROPERTY_IS_SINGLE_VALUED_EXCEPTION.get(pd.getName()));
}
-
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getMessage() {
- return "The property \"" + getPropertyDefinition().getName()
- + "\" must not contain more than one value";
- }
-
}
diff --git a/opends/src/server/org/opends/server/admin/PropertyNotFoundException.java b/opends/src/server/org/opends/server/admin/PropertyNotFoundException.java
index 0783ee3..ff19a36 100644
--- a/opends/src/server/org/opends/server/admin/PropertyNotFoundException.java
+++ b/opends/src/server/org/opends/server/admin/PropertyNotFoundException.java
@@ -27,7 +27,7 @@
package org.opends.server.admin;
-import org.opends.messages.Message;
+import static org.opends.messages.AdminMessages.*;
/**
@@ -56,8 +56,8 @@
* The name of the property that could not be found.
*/
public PropertyNotFoundException(String propertyName) {
- super(Message.raw("The property \"" + propertyName +
- "\" was not recognized")); // TODO: i18n
+ super(ERR_PROPERTY_NOT_FOUND_EXCEPTION.get(propertyName));
+
this.propertyName = propertyName;
}
diff --git a/opends/src/server/org/opends/server/admin/UnknownPropertyDefinitionException.java b/opends/src/server/org/opends/server/admin/UnknownPropertyDefinitionException.java
index 668bf45..0ace2b0 100644
--- a/opends/src/server/org/opends/server/admin/UnknownPropertyDefinitionException.java
+++ b/opends/src/server/org/opends/server/admin/UnknownPropertyDefinitionException.java
@@ -29,10 +29,14 @@
+import static org.opends.messages.AdminMessages.*;
+
+
+
/**
- * Indicates that an unknown type of property definition was encountered. This
- * can occur as the management prototype develops and new kinds of property
- * definitions are added.
+ * Indicates that an unknown type of property definition was
+ * encountered. This can occur as the management prototype develops
+ * and new kinds of property definitions are added.
*/
public final class UnknownPropertyDefinitionException
extends PropertyException {
@@ -48,13 +52,15 @@
/**
* Creates a new unknown property definition exception.
*
- * @param d
+ * @param pd
* The unknown property definition.
* @param p
* The visitor parameter if there was one.
*/
- public UnknownPropertyDefinitionException(PropertyDefinition<?> d, Object p) {
- super(d);
+ public UnknownPropertyDefinitionException(PropertyDefinition<?> pd,
+ Object p) {
+ super(pd, ERR_UNKNOWN_PROPERTY_DEFINITION_EXCEPTION.get(pd.getName(), pd
+ .getClass().getName()));
this.parameter = p;
}
@@ -69,14 +75,4 @@
return parameter;
}
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getMessage() {
- return "Unhandled property definition type encountered \""
- + getPropertyDefinition().getClass().getName() + "\"";
- }
}
diff --git a/opends/src/server/org/opends/server/admin/client/AdminClientException.java b/opends/src/server/org/opends/server/admin/client/AdminClientException.java
index 7f85bf9..53bec1c 100644
--- a/opends/src/server/org/opends/server/admin/client/AdminClientException.java
+++ b/opends/src/server/org/opends/server/admin/client/AdminClientException.java
@@ -26,10 +26,11 @@
*/
package org.opends.server.admin.client;
+
+
+
import org.opends.messages.Message;
-
-
import org.opends.server.admin.AdminException;
@@ -43,7 +44,7 @@
* Client exceptions represent communications problems, security
* problems, and service related problems.
*/
-public class AdminClientException extends AdminException {
+public abstract class AdminClientException extends AdminException {
/**
* Serialization ID.
@@ -53,27 +54,6 @@
/**
- * Create an administration client exception.
- */
- public AdminClientException() {
- // No implementation required.
- }
-
-
-
- /**
- * Create an administration client exception with a cause.
- *
- * @param cause
- * The cause.
- */
- public AdminClientException(Throwable cause) {
- super(cause);
- }
-
-
-
- /**
* Create an administration client exception with a message and
* cause.
*
@@ -82,7 +62,7 @@
* @param cause
* The cause.
*/
- public AdminClientException(Message message, Throwable cause) {
+ protected AdminClientException(Message message, Throwable cause) {
super(message, cause);
}
@@ -94,7 +74,7 @@
* @param message
* The message.
*/
- public AdminClientException(Message message) {
+ protected AdminClientException(Message message) {
super(message);
}
}
diff --git a/opends/src/server/org/opends/server/admin/client/AdminSecurityException.java b/opends/src/server/org/opends/server/admin/client/AdminSecurityException.java
index e372487..c8f4bae 100644
--- a/opends/src/server/org/opends/server/admin/client/AdminSecurityException.java
+++ b/opends/src/server/org/opends/server/admin/client/AdminSecurityException.java
@@ -26,10 +26,12 @@
*/
package org.opends.server.admin.client;
-import org.opends.messages.Message;
+import org.opends.messages.Message;
+
+
/**
* This exception is thrown when a security related problem occurs
@@ -40,27 +42,6 @@
public abstract class AdminSecurityException extends AdminClientException {
/**
- * Create a security exception.
- */
- protected AdminSecurityException() {
- // No implementation required.
- }
-
-
-
- /**
- * Create a security exception with a cause.
- *
- * @param cause
- * The cause.
- */
- protected AdminSecurityException(Throwable cause) {
- super(cause);
- }
-
-
-
- /**
* Create a security exception with a message and cause.
*
* @param message
diff --git a/opends/src/server/org/opends/server/admin/client/AuthenticationException.java b/opends/src/server/org/opends/server/admin/client/AuthenticationException.java
index 3672515..7d14add 100644
--- a/opends/src/server/org/opends/server/admin/client/AuthenticationException.java
+++ b/opends/src/server/org/opends/server/admin/client/AuthenticationException.java
@@ -26,10 +26,14 @@
*/
package org.opends.server.admin.client;
-import org.opends.messages.Message;
+import static org.opends.messages.AdminMessages.*;
+
+import org.opends.messages.Message;
+
+
/**
* This exception is thrown when an authentication error occurs while
@@ -46,22 +50,23 @@
/**
- * Create an authentication exception.
+ * Creates an authentication exception with a default message.
*/
public AuthenticationException() {
- // No implementation required.
+ super(ERR_AUTHENTICATION_EXCEPTION_DEFAULT.get());
}
/**
- * Create an authentication exception with a cause.
+ * Create an authentication exception with a cause and a default
+ * message.
*
* @param cause
* The cause.
*/
public AuthenticationException(Throwable cause) {
- super(cause);
+ super(ERR_AUTHENTICATION_EXCEPTION_DEFAULT.get(), cause);
}
diff --git a/opends/src/server/org/opends/server/admin/client/AuthenticationNotSupportedException.java b/opends/src/server/org/opends/server/admin/client/AuthenticationNotSupportedException.java
index 3907ddb..06d7f3a 100644
--- a/opends/src/server/org/opends/server/admin/client/AuthenticationNotSupportedException.java
+++ b/opends/src/server/org/opends/server/admin/client/AuthenticationNotSupportedException.java
@@ -26,10 +26,14 @@
*/
package org.opends.server.admin.client;
-import org.opends.messages.Message;
+import static org.opends.messages.AdminMessages.*;
+
+import org.opends.messages.Message;
+
+
/**
* This exception is thrown when the particular flavor of
@@ -46,22 +50,24 @@
/**
- * Create an authentication not supported exception.
+ * Creates an authentication not supported exception with a default
+ * message.
*/
public AuthenticationNotSupportedException() {
- // No implementation required.
+ super(ERR_AUTHENTICATION_NOT_SUPPORTED_EXCEPTION_DEFAULT.get());
}
/**
- * Create an authentication not supported exception with a cause.
+ * Creates an authentication not supported exception with a cause
+ * and a default message.
*
* @param cause
* The cause.
*/
public AuthenticationNotSupportedException(Throwable cause) {
- super(cause);
+ super(ERR_AUTHENTICATION_NOT_SUPPORTED_EXCEPTION_DEFAULT.get(), cause);
}
diff --git a/opends/src/server/org/opends/server/admin/client/AuthorizationException.java b/opends/src/server/org/opends/server/admin/client/AuthorizationException.java
index 81e21b7..9855609 100644
--- a/opends/src/server/org/opends/server/admin/client/AuthorizationException.java
+++ b/opends/src/server/org/opends/server/admin/client/AuthorizationException.java
@@ -26,10 +26,14 @@
*/
package org.opends.server.admin.client;
-import org.opends.messages.Message;
+import static org.opends.messages.AdminMessages.*;
+
+import org.opends.messages.Message;
+
+
/**
* This exception is thrown when an authorization error occurs while
@@ -47,22 +51,23 @@
/**
- * Create an authorization exception.
+ * Create an authorization exception with a default message.
*/
public AuthorizationException() {
- // No implementation required.
+ super(ERR_AUTHORIZATION_EXCEPTION_DEFAULT.get());
}
/**
- * Create an authorization exception with a cause.
+ * Create an authorization exception with a cause and a default
+ * message.
*
* @param cause
* The cause.
*/
public AuthorizationException(Throwable cause) {
- super(cause);
+ super(ERR_AUTHORIZATION_EXCEPTION_DEFAULT.get(), cause);
}
diff --git a/opends/src/server/org/opends/server/admin/client/CommunicationException.java b/opends/src/server/org/opends/server/admin/client/CommunicationException.java
index 2bcfaec..01564a6 100644
--- a/opends/src/server/org/opends/server/admin/client/CommunicationException.java
+++ b/opends/src/server/org/opends/server/admin/client/CommunicationException.java
@@ -26,10 +26,14 @@
*/
package org.opends.server.admin.client;
-import org.opends.messages.Message;
+import static org.opends.messages.AdminMessages.*;
+
+import org.opends.messages.Message;
+
+
/**
* This exception is thrown when a communications related problem
@@ -48,22 +52,23 @@
/**
- * Create a communication exception.
+ * Create a communication exception with a default message.
*/
public CommunicationException() {
- // No implementation required.
+ super(ERR_COMMUNICATION_EXCEPTION_DEFAULT.get());
}
/**
- * Create a communication exception with a cause.
+ * Create a communication exception with a cause and a default
+ * message.
*
* @param cause
* The cause.
*/
public CommunicationException(Throwable cause) {
- super(cause);
+ super(ERR_COMMUNICATION_EXCEPTION_DEFAULT.get(), cause);
}
diff --git a/opends/src/server/org/opends/server/admin/client/ConcurrentModificationException.java b/opends/src/server/org/opends/server/admin/client/ConcurrentModificationException.java
index 0c7f95c..b36cd53 100644
--- a/opends/src/server/org/opends/server/admin/client/ConcurrentModificationException.java
+++ b/opends/src/server/org/opends/server/admin/client/ConcurrentModificationException.java
@@ -26,10 +26,12 @@
*/
package org.opends.server.admin.client;
+
+
+
+import static org.opends.messages.AdminMessages.*;
+
import org.opends.messages.Message;
-
-
-
import org.opends.server.admin.OperationsException;
@@ -49,22 +51,24 @@
/**
- * Create a concurrent modification exception.
+ * Create a concurrent modification exception with a default
+ * message.
*/
public ConcurrentModificationException() {
- // No implementation required.
+ super(ERR_CONCURRENT_MODIFICATION_EXCEPTION_DEFAULT.get());
}
/**
- * Create a concurrent modification exception with a cause.
+ * Create a concurrent modification exception with a cause and a
+ * default message.
*
* @param cause
* The cause.
*/
public ConcurrentModificationException(Throwable cause) {
- super(cause);
+ super(ERR_CONCURRENT_MODIFICATION_EXCEPTION_DEFAULT.get(), cause);
}
diff --git a/opends/src/server/org/opends/server/admin/client/IllegalManagedObjectNameException.java b/opends/src/server/org/opends/server/admin/client/IllegalManagedObjectNameException.java
index f9d7066..8731a28 100644
--- a/opends/src/server/org/opends/server/admin/client/IllegalManagedObjectNameException.java
+++ b/opends/src/server/org/opends/server/admin/client/IllegalManagedObjectNameException.java
@@ -26,10 +26,12 @@
*/
package org.opends.server.admin.client;
+
+
+
+import static org.opends.messages.AdminMessages.*;
+
import org.opends.messages.Message;
-
-
-
import org.opends.server.admin.IllegalPropertyValueStringException;
import org.opends.server.admin.OperationsException;
import org.opends.server.admin.PropertyDefinition;
@@ -53,6 +55,30 @@
*/
private static final long serialVersionUID = 7491748228684293291L;
+
+
+ // Create the message
+ private static Message createMessage(String illegalName,
+ PropertyDefinition<?> namingPropertyDefinition) {
+ if (illegalName.length() == 0) {
+ return ERR_ILLEGAL_MANAGED_OBJECT_NAME_EXCEPTION_EMPTY.get();
+ } else if (illegalName.trim().length() == 0) {
+ return ERR_ILLEGAL_MANAGED_OBJECT_NAME_EXCEPTION_BLANK.get();
+ } else if (namingPropertyDefinition != null) {
+ try {
+ namingPropertyDefinition.decodeValue(illegalName);
+ } catch (IllegalPropertyValueStringException e) {
+ PropertyDefinitionUsageBuilder builder =
+ new PropertyDefinitionUsageBuilder(true);
+ return ERR_ILLEGAL_MANAGED_OBJECT_NAME_EXCEPTION_SYNTAX.get(
+ illegalName, namingPropertyDefinition.getName(), builder
+ .getUsage(namingPropertyDefinition));
+ }
+ }
+
+ return ERR_ILLEGAL_MANAGED_OBJECT_NAME_EXCEPTION_OTHER.get(illegalName);
+ }
+
// The illegal name.
private final String illegalName;
@@ -85,6 +111,8 @@
*/
public IllegalManagedObjectNameException(String illegalName,
PropertyDefinition<?> namingPropertyDefinition) {
+ super(createMessage(illegalName, namingPropertyDefinition));
+
this.illegalName = illegalName;
this.namingPropertyDefinition = namingPropertyDefinition;
}
@@ -112,34 +140,4 @@
return namingPropertyDefinition;
}
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Message getMessageObject() {
- if (illegalName.length() == 0) {
- return Message.raw("Empty managed object names are not permitted");
- } else if (illegalName.trim().length() == 0) {
- return Message.raw("Blank managed object names are not permitted");
- } else if (namingPropertyDefinition != null) {
- try {
- namingPropertyDefinition.decodeValue(illegalName);
- } catch (IllegalPropertyValueStringException e) {
- String msg = "The managed object name \"%s\" is not a valid value "
- + "for the naming property \"%s\", which must have the following "
- + "syntax: %s";
- PropertyDefinitionUsageBuilder builder =
- new PropertyDefinitionUsageBuilder(true);
- return Message.raw(String.format(msg, illegalName,
- namingPropertyDefinition.getName(),
- builder.getUsage(namingPropertyDefinition)));
- }
- }
-
- return Message.raw("The managed object name \"" + illegalName +
- "\" is not permitted");
- }
-
}
diff --git a/opends/src/server/org/opends/server/admin/client/ManagedObjectDecodingException.java b/opends/src/server/org/opends/server/admin/client/ManagedObjectDecodingException.java
index d4fd0c1..84eff55 100644
--- a/opends/src/server/org/opends/server/admin/client/ManagedObjectDecodingException.java
+++ b/opends/src/server/org/opends/server/admin/client/ManagedObjectDecodingException.java
@@ -26,22 +26,28 @@
*/
package org.opends.server.admin.client;
+
+
+
+import static org.opends.messages.AdminMessages.*;
+
import org.opends.messages.Message;
-
-
+import org.opends.messages.MessageBuilder;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import org.opends.server.admin.DecodingException;
+import org.opends.server.admin.ManagedObjectDefinition;
import org.opends.server.admin.PropertyException;
+import org.opends.server.util.Validator;
/**
- * The requested managed object was found but one or more of its properties
- * could not be decoded successfully.
+ * The requested managed object was found but one or more of its
+ * properties could not be decoded successfully.
*/
public class ManagedObjectDecodingException extends DecodingException {
@@ -50,26 +56,59 @@
*/
private static final long serialVersionUID = -4268510652395945357L;
- // The partially created managed object.
- private final ManagedObject<?> partialManagedObject;
+
+
+ // Create the message.
+ private static Message createMessage(ManagedObject<?> partialManagedObject,
+ Collection<PropertyException> causes) {
+ Validator.ensureNotNull(causes);
+ Validator.ensureTrue(!causes.isEmpty());
+
+ ManagedObjectDefinition<?, ?> d = partialManagedObject
+ .getManagedObjectDefinition();
+ if (causes.size() == 1) {
+ return ERR_MANAGED_OBJECT_DECODING_EXCEPTION_SINGLE.get(d
+ .getUserFriendlyName(), causes.iterator().next().getMessageObject());
+ } else {
+ MessageBuilder builder = new MessageBuilder();
+
+ boolean isFirst = true;
+ for (PropertyException cause : causes) {
+ if (!isFirst) {
+ builder.append("; ");
+ }
+ builder.append(cause.getMessageObject());
+ isFirst = false;
+ }
+
+ return ERR_MANAGED_OBJECT_DECODING_EXCEPTION_PLURAL.get(d
+ .getUserFriendlyName(), builder.toMessage());
+ }
+ }
// The exception(s) that caused this decoding exception.
private final Collection<PropertyException> causes;
+ // The partially created managed object.
+ private final ManagedObject<?> partialManagedObject;
+
/**
* Create a new property decoding exception.
*
* @param partialManagedObject
- * The partially created managed object containing properties which
- * were successfully decoded and empty properties for those which
- * were not (this may include empty mandatory properties).
+ * The partially created managed object containing
+ * properties which were successfully decoded and empty
+ * properties for those which were not (this may include
+ * empty mandatory properties).
* @param causes
* The exception(s) that caused this decoding exception.
*/
public ManagedObjectDecodingException(ManagedObject<?> partialManagedObject,
Collection<PropertyException> causes) {
+ super(createMessage(partialManagedObject, causes));
+
this.partialManagedObject = partialManagedObject;
this.causes = Collections
.unmodifiableList(new LinkedList<PropertyException>(causes));
@@ -78,10 +117,11 @@
/**
- * Get an unmodifiable collection view of the causes of this exception.
+ * Get an unmodifiable collection view of the causes of this
+ * exception.
*
- * @return Returns an unmodifiable collection view of the causes of this
- * exception.
+ * @return Returns an unmodifiable collection view of the causes of
+ * this exception.
*/
public Collection<PropertyException> getCauses() {
return causes;
@@ -90,28 +130,14 @@
/**
- * {@inheritDoc}
- */
- @Override
- public Message getMessageObject() {
- StringBuilder builder = new StringBuilder();
- builder.append("The managed object could not be decoded due"
- + " to the following property exceptions: ");
- // FIXME: better formatting.
- builder.append(causes.toString());
- return Message.raw(builder.toString()); // TODO: i18n?
- }
-
-
-
- /**
- * Get the partially created managed object containing properties which were
- * successfully decoded and empty properties for those which were not (this
- * may include empty mandatory properties).
+ * Get the partially created managed object containing properties
+ * which were successfully decoded and empty properties for those
+ * which were not (this may include empty mandatory properties).
*
- * @return Returns the partially created managed object containing properties
- * which were successfully decoded and empty properties for those
- * which were not (this may include empty mandatory properties).
+ * @return Returns the partially created managed object containing
+ * properties which were successfully decoded and empty
+ * properties for those which were not (this may include
+ * empty mandatory properties).
*/
public ManagedObject<?> getPartialManagedObject() {
return partialManagedObject;
diff --git a/opends/src/server/org/opends/server/admin/client/MissingMandatoryPropertiesException.java b/opends/src/server/org/opends/server/admin/client/MissingMandatoryPropertiesException.java
index 3ad6c90..288630e 100644
--- a/opends/src/server/org/opends/server/admin/client/MissingMandatoryPropertiesException.java
+++ b/opends/src/server/org/opends/server/admin/client/MissingMandatoryPropertiesException.java
@@ -26,14 +26,17 @@
*/
package org.opends.server.admin.client;
-import org.opends.messages.Message;
+import static org.opends.messages.AdminMessages.*;
+
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import org.opends.messages.Message;
+import org.opends.messages.MessageBuilder;
import org.opends.server.admin.OperationsException;
import org.opends.server.admin.PropertyIsMandatoryException;
import org.opends.server.util.Validator;
@@ -52,6 +55,34 @@
*/
private static final long serialVersionUID = 6342522125252055588L;
+
+
+ // Create the message.
+ private static Message createMessage(
+ Collection<PropertyIsMandatoryException> causes) {
+ Validator.ensureNotNull(causes);
+ Validator.ensureTrue(!causes.isEmpty());
+
+ if (causes.size() == 1) {
+ return ERR_MISSING_MANDATORY_PROPERTIES_EXCEPTION_SINGLE.get(causes
+ .iterator().next().getPropertyDefinition().getName());
+ } else {
+ MessageBuilder builder = new MessageBuilder();
+
+ boolean isFirst = true;
+ for (PropertyIsMandatoryException cause : causes) {
+ if (!isFirst) {
+ builder.append(", ");
+ }
+ builder.append(cause.getPropertyDefinition().getName());
+ isFirst = false;
+ }
+
+ return ERR_MISSING_MANDATORY_PROPERTIES_EXCEPTION_PLURAL.get(builder
+ .toMessage());
+ }
+ }
+
// The causes of this exception.
private final Collection<PropertyIsMandatoryException> causes;
@@ -67,8 +98,7 @@
*/
public MissingMandatoryPropertiesException(
Collection<PropertyIsMandatoryException> causes) {
- Validator.ensureNotNull(causes);
- Validator.ensureTrue(!causes.isEmpty());
+ super(createMessage(causes));
this.causes = new ArrayList<PropertyIsMandatoryException>(causes);
}
@@ -98,24 +128,4 @@
return Collections.unmodifiableCollection(causes);
}
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Message getMessageObject() {
- StringBuilder builder = new StringBuilder();
- builder.append("The following properties are mandatory: ");
- boolean isFirst = true;
- for (PropertyIsMandatoryException e : causes) {
- if (!isFirst) {
- builder.append(", ");
- }
- builder.append(e.getPropertyDefinition().getName());
- isFirst = false;
- }
- return Message.raw(builder.toString());
- }
-
}
diff --git a/opends/src/server/org/opends/server/admin/client/OperationRejectedException.java b/opends/src/server/org/opends/server/admin/client/OperationRejectedException.java
index a2736f0..8f2d81c 100644
--- a/opends/src/server/org/opends/server/admin/client/OperationRejectedException.java
+++ b/opends/src/server/org/opends/server/admin/client/OperationRejectedException.java
@@ -68,18 +68,23 @@
Validator.ensureNotNull(messages);
Validator.ensureTrue(!messages.isEmpty());
- MessageBuilder builder = new MessageBuilder();
+ if (messages.size() == 1) {
+ return ERR_OPERATION_REJECTED_EXCEPTION_SINGLE.get(messages.iterator()
+ .next());
+ } else {
+ MessageBuilder builder = new MessageBuilder();
- boolean isFirst = true;
- for (Message m : messages) {
- if (!isFirst) {
- builder.append("; ");
+ boolean isFirst = true;
+ for (Message m : messages) {
+ if (!isFirst) {
+ builder.append("; ");
+ }
+ builder.append(m);
+ isFirst = false;
}
- builder.append(m);
- isFirst = false;
- }
- return builder.toMessage();
+ return ERR_OPERATION_REJECTED_EXCEPTION_PLURAL.get(builder.toMessage());
+ }
}
// The messages describing the constraint violations that occurred.
@@ -110,8 +115,7 @@
*
* @param message
* The message describing the constraint violation that
- * occurred (must be non-<code>null</code> and
- * non-empty).
+ * occurred.
*/
public OperationRejectedException(Message message) {
this(Collections.singleton(message));
diff --git a/opends/src/server/org/opends/server/admin/client/ldap/LDAPDriver.java b/opends/src/server/org/opends/server/admin/client/ldap/LDAPDriver.java
index a76fd7d..92f3c06 100644
--- a/opends/src/server/org/opends/server/admin/client/ldap/LDAPDriver.java
+++ b/opends/src/server/org/opends/server/admin/client/ldap/LDAPDriver.java
@@ -530,7 +530,7 @@
if (oc == null) {
// No object classes.
- throw new DefinitionDecodingException(Reason.NO_TYPE_INFORMATION);
+ throw new DefinitionDecodingException(d, Reason.NO_TYPE_INFORMATION);
}
final Set<String> objectClasses = new HashSet<String>();
@@ -544,7 +544,7 @@
if (objectClasses.isEmpty()) {
// No object classes.
- throw new DefinitionDecodingException(Reason.NO_TYPE_INFORMATION);
+ throw new DefinitionDecodingException(d, Reason.NO_TYPE_INFORMATION);
}
// Resolve the appropriate sub-type based on the object classes.
diff --git a/opends/src/server/org/opends/server/admin/client/spi/Driver.java b/opends/src/server/org/opends/server/admin/client/spi/Driver.java
index 9f5de09..c39601d 100644
--- a/opends/src/server/org/opends/server/admin/client/spi/Driver.java
+++ b/opends/src/server/org/opends/server/admin/client/spi/Driver.java
@@ -221,8 +221,9 @@
AbstractManagedObjectDefinition<?, ?> supr = target
.getManagedObjectDefinition();
if (!supr.isParentOf(d)) {
- throw new DefaultBehaviorException(nextProperty,
- new DefinitionDecodingException(Reason.WRONG_TYPE_INFORMATION));
+ throw new DefaultBehaviorException(
+ nextProperty, new DefinitionDecodingException(supr,
+ Reason.WRONG_TYPE_INFORMATION));
}
// Save the current property in case of recursion.
diff --git a/opends/src/server/org/opends/server/admin/server/ServerManagedObject.java b/opends/src/server/org/opends/server/admin/server/ServerManagedObject.java
index abe58cc..c453cbe 100644
--- a/opends/src/server/org/opends/server/admin/server/ServerManagedObject.java
+++ b/opends/src/server/org/opends/server/admin/server/ServerManagedObject.java
@@ -264,8 +264,9 @@
AbstractManagedObjectDefinition<?, ?> supr = target
.getManagedObjectDefinition();
if (!supr.isParentOf(d)) {
- throw new DefaultBehaviorException(nextProperty,
- new DefinitionDecodingException(Reason.WRONG_TYPE_INFORMATION));
+ throw new DefaultBehaviorException(
+ nextProperty, new DefinitionDecodingException(supr,
+ Reason.WRONG_TYPE_INFORMATION));
}
// Save the current property in case of recursion.
diff --git a/opends/src/server/org/opends/server/admin/server/ServerManagedObjectDecodingException.java b/opends/src/server/org/opends/server/admin/server/ServerManagedObjectDecodingException.java
index 7736f60..cb20b36 100644
--- a/opends/src/server/org/opends/server/admin/server/ServerManagedObjectDecodingException.java
+++ b/opends/src/server/org/opends/server/admin/server/ServerManagedObjectDecodingException.java
@@ -26,22 +26,27 @@
*/
package org.opends.server.admin.server;
-import org.opends.messages.Message;
+import static org.opends.messages.AdminMessages.*;
+
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
+import org.opends.messages.Message;
+import org.opends.messages.MessageBuilder;
import org.opends.server.admin.DecodingException;
+import org.opends.server.admin.ManagedObjectDefinition;
import org.opends.server.admin.PropertyException;
+import org.opends.server.util.Validator;
/**
- * The requested server managed object was found but one or more of its
- * properties could not be decoded successfully.
+ * The requested server managed object was found but one or more of
+ * its properties could not be decoded successfully.
*/
public class ServerManagedObjectDecodingException extends DecodingException {
@@ -50,27 +55,61 @@
*/
private static final long serialVersionUID = 1598401431084729853L;
- // The partially created server managed object.
- private final ServerManagedObject<?> partialManagedObject;
+
+
+ // Create the message.
+ private static Message createMessage(
+ ServerManagedObject<?> partialManagedObject,
+ Collection<PropertyException> causes) {
+ Validator.ensureNotNull(causes);
+ Validator.ensureTrue(!causes.isEmpty());
+
+ ManagedObjectDefinition<?, ?> d = partialManagedObject
+ .getManagedObjectDefinition();
+ if (causes.size() == 1) {
+ return ERR_MANAGED_OBJECT_DECODING_EXCEPTION_SINGLE.get(d
+ .getUserFriendlyName(), causes.iterator().next().getMessageObject());
+ } else {
+ MessageBuilder builder = new MessageBuilder();
+
+ boolean isFirst = true;
+ for (PropertyException cause : causes) {
+ if (!isFirst) {
+ builder.append("; ");
+ }
+ builder.append(cause.getMessageObject());
+ isFirst = false;
+ }
+
+ return ERR_MANAGED_OBJECT_DECODING_EXCEPTION_PLURAL.get(d
+ .getUserFriendlyName(), builder.toMessage());
+ }
+ }
// The exception(s) that caused this decoding exception.
private final Collection<PropertyException> causes;
+ // The partially created server managed object.
+ private final ServerManagedObject<?> partialManagedObject;
+
/**
* Create a new property decoding exception.
*
* @param partialManagedObject
- * The partially created server managed object containing properties
- * which were successfully decoded and empty properties for those
- * which were not (this may include empty mandatory properties).
+ * The partially created server managed object containing
+ * properties which were successfully decoded and empty
+ * properties for those which were not (this may include
+ * empty mandatory properties).
* @param causes
* The exception(s) that caused this decoding exception.
*/
public ServerManagedObjectDecodingException(
ServerManagedObject<?> partialManagedObject,
Collection<PropertyException> causes) {
+ super(createMessage(partialManagedObject, causes));
+
this.partialManagedObject = partialManagedObject;
this.causes = Collections
.unmodifiableList(new LinkedList<PropertyException>(causes));
@@ -79,10 +118,11 @@
/**
- * Get an unmodifiable collection view of the causes of this exception.
+ * Get an unmodifiable collection view of the causes of this
+ * exception.
*
- * @return Returns an unmodifiable collection view of the causes of this
- * exception.
+ * @return Returns an unmodifiable collection view of the causes of
+ * this exception.
*/
public Collection<PropertyException> getCauses() {
return causes;
@@ -91,28 +131,15 @@
/**
- * {@inheritDoc}
- */
- @Override
- public Message getMessageObject() {
- StringBuilder builder = new StringBuilder();
- builder.append("The managed object could not be decoded due"
- + " to the following property exceptions: ");
- // FIXME: better formatting.
- builder.append(causes.toString());
- return Message.raw(builder.toString()); // TODO: i18n?
- }
-
-
-
- /**
- * Get the partially created server managed object containing properties which
- * were successfully decoded and empty properties for those which were not
- * (this may include empty mandatory properties).
+ * Get the partially created server managed object containing
+ * properties which were successfully decoded and empty properties
+ * for those which were not (this may include empty mandatory
+ * properties).
*
- * @return Returns the partially created server managed object containing
- * properties which were successfully decoded and empty properties for
- * those which were not (this may include empty mandatory properties).
+ * @return Returns the partially created server managed object
+ * containing properties which were successfully decoded and
+ * empty properties for those which were not (this may
+ * include empty mandatory properties).
*/
public ServerManagedObject<?> getPartialManagedObject() {
return partialManagedObject;
--
Gitblit v1.10.0