From 9043b74320002a12a7a60153d8e865f13834aeae Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Tue, 8 Jun 2021 10:37:16 +0200 Subject: [PATCH] Feature #21584 added support for /ServiceEndpoint/{category} REST call --- CHANGELOG.md | 4 ++++ pom.xml | 2 +- .../resources/ServiceEndpointResource.java | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bc2ba3..0d5c9aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v1.2.0-SNAPSHOT] - [2021-06-08] + +- Feature #21584 added support for /ServiceEndpoint/{category} REST call + ## [v1.1.0-SNAPSHOT] - [2016-10-03] - porting to auth v.2 diff --git a/pom.xml b/pom.xml index 9b349f5..c03c6c3 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ 4.0.0 org.gcube.information-system icproxy - 1.1.1-SNAPSHOT + 1.2.0-SNAPSHOT ICProxy war diff --git a/src/main/java/org/gcube/informationsystem/icproxy/resources/ServiceEndpointResource.java b/src/main/java/org/gcube/informationsystem/icproxy/resources/ServiceEndpointResource.java index eb672e2..fb20b48 100644 --- a/src/main/java/org/gcube/informationsystem/icproxy/resources/ServiceEndpointResource.java +++ b/src/main/java/org/gcube/informationsystem/icproxy/resources/ServiceEndpointResource.java @@ -23,6 +23,19 @@ import org.gcube.resources.discovery.client.queries.api.SimpleQuery; @Slf4j @Path("ServiceEndpoint") public class ServiceEndpointResource { + + @GET + @Path("/{category}") + @Produces(MediaType.APPLICATION_XML) + public List retrieve(@NotNull @PathParam("category") String resourceCategory) { + log.info("ServiceEndpoint called with category {} in context {}",resourceCategory, ScopeProvider.instance.get()); + + DiscoveryClient client = clientFor(ServiceEndpoint.class); + + List endpoints = client.submit(getQuery(resourceCategory)); + log.debug("retrieved resources are "+endpoints.size()); + return endpoints; + } @GET @Path("/{category}/{name}") @@ -72,4 +85,10 @@ public class ServiceEndpointResource { return query; } + private SimpleQuery getQuery(String resourceCategory){ + SimpleQuery query = queryFor(ServiceEndpoint.class); + query.addCondition(String.format("$resource/Profile/Category/text() eq '%s'",resourceCategory)); + return query; + } + }