From 58ffacee660a4eb792f49dd311a4e2ddda05afad Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Fri, 25 May 2012 22:12:32 +0000
Subject: [PATCH] Checkpoint local changes: add more attribute mapping support.

---
 opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/ComplexAttributeMapper.java |   33 ++++++++++-----------------------
 1 files changed, 10 insertions(+), 23 deletions(-)

diff --git a/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/ComplexAttributeMapper.java b/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/ComplexAttributeMapper.java
index fcd9f1b..3120ffc 100644
--- a/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/ComplexAttributeMapper.java
+++ b/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/ComplexAttributeMapper.java
@@ -51,35 +51,17 @@
      */
     public ComplexAttributeMapper(String jsonAttributeName, AttributeMapper mapper) {
         this.jsonAttributeName = jsonAttributeName;
-        this.normalizedJsonAttributeName = toLowerCase(jsonAttributeName);
         this.mapper = mapper;
+        this.normalizedJsonAttributeName = toLowerCase(jsonAttributeName);
     }
 
     /**
      * {@inheritDoc}
      */
-    public void getLDAPAttributes(Set<String> ldapAttributes) {
-        mapper.getLDAPAttributes(ldapAttributes);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    public void getLDAPAttributes(Set<String> ldapAttributes, JsonPointer resourceAttribute) {
-        if (resourceAttribute.size() > 0) {
-            String rootName = resourceAttribute.get(0);
-            if (toLowerCase(rootName).equals(normalizedJsonAttributeName)) {
-                JsonPointer relativePointer = resourceAttribute.relativePointer();
-                if (relativePointer == null) {
-                    // User requested the entire contents of this complex
-                    // attribute.
-                    mapper.getLDAPAttributes(ldapAttributes);
-                } else {
-                    // User requested partial contents of this complex
-                    // attribute.
-                    mapper.getLDAPAttributes(ldapAttributes, relativePointer);
-                }
-            }
+    public void getLDAPAttributes(JsonPointer jsonAttribute, Set<String> ldapAttributes) {
+        if (attributeMatchesPointer(jsonAttribute)) {
+            JsonPointer relativePointer = jsonAttribute.relativePointer();
+            mapper.getLDAPAttributes(relativePointer, ldapAttributes);
         }
     }
 
@@ -112,4 +94,9 @@
 
     }
 
+    private boolean attributeMatchesPointer(JsonPointer resourceAttribute) {
+        return resourceAttribute.isEmpty()
+                || toLowerCase(resourceAttribute.get(0)).equals(normalizedJsonAttributeName);
+    }
+
 }

--
Gitblit v1.10.0