From 3bca03c2b22d1aa065cb1f785623d3c89a5e06b0 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Wed, 28 Jan 2009 23:43:17 +0000
Subject: [PATCH] Fix issue 3446 and improve fix for issue 3726:

---
 opendj-sdk/opends/src/server/org/opends/server/api/VirtualAttributeProvider.java |   39 ++++++++++++++++-----------------------
 1 files changed, 16 insertions(+), 23 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/api/VirtualAttributeProvider.java b/opendj-sdk/opends/src/server/org/opends/server/api/VirtualAttributeProvider.java
index 64ef428..9b1c147 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/api/VirtualAttributeProvider.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/api/VirtualAttributeProvider.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2006-2008 Sun Microsystems, Inc.
+ *      Copyright 2006-2009 Sun Microsystems, Inc.
  */
 package org.opends.server.api;
 import org.opends.messages.Message;
@@ -31,8 +31,8 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.LinkedHashSet;
 import java.util.List;
+import java.util.Set;
 
 import org.opends.server.admin.std.server.VirtualAttributeCfg;
 import org.opends.server.config.ConfigException;
@@ -147,19 +147,18 @@
 
 
   /**
-   * Generates a set of values for the provided entry.
+   * Generates an unmodifiable set of values for the provided entry.
    *
-   * @param  entry  The entry for which the values are to be
-   *                generated.
-   * @param  rule   The virtual attribute rule which defines the
-   *                constraints for the virtual attribute.
-   *
-   * @return  The set of values generated for the provided entry.  It
-   *          may be empty, but it must not be {@code null}.
+   * @param entry
+   *          The entry for which the values are to be generated.
+   * @param rule
+   *          The virtual attribute rule which defines the constraints
+   *          for the virtual attribute.
+   * @return The unmodifiable set of values generated for the provided
+   *         entry. It may be empty, but it must not be {@code null}.
    */
-  public abstract LinkedHashSet<AttributeValue>
-                       getValues(Entry entry,
-                                 VirtualAttributeRule rule);
+  public abstract Set<AttributeValue> getValues(
+      Entry entry, VirtualAttributeRule rule);
 
 
 
@@ -221,15 +220,8 @@
   public boolean hasAllValues(Entry entry, VirtualAttributeRule rule,
                               Collection<AttributeValue> values)
   {
-    for (AttributeValue value : values)
-    {
-      if (! getValues(entry, rule).contains(value))
-      {
-        return false;
-      }
-    }
-
-    return true;
+    Set<AttributeValue> virtualValues = getValues(entry, rule);
+    return virtualValues.containsAll(values);
   }
 
 
@@ -251,9 +243,10 @@
   public boolean hasAnyValue(Entry entry, VirtualAttributeRule rule,
                              Collection<AttributeValue> values)
   {
+    Set<AttributeValue> virtualValues = getValues(entry, rule);
     for (AttributeValue value : values)
     {
-      if (getValues(entry, rule).contains(value))
+      if (virtualValues.contains(value))
       {
         return true;
       }

--
Gitblit v1.10.0