Supported share links to Geoportal Data-Entry app #27160

This commit is contained in:
Francesco Mangiacrapa 2024-04-05 10:14:47 +02:00
parent 3dbd14b2b6
commit ef116da956
9 changed files with 213 additions and 65 deletions

View File

@ -167,6 +167,7 @@ public class UriResolverManager {
throw new IllegalArgumentException("Application type is null"); throw new IllegalArgumentException("Application type is null");
Resolver resolver = this.applicationTypes.get(applicationType); Resolver resolver = this.applicationTypes.get(applicationType);
LOG.debug("The resolver found is of kind: "+ resolver.getClass().getSimpleName());
String link = null; String link = null;
if (parameters == null) if (parameters == null)

View File

@ -11,6 +11,21 @@ import java.util.Map;
*/ */
public interface Resolver { public interface Resolver {
//Code used to implement specific (so override) the method 'getLink' of the Resolver
public static enum RESOLVER_ENTRYNAME {
CTLG("ctlg"), SMP("smp"), SHUB("shub"), GEO("geo"), GIS("gis");
String entryName;
RESOLVER_ENTRYNAME(String entryName) {
this.entryName = entryName;
}
public String getEntryName() {
return entryName;
}
}
/** /**
* Gets the resource name. * Gets the resource name.
* *

View File

@ -14,8 +14,9 @@ import org.gcube.common.resources.gcore.utils.XPathHelper;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.uriresolvermanager.entity.GenericResolver; import org.gcube.portlets.user.uriresolvermanager.entity.GenericResolver;
import org.gcube.portlets.user.uriresolvermanager.entity.Resolver; import org.gcube.portlets.user.uriresolvermanager.entity.Resolver;
import org.gcube.portlets.user.uriresolvermanager.resolvers.CatalogueResolverCallBuilder; import org.gcube.portlets.user.uriresolvermanager.resolvers.CatalogueResolver;
import org.gcube.portlets.user.uriresolvermanager.resolvers.SHUBResolverCallBuilder; import org.gcube.portlets.user.uriresolvermanager.resolvers.GeoportalResolver;
import org.gcube.portlets.user.uriresolvermanager.resolvers.SHUBResolver;
import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.Query; import org.gcube.resources.discovery.client.queries.api.Query;
import org.gcube.resources.discovery.client.queries.impl.QueryBox; import org.gcube.resources.discovery.client.queries.impl.QueryBox;
@ -117,10 +118,12 @@ public class UriResolverMapReader {
String resoureName = resources.get(0); String resoureName = resources.get(0);
String entryName = entryNames.get(0); String entryName = entryNames.get(0);
Resolver resolver; Resolver resolver;
if (entryName.equalsIgnoreCase("ctlg")) { if (entryName.equalsIgnoreCase(Resolver.RESOLVER_ENTRYNAME.CTLG.getEntryName())) {
resolver = new CatalogueResolverCallBuilder(resoureName, entryName); resolver = new CatalogueResolver(resoureName, entryName);
} else if (entryName.equalsIgnoreCase("shub")) { } else if (entryName.equalsIgnoreCase(Resolver.RESOLVER_ENTRYNAME.SHUB.getEntryName())) {
resolver = new SHUBResolverCallBuilder(resoureName, entryName); resolver = new SHUBResolver(resoureName, entryName);
} else if (entryName.equalsIgnoreCase(Resolver.RESOLVER_ENTRYNAME.GEO.getEntryName())) {
resolver = new GeoportalResolver(resoureName, entryName);
} else { } else {
resolver = new GenericResolver(resoureName, entryName); resolver = new GenericResolver(resoureName, entryName);
} }

View File

@ -18,16 +18,16 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* The Class CatalogueResolverCallBuilder. * The Class CatalogueResolver.
* *
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* *
* Nov 5, 2021 * Apr 4, 2024
*/ */
public class CatalogueResolverCallBuilder extends GenericResolver { public class CatalogueResolver extends GenericResolver {
private static final int _60SEC = 60000; private static final int _60SEC = 60000;
public static final Logger LOG = LoggerFactory.getLogger(CatalogueResolverCallBuilder.class); public static final Logger LOG = LoggerFactory.getLogger(CatalogueResolver.class);
/** /**
* Instantiates a new catalogue resolver wrapper. * Instantiates a new catalogue resolver wrapper.
@ -35,7 +35,7 @@ public class CatalogueResolverCallBuilder extends GenericResolver {
* @param resourceName the resource name * @param resourceName the resource name
* @param entryName the entry name * @param entryName the entry name
*/ */
public CatalogueResolverCallBuilder(String resourceName, String entryName) { public CatalogueResolver(String resourceName, String entryName) {
super(resourceName, entryName); super(resourceName, entryName);
} }
@ -88,16 +88,16 @@ public class CatalogueResolverCallBuilder extends GenericResolver {
theResponse = readResponse(con.getInputStream()); theResponse = readResponse(con.getInputStream());
if (!((200 <= code) && (code <= 208))) { if (!((200 <= code) && (code <= 208))) {
throw new Exception("CatalogueResolver returned code: " + code + ". Response is: " + theResponse); throw new Exception(CatalogueResolver.class.getSimpleName()+" returned code: " + code + ". Response is: " + theResponse);
} }
} catch (IOException e) { } catch (IOException e) {
theResponse = readResponse(con.getInputStream()); theResponse = readResponse(con.getInputStream());
LOG.error("CatalogueResolver returned code: " + code + ". Response is: " + theResponse); LOG.error(CatalogueResolver.class.getSimpleName()+" returned code: " + code + ". Response is: " + theResponse);
throw e; throw e;
} }
} catch (Exception e) { } catch (Exception e) {
LOG.error(CatalogueResolverCallBuilder.class.getSimpleName() + " error: ", e); LOG.error(CatalogueResolver.class.getSimpleName() + " error: ", e);
throw e; throw e;
} finally { } finally {
try { try {
@ -115,7 +115,7 @@ public class CatalogueResolverCallBuilder extends GenericResolver {
/** /**
* Short link. * Short link.
* *
* @param theLink the the link * @param theLink the the link
* @param parameters the parameters * @param parameters the parameters
* @return the string * @return the string
* @throws Exception the exception * @throws Exception the exception
@ -127,27 +127,13 @@ public class CatalogueResolverCallBuilder extends GenericResolver {
String linkDecoded = theLink; String linkDecoded = theLink;
String[] queryStringArray = theLink.split("\\?"); String[] queryStringArray = theLink.split("\\?");
if(queryStringArray.length>1) { if (queryStringArray.length > 1) {
String queryString = queryStringArray[1]; String queryString = queryStringArray[1];
String queryStringEncoded = UrlEncoderUtil.encodeQuery(queryString); String queryStringEncoded = UrlEncoderUtil.encodeQuery(queryString);
theLink = String.format("%s?%s", queryStringArray[0], queryStringEncoded); theLink = String.format("%s?%s", queryStringArray[0], queryStringEncoded);
} }
// if (parameters != null) {
// LOG.debug("Trying to read the parameter: " + CatalogueResolverQueryStringBuilder.QUERY_STRING_PARAMETER);
// String queryStringParmeters = parameters.get(CatalogueResolverQueryStringBuilder.QUERY_STRING_PARAMETER);
// if (queryStringParmeters != null) {
// LOG.debug(CatalogueResolverQueryStringBuilder.QUERY_STRING_PARAMETER + " found");
// queryString = UrlEncoderUtil.encodeQuery(queryStringParmeters);
// }
// }
try { try {
// LOG.debug(CatalogueResolverQueryStringBuilder.QUERY_STRING_PARAMETER + " encoded is: " + queryString);
// if (queryString != null) {
// String queryStringEncoded = UrlEncoderUtil.encodeString(queryString);
// theLink = String.format("%s?%s", theLink, queryStringEncoded);
// }
LOG.info("Encoded link is: " + theLink); LOG.info("Encoded link is: " + theLink);
LOG.info("Shortner starts.."); LOG.info("Shortner starts..");
String shortLink = shortTheLink(theLink); String shortLink = shortTheLink(theLink);

View File

@ -11,6 +11,8 @@ import java.net.URL;
import java.util.Map; import java.util.Map;
import org.gcube.portlets.user.uriresolvermanager.entity.GenericResolver; import org.gcube.portlets.user.uriresolvermanager.entity.GenericResolver;
import org.gcube.portlets.user.uriresolvermanager.resolvers.query.GeoportalResolverQueryStringBuilder;
import org.gcube.portlets.user.uriresolvermanager.resolvers.query.GeoportalResolverQueryStringBuilder.TARGET_GEOPORTAL_APP;
import org.gcube.portlets.user.uriresolvermanager.util.UrlEncoderUtil; import org.gcube.portlets.user.uriresolvermanager.util.UrlEncoderUtil;
import org.gcube.portlets.user.urlshortener.UrlShortener; import org.gcube.portlets.user.urlshortener.UrlShortener;
import org.json.JSONObject; import org.json.JSONObject;
@ -18,16 +20,16 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* The Class GeoportalResolverCallBuilder. * The Class GeoportalResolver.
* *
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* *
* Mar 27, 2023 * Apr 4, 2024
*/ */
public class GeoportalResolverCallBuilder extends GenericResolver { public class GeoportalResolver extends GenericResolver {
private static final int _60SEC = 60000; private static final int _60SEC = 60000;
public static final Logger LOG = LoggerFactory.getLogger(GeoportalResolverCallBuilder.class); public static final Logger LOG = LoggerFactory.getLogger(GeoportalResolver.class);
/** /**
* Instantiates a new geoportal resolver call builder. * Instantiates a new geoportal resolver call builder.
@ -35,7 +37,7 @@ public class GeoportalResolverCallBuilder extends GenericResolver {
* @param resourceName the resource name * @param resourceName the resource name
* @param entryName the entry name * @param entryName the entry name
*/ */
public GeoportalResolverCallBuilder(String resourceName, String entryName) { public GeoportalResolver(String resourceName, String entryName) {
super(resourceName, entryName); super(resourceName, entryName);
} }
@ -55,6 +57,22 @@ public class GeoportalResolverCallBuilder extends GenericResolver {
String theResponse = null; String theResponse = null;
try { try {
String targetApp = parameters.get(GeoportalResolverQueryStringBuilder.TARGET_APP_AS_PARAMETER);
if (targetApp != null) {
LOG.debug("targetApp is not null: " + targetApp);
baseURI = String.format("%s/%s", baseURI, targetApp);
parameters.remove(GeoportalResolverQueryStringBuilder.TARGET_APP_AS_PARAMETER);
LOG.debug("removed target app from parameters and added to URI as /" + targetApp);
}else {
//Applying default
targetApp = TARGET_GEOPORTAL_APP.GEO_DV.getTargetPath();
LOG.info(GeoportalResolverQueryStringBuilder.TARGET_APP_AS_PARAMETER +" is null using default: " + targetApp);
baseURI = String.format("%s/%s", baseURI, targetApp);
}
LOG.info("Request to URL: " + baseURI);
URL urlObj = new URL(baseURI); URL urlObj = new URL(baseURI);
con = (HttpURLConnection) urlObj.openConnection(); con = (HttpURLConnection) urlObj.openConnection();
con.setRequestMethod("POST"); con.setRequestMethod("POST");
@ -70,11 +88,6 @@ public class GeoportalResolverCallBuilder extends GenericResolver {
jObj.put(key, parameters.get(key)); jObj.put(key, parameters.get(key));
} }
// if (queryStringParameters != null) {
// String queryString = UrlEncoderUtil.toQueryString(queryStringParameters);
// jObj.put(CatalogueResolverQueryStringBuilder.QUERY_STRING_PARAMETER, queryString);
// }
String toJSON = jObj.toString(); String toJSON = jObj.toString();
LOG.info("Submitting JSON: " + toJSON); LOG.info("Submitting JSON: " + toJSON);
Integer code = null; Integer code = null;
@ -88,16 +101,16 @@ public class GeoportalResolverCallBuilder extends GenericResolver {
theResponse = readResponse(con.getInputStream()); theResponse = readResponse(con.getInputStream());
if (!((200 <= code) && (code <= 208))) { if (!((200 <= code) && (code <= 208))) {
throw new Exception("CatalogueResolver returned code: " + code + ". Response is: " + theResponse); throw new Exception(GeoportalResolver.class.getSimpleName()+ " returned code: " + code + ". Response is: " + theResponse);
} }
} catch (IOException e) { } catch (IOException e) {
theResponse = readResponse(con.getInputStream()); theResponse = readResponse(con.getInputStream());
LOG.error("CatalogueResolver returned code: " + code + ". Response is: " + theResponse); LOG.error(GeoportalResolver.class.getSimpleName()+ " returned code: " + code + ". Response is: " + theResponse);
throw e; throw e;
} }
} catch (Exception e) { } catch (Exception e) {
LOG.error(GeoportalResolverCallBuilder.class.getSimpleName() + " error: ", e); LOG.error(GeoportalResolver.class.getSimpleName() + " error: ", e);
throw e; throw e;
} finally { } finally {
try { try {

View File

@ -8,15 +8,15 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
/** /**
* The Class SHUBResolverCallBuilder. * The Class SHUBResolver.
* *
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* *
* Nov 8, 2021 * Apr 4, 2024
*/ */
public class SHUBResolverCallBuilder extends GenericResolver { public class SHUBResolver extends GenericResolver {
public static final Logger LOG = LoggerFactory.getLogger(SHUBResolverCallBuilder.class); public static final Logger LOG = LoggerFactory.getLogger(SHUBResolver.class);
/** /**
* Instantiates a new catalogue resolver wrapper. * Instantiates a new catalogue resolver wrapper.
@ -24,7 +24,7 @@ public class SHUBResolverCallBuilder extends GenericResolver {
* @param resourceName the resource name * @param resourceName the resource name
* @param entryName the entry name * @param entryName the entry name
*/ */
public SHUBResolverCallBuilder(String resourceName, String entryName) { public SHUBResolver(String resourceName, String entryName) {
super(resourceName, entryName); super(resourceName, entryName);
} }
@ -38,7 +38,7 @@ public class SHUBResolverCallBuilder extends GenericResolver {
*/ */
@Override @Override
public String getLink(String baseURI, Map<String, String> parameters) throws Exception { public String getLink(String baseURI, Map<String, String> parameters) throws Exception {
LOG.debug("called getLink: " + baseURI + " parameters: "+parameters); LOG.debug("called getLink: " + baseURI + " parameters: " + parameters);
String toReturn = null; String toReturn = null;
try { try {
@ -51,11 +51,11 @@ public class SHUBResolverCallBuilder extends GenericResolver {
toReturn = pathURI; toReturn = pathURI;
String queryString = UrlEncoderUtil.encodeQuery(parameters); String queryString = UrlEncoderUtil.encodeQuery(parameters);
if(!queryString.isEmpty()) if (!queryString.isEmpty())
toReturn = String.format("%s?%s", pathURI, queryString); toReturn = String.format("%s?%s", pathURI, queryString);
} catch (Exception e) { } catch (Exception e) {
LOG.error(SHUBResolverCallBuilder.class.getSimpleName() + " error: ", e); LOG.error(SHUBResolver.class.getSimpleName() + " error: ", e);
throw e; throw e;
} }
LOG.info("Got Link: " + toReturn); LOG.info("Got Link: " + toReturn);

View File

@ -13,6 +13,7 @@ public class GeoportalResolverQueryString {
private String itemId; private String itemId;
private String gcubeScope; private String gcubeScope;
private String resolveAs; private String resolveAs;
private String targetApp;
/** /**
* Instantiates a new geoportal resolver query string. * Instantiates a new geoportal resolver query string.
@ -24,6 +25,7 @@ public class GeoportalResolverQueryString {
this.itemId = builder.getItemId(); this.itemId = builder.getItemId();
this.gcubeScope = builder.getGcubeScope(); this.gcubeScope = builder.getGcubeScope();
this.resolveAs = builder.getResolveAs() != null ? builder.getResolveAs().getParamValue() : null; this.resolveAs = builder.getResolveAs() != null ? builder.getResolveAs().getParamValue() : null;
this.targetApp = builder.getTargetApp() != null ? builder.getTargetApp().getTargetPath() : null;
} }
@ -63,6 +65,15 @@ public class GeoportalResolverQueryString {
return resolveAs; return resolveAs;
} }
/**
* Gets the target app.
*
* @return the target app
*/
public String getTargetApp() {
return targetApp;
}
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
@ -74,6 +85,8 @@ public class GeoportalResolverQueryString {
builder.append(gcubeScope); builder.append(gcubeScope);
builder.append(", resolveAs="); builder.append(", resolveAs=");
builder.append(resolveAs); builder.append(resolveAs);
builder.append(", targetApp=");
builder.append(targetApp);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }

View File

@ -23,11 +23,13 @@ public final class GeoportalResolverQueryStringBuilder {
public static final String ITEM_ID_PARAMETER = "item_id"; public static final String ITEM_ID_PARAMETER = "item_id";
public static final String GCUBE_SCOPE_PARAMETER = "gcube_scope"; public static final String GCUBE_SCOPE_PARAMETER = "gcube_scope";
public static final String RESOLVE_AS_PARAMETER = "res"; public static final String RESOLVE_AS_PARAMETER = "res";
public static final String TARGET_APP_AS_PARAMETER = "target_app";
private String itemType; private String itemType;
private String itemId; private String itemId;
private String gcubeScope; private String gcubeScope;
private RESOLVE_AS resolveAs; private RESOLVE_AS resolveAs;
private TARGET_GEOPORTAL_APP targetApp;
/** /**
* The Enum RESOLVE_AS_PARAMETER. * The Enum RESOLVE_AS_PARAMETER.
@ -60,6 +62,51 @@ public final class GeoportalResolverQueryStringBuilder {
} }
} }
/**
* The Enum TARGET_GEOPORTAL_APP.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Apr 3, 2024
*/
public static enum TARGET_GEOPORTAL_APP {
GEO_DV("dv", "Geoportal Data-Viewer"), GEO_DE("de", "Geoportal Data-Entry");
private String targetPath;
private String applicationName;
/**
* Instantiates a new target geoportal app.
*
* @param targetPath the target path
* @param applicationName the application name
*/
private TARGET_GEOPORTAL_APP(String targetPath, String applicationName) {
this.targetPath = targetPath;
this.applicationName = applicationName;
}
/**
* Gets the target path.
*
* @return the target path
*/
public String getTargetPath() {
return targetPath;
}
/**
* Gets the application name.
*
* @return the application name
*/
public String getApplicationName() {
return applicationName;
}
}
/** /**
* Instantiates a new geoportal resolver query string builder. * Instantiates a new geoportal resolver query string builder.
* *
@ -93,6 +140,17 @@ public final class GeoportalResolverQueryStringBuilder {
return this; return this;
} }
/**
* Target app.
*
* @param targetApp the target app
* @return the geoportal resolver query string builder
*/
public GeoportalResolverQueryStringBuilder targetApp(TARGET_GEOPORTAL_APP targetApp) {
this.targetApp = targetApp;
return this;
}
/** /**
* Gets the item type. * Gets the item type.
* *
@ -120,10 +178,24 @@ public final class GeoportalResolverQueryStringBuilder {
return gcubeScope; return gcubeScope;
} }
/**
* Gets the resolve as.
*
* @return the resolve as
*/
public RESOLVE_AS getResolveAs() { public RESOLVE_AS getResolveAs() {
return resolveAs; return resolveAs;
} }
/**
* Gets the target app.
*
* @return the target app
*/
public TARGET_GEOPORTAL_APP getTargetApp() {
return targetApp;
}
/** /**
* Builds the query parameters. * Builds the query parameters.
* *
@ -153,6 +225,10 @@ public final class GeoportalResolverQueryStringBuilder {
query.put(RESOLVE_AS_PARAMETER, crQS.getResolveAs()); query.put(RESOLVE_AS_PARAMETER, crQS.getResolveAs());
} }
if(crQS.getTargetApp() != null) {
query.put(TARGET_APP_AS_PARAMETER, crQS.getTargetApp());
}
return query; return query;
} }

View File

@ -11,6 +11,7 @@ import org.gcube.portlets.user.uriresolvermanager.exception.UriResolverMapExcept
import org.gcube.portlets.user.uriresolvermanager.resolvers.query.CatalogueResolverQueryStringBuilder; import org.gcube.portlets.user.uriresolvermanager.resolvers.query.CatalogueResolverQueryStringBuilder;
import org.gcube.portlets.user.uriresolvermanager.resolvers.query.GeoportalResolverQueryStringBuilder; import org.gcube.portlets.user.uriresolvermanager.resolvers.query.GeoportalResolverQueryStringBuilder;
import org.gcube.portlets.user.uriresolvermanager.resolvers.query.GeoportalResolverQueryStringBuilder.RESOLVE_AS; import org.gcube.portlets.user.uriresolvermanager.resolvers.query.GeoportalResolverQueryStringBuilder.RESOLVE_AS;
import org.gcube.portlets.user.uriresolvermanager.resolvers.query.GeoportalResolverQueryStringBuilder.TARGET_GEOPORTAL_APP;
import org.junit.Test; import org.junit.Test;
/** /**
@ -47,7 +48,7 @@ public class UriResolverManagerTest {
} }
// @Test //@Test
public void testCTLG() { public void testCTLG() {
try { try {
@ -129,33 +130,73 @@ public class UriResolverManagerTest {
//@Test //@Test
public void testGeoportalCreateLink() { public void testGeoportalCreateDataEntryLink() {
try { try {
String scope = "/gcube/devsec/devVRE"; String scope = "/gcube/devsec/devVRE";
// String scope = "/pred4s/preprod/preVRE"; // String scope = "/pred4s/preprod/preVRE";
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
UriResolverManager resolver;
String gcubeScope = scope; String gcubeScope = scope;
String itemId = "6384aaac308f5c28c5ee0888"; String itemId = "6384aaac308f5c28c5ee0888";
String itemType = "profiledConcessioni"; String itemType = "profiledConcessioni";
resolver = new UriResolverManager("GEO"); UriResolverManager resolver = new UriResolverManager("GEO");
Map<String, String> params = null; Map<String, String> params = null;
//Method 1 //Method 1
params = new HashMap<String, String>(); // params = new HashMap<String, String>();
params.put(GeoportalResolverQueryStringBuilder.GCUBE_SCOPE_PARAMETER, gcubeScope); // params.put(GeoportalResolverQueryStringBuilder.GCUBE_SCOPE_PARAMETER, gcubeScope);
params.put(GeoportalResolverQueryStringBuilder.ITEM_ID_PARAMETER, itemId); // params.put(GeoportalResolverQueryStringBuilder.ITEM_ID_PARAMETER, itemId);
params.put(GeoportalResolverQueryStringBuilder.ITEM_TYPE_PARAMETER, itemType); // params.put(GeoportalResolverQueryStringBuilder.ITEM_TYPE_PARAMETER, itemType);
params.put(GeoportalResolverQueryStringBuilder.RESOLVE_AS_PARAMETER, GeoportalResolverQueryStringBuilder.RESOLVE_AS.PUBLIC.getParamValue()); // params.put(GeoportalResolverQueryStringBuilder.RESOLVE_AS_PARAMETER, GeoportalResolverQueryStringBuilder.RESOLVE_AS.PUBLIC.getParamValue());
//Method 2 //Method 2
GeoportalResolverQueryStringBuilder builder = new GeoportalResolverQueryStringBuilder(itemType,itemId); GeoportalResolverQueryStringBuilder builder = new GeoportalResolverQueryStringBuilder(itemType,itemId);
builder.scope(gcubeScope); builder.scope(gcubeScope);
builder.resolverAs(RESOLVE_AS.PUBLIC); builder.resolverAs(RESOLVE_AS.PUBLIC);
//builder.resolverAs(RESOLVE_AS.PRIVATE); builder.targetApp(TARGET_GEOPORTAL_APP.GEO_DE);
// builder.resolverAs(RESOLVE_AS.PRIVATE);
params = builder.buildQueryParameters();
String shortLink = resolver.getLink(params, true);
System.out.println(shortLink);
} catch (UriResolverMapException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
//@Test
public void testGeoportalCreateDataViewerLink() {
try {
String scope = "/gcube/devsec/devVRE";
// String scope = "/pred4s/preprod/preVRE";
ScopeProvider.instance.set(scope);
String gcubeScope = scope;
String itemId = "6384aaac308f5c28c5ee0888";
String itemType = "profiledConcessioni";
UriResolverManager resolver = new UriResolverManager("GEO");
Map<String, String> params = null;
//Method 1
// params = new HashMap<String, String>();
// params.put(GeoportalResolverQueryStringBuilder.GCUBE_SCOPE_PARAMETER, gcubeScope);
// params.put(GeoportalResolverQueryStringBuilder.ITEM_ID_PARAMETER, itemId);
// params.put(GeoportalResolverQueryStringBuilder.ITEM_TYPE_PARAMETER, itemType);
// params.put(GeoportalResolverQueryStringBuilder.RESOLVE_AS_PARAMETER, GeoportalResolverQueryStringBuilder.RESOLVE_AS.PUBLIC.getParamValue());
//Method 2
GeoportalResolverQueryStringBuilder builder = new GeoportalResolverQueryStringBuilder(itemType,itemId);
builder.scope(gcubeScope);
builder.resolverAs(RESOLVE_AS.PUBLIC);
//builder.targetApp(TARGET_GEOPORTAL_APP.GEO_DV);
builder.resolverAs(RESOLVE_AS.PRIVATE);
params = builder.buildQueryParameters(); params = builder.buildQueryParameters();
String shortLink = resolver.getLink(params, true); String shortLink = resolver.getLink(params, true);