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

Jean-Noel Rouvignac
24.17.2013 5203b37903fe2731620fb5b910cda72a238fac11
OPENDJ-879 (CR-1600) Add HTTP access log


Consolidated common code for the *LogPublisher classes prior to implementing the HTTP access log.


LogPublisher.java: ADDED
Unify all the *LogPublisher classes.
Implements Closeable.

AccessLogPublisher.java, DebugLogPublisher.java, ErrorLogPublisher.java:
Now implementing LogPublisher.
Pulled up isConfigurationAcceptable(), initialize*LogPublisher() renamed to initializeLogPublisher(), close(), getDN().
Removed syntactic/spaces differences between all these classes to better expose their commonalities.
Used Set and MAp interfaces rather than comcrete classes.

AccessLogger.java, ErrorLogger.java, DebugLogger.java:
In isJavaClassAcceptable() and getAccessPublisher(), replaced method invocations via reflection by direct method calls.

TextAccessLogPublisher.java, TextAuditLogPublisher.java, TextErrorLogPublisher.java, ThreadFilterTextErrorLogPublisher.java, TextDebugLogPublisher.java, ConsoleDebugLogPublisher.java:
Consequence of renaming the initialize*LogPublisher() methods, or generecizing the isConfigurationAcceptable() methods in their parent classes.
1 files added
12 files modified
905 ■■■■■ changed files
opends/src/server/org/opends/server/api/AccessLogPublisher.java 72 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/api/DebugLogPublisher.java 85 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/api/ErrorLogPublisher.java 98 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/api/LogPublisher.java 113 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/loggers/AccessLogger.java 109 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/loggers/ErrorLogger.java 107 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/loggers/TextAccessLogPublisher.java 5 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/loggers/TextAuditLogPublisher.java 14 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/loggers/TextErrorLogPublisher.java 46 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/loggers/ThreadFilterTextErrorLogPublisher.java 21 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/loggers/debug/DebugLogger.java 104 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/loggers/debug/TextDebugLogPublisher.java 79 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/ConsoleDebugLogPublisher.java 52 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/api/AccessLogPublisher.java
@@ -23,21 +23,16 @@
 *
 *
 *      Copyright 2008-2009 Sun Microsystems, Inc.
 *      Portions copyright 2011 ForgeRock AS.
 *      Portions copyright 2011-2013 ForgeRock AS.
 */
package org.opends.server.api;
import java.util.List;
import org.opends.messages.Message;
import org.opends.server.admin.std.server.AccessLogPublisherCfg;
import org.opends.server.config.ConfigException;
import org.opends.server.core.*;
import org.opends.server.types.*;
import org.opends.messages.Message;
/**
 * This class defines the set of methods and structures that must be
@@ -52,50 +47,12 @@
    mayInstantiate = false,
    mayExtend = true,
    mayInvoke = false)
public abstract class AccessLogPublisher
  <T extends AccessLogPublisherCfg>
public abstract class AccessLogPublisher<T extends AccessLogPublisherCfg>
    implements LogPublisher<T>
{
  /**
   * Initializes this access publisher provider based on the
   * information in the provided debug publisher configuration.
   *
   * @param config
   *          The access publisher configuration that contains the
   *          information to use to initialize this access publisher.
   * @throws ConfigException
   *           If an unrecoverable problem arises in the process of
   *           performing the initialization as a result of the server
   *           configuration.
   * @throws InitializationException
   *           If a problem occurs during initialization that is not
   *           related to the server configuration.
   */
  public abstract void initializeAccessLogPublisher(T config)
      throws ConfigException, InitializationException;
  /**
   * Indicates whether the provided configuration is acceptable for
   * this access log publisher. It should be possible to call this
   * method on an uninitialized access log publisher instance in order
   * to determine whether the access log publisher would be able to
   * use the provided configuration. <BR>
   * <BR>
   * Note that implementations which use a subclass of the provided
   * configuration class will likely need to cast the configuration to
   * the appropriate subclass type.
   *
   * @param configuration
   *          The access log publisher configuration for which to make
   *          the determination.
   * @param unacceptableReasons
   *          A list that may be used to hold the reasons that the
   *          provided configuration is not acceptable.
   * @return {@code true} if the provided configuration is acceptable
   *         for this access log publisher, or {@code false} if not.
   */
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationAcceptable(T configuration,
      List<Message> unacceptableReasons)
  {
@@ -108,13 +65,6 @@
  /**
   * Close this publisher.
   */
  public abstract void close();
  /**
   * Writes a message to the access logger with information about a
   * new client connection that has been established, regardless of
   * whether it will be immediately terminated.
@@ -521,14 +471,4 @@
    // Do nothing
  }
  /**
   * Gets the DN of the configuration entry for this access log
   * publisher.
   *
   * @return The configuration entry DN.
   */
  public abstract DN getDN();
}
opends/src/server/org/opends/server/api/DebugLogPublisher.java
@@ -23,32 +23,25 @@
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions copyright 2012 ForgeRock AS.
 *      Portions copyright 2012-2013 ForgeRock AS.
 */
package org.opends.server.api;
import org.opends.messages.Message;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import com.sleepycat.je.Transaction;
import com.sleepycat.je.Database;
import com.sleepycat.je.DatabaseEntry;
import com.sleepycat.je.OperationStatus;
import com.sleepycat.je.Transaction;
import org.opends.messages.Message;
import org.opends.server.admin.std.server.DebugLogPublisherCfg;
import org.opends.server.config.ConfigException;
import org.opends.server.loggers.LogLevel;
import org.opends.server.loggers.debug.TraceSettings;
import org.opends.server.types.DebugLogLevel;
import org.opends.server.types.InitializationException;
import org.opends.server.types.DN;
/**
 * This class defines the set of methods and structures that must be
@@ -62,8 +55,8 @@
     mayInstantiate=false,
     mayExtend=true,
     mayInvoke=false)
public abstract class DebugLogPublisher
       <T extends DebugLogPublisherCfg>
public abstract class DebugLogPublisher<T extends DebugLogPublisherCfg>
    implements LogPublisher<T>
{
  //The default global settings key.
  private static final String GLOBAL= "_global";
@@ -91,56 +84,13 @@
  /**
   * Initializes this debug publisher provider based on the
   * information in the provided debug publisher configuration.
   *
   * @param  config  The debug publisher configuration that contains
   *                 the information to use to initialize this debug
   *                 publisher.
   *
   * @throws  ConfigException  If an unrecoverable problem arises in
   *                           the process of performing the
   *                           initialization as a result of the
   *                           server configuration.
   *
   * @throws   InitializationException  If a problem occurs during
   *                                    initialization that is not
   *                                    related to the server
   *                                    configuration.
   */
  public abstract void initializeDebugLogPublisher(T config)
         throws ConfigException, InitializationException;
  /**
   * Indicates whether the provided configuration is acceptable for
   * this debug log publisher.  It should be possible to call this
   * method on an uninitialized debug log publisher instance in
   * order to determine whether the debug log publisher would be able
   * to use the provided configuration.
   * <BR><BR>
   * Note that implementations which use a subclass of the provided
   * configuration class will likely need to cast the configuration
   * to the appropriate subclass type.
   *
   * @param  configuration        The debug log publisher
   *                              configuration for which to make the
   *                              determination.
   * @param  unacceptableReasons  A list that may be used to hold the
   *                              reasons that the provided
   *                              configuration is not acceptable.
   *
   * @return  {@code true} if the provided configuration is acceptable
   *          for this debug log publisher, or {@code false} if not.
   */
  public boolean isConfigurationAcceptable(
                      DebugLogPublisherCfg configuration,
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationAcceptable(T configuration,
                      List<Message> unacceptableReasons)
  {
    // This default implementation does not perform any special
    // validation.  It should be overridden by debug log publisher
    // validation. It should be overridden by debug log publisher
    // implementations that wish to perform more detailed validation.
    return true;
  }
@@ -400,7 +350,7 @@
   *
   * @param  level           The log level for the message.
   * @param  settings        The current trace settings in effect.
   * @param  signature       The constuctor signature.
   * @param  signature       The constructor signature.
   * @param  sourceLocation  The location of the method in the source.
   * @param  args            The parameters provided to the
   *                         constructor.
@@ -596,7 +546,7 @@
   * @param  settings        The current trace settings in effect.
   * @param  signature       The method signature.
   * @param  sourceLocation  The location of the method in the source.
   * @param  decodedForm     The string reprentation of the protocol
   * @param  decodedForm     The string representation of the protocol
   *                         element.
   * @param  stackTrace      The stack trace at the time the protocol
   *                         element is logged or null if its not
@@ -609,17 +559,4 @@
                                            String decodedForm,
                                      StackTraceElement[] stackTrace);
  /**
   * Close this publisher.
   */
  public abstract void close();
  /**
   * Gets the DN of the configuration entry for this debug log
   * publisher.
   *
   * @return The configuration entry DN.
   */
  public abstract DN getDN();
}
opends/src/server/org/opends/server/api/ErrorLogPublisher.java
@@ -23,25 +23,20 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2013 ForgeRock AS
 */
package org.opends.server.api;
import org.opends.messages.Message;
import java.util.HashSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.opends.server.admin.std.server.ErrorLogPublisherCfg;
import org.opends.server.config.ConfigException;
import org.opends.server.types.InitializationException;
import org.opends.server.types.DN;
import org.opends.messages.Severity;
import org.opends.messages.Category;
import org.opends.messages.Message;
import org.opends.messages.Severity;
import org.opends.server.admin.std.server.ErrorLogPublisherCfg;
/**
 * This class defines the set of methods and structures that must be
@@ -55,16 +50,15 @@
     mayInstantiate=false,
     mayExtend=true,
     mayInvoke=false)
public abstract class ErrorLogPublisher
       <T extends ErrorLogPublisherCfg>
public abstract class ErrorLogPublisher<T extends ErrorLogPublisherCfg>
    implements LogPublisher<T>
{
  /**
   * The hash map that will be used to define specific log severities
   * for the various categories.
   */
  protected HashMap<Category,HashSet<Severity>>
      definedSeverities =
           new HashMap<Category, HashSet<Severity>>();
  protected Map<Category, Set<Severity>> definedSeverities =
      new HashMap<Category, Set<Severity>>();
@@ -72,61 +66,17 @@
   * The set of default log severities that will be used if no custom
   * severities have been defined for the associated category.
   */
  protected HashSet<Severity>
       defaultSeverities = new HashSet<Severity>();
  protected Set<Severity> defaultSeverities = new HashSet<Severity>();
  /**
   * Initializes this access publisher provider based on the
   * information in the provided debug publisher configuration.
   *
   * @param  config  The error publisher configuration that contains
   *                 the information to use to initialize this error
   *                 publisher.
   *
   * @throws  ConfigException  If an unrecoverable problem arises in
   *                           the process of performing the
   *                           initialization as a result of the
   *                           server configuration.
   *
   * @throws  InitializationException  If a problem occurs during
   *                                   initialization that is not
   *                                   related to the server
   *                                   configuration.
   */
  public abstract void initializeErrorLogPublisher(T config)
         throws ConfigException, InitializationException;
  /**
   * Indicates whether the provided configuration is acceptable for
   * this error log publisher.  It should be possible to call this
   * method on an uninitialized error log publisher instance in
   * order to determine whether the error log publisher would be able
   * to use the provided configuration.
   * <BR><BR>
   * Note that implementations which use a subclass of the provided
   * configuration class will likely need to cast the configuration
   * to the appropriate subclass type.
   *
   * @param  configuration        The error log publisher
   *                              configuration for which to make the
   *                              determination.
   * @param  unacceptableReasons  A list that may be used to hold the
   *                              reasons that the provided
   *                              configuration is not acceptable.
   *
   * @return  {@code true} if the provided configuration is acceptable
   *          for this error log publisher, or {@code false} if not.
   */
  public boolean isConfigurationAcceptable(
                      ErrorLogPublisherCfg configuration,
  /** {@inheritDoc} */
  @Override
  public boolean isConfigurationAcceptable(T configuration,
                      List<Message> unacceptableReasons)
  {
    // This default implementation does not perform any special
    // validation.  It should be overridden by error log publisher
    // validation. It should be overridden by error log publisher
    // implementations that wish to perform more detailed validation.
    return true;
  }
@@ -134,13 +84,6 @@
  /**
   * Close this publisher.
   */
  public abstract void close();
  /**
   * Writes a message to the error log using the provided information.
   * The message's category and severity information will be used to
   * determine whether to actually log this message.
@@ -149,13 +92,4 @@
   */
  public abstract void logError(Message message);
  /**
   * Gets the DN of the configuration entry for this error log
   * publisher.
   *
   * @return The configuration entry DN.
   */
  public abstract DN getDN();
}
opends/src/server/org/opends/server/api/LogPublisher.java
New file
@@ -0,0 +1,113 @@
/*
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * 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
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  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 2008-2009 Sun Microsystems, Inc.
 *      Portions copyright 2011-2013 ForgeRock AS.
 */
package org.opends.server.api;
import java.io.Closeable;
import java.util.List;
import org.opends.messages.Message;
import org.opends.server.admin.std.server.LogPublisherCfg;
import org.opends.server.config.ConfigException;
import org.opends.server.types.DN;
import org.opends.server.types.InitializationException;
/**
 * This class defines the set of methods and structures that must be implemented
 * for a Directory Server log publisher.
 *
 * @param <T>
 *          The type of log publisher configuration handled by this log
 *          publisher implementation.
 */
@org.opends.server.types.PublicAPI(
    stability = org.opends.server.types.StabilityLevel.VOLATILE,
    mayInstantiate = false,
    mayExtend = true,
    mayInvoke = false)
public interface LogPublisher<T extends LogPublisherCfg> extends Closeable
{
  /**
   * Initializes this publisher provider based on the information in the
   * provided debug publisher configuration.
   *
   * @param config
   *          The publisher configuration that contains the information to use
   *          to initialize this publisher.
   * @throws ConfigException
   *           If an unrecoverable problem arises in the process of performing
   *           the initialization as a result of the server configuration.
   * @throws InitializationException
   *           If a problem occurs during initialization that is not related to
   *           the server configuration.
   */
  void initializeLogPublisher(T config) throws ConfigException,
      InitializationException;
  /**
   * Indicates whether the provided configuration is acceptable for this log
   * publisher. It should be possible to call this method on an uninitialized
   * log publisher instance in order to determine whether the log publisher
   * would be able to use the provided configuration.
   * <BR><BR>
   * Note that implementations which use a subclass of the provided
   * configuration class will likely need to cast the configuration to the
   * appropriate subclass type.
   *
   * @param configuration
   *          The log publisher configuration for which to make the
   *          determination.
   * @param unacceptableReasons
   *          A list that may be used to hold the reasons that the provided
   *          configuration is not acceptable.
   * @return {@code true} if the provided configuration is acceptable for this
   *         log publisher, or {@code false} if not.
   */
  boolean isConfigurationAcceptable(T configuration,
      List<Message> unacceptableReasons);
  /**
   * Close this publisher.
   */
  @Override
  void close();
  /**
   * Gets the DN of the configuration entry for this log publisher.
   *
   * @return The configuration entry DN.
   */
  DN getDN();
}
opends/src/server/org/opends/server/loggers/AccessLogger.java
@@ -23,38 +23,30 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions copyright 2011 ForgeRock AS.
 *      Portions copyright 2011-2013 ForgeRock AS
 */
package org.opends.server.loggers;
import org.opends.messages.Message;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.server.loggers.debug.DebugLogger.*;
import static org.opends.server.util.StaticUtils.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.List;
import java.util.ArrayList;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import org.opends.server.api.ClientConnection;
import org.opends.server.api.AccessLogPublisher;
import org.opends.server.core.*;
import org.opends.server.types.*;
import org.opends.server.admin.std.server.AccessLogPublisherCfg;
import org.opends.server.admin.std.meta.AccessLogPublisherCfgDefn;
import org.opends.messages.Message;
import org.opends.server.admin.ClassPropertyDefinition;
import org.opends.server.admin.server.ConfigurationAddListener;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.server.ConfigurationDeleteListener;
import org.opends.server.admin.ClassPropertyDefinition;
import org.opends.server.admin.std.meta.AccessLogPublisherCfgDefn;
import org.opends.server.admin.std.server.AccessLogPublisherCfg;
import org.opends.server.api.AccessLogPublisher;
import org.opends.server.api.ClientConnection;
import org.opends.server.config.ConfigException;
import static org.opends.server.loggers.debug.DebugLogger.*;
import org.opends.server.core.*;
import org.opends.server.loggers.debug.DebugTracer;
import static org.opends.messages.ConfigMessages.
    ERR_CONFIG_LOGGER_CANNOT_CREATE_LOGGER;
import static org.opends.messages.ConfigMessages.
    ERR_CONFIG_LOGGER_INVALID_ACCESS_LOGGER_CLASS;
import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString;
import org.opends.server.types.*;
/**
@@ -165,6 +157,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isConfigurationAddAcceptable(
      AccessLogPublisherCfg config,
      List<Message> unacceptableReasons)
@@ -176,6 +169,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isConfigurationChangeAcceptable(
      AccessLogPublisherCfg config,
      List<Message> unacceptableReasons)
@@ -187,6 +181,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public ConfigChangeResult applyConfigurationAdd(AccessLogPublisherCfg config)
  {
    // Default result code.
@@ -232,6 +227,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public ConfigChangeResult applyConfigurationChange(
      AccessLogPublisherCfg config)
  {
@@ -288,6 +284,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isConfigurationDeleteAcceptable(
      AccessLogPublisherCfg config,
      List<Message> unacceptableReasons)
@@ -311,6 +308,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public ConfigChangeResult applyConfigurationDelete(
      AccessLogPublisherCfg config)
  {
@@ -348,13 +346,12 @@
    AccessLogPublisherCfgDefn d = AccessLogPublisherCfgDefn.getInstance();
    ClassPropertyDefinition pd =
        d.getJavaClassPropertyDefinition();
    // Load the class and cast it to a DebugLogPublisher.
    AccessLogPublisher<?> publisher = null;
    Class<? extends AccessLogPublisher<?>> theClass;
    try {
      theClass = (Class<? extends AccessLogPublisher<?>>)
        pd.loadClass(className, AccessLogPublisher.class);
      publisher = theClass.newInstance();
      // Load the class and cast it to a AccessLogPublisher.
      AccessLogPublisher<AccessLogPublisherCfg> publisher =
          pd.loadClass(className, AccessLogPublisher.class).newInstance();
      // The class is valid as far as we can tell.
      return publisher.isConfigurationAcceptable(config, unacceptableReasons);
    } catch (Exception e) {
      Message message = ERR_CONFIG_LOGGER_INVALID_ACCESS_LOGGER_CLASS.get(
          className,
@@ -363,31 +360,6 @@
      unacceptableReasons.add(message);
      return false;
    }
    // Check that the implementation class implements the correct interface.
    try {
      // Determine the initialization method to use: it must take a
      // single parameter which is the exact type of the configuration
      // object.
      Method method = theClass.getMethod("isConfigurationAcceptable",
          AccessLogPublisherCfg.class,
          List.class);
      Boolean acceptable = (Boolean) method.invoke(publisher, config,
          unacceptableReasons);
      if (! acceptable)
      {
        return false;
      }
    } catch (Exception e) {
      Message message = ERR_CONFIG_LOGGER_INVALID_ACCESS_LOGGER_CLASS.get(
          className,
          config.dn().toString(),
          String.valueOf(e));
      unacceptableReasons.add(message);
      return false;
    }
    // The class is valid as far as we can tell.
    return true;
  }
  private AccessLogPublisher<?> getAccessPublisher(AccessLogPublisherCfg config)
@@ -396,29 +368,13 @@
    AccessLogPublisherCfgDefn d = AccessLogPublisherCfgDefn.getInstance();
    ClassPropertyDefinition pd =
        d.getJavaClassPropertyDefinition();
    // Load the class and cast it to a AccessLogPublisher.
    AccessLogPublisher<?> accessLogPublisher;
    try {
      @SuppressWarnings("unchecked")
      Class<? extends AccessLogPublisher<?>> theClass =
        (Class<? extends AccessLogPublisher<?>>) pd
          .loadClass(className, AccessLogPublisher.class);
      accessLogPublisher = theClass.newInstance();
      // Determine the initialization method to use: it must take a
      // single parameter which is the exact type of the configuration
      // object.
      Method method = theClass.getMethod("initializeAccessLogPublisher", config
          .configurationClass());
      method.invoke(accessLogPublisher, config);
    }
    catch (InvocationTargetException ite)
    {
      // Rethrow the exceptions thrown be the invoked method.
      Throwable e = ite.getTargetException();
      Message message = ERR_CONFIG_LOGGER_INVALID_ACCESS_LOGGER_CLASS.get(
          className, config.dn().toString(), stackTraceToSingleLineString(e));
      throw new ConfigException(message, e);
      // Load the class and cast it to a AccessLogPublisher.
      AccessLogPublisher<AccessLogPublisherCfg> accessLogPublisher =
          pd.loadClass(className, AccessLogPublisher.class).newInstance();
      accessLogPublisher.initializeLogPublisher(config);
      // The access publisher has been successfully initialized.
      return accessLogPublisher;
    }
    catch (Exception e)
    {
@@ -426,9 +382,6 @@
          className, config.dn().toString(), String.valueOf(e));
      throw new ConfigException(message, e);
    }
    // The access publisher has been successfully initialized.
    return accessLogPublisher;
  }
opends/src/server/org/opends/server/loggers/ErrorLogger.java
@@ -23,34 +23,37 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions copyright 2013 ForgeRock AS
 */
package org.opends.server.loggers;
import org.opends.messages.Message;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.List;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.server.loggers.debug.DebugLogger.*;
import static org.opends.server.util.StaticUtils.*;
import java.util.ArrayList;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import org.opends.messages.Message;
import org.opends.server.admin.ClassPropertyDefinition;
import org.opends.server.admin.server.ConfigurationAddListener;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.server.ConfigurationDeleteListener;
import org.opends.server.admin.std.meta.ErrorLogPublisherCfgDefn;
import org.opends.server.admin.std.server.ErrorLogPublisherCfg;
import org.opends.server.api.DirectoryThread;
import org.opends.server.api.ErrorLogPublisher;
import org.opends.server.backends.task.Task;
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.types.*;
import org.opends.server.admin.std.server.ErrorLogPublisherCfg;
import org.opends.server.admin.std.meta.ErrorLogPublisherCfgDefn;
import org.opends.server.admin.server.ConfigurationAddListener;
import org.opends.server.admin.server.ConfigurationDeleteListener;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.ClassPropertyDefinition;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.loggers.debug.DebugTracer;
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 static org.opends.server.loggers.debug.DebugLogger.*;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.server.util.StaticUtils.*;
/**
 * This class defines the wrapper that will invoke all registered error loggers
 * for each type of request received or response sent. If no error log
@@ -158,6 +161,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isConfigurationAddAcceptable(ErrorLogPublisherCfg config,
                                              List<Message> unacceptableReasons)
  {
@@ -168,6 +172,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isConfigurationChangeAcceptable(
          ErrorLogPublisherCfg config,
          List<Message> unacceptableReasons)
@@ -179,6 +184,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public ConfigChangeResult applyConfigurationAdd(ErrorLogPublisherCfg config)
  {
    // Default result code.
@@ -223,6 +229,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public ConfigChangeResult applyConfigurationChange(
      ErrorLogPublisherCfg config)
  {
@@ -279,6 +286,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isConfigurationDeleteAcceptable(
          ErrorLogPublisherCfg config,
          List<Message> unacceptableReasons)
@@ -301,6 +309,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public ConfigChangeResult applyConfigurationDelete(
      ErrorLogPublisherCfg config)
  {
@@ -337,12 +346,12 @@
    ErrorLogPublisherCfgDefn d = ErrorLogPublisherCfgDefn.getInstance();
    ClassPropertyDefinition pd =
        d.getJavaClassPropertyDefinition();
    // Load the class and cast it to a DebugLogPublisher.
    ErrorLogPublisher publisher = null;
    Class<? extends ErrorLogPublisher> theClass;
    try {
      theClass = pd.loadClass(className, ErrorLogPublisher.class);
      publisher = theClass.newInstance();
      // Load the class and cast it to a ErrorLogPublisher.
      ErrorLogPublisher<ErrorLogPublisherCfg> publisher =
          pd.loadClass(className, ErrorLogPublisher.class).newInstance();
      // The class is valid as far as we can tell.
      return publisher.isConfigurationAcceptable(config, unacceptableReasons);
    } catch (Exception e) {
      Message message = ERR_CONFIG_LOGGER_INVALID_ERROR_LOGGER_CLASS.get(
              className,
@@ -351,31 +360,6 @@
      unacceptableReasons.add(message);
      return false;
    }
    // Check that the implementation class implements the correct interface.
    try {
      // Determine the initialization method to use: it must take a
      // single parameter which is the exact type of the configuration
      // object.
      Method method = theClass.getMethod("isConfigurationAcceptable",
                                         ErrorLogPublisherCfg.class,
                                         List.class);
      Boolean acceptable = (Boolean) method.invoke(publisher, config,
                                                   unacceptableReasons);
      if (! acceptable)
      {
        return false;
      }
    } catch (Exception e) {
      Message message = ERR_CONFIG_LOGGER_INVALID_ERROR_LOGGER_CLASS.get(
              className,
              config.dn().toString(),
              String.valueOf(e));
      unacceptableReasons.add(message);
      return false;
    }
    // The class is valid as far as we can tell.
    return true;
  }
  private ErrorLogPublisher getErrorPublisher(ErrorLogPublisherCfg config)
@@ -384,27 +368,13 @@
    ErrorLogPublisherCfgDefn d = ErrorLogPublisherCfgDefn.getInstance();
    ClassPropertyDefinition pd =
        d.getJavaClassPropertyDefinition();
    // Load the class and cast it to a ErrorLogPublisher.
    Class<? extends ErrorLogPublisher> theClass;
    ErrorLogPublisher errorLogPublisher;
    try {
      theClass = pd.loadClass(className, ErrorLogPublisher.class);
      errorLogPublisher = theClass.newInstance();
      // Determine the initialization method to use: it must take a
      // single parameter which is the exact type of the configuration
      // object.
      Method method = theClass.getMethod("initializeErrorLogPublisher", config
          .configurationClass());
      method.invoke(errorLogPublisher, config);
    }
    catch (InvocationTargetException ite)
    {
      // Rethrow the exceptions thrown be the invoked method.
      Throwable e = ite.getTargetException();
      Message message = ERR_CONFIG_LOGGER_INVALID_ERROR_LOGGER_CLASS.get(
          className, config.dn().toString(), stackTraceToSingleLineString(e));
      throw new ConfigException(message, e);
      // Load the class and cast it to a ErrorLogPublisher.
      ErrorLogPublisher<ErrorLogPublisherCfg> errorLogPublisher =
          pd.loadClass(className, ErrorLogPublisher.class).newInstance();
      errorLogPublisher.initializeLogPublisher(config);
      // The error publisher has been successfully initialized.
      return errorLogPublisher;
    }
    catch (Exception e)
    {
@@ -412,9 +382,6 @@
          className, config.dn().toString(), String.valueOf(e));
      throw new ConfigException(message, e);
    }
    // The error publisher has been successfully initialized.
    return errorLogPublisher;
  }
opends/src/server/org/opends/server/loggers/TextAccessLogPublisher.java
@@ -262,9 +262,8 @@
   * {@inheritDoc}
   */
  @Override
  public void initializeAccessLogPublisher(
      final FileBasedAccessLogPublisherCfg cfg) throws ConfigException,
      InitializationException
  public void initializeLogPublisher(final FileBasedAccessLogPublisherCfg cfg)
      throws ConfigException, InitializationException
  {
    final File logFile = getFileForPath(cfg.getLogFile());
    final FileNamingPolicy fnPolicy = new TimeStampNaming(logFile);
opends/src/server/org/opends/server/loggers/TextAuditLogPublisher.java
@@ -23,18 +23,16 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions copyright 2011 ForgeRock AS.
 *      Portions copyright 2011-2013 ForgeRock AS.
 */
package org.opends.server.loggers;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.server.types.ResultCode.SUCCESS;
import static org.opends.server.util.ServerConstants.EOL;
import static org.opends.server.util.StaticUtils.getBytes;
import static org.opends.server.util.StaticUtils.getFileForPath;
import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString;
import static org.opends.server.types.ResultCode.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.File;
import java.io.IOException;
@@ -71,6 +69,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public ConfigChangeResult applyConfigurationChange(
      FileBasedAuditLogPublisherCfg config)
  {
@@ -184,7 +183,7 @@
   * {@inheritDoc}
   */
  @Override()
  public void initializeAccessLogPublisher(FileBasedAuditLogPublisherCfg cfg)
  public void initializeLogPublisher(FileBasedAuditLogPublisherCfg cfg)
      throws ConfigException, InitializationException
  {
    File logFile = getFileForPath(cfg.getLogFile());
@@ -267,6 +266,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isConfigurationChangeAcceptable(
      FileBasedAuditLogPublisherCfg config, List<Message> unacceptableReasons)
  {
opends/src/server/org/opends/server/loggers/TextErrorLogPublisher.java
@@ -23,32 +23,29 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions copyright 2012 ForgeRock AS.
 *      Portions copyright 2012-2013 ForgeRock AS.
 */
package org.opends.server.loggers;
import org.opends.messages.Message;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.messages.LoggerMessages.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.File;
import java.io.IOException;
import java.util.*;
import org.opends.server.api.*;
import org.opends.server.core.DirectoryServer;
import org.opends.server.config.ConfigException;
import org.opends.server.types.*;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.messages.LoggerMessages.*;
import org.opends.messages.Severity;
import org.opends.messages.Category;
import org.opends.server.admin.std.server.ErrorLogPublisherCfg;
import org.opends.server.admin.std.server.FileBasedErrorLogPublisherCfg;
import org.opends.server.admin.std.meta.ErrorLogPublisherCfgDefn;
import org.opends.messages.Message;
import org.opends.messages.Severity;
import org.opends.server.admin.server.ConfigurationChangeListener;
import static org.opends.server.util.StaticUtils.getFileForPath;
import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString;
import org.opends.server.admin.std.meta.ErrorLogPublisherCfgDefn;
import org.opends.server.admin.std.server.FileBasedErrorLogPublisherCfg;
import org.opends.server.api.ErrorLogPublisher;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.types.*;
import org.opends.server.util.TimeThread;
import static org.opends.server.util.ServerConstants.*;
/**
@@ -112,7 +109,8 @@
  /**
   * {@inheritDoc}
   */
  public void initializeErrorLogPublisher(FileBasedErrorLogPublisherCfg config)
  @Override
  public void initializeLogPublisher(FileBasedErrorLogPublisherCfg config)
      throws ConfigException, InitializationException
  {
    File logFile = getFileForPath(config.getLogFile());
@@ -292,18 +290,16 @@
   * {@inheritDoc}
   */
  @Override()
  public boolean isConfigurationAcceptable(ErrorLogPublisherCfg configuration,
                                           List<Message> unacceptableReasons)
  public boolean isConfigurationAcceptable(
      FileBasedErrorLogPublisherCfg config, List<Message> unacceptableReasons)
  {
    FileBasedErrorLogPublisherCfg config =
         (FileBasedErrorLogPublisherCfg) configuration;
    return isConfigurationChangeAcceptable(config, unacceptableReasons);
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isConfigurationChangeAcceptable(
      FileBasedErrorLogPublisherCfg config, List<Message> unacceptableReasons)
  {
@@ -384,6 +380,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public ConfigChangeResult applyConfigurationChange(
      FileBasedErrorLogPublisherCfg config)
  {
@@ -591,6 +588,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void close()
  {
    writer.shutdown();
@@ -605,12 +603,13 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void logError(Message message)
  {
    Severity severity = message.getDescriptor().getSeverity();
    Category category = message.getDescriptor().getCategory();
    int msgId = message.getDescriptor().getId();
    HashSet<Severity> severities = definedSeverities.get(category);
    Set<Severity> severities = definedSeverities.get(category);
    if(severities == null)
    {
      severities = defaultSeverities;
@@ -634,6 +633,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public DN getDN()
  {
    if(currentConfig != null)
opends/src/server/org/opends/server/loggers/ThreadFilterTextErrorLogPublisher.java
@@ -23,19 +23,20 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2013 ForgeRock AS
 */
package org.opends.server.loggers;
import org.opends.server.types.InitializationException;
import org.opends.server.types.DN;
import org.opends.server.admin.std.server.ErrorLogPublisherCfg;
import org.opends.server.config.ConfigException;
import org.opends.server.api.ErrorLogPublisher;
import org.opends.server.util.TimeThread;
import org.opends.messages.Category;
import org.opends.messages.Message;
import org.opends.messages.Severity;
import org.opends.messages.Category;
import org.opends.server.admin.std.server.ErrorLogPublisherCfg;
import org.opends.server.api.ErrorLogPublisher;
import org.opends.server.config.ConfigException;
import org.opends.server.types.DN;
import org.opends.server.types.InitializationException;
import org.opends.server.util.TimeThread;
/**
 * This class provides an implementation of an error logger where only messages
@@ -64,7 +65,8 @@
  /**
   * {@inheritDoc}
   */
  public void initializeErrorLogPublisher(ErrorLogPublisherCfg config)
  @Override
  public void initializeLogPublisher(ErrorLogPublisherCfg config)
      throws ConfigException, InitializationException
  {
    // This class should only be used internally in the server and not be
@@ -74,6 +76,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void close()
  {
    writer.shutdown();
@@ -82,6 +85,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void logError(Message message)
  {
    if (message != null) {
@@ -108,6 +112,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public DN getDN()
  {
    // This class should only be used internally in the server and not be
opends/src/server/org/opends/server/loggers/debug/DebugLogger.java
@@ -23,32 +23,33 @@
 *
 *
 *      Copyright 2007-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2013 ForgeRock AS
 */
package org.opends.server.loggers.debug;
import org.opends.messages.Message;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.server.util.StaticUtils.*;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.CopyOnWriteArrayList;
import org.opends.server.api.DebugLogPublisher;
import org.opends.server.loggers.*;
import org.opends.server.types.*;
import org.opends.server.admin.std.server.DebugLogPublisherCfg;
import org.opends.server.admin.std.meta.DebugLogPublisherCfgDefn;
import org.opends.messages.Message;
import org.opends.server.admin.ClassPropertyDefinition;
import org.opends.server.admin.server.ConfigurationAddListener;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.server.ConfigurationDeleteListener;
import org.opends.server.admin.ClassPropertyDefinition;
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.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.server.util.StaticUtils.*;
import org.opends.server.loggers.LogLevel;
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;
/**
 * A logger for debug and trace logging. DebugLogger provides a debugging
@@ -182,6 +183,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isConfigurationAddAcceptable(DebugLogPublisherCfg config,
                                              List<Message> unacceptableReasons)
  {
@@ -192,6 +194,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isConfigurationChangeAcceptable(DebugLogPublisherCfg config,
                                              List<Message> unacceptableReasons)
  {
@@ -202,6 +205,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public ConfigChangeResult applyConfigurationAdd(DebugLogPublisherCfg config)
  {
    // Default result code.
@@ -240,6 +244,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public ConfigChangeResult applyConfigurationChange(
      DebugLogPublisherCfg config)
  {
@@ -295,6 +300,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isConfigurationDeleteAcceptable(DebugLogPublisherCfg config,
                                             List<Message> unacceptableReasons)
  {
@@ -310,12 +316,12 @@
    }
    return debugLogPublisher != null;
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public ConfigChangeResult
         applyConfigurationDelete(DebugLogPublisherCfg config)
  {
@@ -351,12 +357,12 @@
    DebugLogPublisherCfgDefn d = DebugLogPublisherCfgDefn.getInstance();
    ClassPropertyDefinition pd =
        d.getJavaClassPropertyDefinition();
    // Load the class and cast it to a DebugLogPublisher.
    DebugLogPublisher publisher = null;
    Class<? extends DebugLogPublisher> theClass;
    try {
      theClass = pd.loadClass(className, DebugLogPublisher.class);
      publisher = theClass.newInstance();
      // Load the class and cast it to a DebugLogPublisher.
      DebugLogPublisher<DebugLogPublisherCfg> publisher =
          pd.loadClass(className, DebugLogPublisher.class).newInstance();
      // The class is valid as far as we can tell.
      return publisher.isConfigurationAcceptable(config, unacceptableReasons);
    } catch (Exception e) {
      Message message = ERR_CONFIG_LOGGER_INVALID_DEBUG_LOGGER_CLASS.get(
              className,
@@ -365,31 +371,6 @@
      unacceptableReasons.add(message);
      return false;
    }
    // Check that the implementation class implements the correct interface.
    try {
      // Determine the initialization method to use: it must take a
      // single parameter which is the exact type of the configuration
      // object.
      Method method = theClass.getMethod("isConfigurationAcceptable",
                                         DebugLogPublisherCfg.class,
                                         List.class);
      Boolean acceptable = (Boolean) method.invoke(publisher, config,
                                                   unacceptableReasons);
      if (! acceptable)
      {
        return false;
      }
    } catch (Exception e) {
      Message message = ERR_CONFIG_LOGGER_INVALID_DEBUG_LOGGER_CLASS.get(
              className,
              config.dn().toString(),
              String.valueOf(e));
      unacceptableReasons.add(message);
      return false;
    }
    // The class is valid as far as we can tell.
    return true;
  }
  private DebugLogPublisher getDebugPublisher(DebugLogPublisherCfg config)
@@ -398,27 +379,13 @@
    DebugLogPublisherCfgDefn d = DebugLogPublisherCfgDefn.getInstance();
    ClassPropertyDefinition pd =
        d.getJavaClassPropertyDefinition();
    // Load the class and cast it to a DebugLogPublisher.
    Class<? extends DebugLogPublisher> theClass;
    DebugLogPublisher debugLogPublisher;
    try {
      theClass = pd.loadClass(className, DebugLogPublisher.class);
      debugLogPublisher = theClass.newInstance();
      // Determine the initialization method to use: it must take a
      // single parameter which is the exact type of the configuration
      // object.
      Method method = theClass.getMethod("initializeDebugLogPublisher", config
          .configurationClass());
      method.invoke(debugLogPublisher, config);
    }
    catch (InvocationTargetException ite)
    {
      // Rethrow the exceptions thrown be the invoked method.
      Throwable e = ite.getTargetException();
      Message message = ERR_CONFIG_LOGGER_INVALID_DEBUG_LOGGER_CLASS.get(
          className, config.dn().toString(), stackTraceToSingleLineString(e));
      throw new ConfigException(message, e);
      // Load the class and cast it to a DebugLogPublisher.
      DebugLogPublisher<DebugLogPublisherCfg> debugLogPublisher =
          pd.loadClass(className, DebugLogPublisher.class).newInstance();
      debugLogPublisher.initializeLogPublisher(config);
      // The debug publisher has been successfully initialized.
      return debugLogPublisher;
    }
    catch (Exception e)
    {
@@ -426,9 +393,6 @@
          className, config.dn().toString(), String.valueOf(e));
      throw new ConfigException(message, e);
    }
    // The debug publisher has been successfully initialized.
    return debugLogPublisher;
  }
  /**
opends/src/server/org/opends/server/loggers/debug/TextDebugLogPublisher.java
@@ -23,41 +23,38 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2013 ForgeRock AS
 */
package org.opends.server.loggers.debug;
import org.opends.messages.Message;
import org.opends.server.api.*;
import static org.opends.messages.ConfigMessages.*;
import static org.opends.server.util.ServerConstants.*;
import static org.opends.server.util.StaticUtils.*;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.opends.messages.Message;
import org.opends.server.admin.server.ConfigurationAddListener;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.server.ConfigurationDeleteListener;
import org.opends.server.admin.std.meta.DebugLogPublisherCfgDefn;
import org.opends.server.admin.std.server.DebugTargetCfg;
import org.opends.server.admin.std.server.FileBasedDebugLogPublisherCfg;
import org.opends.server.api.DebugLogPublisher;
import org.opends.server.api.DirectoryThread;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import org.opends.server.loggers.*;
import org.opends.server.types.*;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.StaticUtils;
import org.opends.server.util.TimeThread;
import static org.opends.server.util.StaticUtils.stackTraceToSingleLineString;
import static org.opends.server.util.StaticUtils.getFileForPath;
import static org.opends.server.util.ServerConstants.PROPERTY_DEBUG_TARGET;
import org.opends.server.admin.std.server.DebugTargetCfg;
import org.opends.server.admin.std.server.FileBasedDebugLogPublisherCfg;
import org.opends.server.admin.std.server.DebugLogPublisherCfg;
import org.opends.server.admin.std.meta.DebugLogPublisherCfgDefn;
import org.opends.server.admin.server.ConfigurationChangeListener;
import org.opends.server.admin.server.ConfigurationDeleteListener;
import org.opends.server.admin.server.ConfigurationAddListener;
import org.opends.server.config.ConfigException;
import org.opends.server.core.DirectoryServer;
import static org.opends.messages.ConfigMessages.
    ERR_CONFIG_LOGGING_CANNOT_CREATE_WRITER;
import static org.opends.messages.ConfigMessages.
   ERR_CONFIG_LOGGING_CANNOT_OPEN_FILE;
import static org.opends.messages.ConfigMessages.
    ERR_CONFIG_LOGGING_INSANE_MODE;
import static org.opends.messages.ConfigMessages.
    ERR_CONFIG_LOGGING_MODE_INVALID;
import java.util.*;
import java.io.File;
import java.io.IOException;
import com.sleepycat.je.*;
@@ -125,18 +122,18 @@
  /**
   * {@inheritDoc}
   */
  public boolean isConfigurationAcceptable(DebugLogPublisherCfg configuration,
                                           List<Message> unacceptableReasons)
  @Override
  public boolean isConfigurationAcceptable(
      FileBasedDebugLogPublisherCfg config, List<Message> unacceptableReasons)
  {
    FileBasedDebugLogPublisherCfg config =
        (FileBasedDebugLogPublisherCfg) configuration;
    return isConfigurationChangeAcceptable(config, unacceptableReasons);
  }
  /**
   * {@inheritDoc}
   */
  public void initializeDebugLogPublisher(FileBasedDebugLogPublisherCfg config)
  @Override
  public void initializeLogPublisher(FileBasedDebugLogPublisherCfg config)
      throws ConfigException, InitializationException
  {
    File logFile = getFileForPath(config.getLogFile());
@@ -247,6 +244,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isConfigurationChangeAcceptable(
      FileBasedDebugLogPublisherCfg config, List<Message> unacceptableReasons)
  {
@@ -277,6 +275,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public ConfigChangeResult applyConfigurationChange(
      FileBasedDebugLogPublisherCfg config)
  {
@@ -403,6 +402,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isConfigurationAddAcceptable(DebugTargetCfg config,
                                              List<Message> unacceptableReasons)
  {
@@ -412,6 +412,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public boolean isConfigurationDeleteAcceptable(DebugTargetCfg config,
                                              List<Message> unacceptableReasons)
  {
@@ -422,6 +423,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public ConfigChangeResult applyConfigurationAdd(DebugTargetCfg config)
  {
    // Default result code.
@@ -439,6 +441,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public ConfigChangeResult applyConfigurationDelete(DebugTargetCfg config)
  {
    // Default result code.
@@ -456,6 +459,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void traceConstructor(LogLevel level,
                               TraceSettings settings,
                               String signature,
@@ -483,6 +487,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void traceMethodEntry(LogLevel level,
                               TraceSettings settings,
                               String signature,
@@ -510,6 +515,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void traceStaticMethodEntry(LogLevel level,
                                     TraceSettings settings,
                                     String signature,
@@ -536,6 +542,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void traceReturn(LogLevel level,
                          TraceSettings settings,
                          String signature,
@@ -563,6 +570,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void traceThrown(LogLevel level,
                          TraceSettings settings,
                          String signature,
@@ -588,6 +596,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void traceMessage(LogLevel level,
                           TraceSettings settings,
                           String signature,
@@ -609,6 +618,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void traceCaught(LogLevel level,
                          TraceSettings settings,
                          String signature,
@@ -633,6 +643,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void traceJEAccess(LogLevel level,
                            TraceSettings settings,
                            String signature,
@@ -709,6 +720,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void traceData(LogLevel level,
                        TraceSettings settings,
                        String signature,
@@ -741,6 +753,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void traceProtocolElement(LogLevel level,
                                   TraceSettings settings,
                                   String signature,
@@ -767,6 +780,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void close()
  {
    writer.shutdown();
@@ -862,6 +876,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public DN getDN()
  {
    if(currentConfig != null)
opends/src/server/org/opends/server/tools/ConsoleDebugLogPublisher.java
@@ -23,33 +23,36 @@
 *
 *
 *      Copyright 2006-2009 Sun Microsystems, Inc.
 *      Portions Copyright 2013 ForgeRock AS
 */
package org.opends.server.tools;
import org.opends.server.api.DebugLogPublisher;
import org.opends.server.loggers.LogLevel;
import org.opends.server.loggers.LogCategory;
import org.opends.server.loggers.debug.TraceSettings;
import org.opends.server.loggers.debug.DebugStackTraceFormatter;
import org.opends.server.loggers.debug.DebugMessageFormatter;
import org.opends.server.types.DebugLogCategory;
import org.opends.server.types.DN;
import org.opends.server.types.InitializationException;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.StaticUtils;
import org.opends.server.admin.std.server.DebugLogPublisherCfg;
import org.opends.server.config.ConfigException;
import com.sleepycat.je.*;
import java.io.PrintStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import org.opends.server.admin.std.server.DebugLogPublisherCfg;
import org.opends.server.api.DebugLogPublisher;
import org.opends.server.config.ConfigException;
import org.opends.server.loggers.LogCategory;
import org.opends.server.loggers.LogLevel;
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.types.DN;
import org.opends.server.types.DebugLogCategory;
import org.opends.server.types.InitializationException;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.StaticUtils;
import com.sleepycat.je.*;
/**
 * The debug log publisher implementation that writes debug messages in a
 * friendly for console output.
 */
public class ConsoleDebugLogPublisher extends DebugLogPublisher
public class ConsoleDebugLogPublisher extends
    DebugLogPublisher<DebugLogPublisherCfg>
{
  /**
   * The print stream where tracing will be sent.
@@ -74,14 +77,16 @@
  /**
   * {@inheritDoc}
   */
  public void initializeDebugLogPublisher(DebugLogPublisherCfg config)
  @Override
  public void initializeLogPublisher(DebugLogPublisherCfg config)
      throws ConfigException, InitializationException {
    // This pubisher is not configurable.
    // This publisher is not configurable.
  }
  /**
   * {@inheritDoc}
   */
  @Override
  public void traceConstructor(LogLevel level,
                               TraceSettings settings,
                               String signature,
@@ -109,6 +114,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void traceMethodEntry(LogLevel level,
                               TraceSettings settings,
                               String signature,
@@ -136,6 +142,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void traceStaticMethodEntry(LogLevel level,
                                     TraceSettings settings,
                                     String signature,
@@ -162,6 +169,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void traceReturn(LogLevel level,
                          TraceSettings settings,
                          String signature,
@@ -195,6 +203,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void traceThrown(LogLevel level,
                          TraceSettings settings,
                          String signature,
@@ -226,6 +235,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void traceMessage(LogLevel level,
                           TraceSettings settings,
                           String signature,
@@ -247,6 +257,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void traceCaught(LogLevel level,
                          TraceSettings settings,
                          String signature,
@@ -278,6 +289,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void traceJEAccess(LogLevel level,
                            TraceSettings settings,
                            String signature,
@@ -353,6 +365,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void traceData(LogLevel level,
                        TraceSettings settings,
                        String signature,
@@ -384,6 +397,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void traceProtocolElement(LogLevel level,
                                   TraceSettings settings,
                                   String signature,
@@ -405,6 +419,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public void close()
  {
    // Nothing to do.
@@ -465,6 +480,7 @@
  /**
   * {@inheritDoc}
   */
  @Override
  public DN getDN()
  {
    // There is no configuration DN associated with this publisher.