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

Matthew Swift
20.10.2012 db786032bf45be89c4a893281911364d158cfb6e
opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/ConstantAttributeMapper.java
@@ -23,12 +23,13 @@
import org.forgerock.json.fluent.JsonPointer;
import org.forgerock.json.fluent.JsonValue;
import org.forgerock.json.resource.ResultHandler;
import org.forgerock.json.resource.ServerContext;
import org.forgerock.opendj.ldap.Attribute;
import org.forgerock.opendj.ldap.Entry;
import org.forgerock.resource.provider.Context;
/**
 *
 * An attribute mapper which maps a single JSON attribute to a fixed value.
 */
public class ConstantAttributeMapper implements AttributeMapper {
@@ -36,7 +37,7 @@
    private final Object jsonAttributeValue;
    /**
     * Creates a new constant attribute mapper which maps a single LDAP
     * Creates a new constant attribute mapper which maps a single JSON
     * attribute to a fixed value.
     *
     * @param attributeName
@@ -44,7 +45,7 @@
     * @param attributeValue
     *            The value of the simple JSON attribute.
     */
    public ConstantAttributeMapper(String attributeName, Object attributeValue) {
    public ConstantAttributeMapper(final String attributeName, final Object attributeValue) {
        this.jsonAttributeName = attributeName;
        this.jsonAttributeValue = attributeValue;
    }
@@ -52,26 +53,27 @@
    /**
     * {@inheritDoc}
     */
    public void getLDAPAttributes(JsonPointer jsonAttribute, Set<String> ldapAttributes) {
    public void getLDAPAttributes(final JsonPointer jsonAttribute, final Set<String> ldapAttributes) {
        // Nothing to do.
    }
    /**
     * {@inheritDoc}
     */
    public void toJson(Context c, Entry e,
            final AttributeMapperCompletionHandler<Map<String, Object>> h) {
    public void toJson(final ServerContext c, final Entry e,
            final ResultHandler<Map<String, Object>> h) {
        // FIXME: how do we know if the user requested it???
        Map<String, Object> result =
                Collections.singletonMap(jsonAttributeName, jsonAttributeValue);
        h.onSuccess(result);
        final Map<String, Object> result = Collections.singletonMap(jsonAttributeName,
                jsonAttributeValue);
        h.handleResult(result);
    }
    /**
     * {@inheritDoc}
     */
    public void toLDAP(Context c, JsonValue v, AttributeMapperCompletionHandler<List<Attribute>> h) {
    public void toLDAP(final ServerContext c, final JsonValue v,
            final ResultHandler<List<Attribute>> h) {
        // TODO Auto-generated method stub
    }