| | |
| | | |
| | | 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 { |
| | | |
| | |
| | | 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 |
| | |
| | | * @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; |
| | | } |
| | |
| | | /** |
| | | * {@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 |
| | | |
| | | } |