opends/src/server/org/opends/server/core/CompareOperation.java
@@ -22,10 +22,12 @@ * CDDL HEADER END * * * Copyright 2006-2008 Sun Microsystems, Inc. * Copyright 2006-2009 Sun Microsystems, Inc. */ package org.opends.server.core; import java.util.Set; import org.opends.server.types.*; @@ -104,6 +106,22 @@ /** * Retrieves the attribute options for this compare operation. This should * not be called by the pre-parse plugins because the processed attribute * options will not be available yet. * * @return The attribute options for this compare operation. */ public Set<String> getAttributeOptions(); /** * Specifies the attribute options for this compare operation. * * @param attributeOptions The attribute options for this compare operation. */ public void setAttributeOptions(Set<String> attributeOptions); /** * Retrieves the assertion value for this compare operation. * * @return The assertion value for this compare operation. 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; opends/src/server/org/opends/server/core/CompareOperationWrapper.java
@@ -22,7 +22,7 @@ * CDDL HEADER END * * * Copyright 2008 Sun Microsystems, Inc. * Copyright 2008-2009 Sun Microsystems, Inc. */ package org.opends.server.core; @@ -30,7 +30,7 @@ import org.opends.server.types.AttributeType; import org.opends.server.types.ByteString; import org.opends.server.types.DN; import java.util.Set; /** * This abstract class wraps/decorates a given compare operation. @@ -123,6 +123,24 @@ /** * {@inheritDoc} */ public Set<String> getAttributeOptions() { return compare.getAttributeOptions(); } /** * {@inheritDoc} */ public void setAttributeOptions(Set<String> attributeOptions) { compare.setAttributeOptions(attributeOptions); } /** * {@inheritDoc} */ public ByteString getAssertionValue() { return compare.getAssertionValue(); opends/src/server/org/opends/server/workflowelement/localbackend/LocalBackendCompareOperation.java
@@ -28,8 +28,8 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.concurrent.locks.Lock; import org.opends.server.api.Backend; @@ -315,39 +315,10 @@ // Get the base attribute type and set of options. String baseName; HashSet<String> options; String rawAttributeType = getRawAttributeType(); int semicolonPos = rawAttributeType.indexOf(';'); if (semicolonPos > 0) { baseName = toLowerCase(rawAttributeType.substring(0, semicolonPos)); options = new HashSet<String>(); int nextPos = rawAttributeType.indexOf(';', semicolonPos+1); while (nextPos > 0) { options.add(rawAttributeType.substring(semicolonPos+1, nextPos)); semicolonPos = nextPos; nextPos = rawAttributeType.indexOf(';', semicolonPos+1); } options.add(rawAttributeType.substring(semicolonPos+1)); } else { baseName = toLowerCase(rawAttributeType); options = null; } Set<String> options = getAttributeOptions(); // Actually perform the compare operation. AttributeType attrType = getAttributeType(); if (attrType == null) { attrType = DirectoryServer.getAttributeType(baseName, true); setAttributeType(attrType); } List<Attribute> attrList = entry.getAttribute(attrType, options); if ((attrList == null) || attrList.isEmpty()) @@ -356,12 +327,14 @@ if (options == null) { appendErrorMessage(WARN_COMPARE_OP_NO_SUCH_ATTR.get( String.valueOf(entryDN), baseName)); String.valueOf(entryDN), getRawAttributeType())); } else { appendErrorMessage(WARN_COMPARE_OP_NO_SUCH_ATTR_WITH_OPTIONS.get( String.valueOf(entryDN), baseName)); String.valueOf(entryDN), getRawAttributeType())); } } else opends/src/server/org/opends/server/workflowelement/ndb/NDBCompareOperation.java
@@ -28,8 +28,8 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import org.opends.server.api.ClientConnection; import org.opends.server.api.plugin.PluginResult; @@ -238,44 +238,20 @@ // Get the base attribute type and set of options. String baseName; HashSet<String> options; String rawAttributeType = getRawAttributeType(); int semicolonPos = rawAttributeType.indexOf(';'); if (semicolonPos > 0) { baseName = toLowerCase(rawAttributeType.substring(0, semicolonPos)); options = new HashSet<String>(); int nextPos = rawAttributeType.indexOf(';', semicolonPos + 1); while (nextPos > 0) { options.add(rawAttributeType.substring(semicolonPos + 1, nextPos)); semicolonPos = nextPos; nextPos = rawAttributeType.indexOf(';', semicolonPos + 1); } options.add(rawAttributeType.substring(semicolonPos + 1)); } else { baseName = toLowerCase(rawAttributeType); options = null; } Set<String> options = getAttributeOptions(); // Actually perform the compare operation. AttributeType attrType = getAttributeType(); if (attrType == null) { attrType = DirectoryServer.getAttributeType(baseName, true); setAttributeType(attrType); } List<Attribute> attrList = entry.getAttribute(attrType, options); if ((attrList == null) || attrList.isEmpty()) { setResultCode(ResultCode.NO_SUCH_ATTRIBUTE); if (options == null) { appendErrorMessage(WARN_COMPARE_OP_NO_SUCH_ATTR.get( String.valueOf(entryDN), baseName)); String.valueOf(entryDN), getRawAttributeType())); } else { appendErrorMessage(WARN_COMPARE_OP_NO_SUCH_ATTR_WITH_OPTIONS.get( String.valueOf(entryDN), baseName)); String.valueOf(entryDN), getRawAttributeType())); } } else { AttributeValue value = AttributeValues.create(attrType,