From e4c0edea06c8fee28369f03f393b7d54b2b6235c Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 16 Sep 2016 13:25:06 +0000
Subject: [PATCH] OPENDJ-3246 Return the CREST descriptor over REST for rest2ldap endpoints
---
opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/SubResourceCollection.java | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/SubResourceCollection.java b/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/SubResourceCollection.java
index bf79ec4..7713ced 100644
--- a/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/SubResourceCollection.java
+++ b/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/SubResourceCollection.java
@@ -28,6 +28,8 @@
import static org.forgerock.opendj.rest2ldap.Utils.newBadRequestException;
import static org.forgerock.util.promise.Promises.newResultPromise;
+import org.forgerock.api.models.ApiDescription;
+import org.forgerock.http.ApiProducer;
import org.forgerock.http.routing.UriRouterContext;
import org.forgerock.i18n.LocalizedIllegalArgumentException;
import org.forgerock.json.resource.ActionRequest;
@@ -378,6 +380,11 @@
protected <V> Promise<V, ResourceException> handleRequest(final Context context, final Request request) {
return new BadRequestException(ERR_UNSUPPORTED_REQUEST_AGAINST_COLLECTION.get().toString()).asPromise();
}
+
+ @Override
+ public ApiDescription api(ApiProducer<ApiDescription> producer) {
+ return resource.collectionApi(isReadOnly);
+ }
}
/**
@@ -444,5 +451,17 @@
private <T> Function<ResourceException, T, ResourceException> convert404To400() {
return SubResource.convert404To400(ERR_UNSUPPORTED_REQUEST_AGAINST_INSTANCE.get());
}
+
+ /**
+ * Returns {@code null} because the corresponding {@link ApiDescription}
+ * is returned by the {@link CollectionHandler#api(ApiProducer)} method.
+ * <p>
+ * This avoids problems when trying to {@link ApiProducer#merge(java.util.List) merge}
+ * {@link ApiDescription}s with the same path.
+ */
+ @Override
+ public ApiDescription api(ApiProducer<ApiDescription> producer) {
+ return null;
+ }
}
}
--
Gitblit v1.10.0