Fix a problem that prevented the server from handling attribute options in a
case-insensitive manner.
OpenDS Issue Number: 1348
| | |
| | | |
| | | |
| | | // The attribute type for this attribute. |
| | | private AttributeType attributeType; |
| | | private final AttributeType attributeType; |
| | | |
| | | // The set of values for this attribute. |
| | | private LinkedHashSet<AttributeValue> values; |
| | | |
| | | // The set of options for this attribute. |
| | | private LinkedHashSet<String> options; |
| | | private final LinkedHashSet<String> options; |
| | | |
| | | // The set of options for this attribute, formatted in all lowercase |
| | | // characters. |
| | | private final LinkedHashSet<String> lowerOptions; |
| | | |
| | | // The name of this attribute as provided by the end user. |
| | | private String name; |
| | | private final String name; |
| | | |
| | | |
| | | |
| | |
| | | this.name = attributeType.getPrimaryName(); |
| | | this.options = new LinkedHashSet<String>(0); |
| | | this.values = new LinkedHashSet<AttributeValue>(); |
| | | |
| | | lowerOptions = options; |
| | | } |
| | | |
| | | |
| | |
| | | this.name = name; |
| | | this.options = new LinkedHashSet<String>(0); |
| | | this.values = new LinkedHashSet<AttributeValue>(); |
| | | |
| | | lowerOptions = options; |
| | | } |
| | | |
| | | |
| | |
| | | this.name = name; |
| | | this.options = new LinkedHashSet<String>(0); |
| | | |
| | | lowerOptions = options; |
| | | |
| | | if (values == null) |
| | | { |
| | | this.values = new LinkedHashSet<AttributeValue>(); |
| | |
| | | this.values.add(new AttributeValue(this.attributeType, |
| | | valueString)); |
| | | this.options = new LinkedHashSet<String>(0); |
| | | |
| | | lowerOptions = options; |
| | | } |
| | | |
| | | |
| | |
| | | if (options == null) |
| | | { |
| | | this.options = new LinkedHashSet<String>(0); |
| | | lowerOptions = options; |
| | | } |
| | | else |
| | | { |
| | | this.options = options; |
| | | lowerOptions = new LinkedHashSet<String>(); |
| | | for (String option : options) |
| | | { |
| | | lowerOptions.add(toLowerCase(option)); |
| | | } |
| | | } |
| | | |
| | | if (values == null) |
| | |
| | | */ |
| | | public boolean hasOption(String option) |
| | | { |
| | | return options.contains(option); |
| | | return lowerOptions.contains(toLowerCase(option)); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | public boolean hasOptions() |
| | | { |
| | | return ((options != null) && (! options.isEmpty())); |
| | | return (! options.isEmpty()); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | for (String option : options) |
| | | { |
| | | if (! this.options.contains(option)) |
| | | if (! lowerOptions.contains(toLowerCase(option))) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | |
| | | for (String s : options) |
| | | { |
| | | if (! this.options.contains(s)) |
| | | if (! lowerOptions.contains(toLowerCase(s))) |
| | | { |
| | | return false; |
| | | } |
| | |
| | | } |
| | | |
| | | @Test |
| | | public void testCompareOptions3() |
| | | { |
| | | InternalClientConnection conn = |
| | | InternalClientConnection.getRootConnection(); |
| | | |
| | | CompareOperation compareOperation = |
| | | new CompareOperation(conn, InternalClientConnection.nextOperationID(), |
| | | InternalClientConnection.nextMessageID(), |
| | | new ArrayList<Control>(), |
| | | new ASN1OctetString(entry.getDN().toString()), |
| | | "givenName;lAnG-En", |
| | | new ASN1OctetString("Rodney")); |
| | | |
| | | compareOperation.run(); |
| | | assertEquals(compareOperation.getResultCode(), |
| | | ResultCode.COMPARE_TRUE); |
| | | } |
| | | |
| | | @Test |
| | | public void testCompareTrueAssertion() throws Exception |
| | | { |
| | | InvocationCounterPlugin.resetAllCounters(); |
| | |
| | | |
| | | // attribute options |
| | | {JOHN_SMITH_LDIF, "(cn;lang-en=Jonathan Smith)", true}, |
| | | {JOHN_SMITH_LDIF, "(cn;lang-EN=Jonathan Smith)", true}, |
| | | {JOHN_SMITH_LDIF, "(cn;lang-en=Jonathan Smithe)", false}, |
| | | {JOHN_SMITH_LDIF, "(cn;lang-fr=Jonathan Smith)", false}, |
| | | {JOHN_SMITH_LDIF, "(cn;lang-en=*jon*an*)", true}, |
| | | {JOHN_SMITH_LDIF, "(cn;lAnG-En=*jon*an*)", true}, |
| | | |
| | | // attribute subtypes. Enable this once 593 is fixed. |
| | | // {JOHN_SMITH_LDIF, "(name=John Smith)", true}, |
| | | // {JOHN_SMITH_LDIF, "(name=*Smith*)", true}, |
| | | // {JOHN_SMITH_LDIF, "(name;lang-en=Jonathan Smith)", true}, // ? maybe not |
| | | // {JOHN_SMITH_LDIF, "(name;lang-en=*Jonathan*)", true}, // ? maybe not |
| | | {JOHN_SMITH_LDIF, "(name=John Smith)", true}, |
| | | {JOHN_SMITH_LDIF, "(name=*Smith*)", true}, |
| | | {JOHN_SMITH_LDIF, "(name;lang-en=Jonathan Smith)", true}, |
| | | {JOHN_SMITH_LDIF, "(name;lang-EN=Jonathan Smith)", true}, |
| | | {JOHN_SMITH_LDIF, "(name;lang-en=*Jonathan*)", true}, |
| | | |
| | | // Enable this once |
| | | // {JOHN_SMITH_LDIF, "(cn=*Jo**i*th*)", true}, |