#23156 Added support to `query_string` to CatalogueResolver

This commit is contained in:
Francesco Mangiacrapa 2022-04-21 09:44:18 +02:00
parent ceddf17c1f
commit cda5599d27
5 changed files with 60 additions and 24 deletions

View File

@ -1,61 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> <?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="uri-resolver-2.7.2-SNAPSHOT">
<wb-module deploy-name="uri-resolver-2.7.2">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/> <wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<property name="context-root" value="uri-resolver"/> <property name="context-root" value="uri-resolver"/>
<property name="java-output-path" value="/uri-resolver/target/classes"/> <property name="java-output-path" value="/uri-resolver/target/classes"/>
</wb-module> </wb-module>

View File

@ -4,7 +4,13 @@
All notable changes to this project will be documented in this file. 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). 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** **New**
@ -18,7 +24,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- [#20743] Integration with javamelody - [#20743] Integration with javamelody
## [v2-6-1] - 2022-01-17 ## [v2.6.1] - 2022-01-17
**New features** **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 - [#21560] Checking the bug fix done
- Moved to gcube-smartgears-bom.2.1.0 - Moved to gcube-smartgears-bom.2.1.0
## [v2-5-0] - 2021-04-08 ## [v2.5.0] - 2021-04-08
**New features** **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 [#21093] StorageHubResolver HEAD request does not support Content-Length
## [v2-4-1] - 2021-01-13 ## [v2.4.1] - 2021-01-13
**Bug Fixes** **Bug Fixes**

View File

@ -9,7 +9,7 @@
</parent> </parent>
<groupId>org.gcube.data.transfer</groupId> <groupId>org.gcube.data.transfer</groupId>
<artifactId>uri-resolver</artifactId> <artifactId>uri-resolver</artifactId>
<version>2.7.2</version> <version>2.8.0-SNAPSHOT</version>
<packaging>war</packaging> <packaging>war</packaging>
<description>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.</description> <description>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.</description>

View File

@ -5,15 +5,14 @@ package org.gcube.datatransfer.resolver.catalogue;
* *
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* *
* Mar 24, 2022 * Apr 20, 2022
*
* Binding Catalogue Request as a JSON
*/ */
public class CatalogueRequest { public class CatalogueRequest {
private String gcube_scope; private String gcube_scope;
private String entity_context; private String entity_context;
private String entity_name; private String entity_name;
private String query_string;
/** /**
* Gets the gcube_scope. * Gets the gcube_scope.
@ -42,19 +41,22 @@ public class CatalogueRequest {
return entity_name; return entity_name;
} }
/**
* Gets the query string.
*
* @return the query string
*/
public String getQuery_string() {
return query_string;
}
/** /**
* To string. * To string.
* *
* @return the string * @return the string
*/ */
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("CatalogueRequest [gcube_scope="); builder.append("CatalogueRequest [gcube_scope=");
builder.append(gcube_scope); builder.append(gcube_scope);
@ -62,6 +64,8 @@ public class CatalogueRequest {
builder.append(entity_context); builder.append(entity_context);
builder.append(", entity_name="); builder.append(", entity_name=");
builder.append(entity_name); builder.append(entity_name);
builder.append(", query_string=");
builder.append(query_string);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }

View File

@ -2,6 +2,7 @@ package org.gcube.datatransfer.resolver.services;
import java.net.URI; import java.net.URI;
import java.net.URL; import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ExecutionException; 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.GatewayCKANCatalogueReference;
import org.gcube.datatransfer.resolver.catalogue.resource.GetAllInfrastructureScopes; import org.gcube.datatransfer.resolver.catalogue.resource.GetAllInfrastructureScopes;
import org.gcube.datatransfer.resolver.services.error.ExceptionManager; 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.datatransfer.resolver.util.Util;
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VRE; import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VRE;
import org.gcube.smartgears.utils.InnerMethodName; 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); + " 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(); return Response.seeOther(new URL(itemCatalogueURL).toURI()).build();
} catch (Exception e) { } 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()); 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); logger.info("Returining Catalogue URL: " + linkURL);
return Response.ok(linkURL).header("Location", linkURL).build(); return Response.ok(linkURL).header("Location", linkURL).build();