From 300625b855bded33c79af6570d9bcdd6f9aca7c6 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Tue, 07 Jul 2009 00:12:51 +0000
Subject: [PATCH] Improve the displayed messages when an ADSContextException occurs. i18n the messages of the ADSContextException. Make dsreplication consistent with the fix made for dsconfig (see issue 4091). Fix a bug in ADSContext when deleting the contents of the ADS. Fix a bug in the equivalent command display when the user chooses to disable all replication on a server or to disable the replication server.

---
 opendj-sdk/opends/src/ads/org/opends/admin/ads/ADSContextException.java |   61 ++++++++++++++++++++----------
 1 files changed, 41 insertions(+), 20 deletions(-)

diff --git a/opendj-sdk/opends/src/ads/org/opends/admin/ads/ADSContextException.java b/opendj-sdk/opends/src/ads/org/opends/admin/ads/ADSContextException.java
index 12226c0..b8139c6 100644
--- a/opendj-sdk/opends/src/ads/org/opends/admin/ads/ADSContextException.java
+++ b/opendj-sdk/opends/src/ads/org/opends/admin/ads/ADSContextException.java
@@ -22,11 +22,13 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2008 Sun Microsystems, Inc.
+ *      Copyright 2008-2009 Sun Microsystems, Inc.
  */
 
 package org.opends.admin.ads;
 
+import static org.opends.messages.QuickSetupMessages.*;
+
 import org.opends.messages.Message;
 import org.opends.server.types.OpenDsException;
 
@@ -120,7 +122,7 @@
    */
   public ADSContextException(ErrorType error)
   {
-    this.error = error;
+    this(error, null);
   }
 
   /**
@@ -131,8 +133,14 @@
    */
   public ADSContextException(ErrorType error, Throwable x)
   {
+    super(getMessage(error, x), x);
     this.error = error;
     this.embeddedException = x;
+    toString = "ADSContextException: error type "+error+".";
+    if (getCause() != null)
+    {
+      toString += "  Root cause: "+getCause().toString();
+    }
   }
 
   /**
@@ -154,24 +162,6 @@
   }
 
   /**
-   * Retrieves a message providing the reason for this exception.
-   *
-   * @return  A message providing the reason for this exception.
-   */
-  public Message getReason()
-  {
-    if (toString == null)
-    {
-      toString = "ADSContextException: error type "+error+".";
-      if (getCause() != null)
-      {
-        toString += "  Root cause: "+getCause().toString();
-      }
-    }
-    return Message.raw(toString); // TODO: i18n
-  }
-
-  /**
    * {@inheritDoc}
    */
   public void printStackTrace()
@@ -184,4 +174,35 @@
       System.out.println("}");
     }
   }
+
+  /**
+   * {@inheritDoc}
+   */
+  public String toString()
+  {
+    return toString;
+  }
+
+  private static Message getMessage(ErrorType error, Throwable x)
+  {
+    Message msg;
+    if (x != null)
+    {
+      if (x instanceof OpenDsException)
+      {
+        msg = INFO_ADS_CONTEXT_EXCEPTION_WITH_DETAILS_MSG.get(error.toString(),
+            ((OpenDsException)x).getMessageObject());
+      }
+      else
+      {
+        msg = INFO_ADS_CONTEXT_EXCEPTION_WITH_DETAILS_MSG.get(error.toString(),
+            x.toString());
+      }
+    }
+    else
+    {
+      msg = INFO_ADS_CONTEXT_EXCEPTION_MSG.get(error.toString());
+    }
+    return msg;
+  }
 }

--
Gitblit v1.10.0