From 0930abd89f504f1b374467af2311676bfc82c0d6 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Wed, 06 Mar 2013 10:01:06 +0000
Subject: [PATCH] Minor improvements:
---
opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/ReferenceAttributeMapper.java | 55 +++++++++++++++++++++++++++++++++----------------------
1 files changed, 33 insertions(+), 22 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 02b6be7..7b52566 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
@@ -113,31 +113,42 @@
if (attribute == null) {
h.handleResult(null);
} else if (attributeIsSingleValued()) {
- final DN dn = attribute.parse().usingSchema(c.getConfig().schema()).asDN();
- readEntry(c, dn, h);
+ try {
+ final DN dn = attribute.parse().usingSchema(c.getConfig().schema()).asDN();
+ readEntry(c, dn, h);
+ } catch (Exception ex) {
+ // The LDAP attribute could not be decoded.
+ h.handleError(adapt(ex));
+ }
} else {
- final Set<DN> dns = attribute.parse().usingSchema(c.getConfig().schema()).asSetOfDN();
- final ResultHandler<JsonValue> handler =
- accumulate(dns.size(), transform(
- new Function<List<JsonValue>, JsonValue, Void>() {
- @Override
- public JsonValue apply(final List<JsonValue> value, final Void p) {
- if (value.isEmpty()) {
- // No values, so omit the entire JSON object from the resource.
- return null;
- } else {
- // Combine values into a single JSON array.
- final List<Object> result =
- new ArrayList<Object>(value.size());
- for (final JsonValue e : value) {
- result.add(e.getObject());
+ try {
+ final Set<DN> dns =
+ attribute.parse().usingSchema(c.getConfig().schema()).asSetOfDN();
+ final ResultHandler<JsonValue> handler =
+ accumulate(dns.size(), transform(
+ new Function<List<JsonValue>, JsonValue, Void>() {
+ @Override
+ public JsonValue apply(final List<JsonValue> value, final Void p) {
+ if (value.isEmpty()) {
+ // No values, so omit the entire JSON object from the resource.
+ return null;
+ } else {
+ // Combine values into a single JSON array.
+ final List<Object> result =
+ new ArrayList<Object>(value.size());
+ for (final JsonValue e : value) {
+ result.add(e.getObject());
+ }
+ return new JsonValue(result);
}
- return new JsonValue(result);
}
- }
- }, h));
- for (final DN dn : dns) {
- readEntry(c, dn, handler);
+ }, h));
+ for (final DN dn : dns) {
+ readEntry(c, dn, handler);
+ }
+ } catch (Exception ex) {
+ // The LDAP attribute could not be decoded.
+ h.handleError(adapt(ex));
}
}
}
--
Gitblit v1.10.0