From 693f202e6a2b99f21b9ea208ad70567487a72643 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Fri, 08 Mar 2013 18:20:41 +0000
Subject: [PATCH] Final fix for OPENDJ-699: Implement DN reference mapping

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

diff --git a/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAP.java b/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAP.java
index 9964e7f..ef84e2f 100644
--- a/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAP.java
+++ b/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAP.java
@@ -369,8 +369,10 @@
                 final AttributeDescription ldapAttribute =
                         ad(config.get("ldapAttribute").required().asString());
                 final DN baseDN = DN.valueOf(config.get("baseDN").required().asString(), schema);
+                final AttributeDescription primaryKey =
+                        ad(config.get("primaryKey").required().asString());
                 final AttributeMapper m = configureMapper(config.get("mapper").required());
-                final ReferenceAttributeMapper r = reference(ldapAttribute, baseDN, m);
+                final ReferenceAttributeMapper r = reference(ldapAttribute, baseDN, primaryKey, m);
                 if (config.get("isRequired").defaultTo(false).asBoolean()) {
                     r.isRequired();
                 }
@@ -649,13 +651,14 @@
     }
 
     public static ReferenceAttributeMapper reference(final AttributeDescription attribute,
-            final DN baseDN, final AttributeMapper mapper) {
-        return new ReferenceAttributeMapper(attribute, baseDN, mapper);
+            final DN baseDN, final AttributeDescription primaryKey, final AttributeMapper mapper) {
+        return new ReferenceAttributeMapper(attribute, baseDN, primaryKey, mapper);
     }
 
     public static ReferenceAttributeMapper reference(final String attribute, final String baseDN,
-            final AttributeMapper mapper) {
-        return reference(AttributeDescription.valueOf(attribute), DN.valueOf(baseDN), mapper);
+            final String primaryKey, final AttributeMapper mapper) {
+        return reference(AttributeDescription.valueOf(attribute), DN.valueOf(baseDN),
+                AttributeDescription.valueOf(primaryKey), mapper);
     }
 
     public static SimpleAttributeMapper simple(final AttributeDescription attribute) {

--
Gitblit v1.10.0