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

Matthew Swift
08.37.2013 d89aacc0431eab3dce367e8fe9575eb8f83aa535
opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/ConstantAttributeMapper.java
@@ -32,7 +32,7 @@
/**
 * An attribute mapper which maps a single JSON attribute to a fixed value.
 */
public class ConstantAttributeMapper implements AttributeMapper {
final class ConstantAttributeMapper extends AttributeMapper {
    private final String jsonAttributeName;
    private final Object jsonAttributeValue;
@@ -45,27 +45,20 @@
     * @param attributeValue
     *            The value of the simple JSON attribute.
     */
    public ConstantAttributeMapper(final String attributeName, final Object attributeValue) {
    ConstantAttributeMapper(final String attributeName, final Object attributeValue) {
        this.jsonAttributeName = attributeName;
        this.jsonAttributeValue = attributeValue;
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public void getLDAPAttributes(final Context c, final JsonPointer jsonAttribute,
    void getLDAPAttributes(final Context c, final JsonPointer jsonAttribute,
            final Set<String> ldapAttributes) {
        // Nothing to do.
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public void getLDAPFilter(final Context c, final FilterType type,
            final JsonPointer jsonAttribute, final String operator, final Object valueAssertion,
            final ResultHandler<Filter> h) {
    void getLDAPFilter(final Context c, final FilterType type, final JsonPointer jsonAttribute,
            final String operator, final Object valueAssertion, final ResultHandler<Filter> h) {
        if (jsonAttribute.size() == 1 && jsonAttribute.get(0).equalsIgnoreCase(jsonAttributeName)) {
            final Filter filter;
            if (type == FilterType.PRESENT) {
@@ -107,26 +100,20 @@
        }
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public void toJSON(final Context c, final Entry e, final ResultHandler<Map<String, Object>> h) {
    void toJSON(final Context c, final Entry e, final ResultHandler<Map<String, Object>> h) {
        // FIXME: how do we know if the user requested it???
        h.handleResult(Collections.singletonMap(jsonAttributeName, jsonAttributeValue));
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public void toLDAP(final Context c, final JsonValue v, final ResultHandler<List<Attribute>> h) {
    void toLDAP(final Context c, final JsonValue v, final ResultHandler<List<Attribute>> h) {
        // TODO Auto-generated method stub
    }
    private <T extends Comparable<T>> Filter compare(Context c, final FilterType type, final T v1,
            final T v2) {
    private <T extends Comparable<T>> Filter compare(final Context c, final FilterType type,
            final T v1, final T v2) {
        final Filter filter;
        switch (type) {
        case EQUAL_TO:
@@ -134,8 +121,7 @@
            break;
        case GREATER_THAN:
            filter =
                    v1.compareTo(v2) > 0 ? c.getConfig().trueFilter() : c.getConfig()
                            .falseFilter();
                    v1.compareTo(v2) > 0 ? c.getConfig().trueFilter() : c.getConfig().falseFilter();
            break;
        case GREATER_THAN_OR_EQUAL_TO:
            filter =
@@ -144,8 +130,7 @@
            break;
        case LESS_THAN:
            filter =
                    v1.compareTo(v2) < 0 ? c.getConfig().trueFilter() : c.getConfig()
                            .falseFilter();
                    v1.compareTo(v2) < 0 ? c.getConfig().trueFilter() : c.getConfig().falseFilter();
            break;
        case LESS_THAN_OR_EQUAL_TO:
            filter =