mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Matthew Swift
13.32.2015 d73dd29ce6a19cd9f81bc4db24d50a5b53f45a3c
opendj-core/clirr-ignored-api-changes.xml
@@ -408,4 +408,16 @@
    <method>boolean copyTo(java.nio.CharBuffer, java.nio.charset.CharsetDecoder)</method>
    <justification>OPENDJ-1585: Added new utility method copyTo for a char buffer</justification>
  </difference>
  <difference>
    <className>org/forgerock/opendj/ldap/schema/MatchingRule</className>
    <differenceType>7002</differenceType>
    <method>java.util.Comparator comparator()</method>
    <justification>OPENDJ-1689 method has been removed because all matching rules should support the default comparator</justification>
  </difference>
  <difference>
    <className>org/forgerock/opendj/ldap/schema/MatchingRuleImpl</className>
    <differenceType>7002</differenceType>
    <method>java.util.Comparator comparator(org.forgerock.opendj.ldap.schema.Schema)</method>
    <justification>OPENDJ-1689 method has been removed because all matching rules should support the default comparator</justification>
  </difference>
</differences>
opendj-core/src/main/java/org/forgerock/opendj/ldap/AVA.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2010 Sun Microsystems, Inc.
 *      Portions copyright 2011-2012 ForgeRock AS.
 *      Portions copyright 2011-2015 ForgeRock AS.
 */
package org.forgerock.opendj.ldap;
@@ -36,7 +36,6 @@
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CodingErrorAction;
import java.util.Comparator;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.i18n.LocalizedIllegalArgumentException;
@@ -657,13 +656,7 @@
        final ByteString normalizedValue = getOrderingNormalizedValue();
        final ByteString otherNormalizedValue = ava.getOrderingNormalizedValue();
        final MatchingRule rule = attributeType.getOrderingMatchingRule();
        if (rule != null) {
            final Comparator<ByteSequence> comparator = rule.comparator();
            return comparator.compare(normalizedValue, otherNormalizedValue);
        } else {
            return normalizedValue.compareTo(otherNormalizedValue);
        }
        return normalizedValue.compareTo(otherNormalizedValue);
    }
    /** {@inheritDoc} */
@@ -680,13 +673,7 @@
            final ByteString normalizedValue = getEqualityNormalizedValue();
            final ByteString otherNormalizedValue = ava.getEqualityNormalizedValue();
            final MatchingRule rule = attributeType.getEqualityMatchingRule();
            if (rule != null) {
                final Comparator<ByteSequence> comparator = rule.comparator();
                return comparator.compare(normalizedValue, otherNormalizedValue) == 0;
            } else {
                return normalizedValue.equals(otherNormalizedValue);
            }
            return normalizedValue.equals(otherNormalizedValue);
        } else {
            return false;
        }
opendj-core/src/main/java/org/forgerock/opendj/ldap/SortKey.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2010 Sun Microsystems, Inc.
 *      Portions copyright 2012-2013 ForgeRock AS.
 *      Portions copyright 2012-2015 ForgeRock AS.
 */
package org.forgerock.opendj.ldap;
@@ -98,14 +98,12 @@
    private static final class EntryComparator implements Comparator<Entry> {
        private final AttributeDescription attributeDescription;
        private final MatchingRule matchingRule;
        private final Comparator<ByteSequence> valueComparator;
        private final boolean isReverseOrder;
        private EntryComparator(final AttributeDescription attributeDescription,
                final MatchingRule matchingRule, final boolean isReverseOrder) {
            this.attributeDescription = attributeDescription;
            this.matchingRule = matchingRule;
            this.valueComparator = matchingRule.comparator();
            this.isReverseOrder = isReverseOrder;
        }
@@ -125,9 +123,9 @@
            } else if (normalizedValue2 == null) {
                return -1;
            } else if (isReverseOrder) {
                return valueComparator.compare(normalizedValue2, normalizedValue1);
                return normalizedValue2.compareTo(normalizedValue1);
            } else {
                return valueComparator.compare(normalizedValue1, normalizedValue2);
                return normalizedValue1.compareTo(normalizedValue2);
            }
        }
@@ -137,9 +135,7 @@
                for (final ByteString value : attribute) {
                    try {
                        final ByteString tmp = matchingRule.normalizeAttributeValue(value);
                        if (normalizedValue == null) {
                            normalizedValue = tmp;
                        } else if (valueComparator.compare(tmp, normalizedValue) < 0) {
                        if (normalizedValue == null || tmp.compareTo(normalizedValue) < 0) {
                            normalizedValue = tmp;
                        }
                    } catch (final DecodeException ignored) {
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractMatchingRuleImpl.java
@@ -22,12 +22,11 @@
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions copyright 2014 ForgeRock AS
 *      Portions copyright 2014-2015 ForgeRock AS
 */
package org.forgerock.opendj.ldap.schema;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import org.forgerock.opendj.ldap.Assertion;
@@ -105,11 +104,6 @@
    }
    @Override
    public Comparator<ByteSequence> comparator(final Schema schema) {
        return ByteSequence.COMPARATOR;
    }
    @Override
    public Assertion getAssertion(final Schema schema, final ByteSequence assertionValue)
            throws DecodeException {
        return UNDEFINED_ASSERTION;
@@ -134,7 +128,6 @@
        return UNDEFINED_ASSERTION;
    }
    /** {@inheritDoc} */
    @Override
    public boolean isIndexingSupported() {
        return !getIndexers().isEmpty();
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/EqualLengthApproximateMatchingRuleImpl.java
File was deleted
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRule.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2009-2010 Sun Microsystems, Inc.
 *      Portions copyright 2013-2014 ForgeRock AS.
 *      Portions copyright 2013-2015 ForgeRock AS.
 */
package org.forgerock.opendj.ldap.schema;
@@ -30,7 +30,6 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -256,17 +255,6 @@
    }
    /**
     * Get a comparator that can be used to compare the attribute values
     * normalized by this matching rule.
     *
     * @return A comparator that can be used to compare the attribute values
     *         normalized by this matching rule.
     */
    public Comparator<ByteSequence> comparator() {
        return impl.comparator(schema);
    }
    /**
     * Returns {@code true} if the provided object is a matching rule having the
     * same numeric OID as this matching rule.
     *
@@ -468,12 +456,17 @@
    /**
     * Returns the normalized form of the provided attribute value, which is
     * best suited for efficiently performing matching operations on that value.
     * The returned normalized representation can be compared for equality with
     * other values normalized with this matching rule using
     * {@link ByteSequence#equals(Object)}. In addition, normalized values can
     * be compared using {@link ByteSequence#compareTo(ByteSequence)}, although
     * the sort order is only defined for ordering matching rules.
     *
     * @param value
     *            The attribute value to be normalized.
     * @return The normalized version of the provided attribute value.
     * @throws DecodeException
     *             if the syntax of the value is not valid.
     *             If the syntax of the value is not valid.
     */
    public ByteString normalizeAttributeValue(final ByteSequence value) throws DecodeException {
        return impl.normalizeAttributeValue(schema, value);
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/MatchingRuleImpl.java
@@ -22,12 +22,11 @@
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions copyright 2014 ForgeRock AS
 *      Portions copyright 2014-2015 ForgeRock AS
 */
package org.forgerock.opendj.ldap.schema;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import org.forgerock.opendj.ldap.Assertion;
@@ -43,17 +42,6 @@
public interface MatchingRuleImpl {
    /**
     * Get a comparator that can be used to compare the attribute values
     * normalized by this matching rule.
     *
     * @param schema
     *            The schema in which this matching rule is defined.
     * @return A comparator that can be used to compare the attribute values
     *         normalized by this matching rule.
     */
    Comparator<ByteSequence> comparator(Schema schema);
    /**
     * Retrieves the normalized form of the provided assertion value, which is
     * best suited for efficiently performing less than matching operations on
     * that value. The assertion value is guaranteed to be valid against this
@@ -128,6 +116,10 @@
    /**
     * Retrieves the normalized form of the provided attribute value, which is
     * best suited for efficiently performing matching operations on that value.
     * Equality and ordering matching rules should return a normalized
     * representation which can be compared with other normalized values using
     * {@link ByteSequence#equals(Object)} and
     * {@link ByteSequence#compareTo(ByteSequence)}.
     *
     * @param schema
     *            The schema in which this matching rule is defined.
@@ -135,7 +127,7 @@
     *            The attribute value to be normalized.
     * @return The normalized version of the provided attribute value.
     * @throws DecodeException
     *             if an syntax error occurred while parsing the value.
     *             If an syntax error occurred while parsing the value.
     */
    ByteString normalizeAttributeValue(Schema schema, ByteSequence value) throws DecodeException;
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/OrderingMatchingRuleTest.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions copyright 2014 ForgeRock AS
 *      Portions copyright 2014-2015 ForgeRock AS
 */
package org.forgerock.opendj.ldap.schema;
@@ -70,7 +70,7 @@
                ruleInstance.normalizeAttributeValue(ByteString.valueOf(value2));
        // Test the comparator
        final int comp = ruleInstance.comparator().compare(normalizedValue1, normalizedValue2);
        final int comp = normalizedValue1.compareTo(normalizedValue2);
        if (comp == 0) {
            Assert.assertEquals(comp, result);
        } else if (comp > 0) {
opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/VLVKeyComparator.java
@@ -22,13 +22,10 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 *      Portions Copyright 2014-2015 ForgeRock AS
 */
package org.opends.server.backends.jeb;
import java.util.Comparator;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.DecodeException;
import org.forgerock.opendj.ldap.ResultCode;
@@ -201,11 +198,9 @@
        return -1;
      }
      final Comparator<ByteSequence> comp = orderingRules[j].comparator();
      final ByteString val1 = ByteString.valueOf(b1Bytes);
      final ByteString val2 = ByteString.valueOf(b2Bytes);
      final int result = ascending[j] ? comp.compare(val1, val2) : comp.compare(val2, val1);
      final int result = ascending[j] ? val1.compareTo(val2) : val2.compareTo(val1);
      if(result != 0)
      {
        return result;
@@ -299,9 +294,7 @@
        return -1;
      }
      final Comparator<ByteSequence> comp = orderingRules[j].comparator();
      final int result = ascending[j] ? comp.compare(b1Bytes, b2Bytes) : comp.compare(b2Bytes, b1Bytes);
      final int result = ascending[j] ? b1Bytes.compareTo(b2Bytes) : b2Bytes.compareTo(b1Bytes);
      if(result != 0)
      {
        return result;
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VLVIndex.java
@@ -29,7 +29,6 @@
import static org.opends.messages.JebMessages.*;
import static org.opends.server.util.StaticUtils.*;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -1349,10 +1348,7 @@
        return -1;
      }
      final Comparator<ByteSequence> comp = orderingRule.comparator();
      final int result = ascending ? comp.compare(b1Bytes, b2Bytes) : comp
          .compare(b2Bytes, b1Bytes);
      final int result = ascending ? b1Bytes.compareTo(b2Bytes) : b2Bytes.compareTo(b1Bytes);
      if (result != 0)
      {
        return result;
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/HistoricalCsnOrderingMatchingRuleImpl.java
@@ -22,13 +22,12 @@
 *
 *
 *      Copyright 2006-2010 Sun Microsystems, Inc.
 *      Portions Copyright 2012-2014 ForgeRock AS.
 *      Portions Copyright 2012-2015 ForgeRock AS.
 */
package org.opends.server.replication.plugin;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.forgerock.opendj.ldap.Assertion;
@@ -73,18 +72,6 @@
    }
  }
  /**
   * Compare two ByteString values containing historical information.
   *
   * @param value1 first value to compare
   * @param value2 second value to compare
   * @return 0 when equals, -1 or 1 to establish order
   */
  private int compareValues(ByteSequence value1, ByteSequence value2)
  {
    return value1.compareTo(value2);
  }
  /** {@inheritDoc} */
  @Override
  public ByteString normalizeAttributeValue(Schema schema, ByteSequence value) throws DecodeException
@@ -114,20 +101,6 @@
  /** {@inheritDoc} */
  @Override
  public Comparator<ByteSequence> comparator(Schema schema)
  {
    return new Comparator<ByteSequence>()
    {
      @Override
      public int compare(final ByteSequence o1, final ByteSequence o2)
      {
        return compareValues(o1, o2);
      }
    };
  }
  /** {@inheritDoc} */
  @Override
  public Assertion getAssertion(final Schema schema, final ByteSequence value) throws DecodeException
  {
    final ByteString normAssertion = normalizeAttributeValue(schema, value);
@@ -136,7 +109,7 @@
      @Override
      public ConditionResult matches(final ByteSequence attributeValue)
      {
        return ConditionResult.valueOf(compareValues(attributeValue, normAssertion) < 0);
        return ConditionResult.valueOf(attributeValue.compareTo(normAssertion) < 0);
      }
      @Override
@@ -165,7 +138,7 @@
      @Override
      public ConditionResult matches(final ByteSequence normalizedAttributeValue)
      {
        return ConditionResult.valueOf(compareValues(normalizedAttributeValue, normAssertion) >= 0);
        return ConditionResult.valueOf(normalizedAttributeValue.compareTo(normAssertion) >= 0);
      }
      @Override
@@ -186,7 +159,7 @@
      @Override
      public ConditionResult matches(final ByteSequence normalizedAttributeValue)
      {
        return ConditionResult.valueOf(compareValues(normalizedAttributeValue, normAssertion) <= 0);
        return ConditionResult.valueOf(normalizedAttributeValue.compareTo(normAssertion) <= 0);
      }
      @Override
opendj-server-legacy/src/main/java/org/opends/server/schema/AbstractPasswordEqualityMatchingRuleImpl.java
@@ -22,13 +22,12 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 *      Portions Copyright 2014-2015 ForgeRock AS
 */
package org.opends.server.schema;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.forgerock.opendj.ldap.Assertion;
@@ -68,13 +67,6 @@
    }
  });
  /** {@inheritDoc} */
  @Override
  public Comparator<ByteSequence> comparator(Schema schema)
  {
    return ByteSequence.COMPARATOR;
  }
  /**
   * Retrieves the normalized form of the provided value, which is best suited
   * for efficiently performing matching operations on that value.
opendj-server-legacy/src/main/java/org/opends/server/types/RDN.java
@@ -61,8 +61,6 @@
{
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  private static final char HEX_STRING_SEPARATOR = '%';
  /** The set of attribute types for the elements in this RDN. */
  private AttributeType[] attributeTypes;
@@ -1343,7 +1341,7 @@
      {
        val1 = rule.normalizeAttributeValue(val1);
        val2 = rule.normalizeAttributeValue(val2);
        return rule.comparator().compare(val1, val2);
        return val1.compareTo(val2);
      }
      catch (DecodeException e)
      {
opendj-server-legacy/src/main/java/org/opends/server/types/SortKey.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 *      Portions Copyright 2014-2015 ForgeRock AS
 */
package org.opends.server.types;
@@ -187,14 +187,7 @@
    {
      final ByteString val1 = rule.normalizeAttributeValue(value1);
      final ByteString val2 = rule.normalizeAttributeValue(value2);
      if (ascending)
      {
        return rule.comparator().compare(val1, val2);
      }
      else
      {
        return rule.comparator().compare(val2, val1);
      }
      return ascending ? val1.compareTo(val2) : val2.compareTo(val1);
    }
    catch (Exception e)
    {
opendj-server-legacy/src/test/java/org/opends/server/backends/SchemaTestMatchingRuleImpl.java
@@ -22,14 +22,13 @@
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 *      Portions Copyright 2014 ForgeRock AS
 *      Portions Copyright 2014-2015 ForgeRock AS
 */
package org.opends.server.backends;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import org.forgerock.opendj.ldap.Assertion;
@@ -62,17 +61,6 @@
    caseIgnoreMatchingRule = CoreSchema.getCaseIgnoreMatchingRule();
  }
  /**
   * Retrieves the normalized form of the provided value, which is best suited
   * for efficiently performing matching operations on that value.
   *
   * @param  value  The value to be normalized.
   *
   * @return  The normalized version of the provided value.
   *
   * @throws  DecodeException  If the provided value is invalid according to
   *                              the associated attribute syntax.
   */
  @Override
  public ByteString normalizeAttributeValue(Schema schema, ByteSequence value)
         throws DecodeException
@@ -80,21 +68,12 @@
    return caseIgnoreMatchingRule.normalizeAttributeValue(value);
  }
  /** {@inheritDoc} */
  @Override
  public Comparator<ByteSequence> comparator(Schema schema)
  {
    return caseIgnoreMatchingRule.comparator();
  }
  /** {@inheritDoc} */
  @Override
  public Assertion getAssertion(Schema schema, ByteSequence assertionValue) throws DecodeException
  {
    return caseIgnoreMatchingRule.getAssertion(assertionValue);
  }
  /** {@inheritDoc} */
  @Override
  public Assertion getSubstringAssertion(Schema schema, ByteSequence subInitial,
      List<? extends ByteSequence> subAnyElements, ByteSequence subFinal) throws DecodeException
@@ -102,28 +81,24 @@
    return caseIgnoreMatchingRule.getSubstringAssertion(subInitial, subAnyElements, subFinal);
  }
  /** {@inheritDoc} */
  @Override
  public Assertion getGreaterOrEqualAssertion(Schema schema, ByteSequence value) throws DecodeException
  {
    return caseIgnoreMatchingRule.getGreaterOrEqualAssertion(value);
  }
  /** {@inheritDoc} */
  @Override
  public Assertion getLessOrEqualAssertion(Schema schema, ByteSequence value) throws DecodeException
  {
    return caseIgnoreMatchingRule.getLessOrEqualAssertion(value);
  }
  /** {@inheritDoc} */
  @Override
  public Collection<? extends Indexer> getIndexers()
  {
    return caseIgnoreMatchingRule.getIndexers();
  }
  /** {@inheritDoc} */
  @Override
  public boolean isIndexingSupported()
  {
opendj-server-legacy/src/test/java/org/opends/server/schema/AttributeTypeSyntaxTest.java
@@ -30,9 +30,8 @@
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.schema.CoreSchema;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.SchemaBuilder;
import org.forgerock.opendj.ldap.schema.Schema;
import org.opends.server.TestCaseUtils;
import org.opends.server.api.AttributeSyntax;
import org.opends.server.core.DirectoryServer;
@@ -44,7 +43,6 @@
import static org.opends.server.protocols.internal.InternalClientConnection.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.opends.server.schema.EqualLengthApproximateMatchingRule.*;
import static org.testng.Assert.*;
/**
@@ -149,16 +147,8 @@
  @Test
  public void testXAPPROXExtension() throws Exception
  {
    // Create and register the approximate matching rule for testing purposes.
    MatchingRule testApproxRule = new SchemaBuilder(CoreSchema.getInstance())
        .buildMatchingRule(EQUAL_LENGTH_APPROX_MR_OID)
          .names(EQUAL_LENGTH_APPROX_MR_NAME).implementation(new EqualLengthApproximateMatchingRule())
          .syntaxOID(EQUAL_LENGTH_APPROX_MR_SYNTAX_OID)
          .addToSchema()
        .toSchema().getMatchingRule(EQUAL_LENGTH_APPROX_MR_OID);
    DirectoryServer.registerMatchingRule(testApproxRule, false);
    MatchingRule mrule = Schema.getCoreSchema().getMatchingRule("ds-mr-double-metaphone-approx");
    // Get a reference to the attribute type syntax implementation in the
    // server.
    AttributeTypeSyntax attrTypeSyntax =
@@ -185,7 +175,7 @@
                                                 false);
    assertNotNull(attrType);
    assertNotNull(attrType.getApproximateMatchingRule());
    assertEquals(attrType.getApproximateMatchingRule(), testApproxRule);
    assertEquals(attrType.getApproximateMatchingRule(), mrule);
  }
opendj-server-legacy/src/test/java/org/opends/server/schema/EqualLengthApproximateMatchingRule.java
File was deleted