From 39be274a446bc48400fb0f4ff8ec74b54883f7a6 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Wed, 12 Feb 2014 10:55:00 +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/EncodePassword.java |   28 ++++++++++++----------------
 1 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/EncodePassword.java b/opendj3-server-dev/src/server/org/opends/server/tools/EncodePassword.java
index 3e1f0b7..721238b 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/EncodePassword.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/EncodePassword.java
@@ -52,12 +52,13 @@
 import org.opends.server.core.PasswordStorageSchemeConfigManager;
 import org.opends.server.crypto.CryptoManagerSync;
 import org.opends.server.extensions.ConfigFileHandler;
-import org.forgerock.i18n.slf4j.LocalizedLogger;
+import org.opends.server.loggers.JDKLogging;
 import org.opends.server.schema.AuthPasswordSyntax;
 import org.opends.server.schema.UserPasswordSyntax;
 import org.opends.server.types.*;
 import org.forgerock.opendj.ldap.ByteString;
 import org.opends.server.util.BuildVersion;
+
 import com.forgerock.opendj.cli.ArgumentException;
 import com.forgerock.opendj.cli.ArgumentParser;
 import com.forgerock.opendj.cli.BooleanArgument;
@@ -81,9 +82,6 @@
  */
 public class EncodePassword
 {
-  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
-
-
   /**
    * Processes the command-line arguments and performs the requested action.
    *
@@ -135,6 +133,7 @@
   {
     PrintStream out = NullOutputStream.wrapOrNullStream(outStream);
     PrintStream err = NullOutputStream.wrapOrNullStream(errStream);
+    JDKLogging.disableLogging();
 
     // Define the command-line arguments that may be used with this program.
     BooleanArgument   authPasswordSyntax   = null;
@@ -798,8 +797,6 @@
     return SUCCESS;
   }
 
-
-
   private static LocalizableMessage getOutputMessage(boolean passwordMatches)
   {
     if (passwordMatches)
@@ -851,7 +848,7 @@
           HashSet<PluginType> pluginTypes = new HashSet<PluginType>(1);
           directoryServer.initializePlugins(pluginTypes);
           //Initialize Trust Backend.
-          initializeServerBackends(directoryServer);
+          initializeServerBackends(directoryServer, err);
           // Initialize the subentry manager.
           directoryServer.initializeSubentryManager();
           //Initialize PWD policy components.
@@ -872,7 +869,7 @@
     return true;
   }
 
-  private static void initializeServerBackends(DirectoryServer directoryServer)
+  private static void initializeServerBackends(DirectoryServer directoryServer, PrintStream err)
   throws InitializationException, ConfigException {
     directoryServer.initializeRootDSE();
     ServerManagementContext context = ServerManagementContext.getInstance();
@@ -882,7 +879,6 @@
       DN configEntryDN = DN.valueOf(ConfigConstants.DN_BACKEND_BASE);
       backendRoot   = DirectoryServer.getConfigEntry(configEntryDN);
     } catch (Exception e) {
-      logger.traceException(e);
       LocalizableMessage message = ERR_CONFIG_BACKEND_CANNOT_GET_CONFIG_BASE.get(
           getExceptionMessage(e));
       throw new ConfigException(message, e);
@@ -904,9 +900,9 @@
             backendClass = DirectoryServer.loadClass(className);
             backend = (Backend) backendClass.newInstance();
           } catch (Exception e) {
-            logger.traceException(e);
-            logger.error(ERR_CONFIG_BACKEND_CANNOT_INSTANTIATE, className, backendCfg.dn(),
-                  stackTraceToSingleLineString(e));
+            LocalizableMessage msg = ERR_CONFIG_BACKEND_CANNOT_INSTANTIATE.get(className, backendCfg.dn(),
+                stackTraceToSingleLineString(e));
+            err.println(wrapText(msg, MAX_LINE_WIDTH));
             continue;
           }
           backend.setBackendID(backendID);
@@ -915,17 +911,17 @@
             backend.configureBackend(backendCfg);
             backend.initializeBackend();
           } catch (Exception e) {
-            logger.traceException(e);
-            logger.error(ERR_CONFIG_BACKEND_CANNOT_INITIALIZE, className, backendCfg.dn(),
+            LocalizableMessage msg = ERR_CONFIG_BACKEND_CANNOT_INITIALIZE.get(className, backendCfg.dn(),
                   stackTraceToSingleLineString(e));
+            err.println(wrapText(msg, MAX_LINE_WIDTH));
           }
           try {
             DirectoryServer.registerBackend(backend);
           } catch (Exception e)
           {
-            logger.traceException(e);
-            logger.warn(WARN_CONFIG_BACKEND_CANNOT_REGISTER_BACKEND, backendCfg.getBackendId(),
+            LocalizableMessage msg = WARN_CONFIG_BACKEND_CANNOT_REGISTER_BACKEND.get(backendCfg.getBackendId(),
                   getExceptionMessage(e));
+            err.println(wrapText(msg, MAX_LINE_WIDTH));
           }
         }
       }

--
Gitblit v1.10.0