fixing the bug #21240

task_22385
Francesco Mangiacrapa 3 years ago
parent c2b787b19c
commit 361a9da7d1

@ -13,7 +13,12 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/test/resources"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>

@ -1,4 +1,5 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8

@ -3,11 +3,17 @@
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).
## [1-4-1] - 2020-05-06
### Changed
## [v1.4.2-SNAPSHOT] - 2021-04-21
### Bug fixes
[#21240] Generates broken gis-link
## [1-4-1] - 2020-05-06
**Fixes**
### Bug fixes
[#19215] UriResolverManager: request to DL (the shortener) must be encoded

@ -11,7 +11,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>uri-resolver-manager</artifactId>
<version>1.4.1</version>
<version>1.4.2-SNAPSHOT</version>
<packaging>jar</packaging>
<name>uri-resolver-manager</name>
<description>The URI Resolver Manager</description>
@ -49,7 +49,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-bom</artifactId>
<version>1.4.0</version>
<version>2.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>

@ -205,23 +205,27 @@ public class UriResolverManager {
}
String baseURI = serviceAccessPoint.getServiceUrl();
//Encoding only the query string
//TO ENCODE THE WHOLE URL
// String queryString = UrlEncoderUtil.toQueryString(parameters);
// link = baseURI+"?"+queryString;
// logger.info("Created HTTP URI request (link): "+link);
// link = UrlEncoderUtil.encodeString(link);
// logger.info("Encoded it, like: "+link);
//Enconding only the query string
String queryString = UrlEncoderUtil.toQueryString(parameters);
String linkDecoded = String.format("%s?%s", baseURI,queryString);
String queryStringEncoded = UrlEncoderUtil.encodeString(queryString);
link = String.format("%s?%s", baseURI,queryStringEncoded);
String linkDecoded = null;
String queryString = null;
if(!shortLink) {
//not shortening so returning the link with the query string with only the parameters encoded
queryString = UrlEncoderUtil.encodeQuery(parameters);
String toReturn = String.format("%s?%s", baseURI,queryString);
logger.info("returning link with encoded parameters in the query string: "+toReturn);
return toReturn;
}
queryString = UrlEncoderUtil.toQueryString(parameters);
linkDecoded = String.format("%s?%s", baseURI,queryString);
link = linkDecoded;
logger.info("Created HTTP URI request (link): "+link);
if(shortLink){
try{
String queryStringEncoded = UrlEncoderUtil.encodeString(queryString);
link = String.format("%s?%s", baseURI,queryStringEncoded);
logger.info("Encoded link is: "+link);
logger.info("Shortner start..");
UrlShortener shortener = new UrlShortener();
String shortedLink = shortener.shorten(link);

@ -5,7 +5,6 @@ import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.uriresolvermanager.UriResolverManager;
import org.gcube.portlets.user.uriresolvermanager.exception.IllegalArgumentException;
import org.gcube.portlets.user.uriresolvermanager.exception.UriResolverMapException;
import org.junit.Test;
/**
*
@ -45,7 +44,7 @@ public class UriResolverManagerTest {
Map<String, String> params = new HashMap<String, String>();
params.put("gis-UUID", "1a657005-29c6-4528-a115-69640c4c2900");
params.put("scope", "/pred4s/preprod/preVRE");
String shortLink = resolver.getLink(params, true);
String shortLink = resolver.getLink(params, false);
System.out.println(shortLink); //true, link is shorted otherwise none
} catch (UriResolverMapException e) {
e.printStackTrace();

@ -13,3 +13,4 @@
/log4j.properties
/pred4s.gcubekey
/preprod.gcubekey
/devVRE.gcubekey

Loading…
Cancel
Save