From cda5599d275c637bcb9d4d83ea39391ce70d70c1 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 21 Apr 2022 09:44:18 +0200 Subject: [PATCH] #23156 Added support to `query_string` to CatalogueResolver --- .settings/org.eclipse.wst.common.component | 29 ++++++++++++------- CHANGELOG.md | 14 ++++++--- pom.xml | 2 +- .../resolver/catalogue/CatalogueRequest.java | 22 ++++++++------ .../resolver/services/CatalogueResolver.java | 17 +++++++++++ 5 files changed, 60 insertions(+), 24 deletions(-) diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 589972b..1331b59 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,61 +1,70 @@ - + - - + + + + - + + - + + - + + - + + - + + - + + - + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 324d516..527e224 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,13 @@ 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). -## [v2-7.2] - 2022-04-06 +## [v2.8.0-SNAPSHOT] - 2022-04-20 + +**New** + +- [#23156] CatalogueResolver enhanced to manage (create/resolve) an input query string + +## [v2.7.2] - 2022-04-06 **New** @@ -18,7 +24,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - [#20743] Integration with javamelody -## [v2-6-1] - 2022-01-17 +## [v2.6.1] - 2022-01-17 **New features** @@ -30,7 +36,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - [#21560] Checking the bug fix done - Moved to gcube-smartgears-bom.2.1.0 -## [v2-5-0] - 2021-04-08 +## [v2.5.0] - 2021-04-08 **New features** @@ -41,7 +47,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm [#21093] StorageHubResolver HEAD request does not support Content-Length -## [v2-4-1] - 2021-01-13 +## [v2.4.1] - 2021-01-13 **Bug Fixes** diff --git a/pom.xml b/pom.xml index 24595a4..3df99b0 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.gcube.data.transfer uri-resolver - 2.7.2 + 2.8.0-SNAPSHOT war The URI Resolver is an HTTP URI resolver implemented as a REST service which gives access trough HTTP to different gcube Resolvers and gCube Applications. diff --git a/src/main/java/org/gcube/datatransfer/resolver/catalogue/CatalogueRequest.java b/src/main/java/org/gcube/datatransfer/resolver/catalogue/CatalogueRequest.java index 1a025e5..320ee3c 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/catalogue/CatalogueRequest.java +++ b/src/main/java/org/gcube/datatransfer/resolver/catalogue/CatalogueRequest.java @@ -5,15 +5,14 @@ package org.gcube.datatransfer.resolver.catalogue; * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Mar 24, 2022 - * - * Binding Catalogue Request as a JSON + * Apr 20, 2022 */ public class CatalogueRequest { private String gcube_scope; private String entity_context; private String entity_name; + private String query_string; /** * Gets the gcube_scope. @@ -42,19 +41,22 @@ public class CatalogueRequest { return entity_name; } + /** + * Gets the query string. + * + * @return the query string + */ + public String getQuery_string() { + return query_string; + } + /** * To string. * * @return the string */ - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ @Override public String toString() { - StringBuilder builder = new StringBuilder(); builder.append("CatalogueRequest [gcube_scope="); builder.append(gcube_scope); @@ -62,6 +64,8 @@ public class CatalogueRequest { builder.append(entity_context); builder.append(", entity_name="); builder.append(entity_name); + builder.append(", query_string="); + builder.append(query_string); builder.append("]"); return builder.toString(); } diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java index 6f781a5..7772103 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java @@ -2,6 +2,7 @@ package org.gcube.datatransfer.resolver.services; import java.net.URI; import java.net.URL; +import java.net.URLEncoder; import java.util.HashMap; import java.util.Map; import java.util.concurrent.ExecutionException; @@ -33,6 +34,7 @@ import org.gcube.datatransfer.resolver.catalogue.resource.CkanCatalogueConfigura import org.gcube.datatransfer.resolver.catalogue.resource.GatewayCKANCatalogueReference; import org.gcube.datatransfer.resolver.catalogue.resource.GetAllInfrastructureScopes; import org.gcube.datatransfer.resolver.services.error.ExceptionManager; +import org.gcube.datatransfer.resolver.util.UrlEncoderUtil; import org.gcube.datatransfer.resolver.util.Util; import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VRE; import org.gcube.smartgears.utils.InnerMethodName; @@ -115,6 +117,15 @@ public class CatalogueResolver { + " is a private item (to VRE) so using protected access to CKAN portlet: " + itemCatalogueURL); } + String queryString = req.getQueryString(); + if (queryString != null) { + logger.debug("Query string found: " + queryString); + String qsEnc = URLEncoder.encode(queryString, "UTF-8"); + logger.info("Adding encoded query string " + qsEnc + " to Catalogue URL response"); + + itemCatalogueURL += "?" + qsEnc; + } + return Response.seeOther(new URL(itemCatalogueURL).toURI()).build(); } catch (Exception e) { @@ -190,6 +201,12 @@ public class CatalogueResolver { } String linkURL = String.format("%s/%s/%s/%s", serverUrl, rc.getId(), vreName, jsonRequest.getEntity_name()); + + if (jsonRequest.getQuery_string() != null) { + String qsEnc = URLEncoder.encode(jsonRequest.getQuery_string(), "UTF-8"); + linkURL += "?" + qsEnc; + } + logger.info("Returining Catalogue URL: " + linkURL); return Response.ok(linkURL).header("Location", linkURL).build();