From c8c1aceb026a3a793c01d6b7562bc8cb9e1ca139 Mon Sep 17 00:00:00 2001
From: neil_a_wilson <neil_a_wilson@localhost>
Date: Thu, 03 Aug 2006 23:41:12 +0000
Subject: [PATCH] Add a new set of methods to the Operation class that make it possible for operations to provide information that will be available to the logger but that should not be sent back to the client for some reason.

---
 opends/src/server/org/opends/server/core/Operation.java |   88 +++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 82 insertions(+), 6 deletions(-)

diff --git a/opends/src/server/org/opends/server/core/Operation.java b/opends/src/server/org/opends/server/core/Operation.java
index d9da440..baf1b94 100644
--- a/opends/src/server/org/opends/server/core/Operation.java
+++ b/opends/src/server/org/opends/server/core/Operation.java
@@ -121,7 +121,12 @@
   // The result code for this operation.
   private ResultCode resultCode;
 
-  // The error message for this operation.
+  // Additional information that should be included in the log but not sent to
+  // the client.
+  private StringBuilder additionalLogMessage;
+
+  // The error message for this operation that should be included in the log and
+  // in the response to the client.
   private StringBuilder errorMessage;
 
 
@@ -150,6 +155,7 @@
     this.requestControls  = requestControls;
 
     resultCode                 = ResultCode.UNDEFINED;
+    additionalLogMessage       = new StringBuilder();
     errorMessage               = new StringBuilder();
     attachments                = new HashMap<String,Object>();
     matchedDN                  = null;
@@ -342,11 +348,10 @@
 
 
   /**
-   * Retrieves the error message for this operation.  If it is non-null, then
-   * its contents may be altered by the caller.
+   * Retrieves the error message for this operation.  Its contents may be
+   * altered by the caller.
    *
-   * @return  The error message for this operation, or <CODE>null</CODE> if the
-   *          operation has not yet completed or does not have an error message.
+   * @return  The error message for this operation.
    */
   public StringBuilder getErrorMessage()
   {
@@ -367,7 +372,14 @@
     assert debugEnter(CLASS_NAME, "setErrorMessage",
                       String.valueOf(errorMessage));
 
-    this.errorMessage = errorMessage;
+    if (errorMessage == null)
+    {
+      this.errorMessage = new StringBuilder();
+    }
+    else
+    {
+      this.errorMessage = errorMessage;
+    }
   }
 
 
@@ -402,6 +414,70 @@
 
 
   /**
+   * Retrieves the additional log message for this operation, which should be
+   * written to the log but not included in the response to the client.  The
+   * contents of this buffer may be altered by the caller.
+   *
+   * @return  The additional log message for this operation.
+   */
+  public StringBuilder getAdditionalLogMessage()
+  {
+    assert debugEnter(CLASS_NAME, "getAdditionalLogMessage");
+
+    return additionalLogMessage;
+  }
+
+
+
+  /**
+   * Specifies the additional log message for this operation, which should be
+   * written to the log but not included in the response to the client.
+   *
+   * @param  additionalLogMessage  The additional log message for this
+   *                               operation.
+   */
+  public void setAdditionalLogMessage(StringBuilder additionalLogMessage)
+  {
+    assert debugEnter(CLASS_NAME, "setAdditionalLogMessage",
+                      String.valueOf(additionalLogMessage));
+
+    if (additionalLogMessage == null)
+    {
+      this.additionalLogMessage = new StringBuilder();
+    }
+    else
+    {
+      this.additionalLogMessage = additionalLogMessage;
+    }
+  }
+
+
+
+  /**
+   * Appends the provided message to the additional log information for this
+   * operation.
+   *
+   * @param  message  The message that should be appended to the additional log
+   *                  information for this operation.
+   */
+  public void appendAdditionalLogMessage(String message)
+  {
+    assert debugEnter(CLASS_NAME, "appendAdditionalLogMessage",
+                      String.valueOf(message));
+
+    if (additionalLogMessage == null)
+    {
+      additionalLogMessage = new StringBuilder(message);
+    }
+    else
+    {
+      additionalLogMessage.append(message);
+    }
+  }
+
+
+
+  /**
    * Retrieves the matched DN for this operation.
    *
    * @return  The matched DN for this operation, or <CODE>null</CODE> if the

--
Gitblit v1.10.0