From 3eca18748064ed39f967201ecfa07cb58907fd90 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Sat, 18 Jan 2014 01:12:08 +0000
Subject: [PATCH] Simplify config framework exception hierarchy by removing AdminRuntimeException + additional minor cleanup.

---
 opendj-config/src/main/java/org/forgerock/opendj/config/PropertyException.java |   33 +++++++++++++++++++++++----------
 1 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/opendj-config/src/main/java/org/forgerock/opendj/config/PropertyException.java b/opendj-config/src/main/java/org/forgerock/opendj/config/PropertyException.java
index 59ce8cf..9eb6966 100644
--- a/opendj-config/src/main/java/org/forgerock/opendj/config/PropertyException.java
+++ b/opendj-config/src/main/java/org/forgerock/opendj/config/PropertyException.java
@@ -33,13 +33,14 @@
 import static com.forgerock.opendj.ldap.AdminMessages.ERR_PROPERTY_IS_SINGLE_VALUED_EXCEPTION;
 import static com.forgerock.opendj.ldap.AdminMessages.ERR_UNKNOWN_PROPERTY_DEFINITION_EXCEPTION;
 
+import org.forgerock.i18n.LocalizableException;
 import org.forgerock.i18n.LocalizableMessage;
 
 /**
  * Exceptions thrown as a result of errors that occurred when decoding and
  * modifying property values.
  */
-public final class PropertyException extends AdminRuntimeException {
+public final class PropertyException extends RuntimeException implements LocalizableException {
 
     /**
      * Version ID required by serializable classes.
@@ -94,7 +95,7 @@
     }
 
     /**
-     * Create a new property is mandatory exception.
+     * Creates a new property is mandatory exception.
      *
      * @param pd
      *            The property definition.
@@ -105,7 +106,7 @@
     }
 
     /**
-     * Create a new property is read-only exception.
+     * Creates a new property is read-only exception.
      *
      * @param pd
      *            The property definition.
@@ -116,7 +117,7 @@
     }
 
     /**
-     * Create a new property is single valued exception.
+     * Creates a new property is single valued exception.
      *
      * @param pd
      *            The property definition.
@@ -149,27 +150,39 @@
                 builder.getUsage(pd));
     }
 
+    // LocalizableMessage that explains the problem.
+    private final LocalizableMessage message;
+
     // The property definition associated with the property that caused
     // the exception.
     private final PropertyDefinition<?> pd;
 
     private PropertyException(final PropertyDefinition<?> pd, final LocalizableMessage message) {
-        super(message);
+        super(message.toString());
+        this.message = message;
         this.pd = pd;
     }
 
     private PropertyException(final PropertyDefinition<?> pd, final LocalizableMessage message,
             final Throwable cause) {
-        super(message, cause);
+        super(message.toString(), cause);
+        this.message = message;
         this.pd = pd;
     }
 
     /**
-     * Get the property definition associated with the property that caused the
-     * exception.
+     * {@inheritDoc}
+     */
+    public LocalizableMessage getMessageObject() {
+        return message;
+    }
+
+    /**
+     * Returns the property definition associated with the property that caused
+     * the exception.
      *
-     * @return Returns the property definition associated with the property that
-     *         caused the exception.
+     * @return The property definition associated with the property that caused
+     *         the exception.
      */
     public final PropertyDefinition<?> getPropertyDefinition() {
         return pd;

--
Gitblit v1.10.0