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

Nicolas Capponi
20.06.2014 5203374a1e5dc294088749071cf5350d2f82787d
opendj3-server-dev/src/server/org/opends/server/api/VirtualAttributeProvider.java
@@ -349,45 +349,41 @@
  }
  /**
   * Indicates whether this virtual attribute provider will generate
   * any value for the provided entry that is greater than or equal to
   * the given value.
   * Indicates whether this virtual attribute provider will generate any value
   * for the provided entry that is greater than or equal to the given value.
   *
   * @param  entry  The entry for which to make the determination.
   * @param  rule   The virtual attribute rule which defines the
   *                constraints for the virtual attribute.
   * @param  value  The value for which to make the determination.
   *
   * @return  {@code UNDEFINED} if the associated attribute type does
   *          not have an ordering matching rule, {@code TRUE} if at
   *          least one of the generated values will be greater than
   *          or equal to the specified value, or {@code FALSE} if
   *          none of the generated values will be greater than or
   *          equal to the specified value.
   * @param entry
   *          The entry for which to make the determination.
   * @param rule
   *          The virtual attribute rule which defines the constraints for the
   *          virtual attribute.
   * @param assertionValue
   *          The value for which to make the determination.
   * @return {@code UNDEFINED} if the associated attribute type does not have an
   *         ordering matching rule, {@code TRUE} if at least one of the
   *         generated values will be greater than or equal to the specified
   *         value, or {@code FALSE} if none of the generated values will be
   *         greater than or equal to the specified value.
   */
  public ConditionResult greaterThanOrEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              ByteString value)
                              ByteString assertionValue)
  {
    OrderingMatchingRule matchingRule =
         rule.getAttributeType().getOrderingMatchingRule();
    MatchingRule matchingRule = rule.getAttributeType().getOrderingMatchingRule();
    if (matchingRule == null)
    {
      return ConditionResult.UNDEFINED;
    }
    ByteString normalizedValue;
    Assertion assertion = null;
    try
    {
      normalizedValue = matchingRule.normalizeAttributeValue(value);
      assertion = matchingRule.getGreaterOrEqualAssertion(assertionValue);
    }
    catch (Exception e)
    {
      logger.traceException(e);
      // We couldn't normalize the provided value => return "undefined".
      return ConditionResult.UNDEFINED;
    }
@@ -396,8 +392,7 @@
    {
      try
      {
        ByteString nv = matchingRule.normalizeAttributeValue(v);
        if (matchingRule.compareValues(nv, normalizedValue) >= 0)
        if (assertion.matches(matchingRule.normalizeAttributeValue(v)).toBoolean())
        {
          return ConditionResult.TRUE;
        }
@@ -405,7 +400,6 @@
      catch (Exception e)
      {
        logger.traceException(e);
        // We couldn't normalize one of the attribute values.
        // We will return "undefined" if we can't find a definite match
        result = ConditionResult.UNDEFINED;
@@ -418,43 +412,40 @@
  /**
   * Indicates whether this virtual attribute provider will generate
   * any value for the provided entry that is less than or equal to
   * the given value.
   * Indicates whether this virtual attribute provider will generate any value
   * for the provided entry that is less than or equal to the given value.
   *
   * @param  entry  The entry for which to make the determination.
   * @param  rule   The virtual attribute rule which defines the
   *                constraints for the virtual attribute.
   * @param  value  The value for which to make the determination.
   *
   * @return  {@code UNDEFINED} if the associated attribute type does
   *          not have an ordering matching rule, {@code TRUE} if at
   *          least one of the generated values will be less than or
   *          equal to the specified value, or {@code FALSE} if none
   *          of the generated values will be greater than or equal to
   *          the specified value.
   * @param entry
   *          The entry for which to make the determination.
   * @param rule
   *          The virtual attribute rule which defines the constraints for the
   *          virtual attribute.
   * @param assertionValue
   *          The value for which to make the determination.
   * @return {@code UNDEFINED} if the associated attribute type does not have an
   *         ordering matching rule, {@code TRUE} if at least one of the
   *         generated values will be less than or equal to the specified value,
   *         or {@code FALSE} if none of the generated values will be greater
   *         than or equal to the specified value.
   */
  public ConditionResult lessThanOrEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              ByteString value)
                              ByteString assertionValue)
  {
    OrderingMatchingRule matchingRule =
         rule.getAttributeType().getOrderingMatchingRule();
    MatchingRule matchingRule = rule.getAttributeType().getOrderingMatchingRule();
    if (matchingRule == null)
    {
      return ConditionResult.UNDEFINED;
    }
    ByteString normalizedValue;
    Assertion assertion = null;
    try
    {
      normalizedValue = matchingRule.normalizeAttributeValue(value);
      assertion = matchingRule.getLessOrEqualAssertion(assertionValue);
    }
    catch (Exception e)
    {
      logger.traceException(e);
      // We couldn't normalize the provided value => return "undefined".
      return ConditionResult.UNDEFINED;
    }
@@ -463,8 +454,7 @@
    {
      try
      {
        ByteString nv = matchingRule.normalizeAttributeValue(v);
        if (matchingRule.compareValues(nv, normalizedValue) <= 0)
        if (assertion.matches(matchingRule.normalizeAttributeValue(v)).toBoolean())
        {
          return ConditionResult.TRUE;
        }
@@ -492,7 +482,7 @@
   * @param  entry  The entry for which to make the determination.
   * @param  rule   The virtual attribute rule which defines the
   *                constraints for the virtual attribute.
   * @param  value  The value for which to make the determination.
   * @param  assertionValue  The value for which to make the determination.
   *
   * @return  {@code UNDEFINED} if the associated attribute type does
   *          not have an approximate matching rule, {@code TRUE} if at
@@ -503,7 +493,7 @@
   */
  public ConditionResult approximatelyEqualTo(Entry entry,
                              VirtualAttributeRule rule,
                              ByteString value)
                              ByteString assertionValue)
  {
    MatchingRule matchingRule = rule.getAttributeType().getApproximateMatchingRule();
    if (matchingRule == null)
@@ -514,7 +504,7 @@
    Assertion assertion = null;
    try
    {
      assertion = matchingRule.getAssertion(value);
      assertion = matchingRule.getAssertion(assertionValue);
    }
    catch (Exception e)
    {
@@ -527,7 +517,10 @@
    {
      try
      {
        result = assertion.matches(matchingRule.normalizeAttributeValue(v));
        if  (assertion.matches(matchingRule.normalizeAttributeValue(v)).toBoolean())
        {
          return ConditionResult.TRUE;
        }
      }
      catch (Exception e)
      {