Added new method `createDataViewerLink`

This commit is contained in:
Francesco Mangiacrapa 2023-03-27 10:55:08 +02:00
parent b2ec64c828
commit 4864094ed0
1 changed files with 40 additions and 11 deletions

View File

@ -37,8 +37,8 @@ import org.slf4j.LoggerFactory;
import com.google.common.cache.CacheLoader.InvalidCacheLoadException;
/**
* The GeoportalResolver is able to get/resolve a link to "Geoportal Viewer"
* or "Geoportal Entry" Application.
* The GeoportalResolver is able to get/resolve a link to "Geoportal Viewer" or
* "Geoportal Entry" Application.
*
* See more at
* https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#Geoportal_Resolver
@ -94,12 +94,13 @@ public class GeoportalResolver {
LOG.info(this.getClass().getSimpleName() + " resolveGeoportalNoAppDef - GET starts...");
TargetAppGeoportalCodes targetAppGeoportalCodes = checkTargetApplictionID(req, null);
LOG.info("The target app is: " + targetAppGeoportalCodes);
return genericGet(req, targetAppGeoportalCodes, vreName, ucdID, projectID, resolveAs);
return genericResolveLink(req, targetAppGeoportalCodes, vreName, ucdID, projectID, resolveAs);
}
/**
* Resolve geoportal. Resolve a Geoportal Link to "Data-Viewer" or "Data-Entry" App
* Resolve geoportal. Resolve a Geoportal Link to "Data-Viewer" or "Data-Entry"
* App
*
* @param req the req
* @param targetAppId the target app id
@ -120,7 +121,35 @@ public class GeoportalResolver {
LOG.info(this.getClass().getSimpleName() + " resolveGeoportal - GET starts...");
TargetAppGeoportalCodes targetAppGeoportalCodes = checkTargetApplictionID(req, targetAppId);
LOG.info("The target app is: " + targetAppGeoportalCodes);
return genericGet(req, targetAppGeoportalCodes, vreName, ucdID, projectID, resolveAs);
return genericResolveLink(req, targetAppGeoportalCodes, vreName, ucdID, projectID, resolveAs);
}
/**
* Creates the data viewer link.
*
* @param req the req
* @param gcubeScope the gcube scope
* @param itemId the item id
* @param itemType the item type
* @return the response
* @throws WebApplicationException the web application exception
*/
@GET
@Path("/")
public Response createDataViewerLink(@Context HttpServletRequest req,
@QueryParam(GeoportalRequest.P_GCUBE_SCOPE) String gcubeScope,
@QueryParam(GeoportalRequest.P_ITEM_ID) String itemId,
@QueryParam(GeoportalRequest.P_ITEM_TYPE) String itemType) throws WebApplicationException {
LOG.info(this.getClass().getSimpleName() + " resolveGeoportalNoAppDef - GET starts...");
TargetAppGeoportalCodes targetAppGeoportalCodes = checkTargetApplictionID(req, null);
LOG.info("The target app is: " + targetAppGeoportalCodes);
GeoportalRequest geoportalRequest = new GeoportalRequest();
geoportalRequest.setGcubeScope(gcubeScope);
geoportalRequest.setItemID(itemId);
geoportalRequest.setItemType(itemType);
return genericCreateLink(req, geoportalRequest, targetAppGeoportalCodes);
}
@ -142,7 +171,7 @@ public class GeoportalResolver {
LOG.info(this.getClass().getSimpleName() + " postGeoportalNoAppDef - POST starts...");
TargetAppGeoportalCodes targetAppGeoportalCodes = checkTargetApplictionID(req, null);
LOG.info("The target app is: " + targetAppGeoportalCodes);
return genericPost(req, jsonRequest, targetAppGeoportalCodes);
return genericCreateLink(req, jsonRequest, targetAppGeoportalCodes);
}
/**
@ -164,7 +193,7 @@ public class GeoportalResolver {
LOG.info(this.getClass().getSimpleName() + " postGeoportal - POST starts...");
TargetAppGeoportalCodes targetAppGeoportalCodes = checkTargetApplictionID(req, targetAppId);
LOG.info("The target app is: " + targetAppGeoportalCodes);
return genericPost(req, jsonRequest, targetAppGeoportalCodes);
return genericCreateLink(req, jsonRequest, targetAppGeoportalCodes);
}
/**
@ -201,7 +230,7 @@ public class GeoportalResolver {
}
/**
* Generic get.
* Generic resolve link.
*
* @param req the req
* @param resoruceGeoportalCodes the resoruce geoportal codes
@ -212,7 +241,7 @@ public class GeoportalResolver {
* @return the response
* @throws WebApplicationException the web application exception
*/
public Response genericGet(@Context HttpServletRequest req, TargetAppGeoportalCodes resoruceGeoportalCodes,
public Response genericResolveLink(@Context HttpServletRequest req, TargetAppGeoportalCodes resoruceGeoportalCodes,
@PathParam(PATH_VRE_NAME) String vreName, @PathParam(PATH_USECASE_ID) String ucdID,
@PathParam(PATH_PROJECT_ID) String projectID, @QueryParam(QP_RESOLVE_AS) String resolveAs)
throws WebApplicationException {
@ -366,14 +395,14 @@ public class GeoportalResolver {
}
/**
* Generic post.
* Generic create link.
*
* @param req the req
* @param jsonRequest the json request
* @param targetAppGeoportalCodes the target app geoportal codes
* @return the response
*/
protected Response genericPost(@Context HttpServletRequest req, GeoportalRequest jsonRequest,
protected Response genericCreateLink(@Context HttpServletRequest req, GeoportalRequest jsonRequest,
TargetAppGeoportalCodes targetAppGeoportalCodes) {
LOG.info(this.getClass().getSimpleName() + " POST starts...");