mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Nicolas Capponi
30.38.2014 22542acc2f7a03a735ae73c49c09252068ebc86d
Checkpoint commit for OPENDJ-1288 : 
Migrate I18n and logging support to i18n framework and SLF4J

* Move classes from org.opends.server.loggers.debug
to org.opends.server.loggers
** Impact FileBasedAccessLogPublisher and
FileBasedDebugLogPublisher XML configurations
** Impact config.ldif

* Reduce visibility of classes and methods in
org.opends.server.loggers package

* Align logging method names to trace and traceException
in DebugLogPublisher classes

* Clean DebugTracer class

* Add class LoggingCategoryNames to retrieve simple
category name (eg, CORE) from class name

* Temporary removal of opendj-slf4j-adapter module
and disabling of TestBackupAndRestore tests to
avoid build failure
2 files deleted
3 files added
5 files renamed
29 files modified
1360 ■■■■ changed files
opendj3-server-dev/ivy.xml 6 ●●●● patch | view | raw | blame | history
opendj3-server-dev/resource/config/config.ldif 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/admin/defn/org/opends/server/admin/std/FileBasedAccessLogPublisherConfiguration.xml 8 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/admin/defn/org/opends/server/admin/std/FileBasedDebugLogPublisherConfiguration.xml 7 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/api/DebugLogPublisher.java 19 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java 4 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/core/LoggerConfigManager.java 4 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/AbstractLogger.java 17 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/AbstractTextAccessLogPublisher.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/AsynchronousTextWriter.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/DebugLogger.java 19 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/DebugMessageFormatter.java 10 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/DebugStackTraceFormatter.java 3 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/DebugTracer.java 328 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/EncryptAction.java 3 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/FileComparator.java 3 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/GZIPAction.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/LogFileFilter.java 3 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/LogPublisherErrorHandler.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/LoggerAlarmHandler.java 3 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/LoggingCategoryNames.java 142 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/MultifileTextWriter.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/ParallelTextWriter.java 2 ●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/PostRotationAction.java 3 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/TextDebugLogPublisher.java 44 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/TraceSettings.java 6 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/debug/DebugTracer.java 512 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/debug/package-info.java 44 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/loggers/package-info.java 5 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/BackUpDB.java 6 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/ConsoleDebugLogPublisher.java 29 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/ExportLDIF.java 11 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/LDAPConnection.java 4 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/RebuildIndex.java 7 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/RestoreDB.java 8 ●●●● patch | view | raw | blame | history
opendj3-server-dev/src/server/org/opends/server/tools/VerifyIndex.java 7 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java 2 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/loggers/LoggingCategoryNamesTest.java 76 ●●●●● patch | view | raw | blame | history
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tasks/TestBackupAndRestore.java 3 ●●●● patch | view | raw | blame | history
opendj3-server-dev/ivy.xml
@@ -51,11 +51,11 @@
    <dependency org="javax.servlet"         name="javax.servlet-api"        rev="[3.1-b02]" />
    <dependency org="com.sleepycat"         name="je"                       rev="5.0.97" />
    <dependency org="org.forgerock.opendj"  name="opendj-rest2ldap-servlet" rev="&opendj.sdk.version;" conf="default->master,compile" />
    <dependency org="org.forgerock.opendj"  name="opendj-slf4j-adapter" rev="&opendj.sdk.version;" />
    <!--  <dependency org="org.forgerock.opendj"  name="opendj-slf4j-adapter" rev="&opendj.sdk.version;" /> -->
    <dependency org="org.forgerock.commons"  name="i18n-slf4j"  rev="&i18n.version;" />
    <dependency org="org.forgerock.opendj"  name="opendj-server2x-adapter"  rev="&opendj.sdk.version;" />
    <dependency org="org.glassfish.grizzly" name="grizzly-http-servlet"     rev="&grizzly.version;">
      <exclude module="javax.servlet-api" />
    <dependency org="org.glassfish.grizzly" name="grizzly-http-servlet"     rev="&grizzly.version;">
      <exclude module="javax.servlet-api" />
    </dependency>
    <!-- Test libs -->
opendj3-server-dev/resource/config/config.ldif
@@ -800,7 +800,7 @@
objectClass: ds-cfg-debug-log-publisher
objectClass: ds-cfg-file-based-debug-log-publisher
cn: File-Based Debug Logger
ds-cfg-java-class: org.opends.server.loggers.debug.TextDebugLogPublisher
ds-cfg-java-class: org.opends.server.loggers.TextDebugLogPublisher
ds-cfg-enabled: false
ds-cfg-log-file: logs/debug
ds-cfg-log-file-permissions: 640
opendj3-server-dev/src/admin/defn/org/opends/server/admin/std/FileBasedAccessLogPublisherConfiguration.xml
@@ -23,7 +23,7 @@
  !
  !
  !      Copyright 2007-2009 Sun Microsystems, Inc.
  !      Portions copyright 2011 ForgeRock AS.
  !      Portions copyright 2011-2014 ForgeRock AS.
  ! -->
<adm:managed-object name="file-based-access-log-publisher"
  plural-name="file-based-access-log-publishers"
@@ -83,7 +83,7 @@
    <adm:requires-admin-action>
      <adm:other>
        <adm:synopsis>
          The <adm:user-friendly-name /> must be restarted if this property
          The <adm:user-friendly-name /> must be restarted if this property
          is changed and the asynchronous property is set to true.
        </adm:synopsis>
      </adm:other>
@@ -158,7 +158,7 @@
  </adm:property>
  <adm:property name="time-interval" advanced="true">
    <adm:synopsis>
      Specifies the interval at which to check whether the log files
      Specifies the interval at which to check whether the log files
      need to be rotated.
    </adm:synopsis>
    <adm:default-behavior>
@@ -332,7 +332,7 @@
        <adm:regex>.*</adm:regex>
        <adm:usage>STRING</adm:usage>
          <adm:synopsis>
            Any valid format string that can be used with the
            Any valid format string that can be used with the
            java.text.SimpleDateFormat class.
          </adm:synopsis>
        </adm:pattern>
opendj3-server-dev/src/admin/defn/org/opends/server/admin/std/FileBasedDebugLogPublisherConfiguration.xml
@@ -23,6 +23,7 @@
  !
  !
  !      Copyright 2007-2008 Sun Microsystems, Inc.
  !      Portions Copyright 2014 ForgeRock AS.
  ! -->
<adm:managed-object name="file-based-debug-log-publisher"
  plural-name="file-based-debug-log-publishers"
@@ -43,7 +44,7 @@
    <adm:default-behavior>
      <adm:defined>
        <adm:value>
          org.opends.server.loggers.debug.TextDebugLogPublisher
          org.opends.server.loggers.TextDebugLogPublisher
        </adm:value>
      </adm:defined>
    </adm:default-behavior>
@@ -139,7 +140,7 @@
  </adm:property>
  <adm:property name="time-interval" advanced="true">
    <adm:synopsis>
      Specifies the interval at which to check whether the log files
      Specifies the interval at which to check whether the log files
      need to be rotated.
    </adm:synopsis>
    <adm:default-behavior>
@@ -252,7 +253,7 @@
    <adm:default-behavior>
      <adm:alias>
        <adm:synopsis>
          No retention policy is used and log files are never
          No retention policy is used and log files are never
          cleaned.
        </adm:synopsis>
      </adm:alias>
opendj3-server-dev/src/server/org/opends/server/api/DebugLogPublisher.java
@@ -33,7 +33,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.admin.std.server.DebugLogPublisherCfg;
import org.opends.server.loggers.debug.TraceSettings;
import org.opends.server.loggers.TraceSettings;
import org.opends.server.types.DebugLogLevel;
/**
@@ -347,11 +347,8 @@
   * @param  stackTrace      The stack trace at the time the message
   *                         is logged or null if its not available.
   */
  public abstract void traceMessage(TraceSettings settings,
                                    String signature,
                                    String sourceLocation,
                                    String msg,
                                    StackTraceElement[] stackTrace);
  public abstract void trace(TraceSettings settings, String signature,
      String sourceLocation, String msg, StackTraceElement[] stackTrace);
@@ -360,15 +357,13 @@
   * @param  settings        The current trace settings in effect.
   * @param  signature       The method signature.
   * @param  sourceLocation  The location of the method in the source.
   * @param msg TODO
   * @param  msg             The message to be logged.
   * @param  ex              The exception that was caught.
   * @param  stackTrace      The stack trace at the time the exception
   *                         is caught or null if its not available.
   */
  public abstract void traceCaught(TraceSettings settings,
                                   String signature,
                                   String sourceLocation,
                                   String msg,
                                   Throwable ex, StackTraceElement[] stackTrace);
  public abstract void traceException(TraceSettings settings, String signature,
      String sourceLocation, String msg, Throwable ex,
      StackTraceElement[] stackTrace);
}
opendj3-server-dev/src/server/org/opends/server/core/DirectoryServer.java
@@ -31,8 +31,8 @@
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.config.ConfigConstants.*;
import static org.opends.server.loggers.AccessLogger.*;
import static org.opends.server.loggers.DebugLogger.*;
import static org.opends.server.loggers.ErrorLogger.*;
import static org.opends.server.loggers.debug.DebugLogger.*;
import static org.opends.server.schema.SchemaConstants.*;
import static org.opends.server.util.DynamicConstants.*;
import static org.opends.server.util.ServerConstants.*;
@@ -77,9 +77,7 @@
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.extensions.JMXAlertHandler;
import org.opends.server.loggers.*;
import org.opends.server.loggers.debug.DebugLogger;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.loggers.debug.TextDebugLogPublisher;
import org.opends.server.monitors.BackendMonitor;
import org.opends.server.monitors.ConnectionHandlerMonitor;
import org.opends.server.protocols.internal.InternalClientConnection;
opendj3-server-dev/src/server/org/opends/server/core/LoggerConfigManager.java
@@ -27,7 +27,9 @@
package org.opends.server.core;
import static org.opends.messages.ConfigMessages.*;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import java.util.ArrayList;
import java.util.List;
@@ -44,9 +46,9 @@
import org.opends.server.config.ConfigException;
import org.opends.server.loggers.AbstractLogger;
import org.opends.server.loggers.AccessLogger;
import org.opends.server.loggers.DebugLogger;
import org.opends.server.loggers.ErrorLogger;
import org.opends.server.loggers.HTTPAccessLogger;
import org.opends.server.loggers.debug.DebugLogger;
import org.opends.server.types.ConfigChangeResult;
import org.opends.server.types.InitializationException;
import org.opends.server.types.ResultCode;
opendj3-server-dev/src/server/org/opends/server/loggers/AbstractLogger.java
@@ -36,6 +36,7 @@
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizableMessageDescriptor.Arg3;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.admin.ClassPropertyDefinition;
import org.opends.server.admin.server.ConfigurationAddListener;
import org.opends.server.admin.server.ConfigurationChangeListener;
@@ -45,10 +46,8 @@
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
import org.opends.server.loggers.debug.DebugLogger;
import org.opends.server.types.ConfigChangeResult;
import org.opends.server.types.DN;
import org.opends.server.types.DebugLogLevel;
import org.opends.server.types.InitializationException;
import org.opends.server.types.ResultCode;
import org.opends.server.util.StaticUtils;
@@ -69,6 +68,8 @@
    ConfigurationChangeListener<C>
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  /**
   * The storage designed to store log publishers. It is helpful in abstracting
   * away the methods used to manage the collection.
@@ -257,13 +258,13 @@
      }
      catch(ConfigException e)
      {
        debugCaught(DebugLogLevel.ERROR, e);
        logger.traceException(e);
        messages.add(e.getMessageObject());
        resultCode = DirectoryServer.getServerErrorResultCode();
      }
      catch (Exception e)
      {
        debugCaught(DebugLogLevel.ERROR, e);
        logger.traceException(e);
        messages.add(ERR_CONFIG_LOGGER_CANNOT_CREATE_LOGGER.get(
                String.valueOf(config.dn().toString()),
                stackTraceToSingleLineString(e)));
@@ -273,14 +274,6 @@
    return new ConfigChangeResult(resultCode, adminActionRequired, messages);
  }
  private void debugCaught(LogLevel error, Exception e)
  {
    if (DebugLogger.debugEnabled())
    {
      DebugLogger.getTracer().debugCaught(DebugLogLevel.ERROR, e);
    }
  }
  private P findLogPublisher(DN dn)
  {
    Collection<P> logPublishers = getStorage().getLogPublishers();
opendj3-server-dev/src/server/org/opends/server/loggers/AbstractTextAccessLogPublisher.java
@@ -62,7 +62,7 @@
 * @param <T>
 *          The type of access log publisher configuration.
 */
public abstract class AbstractTextAccessLogPublisher
abstract class AbstractTextAccessLogPublisher
    <T extends AccessLogPublisherCfg> extends AccessLogPublisher<T>
{
  /**
opendj3-server-dev/src/server/org/opends/server/loggers/AsynchronousTextWriter.java
@@ -40,7 +40,7 @@
 * A Text Writer which writes log records asynchronously to
 * character-based stream.
 */
public class AsynchronousTextWriter
class AsynchronousTextWriter
    implements ServerShutdownListener, TextWriter
{
  /**
opendj3-server-dev/src/server/org/opends/server/loggers/DebugLogger.java
File was renamed from opendj3-server-dev/src/server/org/opends/server/loggers/debug/DebugLogger.java
@@ -24,7 +24,7 @@
 *      Copyright 2007-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2014 ForgeRock AS
 */
package org.opends.server.loggers.debug;
package org.opends.server.loggers;
import static org.opends.messages.ConfigMessages.*;
@@ -35,7 +35,6 @@
import org.opends.server.admin.std.meta.DebugLogPublisherCfgDefn;
import org.opends.server.admin.std.server.DebugLogPublisherCfg;
import org.opends.server.api.DebugLogPublisher;
import org.opends.server.loggers.AbstractLogger;
/**
 * A logger for debug and trace logging. DebugLogger provides a debugging
@@ -161,7 +160,7 @@
   *
   * @return True if debug logging is enabled. False otherwise.
   */
  public static boolean debugEnabled()
  static boolean debugEnabled()
  {
    return enabled;
  }
@@ -177,25 +176,13 @@
  }
  /**
   * Creates a new Debug Tracer for the caller class and registers it
   * with the Debug Logger.
   *
   * @return The tracer created for the caller class.
   */
  public static DebugTracer getTracer()
  {
    // TODO : remove this method
    return getTracer("org.opends");
  }
  /**
   * Returns the registered Debug Tracer for a traced class.
   *
   * @param className The name of the class tracer to retrieve.
   * @return The tracer for the provided class or null if there are
   *         no tracers registered.
   */
  public static DebugTracer getTracer(String className)
  static DebugTracer getTracer(final String className)
  {
    DebugTracer tracer = classTracers.get(className);
    if (tracer == null)
opendj3-server-dev/src/server/org/opends/server/loggers/DebugMessageFormatter.java
File was renamed from opendj3-server-dev/src/server/org/opends/server/loggers/debug/DebugMessageFormatter.java
@@ -22,8 +22,9 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS.
 */
package org.opends.server.loggers.debug;
package org.opends.server.loggers;
import java.util.*;
@@ -133,7 +134,6 @@
  {
    StringBuilder buffer= new StringBuilder();
    buffer.append("[ ");
    boolean firstElement= true;
    for (int i= 0; i < array.length; i++) {
      if (i > 0) buffer.append(", ");
      buffer.append(array[i]);
@@ -147,7 +147,6 @@
  {
    StringBuilder buffer= new StringBuilder();
    buffer.append("[ ");
    boolean firstElement= true;
    for (int i= 0; i < array.length; i++) {
      if (i > 0) buffer.append(", ");
      buffer.append(array[i]);
@@ -161,7 +160,6 @@
  {
    StringBuilder buffer= new StringBuilder();
    buffer.append("[ ");
    boolean firstElement= true;
    for (int i= 0; i < array.length; i++) {
      if (i > 0) buffer.append(", ");
      buffer.append(array[i]);
@@ -175,7 +173,6 @@
  {
    StringBuilder buffer= new StringBuilder();
    buffer.append("[ ");
    boolean firstElement= true;
    for (int i= 0; i < array.length; i++) {
      if (i > 0) buffer.append(", ");
      buffer.append(array[i]);
@@ -189,7 +186,6 @@
  {
    StringBuilder buffer= new StringBuilder();
    buffer.append("[ ");
    boolean firstElement= true;
    for (int i= 0; i < array.length; i++) {
      if (i > 0) buffer.append(", ");
      buffer.append(array[i]);
@@ -203,7 +199,6 @@
  {
    StringBuilder buffer= new StringBuilder();
    buffer.append("[ ");
    boolean firstElement= true;
    for (int i= 0; i < array.length; i++) {
      if (i > 0) buffer.append(", ");
      buffer.append(array[i]);
@@ -217,7 +212,6 @@
  {
    StringBuilder buffer= new StringBuilder();
    buffer.append("[ ");
    boolean firstElement= true;
    for (int i= 0; i < array.length; i++) {
      if (i > 0) buffer.append(", ");
      buffer.append(array[i]);
opendj3-server-dev/src/server/org/opends/server/loggers/DebugStackTraceFormatter.java
File was renamed from opendj3-server-dev/src/server/org/opends/server/loggers/debug/DebugStackTraceFormatter.java
@@ -22,8 +22,9 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS.
 */
package org.opends.server.loggers.debug;
package org.opends.server.loggers;
import static org.opends.server.util.ServerConstants.EOL;
opendj3-server-dev/src/server/org/opends/server/loggers/DebugTracer.java
New file
@@ -0,0 +1,328 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 */
package org.opends.server.loggers;
import java.util.Map;
import org.opends.server.api.DebugLogPublisher;
import org.opends.server.types.DebugLogCategory;
/**
 * Class for source-code tracing at the method level.
 *
 * One DebugTracer instance exists for each Java class using tracing.
 * Tracer must be registered with the DebugLogger.
 *
 * Logging is always done at a level basis, with debug log messages
 * exceeding the trace threshold being traced, others being discarded.
 */
class DebugTracer
{
  /** The class this aspect traces. */
  private String className;
  /**
   * A class that represents a settings cache entry.
   */
  private class PublisherSettings
  {
    DebugLogPublisher<?> debugPublisher;
    TraceSettings classSettings;
    Map<String, TraceSettings> methodSettings;
  }
  private PublisherSettings[] publisherSettings;
  /**
   * Construct a new DebugTracer object with cached settings obtained from
   * the provided array of publishers.
   *
   * @param className The classname to use as category for logging.
   * @param publishers The array of publishers to obtain the settings from.
   */
  @SuppressWarnings({ "unchecked", "rawtypes" })
  DebugTracer(String className, DebugLogPublisher[] publishers)
  {
    this.className = className;
    publisherSettings = new PublisherSettings[publishers.length];
    // Get the settings from all publishers.
    for(int i = 0; i < publishers.length; i++)
    {
      DebugLogPublisher publisher = publishers[i];
      PublisherSettings settings = new PublisherSettings();
      settings.debugPublisher = publisher;
      settings.classSettings = publisher.getClassSettings(className);
      // For some reason, the compiler doesn't see that
      // debugLogPublihser.getMethodSettings returns a parameterized Map.
      // This problem goes away if a parameterized verson of DebugLogPublisher
      // is used. However, we can't not use reflection to instantiate a generic
      // DebugLogPublisher<? extends DebugLogPublisherCfg> type. The only thing
      // we can do is to just supress the compiler warnings.
      settings.methodSettings = publisher.getMethodSettings(className);
      publisherSettings[i] = settings;
    }
  }
  /**
   * Log the provided message.
   *
   * @param msg
   *          message to log.
   */
  void trace(String msg)
  {
    traceException(msg, null);
  }
  /**
   * Log the provided message and exception.
   *
   * @param msg
   *          the message
   * @param exception
   *          the exception caught. May be {@code null}.
   */
  void traceException(String msg, Throwable exception)
  {
    if(DebugLogger.debugEnabled())
    {
      StackTraceElement[] stackTrace = null;
      StackTraceElement[] filteredStackTrace = null;
      StackTraceElement callerFrame = null;
      for (PublisherSettings settings : publisherSettings)
      {
        TraceSettings activeSettings = settings.classSettings;
        Map<String, TraceSettings> methodSettings = settings.methodSettings;
        if (shouldLog(DebugLogCategory.CAUGHT, activeSettings) || methodSettings != null)
        {
          if(stackTrace == null)
          {
            stackTrace = Thread.currentThread().getStackTrace();
          }
          if (callerFrame == null)
          {
            callerFrame = getCallerFrame(stackTrace);
          }
          String signature = callerFrame.getMethodName();
          // Specific method settings still could exist. Try getting
          // the settings for this method.
          if(methodSettings != null)
          {
            TraceSettings mSettings = methodSettings.get(signature);
            if (mSettings == null)
            {
              // Try looking for an undecorated method name
              int idx = signature.indexOf('(');
              if (idx != -1)
              {
                mSettings =
                    methodSettings.get(signature.substring(0, idx));
              }
            }
            // If this method does have a specific setting and it is not
            // suppose to be logged, continue.
            if (mSettings != null)
            {
              if(!shouldLog(DebugLogCategory.CAUGHT, mSettings))
              {
                continue;
              }
              else
              {
                activeSettings = mSettings;
              }
            }
          }
          String sourceLocation = callerFrame.getFileName() + ":" +
              callerFrame.getLineNumber();
          if (filteredStackTrace == null && activeSettings.stackDepth > 0)
          {
            StackTraceElement[] trace = exception == null ? stackTrace : exception.getStackTrace();
            filteredStackTrace =
                DebugStackTraceFormatter.SMART_FRAME_FILTER.
                    getFilteredStackTrace(trace);
          }
          if (exception == null)
          {
            settings.debugPublisher.trace(activeSettings, signature,
                sourceLocation, msg, filteredStackTrace);
          }
          else
          {
            settings.debugPublisher.traceException(activeSettings, signature,
                sourceLocation, msg, exception, filteredStackTrace);
          }
        }
      }
    }
  }
  /**
   * Gets the name of the class this tracer traces.
   *
   * @return The name of the class this tracer traces.
   */
  String getTracedClassName()
  {
    return className;
  }
  /**
   * Indicates if logging is enabled for the provided debug log
   * category.
   *
   * @param logCategory
   *            Log category to check
   * @return {@code true} if logging is enabled, false otherwise.
   */
  boolean enabledFor(LogCategory logCategory)
  {
    for (PublisherSettings settings : publisherSettings)
    {
      TraceSettings activeSettings = settings.classSettings;
      Map<String, TraceSettings> methodSettings = settings.methodSettings;
      if (shouldLog(logCategory, activeSettings)
          || methodSettings != null)
      {
        return true;
      }
    }
    return false;
  }
  /**
   * Indicates if logging is enabled for at least one category
   * in a publisher.
   *
   * @return {@code true} if logging is enabled, false otherwise.
   */
  boolean enabled()
  {
    for (PublisherSettings settings : publisherSettings)
    {
      TraceSettings activeSettings = settings.classSettings;
      Map<String, TraceSettings> methodSettings = settings.methodSettings;
      if (shouldLog(activeSettings) || methodSettings != null)
      {
        return true;
      }
    }
    return false;
  }
  /**
   * Update the cached settings of the tracer with the settings from the
   * provided publishers.
   *
   * @param publishers The array of publishers to obtain the settings from.
   */
  @SuppressWarnings({ "unchecked", "rawtypes" })
  void updateSettings(DebugLogPublisher[] publishers)
  {
    PublisherSettings[] newSettings =
        new PublisherSettings[publishers.length];
    // Get the settings from all publishers.
    for(int i = 0; i < publishers.length; i++)
    {
      DebugLogPublisher publisher = publishers[i];
      PublisherSettings settings = new PublisherSettings();
      settings.debugPublisher = publisher;
      settings.classSettings = publisher.getClassSettings(className);
      // For some reason, the compiler doesn't see that
      // debugLogPublihser.getMethodSettings returns a parameterized Map.
      // This problem goes away if a parameterized verson of DebugLogPublisher
      // is used. However, we can't not use reflection to instantiate a generic
      // DebugLogPublisher<? extends DebugLogPublisherCfg> type. The only thing
      // we can do is to just supress the compiler warnings.
      settings.methodSettings = publisher.getMethodSettings(className);
      newSettings[i] = settings;
    }
    publisherSettings = newSettings;
  }
  /**
   * Return the caller stack frame.
   *
   * @param stackTrace The entrie stack trace frames.
   * @return the caller stack frame or null if none is found on the
   * stack trace.
   */
  private StackTraceElement getCallerFrame(StackTraceElement[] stackTrace)
  {
    if (stackTrace != null && stackTrace.length > 0)
    {
      // Skip leading frames debug logging classes and getStackTrace
      // method call frame if any.
      for (StackTraceElement aStackTrace : stackTrace)
      {
        if(aStackTrace.getClassName().startsWith("java.lang.Thread"))
        {
          continue;
        }
        if (!aStackTrace.getClassName().startsWith(
            "org.opends.server.loggers.debug"))
        {
          return aStackTrace;
        }
      }
    }
    return null;
  }
  private boolean shouldLog(LogCategory messageCategory, TraceSettings activeSettings)
  {
    return activeSettings.includeCategories != null &&
        activeSettings.includeCategories.contains(messageCategory);
  }
  /** Indicates if at least one category is active for logging. */
  private boolean shouldLog(TraceSettings settings)
  {
    return settings.includeCategories != null && !settings.includeCategories.isEmpty();
  }
}
opendj3-server-dev/src/server/org/opends/server/loggers/EncryptAction.java
@@ -22,6 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 */
package org.opends.server.loggers;
@@ -31,7 +32,7 @@
 * This class implements a post rotation action that encrypts
 * the log file.
 */
public class EncryptAction implements PostRotationAction
class EncryptAction implements PostRotationAction
{
  private File originalFile;
opendj3-server-dev/src/server/org/opends/server/loggers/FileComparator.java
@@ -22,6 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 */
package org.opends.server.loggers;
@@ -35,7 +36,7 @@
 * This class implements a comparator that can compare two files based on the
 * time that they were last modified.
 */
public class FileComparator implements Comparator<File>
class FileComparator implements Comparator<File>
{
  /**
   * Compare two files based on file modification time.
opendj3-server-dev/src/server/org/opends/server/loggers/GZIPAction.java
@@ -38,7 +38,7 @@
 * This class implements a post rotation action that compresses
 * the file using GZIP compression.
 */
public class GZIPAction implements PostRotationAction
class GZIPAction implements PostRotationAction
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
opendj3-server-dev/src/server/org/opends/server/loggers/LogFileFilter.java
@@ -22,6 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 */
package org.opends.server.loggers;
@@ -32,7 +33,7 @@
/**
 * This class defines a filename filter that will be used for log files.
 */
public class LogFileFilter implements FilenameFilter
class LogFileFilter implements FilenameFilter
{
  private String prefix;
opendj3-server-dev/src/server/org/opends/server/loggers/LogPublisherErrorHandler.java
@@ -41,7 +41,7 @@
 * The advantage of using a handler is that we can handle exceptions
 * asynchronously (useful when dealing with an AsynchronousPublisher).
 */
public class LogPublisherErrorHandler
class LogPublisherErrorHandler
{
  private DN publisherConfigDN;
  private boolean writeErroroccurred = false;
opendj3-server-dev/src/server/org/opends/server/loggers/LoggerAlarmHandler.java
@@ -22,6 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 */
package org.opends.server.loggers;
@@ -31,7 +32,7 @@
 * This interface describes the handler that is invoked when the logger
 * thread generates an alarm based on a rotation policy condition being met.
 */
public interface LoggerAlarmHandler
interface LoggerAlarmHandler
{
  /**
opendj3-server-dev/src/server/org/opends/server/loggers/LoggingCategoryNames.java
New file
@@ -0,0 +1,142 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2014 ForgeRock AS.
 */
package org.opends.server.loggers;
import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.TreeMap;
/**
 * Provides mapping from class names to simple category names used for logging.
 * <p>
 * Given a classname, eg org.forgerock.opendj.server.core.SomeClass, it allows
 * to get the corresponding simplified category name if it exists, eg "CORE". If
 * no simplified category name exist, the classname is used as a category name.
 */
class LoggingCategoryNames
{
  /**
   * Contains mapping from class names (or package names) to category names. In
   * most case, package name is sufficient to map to a category name. It is
   * valid if several entries point to the same category name.
   */
  private static final NavigableMap<String, String> NAMES =
      new TreeMap<String, String>();
  static
  {
    // The category used for messages associated with the core server.
    NAMES.put("org.opends.server.core", "CORE");
    // The category used for messages associated with server
    //extensions (e.g., extended operations, SASL mechanisms, password storage
    // schemes, password validators, etc.).
    NAMES.put("org.opends.server.extensions", "EXTENSIONS");
    // The category used for messages associated with
    // connection and protocol handling (e.g., ASN.1 and LDAP).
    NAMES.put("org.opends.server.protocol", "PROTOCOL");
    // The category used for messages associated with
    // configuration handling.
    NAMES.put("org.opends.server.config", "CONFIG");
    // The category used for messages associated with the
    // server loggers.
    NAMES.put("org.opends.server.loggers", "LOG");
    // The category used for messages associated with the
    // general server utilities.
    NAMES.put("org.opends.server.util", "UTIL");
    // The category used for messages associated with the
    // server schema elements.
    NAMES.put("org.opends.server.schema", "SCHEMA");
    // The category that will be used for messages associated with plugin
    // processing.
    NAMES.put("org.opends.server.plugins", "PLUGIN");
    // The category used for messages associated with the JE backend.
    NAMES.put("org.opends.server.backends.jeb", "JEB");
    // The category used for messages associated with generic backends.
    NAMES.put("org.opends.server.backends", "BACKEND");
    // The category used for messages associated with tools
    NAMES.put("org.opends.server.tools", "TOOLS");
    // The category used for messages associated with tasks
    NAMES.put("org.opends.server.tasks", "TASK");
    // The category used for messages associated with Access Control
    NAMES.put("org.opends.server.authorization", "ACCESS_CONTROL");
    // The category used for messages associated with the administration
    // framework.
    NAMES.put("org.opends.server.admin", "ADMIN");
    // The category used for messages associated with the Synchronization
    NAMES.put("org.opends.server.replication", "SYNC");
    // The category used for messages associated with version information
    //PACKAGES_TO_NAMES.put("org.opends.server", "VERSION");
    // The category used for messages associated with quicksetup tools
    NAMES.put("org.opends.quicksetup", "QUICKSETUP");
    // The category used for messages associated with the tool like the offline
    // installer and unintaller.
    NAMES.put("org.opends.quicksetup.offline", "ADMIN_TOOL");
    NAMES.put("org.opends.guitools.uninstaller", "ADMIN_TOOL");
    // The category used for messages associated with the dsconfig
    // administration tool.
    NAMES.put("org.opends.admin.ads", "DSCONFIG");
    // The category used for messages associated with the runtime information
    //NAMES.put("org.opends.server", "RUNTIME_INFORMATION");
  }
  /**
   * Returns the simple category name corresponding to the provided class name
   * or the class name if no mapping corresponds.
   *
   * @param className
   *          The classname to retrieve the category name from.
   * @return the simple category name, or the provided className if no matching
   *         simple category name is found
   */
  static String getCategoryName(final String className)
  {
    final Entry<String, String> entry = NAMES.floorEntry(className);
    if (entry != null && className.startsWith(entry.getKey()))
    {
      return entry.getValue();
    }
    return className;
  }
}
opendj3-server-dev/src/server/org/opends/server/loggers/MultifileTextWriter.java
@@ -57,7 +57,7 @@
 * When a switch is required, the writer closes the current file and opens a
 * new one named in accordance with a specified FileNamingPolicy.
 */
public class MultifileTextWriter
class MultifileTextWriter
    implements ServerShutdownListener, TextWriter,
    ConfigurationChangeListener<SizeLimitLogRotationPolicyCfg>
{
opendj3-server-dev/src/server/org/opends/server/loggers/ParallelTextWriter.java
@@ -45,7 +45,7 @@
 * character-based stream. Note that this implementation is
 * parallel unbound ie there is no queue size cap imposed.
 */
public class ParallelTextWriter
class ParallelTextWriter
    implements ServerShutdownListener, TextWriter
{
  /**
opendj3-server-dev/src/server/org/opends/server/loggers/PostRotationAction.java
@@ -22,6 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 */
package org.opends.server.loggers;
@@ -31,7 +32,7 @@
 * This interface describes the action that needs to be taken
 * at the time of a rotation.
 */
public interface PostRotationAction
interface PostRotationAction
{
  /**
   * The action that needs to be executed. Returns true
opendj3-server-dev/src/server/org/opends/server/loggers/TextDebugLogPublisher.java
File was renamed from opendj3-server-dev/src/server/org/opends/server/loggers/debug/TextDebugLogPublisher.java
@@ -24,7 +24,7 @@
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2013-2014 ForgeRock AS
 */
package org.opends.server.loggers.debug;
package org.opends.server.loggers;
import java.io.File;
import java.io.IOException;
@@ -42,7 +42,6 @@
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.ServerContext;
import org.opends.server.loggers.*;
import org.opends.server.types.*;
import org.opends.server.util.TimeThread;
@@ -450,50 +449,35 @@
   * {@inheritDoc}
   */
  @Override
  public void traceMessage(TraceSettings settings,
                           String signature,
                           String sourceLocation,
                           String msg,
                           StackTraceElement[] stackTrace)
  public void trace(TraceSettings settings, String signature,
      String sourceLocation, String msg, StackTraceElement[] stackTrace)
  {
    LogCategory category = DebugLogCategory.MESSAGE;
    String stack = null;
    if(stackTrace != null)
    if (stackTrace != null)
    {
      stack = DebugStackTraceFormatter.formatStackTrace(stackTrace,
                                                        settings.stackDepth);
          settings.stackDepth);
    }
    publish(category, signature, sourceLocation, msg, stack);
    publish(DebugLogCategory.MESSAGE, signature, sourceLocation, msg, stack);
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public void traceCaught(TraceSettings settings,
                          String signature,
                          String sourceLocation,
                          String msg,
                          Throwable ex, StackTraceElement[] stackTrace)
  public void traceException(TraceSettings settings, String signature,
      String sourceLocation, String msg, Throwable ex,
      StackTraceElement[] stackTrace)
  {
    LogCategory category = DebugLogCategory.CAUGHT;
    StringBuilder message = new StringBuilder();
    if (!msg.isEmpty())
    {
      message.append(msg).append(" ");
    }
    message.append(DebugMessageFormatter.format("caught={%s}",
        new Object[] { ex }));
    String message = DebugMessageFormatter.format("%s caught={%s}", new Object[] { msg, ex });
    String stack = null;
    if(stackTrace != null)
    if (stackTrace != null)
    {
      stack = DebugStackTraceFormatter.formatStackTrace(ex,
                                                        settings.stackDepth,
                                                        settings.includeCause);
      stack = DebugStackTraceFormatter.formatStackTrace(ex, settings.stackDepth,
          settings.includeCause);
    }
    publish(category, signature, sourceLocation, message.toString(), stack);
    publish(DebugLogCategory.CAUGHT, signature, sourceLocation, message, stack);
  }
  /**
opendj3-server-dev/src/server/org/opends/server/loggers/TraceSettings.java
File was renamed from opendj3-server-dev/src/server/org/opends/server/loggers/debug/TraceSettings.java
@@ -25,20 +25,16 @@
 *      Portions Copyright 2014 ForgeRock AS
 */
package org.opends.server.loggers.debug;
package org.opends.server.loggers;
import org.forgerock.i18n.LocalizableMessage;
import org.opends.server.types.DebugLogLevel;
import org.opends.server.types.DebugLogCategory;
import org.opends.server.types.ConfigChangeResult;
import org.opends.server.types.ResultCode;
import org.opends.server.loggers.LogLevel;
import org.opends.server.loggers.LogCategory;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.std.meta.DebugTargetCfgDefn;
import org.opends.server.admin.std.server.DebugTargetCfg;
import java.util.*;
/**
opendj3-server-dev/src/server/org/opends/server/loggers/debug/DebugTracer.java
File was deleted
opendj3-server-dev/src/server/org/opends/server/loggers/debug/package-info.java
File was deleted
opendj3-server-dev/src/server/org/opends/server/loggers/package-info.java
@@ -22,13 +22,12 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 */
/**
 * Contains implementations of Directory Server access, error, and debug
 * loggers.  This includes classes with static methods that should be used to
 * loggers.  This includes classes with static methods are used to
 * trigger the generation of log messages, as well as actual implementations
 * that can write the log contents to various targets.
 */
opendj3-server-dev/src/server/org/opends/server/tools/BackUpDB.java
@@ -27,7 +27,9 @@
package org.opends.server.tools;
import java.io.File;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import java.io.OutputStream;
import java.io.PrintStream;
import java.text.SimpleDateFormat;
@@ -48,11 +50,11 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.DebugLogger;
import org.opends.server.loggers.ErrorLogger;
import org.opends.server.loggers.TextDebugLogPublisher;
import org.opends.server.loggers.TextErrorLogPublisher;
import org.opends.server.loggers.TextWriter;
import org.opends.server.loggers.debug.DebugLogger;
import org.opends.server.loggers.debug.TextDebugLogPublisher;
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.tasks.BackupTask;
import org.opends.server.tools.tasks.TaskTool;
opendj3-server-dev/src/server/org/opends/server/tools/ConsoleDebugLogPublisher.java
@@ -34,10 +34,10 @@
import org.opends.server.api.DebugLogPublisher;
import org.opends.server.config.ConfigException;
import org.opends.server.core.ServerContext;
import org.opends.server.loggers.DebugMessageFormatter;
import org.opends.server.loggers.DebugStackTraceFormatter;
import org.opends.server.loggers.LogCategory;
import org.opends.server.loggers.debug.DebugMessageFormatter;
import org.opends.server.loggers.debug.DebugStackTraceFormatter;
import org.opends.server.loggers.debug.TraceSettings;
import org.opends.server.loggers.TraceSettings;
import org.opends.server.types.DN;
import org.opends.server.types.DebugLogCategory;
import org.opends.server.types.InitializationException;
@@ -83,7 +83,7 @@
   * {@inheritDoc}
   */
  @Override
  public void traceMessage(TraceSettings settings,
  public void trace(TraceSettings settings,
                           String signature,
                           String sourceLocation,
                           String msg,
@@ -94,8 +94,7 @@
    String stack = null;
    if(stackTrace != null)
    {
      stack = DebugStackTraceFormatter.formatStackTrace(stackTrace,
                                                      settings.getStackDepth());
      stack = DebugStackTraceFormatter.formatStackTrace(stackTrace, settings.getStackDepth());
    }
    publish(category, msg, stack);
  }
@@ -104,7 +103,7 @@
   * {@inheritDoc}
   */
  @Override
  public void traceCaught(TraceSettings settings,
  public void traceException(TraceSettings settings,
                          String signature,
                          String sourceLocation,
                          String msg,
@@ -112,18 +111,8 @@
  {
    LogCategory category = DebugLogCategory.CAUGHT;
    StringBuilder format = new StringBuilder();
    format.append("caught={%s} ");
    format.append(signature);
    format.append("():");
    format.append(sourceLocation);
    StringBuilder message = new StringBuilder();
    if (!msg.isEmpty())
    {
      message.append(msg).append(" ");
    }
    message.append(DebugMessageFormatter.format("caught={%s}",
        new Object[] { ex }));
    String message = DebugMessageFormatter.format("%s caught={%s} %s(): %s",
        new Object[] { msg, ex, signature, sourceLocation });
    String stack = null;
    if (stackTrace != null)
@@ -132,7 +121,7 @@
          DebugStackTraceFormatter.formatStackTrace(ex, settings
              .getStackDepth(), settings.isIncludeCause());
    }
    publish(category, message.toString(), stack);
    publish(category, message, stack);
  }
  /**
opendj3-server-dev/src/server/org/opends/server/tools/ExportLDIF.java
@@ -27,7 +27,9 @@
package org.opends.server.tools;
import java.io.OutputStream;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashSet;
@@ -38,16 +40,18 @@
import org.opends.server.api.DebugLogPublisher;
import org.opends.server.api.plugin.PluginType;
import org.opends.server.config.ConfigException;
import static org.opends.server.config.ConfigConstants.*;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.DebugLogger;
import org.opends.server.loggers.TextDebugLogPublisher;
import org.opends.server.loggers.TextWriter;
import org.opends.server.loggers.TextErrorLogPublisher;
import org.opends.server.loggers.ErrorLogger;
import org.opends.server.loggers.debug.TextDebugLogPublisher;
import org.opends.server.loggers.debug.DebugLogger;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.util.BuildVersion;
@@ -57,12 +61,13 @@
import org.opends.server.util.args.StringArgument;
import org.opends.server.util.args.LDAPConnectionArgumentParser;
import org.opends.server.util.cli.CLIException;
import org.forgerock.i18n.LocalizableMessage;
import static org.opends.messages.ToolMessages.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static org.opends.server.tools.ToolConstants.*;
import org.opends.server.tools.tasks.TaskTool;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.protocols.ldap.LDAPAttribute;
opendj3-server-dev/src/server/org/opends/server/tools/LDAPConnection.java
@@ -41,9 +41,9 @@
import org.opends.server.controls.PasswordPolicyErrorType;
import org.opends.server.controls.PasswordPolicyResponseControl;
import org.opends.server.controls.PasswordPolicyWarningType;
import org.opends.server.loggers.debug.DebugLogger;
import org.opends.server.loggers.DebugLogger;
import org.opends.server.loggers.TraceSettings;
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.opends.server.loggers.debug.TraceSettings;
import org.opends.server.protocols.ldap.ExtendedRequestProtocolOp;
import org.opends.server.protocols.ldap.ExtendedResponseProtocolOp;
import org.opends.server.protocols.ldap.LDAPControl;
opendj3-server-dev/src/server/org/opends/server/tools/RebuildIndex.java
@@ -41,16 +41,13 @@
import org.opends.server.util.args.LDAPConnectionArgumentParser;
import org.opends.server.util.args.StringArgument;
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.config.ConfigException;
import org.opends.server.loggers.DebugLogger;
import org.opends.server.loggers.TextDebugLogPublisher;
import org.opends.server.loggers.TextWriter;
import org.opends.server.loggers.ErrorLogger;
import org.opends.server.loggers.TextErrorLogPublisher;
import org.opends.server.loggers.debug.TextDebugLogPublisher;
import org.opends.server.loggers.debug.DebugLogger;
import org.opends.server.protocols.ldap.LDAPAttribute;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.LockFileManager;
opendj3-server-dev/src/server/org/opends/server/tools/RestoreDB.java
@@ -30,6 +30,7 @@
import java.io.OutputStream;
import java.io.PrintStream;
import java.text.DateFormat;
@@ -43,16 +44,18 @@
import org.opends.server.api.ErrorLogPublisher;
import org.opends.server.api.DebugLogPublisher;
import org.opends.server.config.ConfigException;
import static org.opends.server.config.ConfigConstants.*;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.DebugLogger;
import org.opends.server.loggers.TextDebugLogPublisher;
import org.opends.server.loggers.TextWriter;
import org.opends.server.loggers.ErrorLogger;
import org.opends.server.loggers.TextErrorLogPublisher;
import org.opends.server.loggers.debug.TextDebugLogPublisher;
import org.opends.server.loggers.debug.DebugLogger;
import org.opends.server.types.*;
import org.forgerock.opendj.ldap.ByteString;
import org.opends.server.util.BuildVersion;
@@ -66,6 +69,7 @@
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static org.opends.server.tools.ToolConstants.*;
import org.opends.server.tools.tasks.TaskTool;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.protocols.ldap.LDAPAttribute;
opendj3-server-dev/src/server/org/opends/server/tools/VerifyIndex.java
@@ -39,12 +39,12 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.core.LockFileManager;
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.DebugLogger;
import org.opends.server.loggers.TextDebugLogPublisher;
import org.opends.server.loggers.TextWriter;
import org.opends.server.loggers.ErrorLogger;
import org.opends.server.loggers.TextErrorLogPublisher;
import org.opends.server.loggers.debug.TextDebugLogPublisher;
import org.opends.server.loggers.debug.DebugLogger;
import org.opends.server.loggers.debug.TraceSettings;
import org.opends.server.loggers.TraceSettings;
import org.opends.server.types.*;
import org.opends.server.util.BuildVersion;
import org.opends.server.util.args.ArgumentException;
@@ -64,6 +64,7 @@
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import static org.opends.server.tools.ToolConstants.*;
import org.opends.server.admin.std.server.BackendCfg;
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
@@ -51,8 +51,6 @@
import org.opends.server.core.DirectoryServer;
import org.opends.server.extensions.ConfigFileHandler;
import org.opends.server.loggers.*;
import org.opends.server.loggers.debug.DebugLogger;
import org.opends.server.loggers.debug.TextDebugLogPublisher;
import org.opends.server.plugins.InvocationCounterPlugin;
import org.opends.server.protocols.asn1.ASN1;
import org.opends.server.protocols.asn1.ASN1Reader;
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/loggers/LoggingCategoryNamesTest.java
New file
@@ -0,0 +1,76 @@
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
 * or http://forgerock.org/license/CDDLv1.0.html.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at legal-notices/CDDLv1_0.txt.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2014 ForgeRock AS.
 */
package org.opends.server.loggers;
import org.opends.server.DirectoryServerTestCase;
import org.opends.server.core.DirectoryServer;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
@SuppressWarnings("javadoc")
public class LoggingCategoryNamesTest extends DirectoryServerTestCase
{
  private final static String CORE_PACKAGE = DirectoryServer.class.getPackage().getName();
  private final static String CORE_PACKAGE_NAME = "CORE";
  @DataProvider
  public Object[][] matchingNames()
  {
    return new Object[][] {
      { CORE_PACKAGE },
      { CORE_PACKAGE + ".SomeClass" },
      { CORE_PACKAGE + ".pack1.SomeClass"},
      { CORE_PACKAGE + ".pack1.pack2.SomeClass" },
    };
  }
  @DataProvider
  public Object[][] nonMatchingNames()
  {
    return new Object[][] {
      { CORE_PACKAGE.substring(0, CORE_PACKAGE.length()-1) },
      { CORE_PACKAGE.substring(0, CORE_PACKAGE.length()-1) + ".SomeClass" },
      { CORE_PACKAGE.substring(0, CORE_PACKAGE.length()-1) + ".pack1.SomeClass"},
      { "org.opends.server" },
      { "" },
      { "anyvalue" },
    };
  }
  @Test(dataProvider = "matchingNames")
  public void testMatching(String classname) throws Exception
  {
    assertEquals(LoggingCategoryNames.getCategoryName(classname), CORE_PACKAGE_NAME);
  }
  @Test(dataProvider = "nonMatchingNames")
  public void testNonMatching(String classname) throws Exception
  {
    assertEquals(LoggingCategoryNames.getCategoryName(classname), classname);
  }
}
opendj3-server-dev/tests/unit-tests-testng/src/server/org/opends/server/tasks/TestBackupAndRestore.java
@@ -22,6 +22,7 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS.
 */
@@ -236,7 +237,7 @@
   * @param taskEntry The task entry.
   * @param expectedState The expected completion state of the task.
   */
  @Test(dataProvider = "backups")
  @Test(enabled=false, dataProvider = "backups")
  public void testBackups(Entry taskEntry, TaskState expectedState)
       throws Exception
  {