From e451ab682bef06d6435c67e80b3a3be8adf7db2f Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Wed, 26 Sep 2007 20:05:48 +0000
Subject: [PATCH] Fix for issue 2354 (dsreplication CLI : parallel runs should raise more explicit error information). The messages have been updated with a reference to the log file and a String representation of the exception that caused the error.

---
 opendj-sdk/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliMain.java |   47 +++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/opendj-sdk/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliMain.java b/opendj-sdk/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliMain.java
index 6b93164..7cb75ee 100644
--- a/opendj-sdk/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliMain.java
+++ b/opendj-sdk/opends/src/guitools/org/opends/guitools/replicationcli/ReplicationCliMain.java
@@ -2449,7 +2449,7 @@
         {
           returnValue = rce.getErrorCode();
           printLineBreak();
-          printErrorMessage(rce.getMessageObject());
+          printErrorMessage(getCriticalExceptionMessage(rce));
           LOG.log(Level.SEVERE, "Complete error stack:", rce);
         }
       }
@@ -2542,7 +2542,7 @@
         {
           returnValue = rce.getErrorCode();
           printLineBreak();
-          printErrorMessage(rce.getMessageObject());
+          printErrorMessage(getCriticalExceptionMessage(rce));
           LOG.log(Level.SEVERE, "Complete error stack:", rce);
         }
       }
@@ -2610,7 +2610,7 @@
       {
         returnValue = rce.getErrorCode();
         printLineBreak();
-        printErrorMessage(rce.getMessageObject());
+        printErrorMessage(getCriticalExceptionMessage(rce));
         LOG.log(Level.SEVERE, "Complete error stack:", rce);
       }
     }
@@ -2701,7 +2701,7 @@
           catch (ReplicationCliException rce)
           {
             printLineBreak();
-            printErrorMessage(rce.getMessageObject());
+            printErrorMessage(getCriticalExceptionMessage(rce));
             returnValue = rce.getErrorCode();
             LOG.log(Level.SEVERE, "Complete error stack:", rce);
           }
@@ -5161,4 +5161,43 @@
     }
     return c1;
   }
+
+  /**
+   * Returns the message that must be displayed to the user for a given
+   * exception.  This is assumed to be a critical exception that stops all
+   * the processing.
+   * @param rce the ReplicationCliException.
+   * @return a message to be displayed to the user.
+   */
+  private Message getCriticalExceptionMessage(ReplicationCliException rce)
+  {
+    MessageBuilder mb = new MessageBuilder();
+    mb.append(rce.getMessageObject());
+    File logFile = QuickSetupLog.getLogFile();
+    if (logFile != null)
+    {
+      mb.append(Constants.LINE_SEPARATOR);
+      mb.append(INFO_GENERAL_SEE_FOR_DETAILS.get(logFile.getPath()));
+    }
+    // Check if the cause has already been included in the message
+    Throwable c = rce.getCause();
+    if (c != null)
+    {
+      String s;
+      if (c instanceof NamingException)
+      {
+        s = ((NamingException)c).toString(true);
+      }
+      else
+      {
+        s = c.toString();
+      }
+      if (mb.toString().indexOf(s) == -1)
+      {
+        mb.append(Constants.LINE_SEPARATOR);
+        mb.append(INFO_REPLICATION_CRITICAL_ERROR_DETAILS.get(s));
+      }
+    }
+    return mb.toMessage();
+  }
 }

--
Gitblit v1.10.0