From 91ab043447a92fe894e52bcd0d3f02c6af06f81b Mon Sep 17 00:00:00 2001
From: abobrov <abobrov@localhost>
Date: Mon, 16 Jul 2007 13:24:35 +0000
Subject: [PATCH] - [Issue 1591] consolidate common exclude/include EntryCache functionality:   this fix consolidates exclude and include filter sets functionality under the   single filtersAllowCaching() method, common to all cache implementations.

---
 opendj-sdk/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java |   98 +++----------------------------------------------
 1 files changed, 6 insertions(+), 92 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java b/opendj-sdk/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java
index bddb334..1ca983c 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/extensions/FileSystemEntryCache.java
@@ -124,14 +124,6 @@
   // The DN of the configuration entry for this entry cache.
   private DN configEntryDN;
 
-  // The set of filters that define the entries that should be excluded from the
-  // cache.
-  private Set<SearchFilter> excludeFilters;
-
-  // The set of filters that define the entries that should be included in the
-  // cache.
-  private Set<SearchFilter> includeFilters;
-
   // The maximum amount of space in bytes that can be consumed in the filesystem
   // before we need to start purging entries.
   private long maxAllowedMemory;
@@ -748,48 +740,9 @@
    */
   public void putEntry(Entry entry, Backend backend, long entryID) {
 
-    // If there is a set of exclude filters, then make sure that the provided
-    // entry doesn't match any of them.
-    if (! excludeFilters.isEmpty()) {
-      for (SearchFilter f : excludeFilters) {
-        try {
-          if (f.matchesEntry(entry)) {
-            return;
-          }
-        } catch (Exception e) {
-          if (debugEnabled()) {
-            TRACER.debugCaught(DebugLogLevel.ERROR, e);
-          }
-
-          // This shouldn't happen, but if it does then we can't be sure whether
-          // the entry should be excluded, so we will by default.
-          return;
-        }
-      }
-    }
-
-    // If there is a set of include filters, then make sure that the provided
-    // entry matches at least one of them.
-    if (! includeFilters.isEmpty()) {
-      boolean matchFound = false;
-      for (SearchFilter f : includeFilters) {
-        try {
-          if (f.matchesEntry(entry)) {
-            matchFound = true;
-            break;
-          }
-        } catch (Exception e) {
-          if (debugEnabled()) {
-            TRACER.debugCaught(DebugLogLevel.ERROR, e);
-          }
-
-          // This shouldn't happen, but if it does, then just ignore it.
-        }
-      }
-
-      if (! matchFound) {
-        return;
-      }
+    // Check exclude and include filters first.
+    if (!filtersAllowCaching(entry)) {
+      return;
     }
 
     // Obtain a lock on the cache.  If this fails, then don't do anything.
@@ -813,48 +766,9 @@
    */
   public boolean putEntryIfAbsent(Entry entry, Backend backend, long entryID)
   {
-    // If there is a set of exclude filters, then make sure that the provided
-    // entry doesn't match any of them.
-    if (! excludeFilters.isEmpty()) {
-      for (SearchFilter f : excludeFilters) {
-        try {
-          if (f.matchesEntry(entry)) {
-            return true;
-          }
-        } catch (Exception e) {
-          if (debugEnabled()) {
-            TRACER.debugCaught(DebugLogLevel.ERROR, e);
-          }
-
-          // This shouldn't happen, but if it does then we can't be sure whether
-          // the entry should be excluded, so we will by default.
-          return false;
-        }
-      }
-    }
-
-    // If there is a set of include filters, then make sure that the provided
-    // entry matches at least one of them.
-    if (! includeFilters.isEmpty()) {
-      boolean matchFound = false;
-      for (SearchFilter f : includeFilters) {
-        try {
-          if (f.matchesEntry(entry)) {
-            matchFound = true;
-            break;
-          }
-        } catch (Exception e) {
-          if (debugEnabled()) {
-            TRACER.debugCaught(DebugLogLevel.ERROR, e);
-          }
-
-          // This shouldn't happen, but if it does, then just ignore it.
-        }
-      }
-
-      if (! matchFound) {
-        return true;
-      }
+    // Check exclude and include filters first.
+    if (!filtersAllowCaching(entry)) {
+      return true;
     }
 
     try {

--
Gitblit v1.10.0