From 1d5d1a6a4a0a58d6bb4803527dacb6641c027816 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Tue, 28 Jan 2014 13:34:12 +0000
Subject: [PATCH] Checkpoint commit for OPENDJ-1288 :    Migrate I18n and logging support to i18n framework and SLF4J

---
 opendj3-server-dev/src/server/org/opends/server/tools/LDAPModify.java |   83 ++++++++---------------------------------
 1 files changed, 17 insertions(+), 66 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/LDAPModify.java b/opendj3-server-dev/src/server/org/opends/server/tools/LDAPModify.java
index 05a9dd9..0c218e4 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/LDAPModify.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/LDAPModify.java
@@ -40,7 +40,7 @@
 
 import org.opends.server.controls.*;
 import org.opends.server.controls.ProxiedAuthV2Control;
-import org.opends.server.loggers.debug.DebugTracer;
+import org.forgerock.i18n.slf4j.LocalizedLogger;
 import org.opends.server.plugins.ChangeNumberControlPlugin;
 import org.opends.server.protocols.asn1.ASN1Exception;
 import org.opends.server.protocols.ldap.AddRequestProtocolOp;
@@ -76,7 +76,6 @@
 import org.opends.server.util.args.StringArgument;
 
 import static org.opends.messages.ToolMessages.*;
-import static org.opends.server.loggers.debug.DebugLogger.*;
 import static org.opends.server.protocols.ldap.LDAPResultCode.*;
 import static org.opends.server.tools.ToolConstants.*;
 import static org.opends.server.util.ServerConstants.*;
@@ -90,10 +89,7 @@
  */
 public class LDAPModify
 {
-  /**
-   * The tracer object for the debug logger.
-   */
-  private static final DebugTracer TRACER = getTracer();
+  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
 
   /**
    * The fully-qualified name of this class.
@@ -161,10 +157,7 @@
       reader = new LDIFReader(importConfig);
     } catch (Exception e)
     {
-      if (debugEnabled())
-      {
-        TRACER.debugCaught(DebugLogLevel.ERROR, e);
-      }
+      logger.traceException(e);
       LocalizableMessage message =
           ERR_LDIF_FILE_CANNOT_OPEN_FOR_READ.get(fileNameValue,
                   e.getLocalizedMessage());
@@ -186,10 +179,7 @@
         entry = reader.readChangeRecord(modifyOptions.getDefaultAdd());
       } catch (LDIFException le)
       {
-        if (debugEnabled())
-        {
-          TRACER.debugCaught(DebugLogLevel.ERROR, le);
-        }
+        logger.traceException(le);
         if (!modifyOptions.continueOnError())
         {
           try
@@ -198,10 +188,7 @@
           }
           catch (Exception e)
           {
-            if (debugEnabled())
-            {
-              TRACER.debugCaught(DebugLogLevel.ERROR, e);
-            }
+            logger.traceException(e);
           }
 
           LocalizableMessage message = ERR_LDIF_FILE_INVALID_LDIF_ENTRY.get(
@@ -217,10 +204,7 @@
         }
       } catch (Exception e)
       {
-        if (debugEnabled())
-        {
-          TRACER.debugCaught(DebugLogLevel.ERROR, e);
-        }
+        logger.traceException(e);
 
         if (!modifyOptions.continueOnError())
         {
@@ -230,10 +214,7 @@
           }
           catch (Exception e2)
           {
-            if (debugEnabled())
-            {
-              TRACER.debugCaught(DebugLogLevel.ERROR, e2);
-            }
+            logger.traceException(e2);
           }
 
           LocalizableMessage message =
@@ -258,10 +239,7 @@
         }
         catch (Exception e)
         {
-          if (debugEnabled())
-          {
-            TRACER.debugCaught(DebugLogLevel.ERROR, e);
-          }
+          logger.traceException(e);
         }
 
         break;
@@ -340,10 +318,7 @@
           responseMessage = connection.getLDAPReader().readMessage();
         } catch(ASN1Exception ae)
         {
-          if (debugEnabled())
-          {
-            TRACER.debugCaught(DebugLogLevel.ERROR, ae);
-          }
+          logger.traceException(ae);
           LocalizableMessage message = INFO_OPERATION_FAILED.get(operationType);
           err.println(wrapText(message, MAX_LINE_WIDTH));
           err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
@@ -417,10 +392,7 @@
             // This shouldnt happen but if it does debug
             // log it, set the error code to OTHER and
             // fall thru.
-            if (debugEnabled())
-            {
-              TRACER.debugCaught(DebugLogLevel.ERROR, ce);
-            }
+            logger.traceException(ce);
             resultCode = ResultCode.OTHER.getIntValue();
             errorMessage = null;
             matchedDN = null;
@@ -964,10 +936,7 @@
       portNumber = port.getIntValue();
     } catch(ArgumentException ae)
     {
-      if (debugEnabled())
-      {
-        TRACER.debugCaught(DebugLogLevel.ERROR, ae);
-      }
+      logger.traceException(ae);
       err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
       return CLIENT_SIDE_PARAM_ERROR;
     }
@@ -985,10 +954,7 @@
       connectionOptions.setVersionNumber(versionNumber);
     } catch(ArgumentException ae)
     {
-      if (debugEnabled())
-      {
-        TRACER.debugCaught(DebugLogLevel.ERROR, ae);
-      }
+      logger.traceException(ae);
       err.println(wrapText(ae.getMessage(), MAX_LINE_WIDTH));
       return CLIENT_SIDE_PARAM_ERROR;
     }
@@ -1019,10 +985,7 @@
         bindPasswordValue = new String(pwChars);
       } catch(Exception ex)
       {
-        if (debugEnabled())
-        {
-          TRACER.debugCaught(DebugLogLevel.ERROR, ex);
-        }
+        logger.traceException(ex);
         err.println(wrapText(ex.getMessage(), MAX_LINE_WIDTH));
         return CLIENT_SIDE_PARAM_ERROR;
       }
@@ -1224,10 +1187,7 @@
       ldapModify.readAndExecute(connection, fileNameValue, modifyOptions);
     } catch(LDAPException le)
     {
-      if (debugEnabled())
-      {
-        TRACER.debugCaught(DebugLogLevel.ERROR, le);
-      }
+      logger.traceException(le);
       LDAPToolUtils.printErrorMessage(err, le.getMessageObject(),
                                       le.getResultCode(),
                                       le.getErrorMessage(), le.getMatchedDN());
@@ -1235,10 +1195,7 @@
       return code;
     } catch(LDAPConnectionException lce)
     {
-      if (debugEnabled())
-      {
-        TRACER.debugCaught(DebugLogLevel.ERROR, lce);
-      }
+      logger.traceException(lce);
       LDAPToolUtils.printErrorMessage(err, lce.getMessageObject(),
                                       lce.getResultCode(),
                                       lce.getErrorMessage(),
@@ -1247,18 +1204,12 @@
       return code;
     } catch (FileNotFoundException fe)
     {
-      if (debugEnabled())
-      {
-        TRACER.debugCaught(DebugLogLevel.ERROR, fe);
-      }
+      logger.traceException(fe);
       err.println(wrapText(fe.getMessage(), MAX_LINE_WIDTH));
       return CLIENT_SIDE_PARAM_ERROR;
     } catch(Exception e)
     {
-      if (debugEnabled())
-      {
-        TRACER.debugCaught(DebugLogLevel.ERROR, e);
-      }
+      logger.traceException(e);
       err.println(wrapText(e.getMessage(), MAX_LINE_WIDTH));
       return OPERATIONS_ERROR;
     } finally

--
Gitblit v1.10.0