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

Jean-Noël Rouvignac
30.55.2015 0e8959961d70e402fccea12d371756d10df5f34b
IntegerFirstComponentEqualityMatchingRuleImpl.java: In normalizeAttributeValue(), used ByteString.valueOfObject() instead of ByteString.valueOfInt()

SubstringReader.java:
Added toString()
2 files modified
41 ■■■■ changed files
opendj-sdk/opendj-core/src/main/java/com/forgerock/opendj/util/SubstringReader.java 10 ●●●●● patch | view | raw | blame | history
opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/IntegerFirstComponentEqualityMatchingRuleImpl.java 31 ●●●●● patch | view | raw | blame | history
opendj-sdk/opendj-core/src/main/java/com/forgerock/opendj/util/SubstringReader.java
@@ -22,7 +22,7 @@
 *
 *
 *      Copyright 2009-2010 Sun Microsystems, Inc.
 *      Portions copyright 2012 ForgeRock AS.
 *      Portions copyright 2012-2015 ForgeRock AS.
 */
package com.forgerock.opendj.util;
@@ -150,4 +150,12 @@
        }
        return skipped;
    }
    @Override
    public String toString() {
        return getClass().getSimpleName() + "("
                + "source=" + source
                + ", remaining=" + source.substring(pos, length)
                + ")";
    }
}
opendj-sdk/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/IntegerFirstComponentEqualityMatchingRuleImpl.java
@@ -54,36 +54,27 @@
    }
    @Override
    public Assertion getAssertion(final Schema schema, final ByteSequence assertionValue)
            throws DecodeException {
    public Assertion getAssertion(final Schema schema, final ByteSequence assertionValue) throws DecodeException {
        try {
            final String definition = assertionValue.toString();
            final SubstringReader reader = new SubstringReader(definition);
            final int intValue = SchemaUtils.readRuleID(reader);
            return defaultAssertion(ByteString.valueOfInt(intValue));
            return defaultAssertion(normalizeRuleID(new SubstringReader(definition)));
        } catch (final Exception e) {
            logger.debug(LocalizableMessage.raw("%s", e));
            final LocalizableMessage message =
                    ERR_EMR_INTFIRSTCOMP_FIRST_COMPONENT_NOT_INT.get(assertionValue.toString());
            throw DecodeException.error(message);
            throw DecodeException.error(ERR_EMR_INTFIRSTCOMP_FIRST_COMPONENT_NOT_INT.get(assertionValue));
        }
    }
    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value)
            throws DecodeException {
    public ByteString normalizeAttributeValue(final Schema schema, final ByteSequence value) throws DecodeException {
        final String definition = value.toString();
        final SubstringReader reader = new SubstringReader(definition);
        // We'll do this a character at a time. First, skip over any leading
        // whitespace.
        // We'll do this a character at a time. First, skip over any leading whitespace.
        reader.skipWhitespaces();
        if (reader.remaining() <= 0) {
            // This means that the value was empty or contained only
            // whitespace. That is illegal.
            final LocalizableMessage message = ERR_ATTR_SYNTAX_EMPTY_VALUE.get();
            throw DecodeException.error(message);
            // This means that the value was empty or contained only whitespace.
            // That is illegal.
            throw DecodeException.error(ERR_ATTR_SYNTAX_EMPTY_VALUE.get());
        }
        // The next character must be an open parenthesis.
@@ -98,6 +89,10 @@
        reader.skipWhitespaces();
        // The next set of characters must be the OID.
        return ByteString.valueOfObject(SchemaUtils.readRuleID(reader));
        return normalizeRuleID(reader);
    }
    private ByteString normalizeRuleID(final SubstringReader reader) throws DecodeException {
        return ByteString.valueOfInt(SchemaUtils.readRuleID(reader));
    }
}