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/ReferenceAttributeMapper.java |   31 ++++++++++++++-----------------
 1 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/ReferenceAttributeMapper.java b/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/ReferenceAttributeMapper.java
index 3ac297f..c899a5d 100644
--- a/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/ReferenceAttributeMapper.java
+++ b/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/ReferenceAttributeMapper.java
@@ -38,7 +38,6 @@
 import org.forgerock.json.resource.ResultHandler;
 import org.forgerock.opendj.ldap.Attribute;
 import org.forgerock.opendj.ldap.AttributeDescription;
-import org.forgerock.opendj.ldap.Attributes;
 import org.forgerock.opendj.ldap.ByteString;
 import org.forgerock.opendj.ldap.DN;
 import org.forgerock.opendj.ldap.Entry;
@@ -183,12 +182,6 @@
     @Override
     void getNewLDAPAttributes(final Context c, final JsonPointer path,
             final List<Object> newValues, final ResultHandler<Attribute> h) {
-        // No need to do anything if there are no values.
-        if (newValues.isEmpty()) {
-            h.handleResult(Attributes.emptyAttribute(ldapAttributeName));
-            return;
-        }
-
         /*
          * For each value use the subordinate mapper to obtain the LDAP primary
          * key, the perform a search for each one to find the corresponding
@@ -252,21 +245,25 @@
                                                     try {
                                                         throw error;
                                                     } catch (final EntryNotFoundException e) {
-                                                        // FIXME: improve error message.
                                                         re =
                                                                 new BadRequestException(
-                                                                        "the resource referenced by '"
-                                                                                + primaryKeyValue
-                                                                                        .toString()
-                                                                                + "' does not exist");
+                                                                        i18n("The request cannot be processed "
+                                                                                + "because the resource '%s' "
+                                                                                + "referenced in field '%s' does "
+                                                                                + "not exist",
+                                                                                primaryKeyValue
+                                                                                        .toString(),
+                                                                                path));
                                                     } catch (final MultipleEntriesFoundException e) {
-                                                        // FIXME: improve error message.
                                                         re =
                                                                 new BadRequestException(
-                                                                        "the resource referenced by '"
-                                                                                + primaryKeyValue
-                                                                                        .toString()
-                                                                                + "' is ambiguous");
+                                                                        i18n("The request cannot be processed "
+                                                                                + "because the resource '%s' "
+                                                                                + "referenced in field '%s' is "
+                                                                                + "ambiguous",
+                                                                                primaryKeyValue
+                                                                                        .toString(),
+                                                                                path));
                                                     } catch (final ErrorResultException e) {
                                                         re = asResourceException(e);
                                                     }

--
Gitblit v1.10.0