From d755882f59202fe62b2ad5a141b3c044c1898aa6 Mon Sep 17 00:00:00 2001
From: boli <boli@localhost>
Date: Thu, 03 May 2007 21:55:23 +0000
Subject: [PATCH] Major changes made to the logging framework. It should resolve the following issues:

---
 opends/src/server/org/opends/server/loggers/TimeStampNaming.java |   54 ++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 48 insertions(+), 6 deletions(-)

diff --git a/opends/src/server/org/opends/server/loggers/TimeStampNaming.java b/opends/src/server/org/opends/server/loggers/TimeStampNaming.java
index 43a8535..49f14f3 100644
--- a/opends/src/server/org/opends/server/loggers/TimeStampNaming.java
+++ b/opends/src/server/org/opends/server/loggers/TimeStampNaming.java
@@ -29,6 +29,7 @@
 import org.opends.server.util.TimeThread;
 
 import java.io.File;
+import java.io.FilenameFilter;
 
 /**
  * A file name policy that names files suffixed by the time it was created.
@@ -38,6 +39,32 @@
   File file;
 
   /**
+   * The FilenameFilter implementation for this naming policy to filter
+   * for all the files named by this policy.
+   */
+  private class TimeStampNamingFilter implements FilenameFilter
+  {
+    /**
+     * Select only files that are named by this policy.
+     *
+     * @param dir  The directory to search.
+     * @param name The filename to which to apply the filter.
+     *
+     * @return  <CODE>true</CODE> if the given filename matches the filter, or
+     *          <CODE>false</CODE> if it does not.
+     */
+    public boolean accept(File dir, String name)
+    {
+      if(new File(dir, name).isDirectory())
+      {
+        return false;
+      }
+      name = name.toLowerCase();
+      return name.startsWith(file.getName().toLowerCase());
+    }
+  }
+
+  /**
    * Create a new instance of the TimeStampNaming policy. Files will be created
    * with the names in the prefix.utctime format.
    *
@@ -47,10 +74,9 @@
   {
     this.file = file;
   }
+
   /**
-   * Initializes the policy and returns the current name to use.
-   *
-   * @return the initial file.
+   * {@inheritDoc}
    */
   public File getInitialName()
   {
@@ -58,12 +84,28 @@
   }
 
   /**
-   * Gets the next name to use.
-   *
-   * @return the next file.
+   * {@inheritDoc}
    */
   public File getNextName()
   {
     return new File(file + "." + TimeThread.getGMTTime());
   }
+
+  /**
+   * {@inheritDoc}
+   */
+  public FilenameFilter getFilenameFilter()
+  {
+    return new TimeStampNamingFilter();
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  public File[] listFiles()
+  {
+    File directory = file.getParentFile();
+    return directory.listFiles(getFilenameFilter());
+  }
+
 }

--
Gitblit v1.10.0