From 92c2f4c29958502b6dee0da079f7687bc5f27af0 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Thu, 11 Apr 2013 09:05:06 +0000
Subject: [PATCH] Fix for OPENDJ-693: Implement modify/update support

---
 opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/SimpleAttributeMapper.java |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/SimpleAttributeMapper.java b/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/SimpleAttributeMapper.java
index b59180f..c7bc8c2 100644
--- a/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/SimpleAttributeMapper.java
+++ b/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/SimpleAttributeMapper.java
@@ -28,6 +28,7 @@
 import static org.forgerock.opendj.rest2ldap.Utils.jsonToByteString;
 import static org.forgerock.opendj.rest2ldap.Utils.toFilter;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
 
@@ -77,7 +78,6 @@
      * @return This attribute mapper.
      */
     public SimpleAttributeMapper defaultJSONValue(final Object defaultValue) {
-        this.defaultJSONValue = defaultValue;
         this.defaultJSONValues = defaultValue != null ? singletonList(defaultValue) : emptyList();
         return this;
     }
@@ -157,11 +157,13 @@
         try {
             final Object value;
             if (attributeIsSingleValued()) {
-                value = e.parseAttribute(ldapAttributeName).as(decoder(), defaultJSONValue);
+                value =
+                        e.parseAttribute(ldapAttributeName).as(decoder(),
+                                defaultJSONValues.isEmpty() ? null : defaultJSONValues.get(0));
             } else {
                 final Set<Object> s =
                         e.parseAttribute(ldapAttributeName).asSetOf(decoder(), defaultJSONValues);
-                value = s.isEmpty() ? null : s;
+                value = s.isEmpty() ? null : new ArrayList<Object>(s);
             }
             h.handleResult(value != null ? new JsonValue(value) : null);
         } catch (final Exception ex) {

--
Gitblit v1.10.0