From 95a51683c9ef42bbbdb71ef65c2544048bb20f91 Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Tue, 29 May 2012 12:05:52 +0000
Subject: [PATCH] Fix OPENDJ-508 - Searches that rely on searchable virtual attribute may be slow. For those searchable virtual attributes that can be faster than indexing (like when always matching a single entry), we process them before indexes. For the others, we fall back to them when indexes are not enough. Changes include a little bit of tidy up of comments and IDE warnings.

---
 opendj-sdk/opends/src/server/org/opends/server/replication/common/LastCookieVirtualProvider.java |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/replication/common/LastCookieVirtualProvider.java b/opendj-sdk/opends/src/server/org/opends/server/replication/common/LastCookieVirtualProvider.java
index da4335c..6766286 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/replication/common/LastCookieVirtualProvider.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/replication/common/LastCookieVirtualProvider.java
@@ -23,7 +23,7 @@
  *
  *
  *      Copyright 2009 Sun Microsystems, Inc.
- *      Portions Copyright 2011 ForgeRock AS
+ *      Portions Copyright 2011-2012 ForgeRock AS
  */
 
 package org.opends.server.replication.common;
@@ -34,6 +34,7 @@
 import java.util.List;
 import java.util.Set;
 
+import static org.opends.messages.ExtensionMessages.*;
 import org.opends.messages.Message;
 import org.opends.server.admin.server.ConfigurationChangeListener;
 import org.opends.server.admin.std.server.UserDefinedVirtualAttributeCfg;
@@ -164,9 +165,11 @@
    */
   @Override()
   public boolean isSearchable(VirtualAttributeRule rule,
-                              SearchOperation searchOperation)
+                              SearchOperation searchOperation,
+                              boolean isPreIndexed)
   {
-    // We will not allow searches based only on user-defined virtual attributes.
+    // We do not allow search for the lastCookie. It's a read-only
+    // attribute of the RootDSE.
     return false;
   }
 
@@ -180,7 +183,9 @@
                             SearchOperation searchOperation)
   {
     searchOperation.setResultCode(ResultCode.UNWILLING_TO_PERFORM);
-    return;
+    final Message message = ERR_LASTCOOKIE_VATTR_NOT_SEARCHABLE.get(
+            rule.getAttributeType().getNameOrOID());
+    searchOperation.appendErrorMessage(message);
   }
 
 

--
Gitblit v1.10.0