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

Jean-Noël Rouvignac
31.51.2016 0b1d47206c74ddfdcbf60b81b30ef24f59aa56d0
AutoRefactor'ed code in loggers
14 files modified
98 ■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/loggers/CommonAudit.java 20 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/loggers/CommonAuditAccessLogPublisher.java 7 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/loggers/CommonAuditDependencyProvider.java 8 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/loggers/CommonAuditHTTPAccessLogPublisher.java 2 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/loggers/CommonAuditLogPublisher.java 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/loggers/CsvFileAccessLogPublisher.java 5 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/loggers/DebugLogPublisher.java 14 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/loggers/DebugStackTraceFormatter.java 2 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/loggers/ExternalAccessLogPublisher.java 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/loggers/GZIPAction.java 4 ●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/loggers/HTTPRequestInfo.java 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/loggers/JsonFileAccessLogPublisher.java 5 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/loggers/PostRotationAction.java 7 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/loggers/RotatableLogFile.java 6 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/loggers/CommonAudit.java
@@ -82,7 +82,6 @@
import org.forgerock.opendj.server.config.server.SizeLimitLogRotationPolicyCfg;
import org.forgerock.opendj.server.config.server.TimeLimitLogRotationPolicyCfg;
import org.opends.server.core.ServerContext;
import org.opends.server.util.StaticUtils;
/**
 * Entry point for the common audit facility.
@@ -352,7 +351,6 @@
    {
      return existingAuditServiceProxy;
    }
  }
  private AuditServiceProxy buildAuditService(AuditServiceSetup setup)
@@ -564,7 +562,7 @@
      else if (policyConfig instanceof TimeLimitLogRotationPolicyCfg)
      {
        long rotationInterval = ((TimeLimitLogRotationPolicyCfg) policyConfig).getRotationInterval();
        fileRotation.setRotationInterval(String.valueOf(rotationInterval) + " ms");
        fileRotation.setRotationInterval(rotationInterval + " ms");
      }
      else
      {
@@ -626,12 +624,12 @@
      try
      {
        int time = Integer.valueOf(timeOfDay.substring(0, 2)) * 60 + Integer.valueOf(timeOfDay.substring(2, 4));
        times.add(String.valueOf(time) + " minutes");
        times.add(time + " minutes");
      }
      catch (NumberFormatException | IndexOutOfBoundsException e)
      {
        throw new ConfigException(ERR_COMMON_AUDIT_INVALID_TIME_OF_DAY.get(publisher.getDn(), timeOfDay,
            StaticUtils.stackTraceToSingleLineString(e)));
        throw new ConfigException(ERR_COMMON_AUDIT_INVALID_TIME_OF_DAY.get(
            publisher.getDn(), timeOfDay, stackTraceToSingleLineString(e)));
      }
    }
    return times;
@@ -826,7 +824,6 @@
    {
      return config.dn().hashCode();
    }
  }
  /** Types of audit handlers managed. */
@@ -835,7 +832,7 @@
    CSV, JSON, EXTERNAL
  }
  /** Log types for LDAP or HTTP, to get specific configuration depending on the handler. **/
  /** Log types for LDAP or HTTP, to get specific configuration depending on the handler. */
  private enum LogType
  {
    UNCONFIGURED
@@ -961,7 +958,7 @@
   * a common ancestor with all the parameters (e.g Access Log, HTTP Access Log, ...), hence this class
   * is necessary to avoid duplicating code that setup configuration of the handler.
   */
  private abstract static class HandlerConfigData
  private static abstract class HandlerConfigData
  {
    private final String logDirectory;
    private final SortedSet<String> rotationPolicies;
@@ -990,9 +987,7 @@
    }
  }
  /**
   * Contains common parameters for the Json handler.
   */
  /** Contains common parameters for the Json handler. */
  private static class JsonConfigData extends HandlerConfigData
  {
    JsonConfigData(String logDirectory, SortedSet<String> rotationPolicies, SortedSet<String> retentionPolicies)
@@ -1112,5 +1107,4 @@
      return configurationFile;
    }
  }
}
opendj-server-legacy/src/main/java/org/opends/server/loggers/CommonAuditAccessLogPublisher.java
@@ -73,7 +73,6 @@
  extends AbstractTextAccessLogPublisher<T>
  implements CommonAuditLogPublisher
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  /** Audit service handler. */
@@ -238,7 +237,7 @@
        .client(clientConnection.getClientAddress(), clientConnection.getClientPort())
        .server(clientConnection.getServerAddress(), clientConnection.getServerPort())
        .request(clientConnection.getProtocol(), "CONNECT")
        .transactionId(CommonAudit.DEFAULT_TRANSACTION_ID)
        .transactionId(DEFAULT_TRANSACTION_ID)
        .response(ResponseStatus.SUCCESSFUL, String.valueOf(ResultCode.SUCCESS.intValue()), 0, TimeUnit.MILLISECONDS)
        .ldapConnectionId(clientConnection.getConnectionID());
@@ -273,7 +272,7 @@
        .client(clientConnection.getClientAddress(), clientConnection.getClientPort())
        .server(clientConnection.getServerAddress(), clientConnection.getServerPort())
        .request(clientConnection.getProtocol(), "DISCONNECT")
        .transactionId(CommonAudit.DEFAULT_TRANSACTION_ID)
        .transactionId(DEFAULT_TRANSACTION_ID)
        .response(ResponseStatus.SUCCESSFUL, String.valueOf(ResultCode.SUCCESS.intValue()), 0, TimeUnit.MILLISECONDS)
        .ldapConnectionId(clientConnection.getConnectionID())
        .ldapReason(disconnectReason)
@@ -389,7 +388,6 @@
    builder.ldapAuthType(authType);
    builder.ldapDn(bindOperation.getRawBindDN().toString());
  }
  private void appendCompareRequest(final CompareOperation compareOperation,
@@ -533,5 +531,4 @@
          }
        });
  }
}
opendj-server-legacy/src/main/java/org/opends/server/loggers/CommonAuditDependencyProvider.java
@@ -23,12 +23,9 @@
import org.forgerock.audit.providers.ProductInfoProvider;
import org.opends.server.util.DynamicConstants;
/**
 * Simple implementation of dependency provider for common audit.
 */
/** Simple implementation of dependency provider for common audit. */
class CommonAuditDependencyProvider implements DependencyProvider
{
  @Override
  public <T> T getDependency(Class<T> clazz) throws ClassNotFoundException
  {
@@ -63,13 +60,10 @@
  /** DJ implementation for ProductInfoProvider. */
  private static class DJProductInfoProvider implements ProductInfoProvider
  {
    @Override
    public String getProductName()
    {
      return DynamicConstants.PRODUCT_NAME;
    }
  }
}
opendj-server-legacy/src/main/java/org/opends/server/loggers/CommonAuditHTTPAccessLogPublisher.java
@@ -37,7 +37,6 @@
  extends HTTPAccessLogPublisher<T>
  implements CommonAuditLogPublisher, ConfigurationChangeListener<T>
{
  /** Current configuration for this publisher. */
  private T config;
@@ -95,5 +94,4 @@
  {
    // nothing to do
  }
}
opendj-server-legacy/src/main/java/org/opends/server/loggers/CommonAuditLogPublisher.java
@@ -17,12 +17,9 @@
import org.forgerock.json.resource.RequestHandler;
/**
 * Common interface for all log publisher that log to Common Audit.
 */
/** Common interface for all log publisher that log to Common Audit. */
interface CommonAuditLogPublisher
{
  /**
   * Sets the handler to use for publishing audit events.
   *
@@ -30,5 +27,4 @@
   *          The common audit handler accepting requests.
   */
  void setRequestHandler(RequestHandler handler);
}
opendj-server-legacy/src/main/java/org/opends/server/loggers/CsvFileAccessLogPublisher.java
@@ -31,14 +31,11 @@
import org.forgerock.opendj.config.server.ConfigurationChangeListener;
import org.forgerock.opendj.server.config.server.CsvFileAccessLogPublisherCfg;
/**
 * Common Audit publisher which publishes access events to CSV files.
 */
/** Common Audit publisher which publishes access events to CSV files. */
final class CsvFileAccessLogPublisher
  extends CommonAuditAccessLogPublisher<CsvFileAccessLogPublisherCfg>
  implements ConfigurationChangeListener<CsvFileAccessLogPublisherCfg>
{
  @Override
  boolean shouldLogControlOids()
  {
opendj-server-legacy/src/main/java/org/opends/server/loggers/DebugLogPublisher.java
@@ -84,21 +84,11 @@
   *         or {@code null} if no method-level tracing is configured
   *         for the scope.
   */
  final Map<String,TraceSettings> getMethodSettings(
                                              String className)
  final Map<String, TraceSettings> getMethodSettings(String className)
  {
    if(methodTraceSettings == null)
    {
      return null;
    }
    else
    {
      return methodTraceSettings.get(className);
    }
    return methodTraceSettings != null ? methodTraceSettings.get(className) : null;
  }
  /**
   * Get the trace settings for a specified class.
   *
opendj-server-legacy/src/main/java/org/opends/server/loggers/DebugStackTraceFormatter.java
@@ -48,7 +48,7 @@
  {
    private boolean isFrameForPackage(StackTraceElement frame, String packageName)
    {
      return frame != null ? startsWith(frame.getClassName(), packageName) : false;
      return frame != null && startsWith(frame.getClassName(), packageName);
    }
    private boolean startsWith(String className, String packageName)
opendj-server-legacy/src/main/java/org/opends/server/loggers/ExternalAccessLogPublisher.java
@@ -22,15 +22,11 @@
import org.forgerock.opendj.config.server.ConfigurationChangeListener;
import org.forgerock.opendj.server.config.server.ExternalAccessLogPublisherCfg;
/**
 * Common audit publisher which publishes access events to some external
 * publisher.
 */
/** Common audit publisher which publishes access events to some external publisher. */
final class ExternalAccessLogPublisher
  extends CommonAuditAccessLogPublisher<ExternalAccessLogPublisherCfg>
  implements ConfigurationChangeListener<ExternalAccessLogPublisherCfg>
{
  @Override
  boolean shouldLogControlOids()
  {
opendj-server-legacy/src/main/java/org/opends/server/loggers/GZIPAction.java
@@ -30,10 +30,8 @@
 */
class GZIPAction implements PostRotationAction
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  private File originalFile;
  private File newFile;
  private boolean deleteOriginal;
@@ -74,7 +72,7 @@
      try (FileInputStream fis = new FileInputStream(originalFile);
          FileOutputStream fos = new FileOutputStream(newFile);
          GZIPOutputStream gzip = new GZIPOutputStream(fos);)
          GZIPOutputStream gzip = new GZIPOutputStream(fos))
      {
        byte[] buf = new byte[8192];
        int n;
opendj-server-legacy/src/main/java/org/opends/server/loggers/HTTPRequestInfo.java
@@ -17,12 +17,9 @@
import java.net.URI;
/**
 * Contains the information required for logging the HTTP request.
 */
/** Contains the information required for logging the HTTP request. */
public interface HTTPRequestInfo
{
  /**
   * Returns the server's host.
   *
@@ -145,5 +142,4 @@
   *          the HTTP status code that was returned to the client.
   */
  void log(int statusCode);
}
opendj-server-legacy/src/main/java/org/opends/server/loggers/JsonFileAccessLogPublisher.java
@@ -22,14 +22,11 @@
import java.util.List;
/**
 * Common Audit publisher which publishes access events to Json files.
 */
/** Common Audit publisher which publishes access events to Json files. */
final class JsonFileAccessLogPublisher
  extends CommonAuditAccessLogPublisher<JsonFileAccessLogPublisherCfg>
  implements ConfigurationChangeListener<JsonFileAccessLogPublisherCfg>
{
  @Override
  boolean shouldLogControlOids()
  {
opendj-server-legacy/src/main/java/org/opends/server/loggers/PostRotationAction.java
@@ -16,10 +16,7 @@
 */
package org.opends.server.loggers;
/**
 * This interface describes the action that needs to be taken
 * at the time of a rotation.
 */
/** This interface describes the action that needs to be taken at the time of a rotation. */
interface PostRotationAction
{
  /**
@@ -30,6 +27,4 @@
   *          <CODE>false</CODE> if it was not.
   */
  boolean execute();
}
opendj-server-legacy/src/main/java/org/opends/server/loggers/RotatableLogFile.java
@@ -17,12 +17,9 @@
import java.util.Calendar;
/**
 * Represents a file that can be rotated based on size or on time.
 */
/** Represents a file that can be rotated based on size or on time. */
public interface RotatableLogFile
{
  /**
   * Retrieves the number of bytes written to the file.
   *
@@ -37,5 +34,4 @@
   * @return The last time file rotation occurred.
   */
  Calendar getLastRotationTime();
}