From 0cdc4f67dfc0e2fb8b83d5f0de8188ec3686d04c Mon Sep 17 00:00:00 2001
From: floblanc <floblanc@localhost>
Date: Tue, 10 Nov 2009 13:59:02 +0000
Subject: [PATCH] Fix Issue 4344 CompareOperation API does not support attribute options and Issue CompareOperationBasis does not properly handle get/setAttributeType.

---
 opends/src/server/org/opends/server/core/CompareOperationBasis.java |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/opends/src/server/org/opends/server/core/CompareOperationBasis.java b/opends/src/server/org/opends/server/core/CompareOperationBasis.java
index 2d6e54f..b038e85 100644
--- a/opends/src/server/org/opends/server/core/CompareOperationBasis.java
+++ b/opends/src/server/org/opends/server/core/CompareOperationBasis.java
@@ -32,9 +32,12 @@
 import static org.opends.server.loggers.AccessLogger.logCompareResponse;
 import static org.opends.server.loggers.debug.DebugLogger.debugEnabled;
 import static org.opends.messages.CoreMessages.*;
+import static org.opends.server.util.StaticUtils.*;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 
 import org.opends.server.api.ClientConnection;
 import org.opends.server.api.plugin.PluginResult;
@@ -69,6 +72,9 @@
   // The assertion value for the compare operation.
   private ByteString assertionValue;
 
+  // The set of attribute options
+  private Set<String> attributeOptions;
+
   // The raw, unprocessed entry DN as included in the client request.
   private ByteString rawEntryDN;
 
@@ -117,6 +123,7 @@
     responseControls       = new ArrayList<Control>();
     entryDN                = null;
     attributeType          = null;
+    attributeOptions       = null;
     cancelRequest          = null;
     proxiedAuthorizationDN = null;
   }
@@ -154,6 +161,7 @@
     rawAttributeType       = attributeType.getNameOrOID();
     cancelRequest          = null;
     proxiedAuthorizationDN = null;
+    attributeOptions       = new HashSet<String>();
   }
 
 
@@ -224,15 +232,45 @@
     this.rawAttributeType = rawAttributeType;
 
     attributeType = null;
+    attributeOptions = null;
   }
 
 
 
+  private void getAttributeTypeAndOptions() {
+    String baseName;
+    int semicolonPos = rawAttributeType.indexOf(';');
+    if (semicolonPos > 0) {
+      baseName = toLowerCase(rawAttributeType.substring(0, semicolonPos));
+
+      attributeOptions = new HashSet<String>();
+      int nextPos = rawAttributeType.indexOf(';', semicolonPos+1);
+      while (nextPos > 0)
+      {
+        attributeOptions.add(
+            rawAttributeType.substring(semicolonPos+1, nextPos));
+        semicolonPos = nextPos;
+        nextPos = rawAttributeType.indexOf(';', semicolonPos+1);
+      }
+
+      attributeOptions.add(rawAttributeType.substring(semicolonPos+1));
+    }
+    else
+    {
+      baseName = toLowerCase(rawAttributeType);
+      attributeOptions  = null;
+    }
+    attributeType = DirectoryServer.getAttributeType(baseName, true);
+  }
+
   /**
    * {@inheritDoc}
    */
   public final AttributeType getAttributeType()
   {
+    if (attributeType == null) {
+      getAttributeTypeAndOptions();
+    }
     return attributeType;
   }
 
@@ -251,6 +289,27 @@
   /**
    * {@inheritDoc}
    */
+  public Set<String> getAttributeOptions()
+  {
+    if (attributeOptions == null) {
+      getAttributeTypeAndOptions();
+    }
+    return attributeOptions;
+  }
+
+
+
+  /**
+   * {@inheritDoc}
+   */
+  public void setAttributeOptions(Set<String> attributeOptions)
+  {
+    this.attributeOptions = attributeOptions;
+  }
+
+  /**
+   * {@inheritDoc}
+   */
   public final ByteString getAssertionValue()
   {
     return assertionValue;

--
Gitblit v1.10.0