fixing documentation

This commit is contained in:
Francesco Mangiacrapa 2022-03-24 17:33:54 +01:00
parent fd9a10be6c
commit 2881f76ed0
16 changed files with 708 additions and 554 deletions

View File

@ -11,7 +11,7 @@
<artifactId>uri-resolver</artifactId>
<version>2.7.1-SNAPSHOT</version>
<packaging>war</packaging>
<description>The URI Resolver is an HTTP URI resolver implemented as an 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>
<scm>
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</connection>

View File

@ -1,11 +1,11 @@
package org.gcube.datatransfer.resolver.catalogue;
/**
* The Class CatalogueRequest.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Nov 6, 2018
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Mar 24, 2022
*
* Binding Catalogue Request as a JSON
*/
@ -42,7 +42,14 @@ public class CatalogueRequest {
return entity_name;
}
/* (non-Javadoc)
/**
* To string.
*
* @return the string
*/
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
@Override

View File

@ -11,16 +11,37 @@ import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Nov 26, 2018
* Instantiates a new parthenos request.
*/
@NoArgsConstructor
/**
* Instantiates a new parthenos request.
*
* @param entity_name the entity name
*/
@AllArgsConstructor
/**
* Gets the entity name.
*
* @return the entity name
*/
@Getter
/**
* Sets the entity name.
*
* @param entity_name the new entity name
*/
@Setter
/**
* To string.
*
* @return the java.lang. string
*/
@ToString
public class ParthenosRequest {

View File

@ -77,7 +77,6 @@ public class AnalyticsCreateResolver {
private static Logger logger = LoggerFactory.getLogger(AnalyticsCreateResolver.class);
private static String helpURI = "https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#Analytics_Resolver";
/**
* Creates the analytics url.
*
@ -99,11 +98,13 @@ public class AnalyticsCreateResolver {
DataMinerInvocation jsonRequest = null;
try {
jsonRequest = DataMinerInvocationManager.getInstance().unmarshalingJSON(IOUtils.toInputStream(body), true);
}
catch (IOException | JAXBException | SAXException e1) {
jsonRequest = DataMinerInvocationManager.getInstance().unmarshalingJSON(IOUtils.toInputStream(body),
true);
} catch (IOException | JAXBException | SAXException e1) {
logger.error("The body is not a valid DataMinerInvocation JSON request", e1);
throw ExceptionManager.badRequestException(req, "Bad 'dataminer-invocation' JSON request: \n"+e1.getCause().getMessage(), this.getClass(), helpURI);
throw ExceptionManager.badRequestException(req,
"Bad 'dataminer-invocation' JSON request: \n" + e1.getCause().getMessage(), this.getClass(),
helpURI);
}
logger.debug("The body contains the request: " + jsonRequest.toString());
@ -116,21 +117,26 @@ public class AnalyticsCreateResolver {
String appToken = req.getServletContext().getInitParameter(RequestHandler.ROOT_APP_TOKEN);
if (contextToken.compareTo(appToken) == 0) {
logger.error("Token not passed, SecurityTokenProvider contains the root app token: "+appToken.substring(0,10)+"...");
throw ExceptionManager.unauthorizedException(req, "You are not authorized. You must pass a token of VRE", this.getClass(), helpURI);
logger.error("Token not passed, SecurityTokenProvider contains the root app token: "
+ appToken.substring(0, 10) + "...");
throw ExceptionManager.unauthorizedException(req,
"You are not authorized. You must pass a token of VRE", this.getClass(), helpURI);
}
String operatorID = jsonRequest.getOperatorId();
if (scope == null || scope.isEmpty()) {
logger.error("The parameter 'scope' not found or empty in the JSON object");
throw ExceptionManager.badRequestException(req, "Mandatory body parameter 'scope' not found or empty in the JSON object", this.getClass(), helpURI);
throw ExceptionManager.badRequestException(req,
"Mandatory body parameter 'scope' not found or empty in the JSON object", this.getClass(),
helpURI);
}
if (operatorID == null || operatorID.isEmpty()) {
logger.error("The parameter 'operatorId' not found or empty in the JSON object");
throw ExceptionManager.badRequestException(req, "Mandatory body parameter 'operatorId' not found or empty in the JSON object", this.getClass(), helpURI);
throw ExceptionManager.badRequestException(req,
"Mandatory body parameter 'operatorId' not found or empty in the JSON object", this.getClass(),
helpURI);
}
ScopeBean scopeBean = new ScopeBean(scope);
@ -160,7 +166,10 @@ public class AnalyticsCreateResolver {
String infra = ScopeUtil.getInfrastructureNameFromScope(ScopeProvider.instance.get());
String theAppToken = readApplicationTokenFromSE(req, infra);
logger.info("By using infra scope: "+infra +" and the Application Token: "+theAppToken.substring(0,theAppToken.length()/2)+"... of "+ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME+" to instance the "+StorageHubManagement.class.getSimpleName());
logger.info("By using infra scope: " + infra + " and the Application Token: "
+ theAppToken.substring(0, theAppToken.length() / 2) + "... of "
+ ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME + " to instance the "
+ StorageHubManagement.class.getSimpleName());
ScopeProvider.instance.set(infra);
ApplicationMode applicationMode = new ApplicationMode(theAppToken);
applicationMode.start();
@ -173,26 +182,33 @@ public class AnalyticsCreateResolver {
try {
logger.info("Saving dataminer-invocation file for the user: " + owner);
thePublicLink = storageHubManagement.persistFile(new FileInputStream(tempInvocationFile), tempInvocationFile.getName(), "application/xml", metadata);
thePublicLink = storageHubManagement.persistFile(new FileInputStream(tempInvocationFile),
tempInvocationFile.getName(), "application/xml", metadata);
logger.info("Saved dataminer-invocation file at: " + thePublicLink);
} catch (Exception e) {
logger.error("Error when storing your 'dataminer-invocation':", e);
throw ExceptionManager.internalErrorException(req, "Error when storing your 'dataminer-invocation' request with "+jsonRequest+". \nPlease contact the support", this.getClass(), helpURI);
throw ExceptionManager
.internalErrorException(
req, "Error when storing your 'dataminer-invocation' request with "
+ jsonRequest + ". \nPlease contact the support",
this.getClass(), helpURI);
}
// FileContainer fileContainer = shc.getWSRoot().uploadFile(new FileInputStream(tempInvocationFile), tempInvocationFile.getName(), "DataMinerInvocation Request created by "+this.getClass().getSimpleName());
// logger.info("UPLOADED FILE at: "+fileContainer.getPublicLink());
// URL thePublicLink = fileContainer.getPublicLink();
publicLinkToDMInvFile = thePublicLink != null ? thePublicLink.toString() : null;
}
catch (Exception e) {
} catch (Exception e) {
if (e instanceof InternalServerException) {
// error during storing the file via StorageHubManagent
throw e;
}
logger.error("Error on creating 'dataminer-invocation:", e);
throw ExceptionManager.badRequestException(req, "Error on creating your 'dataminer-invocation' request with "+jsonRequest+". \nPlease contact the support", this.getClass(), helpURI);
throw ExceptionManager.badRequestException(req,
"Error on creating your 'dataminer-invocation' request with " + jsonRequest
+ ". \nPlease contact the support",
this.getClass(), helpURI);
} finally {
// No needed to reset the scope, it is provided by TokenSetter
try {
@ -206,23 +222,30 @@ public class AnalyticsCreateResolver {
if (publicLinkToDMInvFile == null) {
logger.error("Error on creating the public link to file");
throw ExceptionManager.badRequestException(req, "Error on getting link to your 'dataminer-invocation' request. Plese contact the support "+jsonRequest, this.getClass(), helpURI);
throw ExceptionManager.badRequestException(req,
"Error on getting link to your 'dataminer-invocation' request. Plese contact the support "
+ jsonRequest,
this.getClass(), helpURI);
}
String dataMinerURL = String.format("%s/%s?%s=%s", analyticsGetResolverURL, vreName, DATAMINER_INVOCATION_MODEL, publicLinkToDMInvFile);
String dataMinerURL = String.format("%s/%s?%s=%s", analyticsGetResolverURL, vreName,
DATAMINER_INVOCATION_MODEL, publicLinkToDMInvFile);
logger.info("Returning Analytics URL: " + dataMinerURL);
return Response.ok(dataMinerURL).header("Location", dataMinerURL).build();
} else {
logger.error("The input scope " + scope + " is not a VRE");
throw ExceptionManager.badRequestException(req, "Working in the "+scope+" scope that is not a VRE. Use a token of VRE", this.getClass(), helpURI);
throw ExceptionManager.badRequestException(req,
"Working in the " + scope + " scope that is not a VRE. Use a token of VRE", this.getClass(),
helpURI);
}
} catch (Exception e) {
if (!(e instanceof WebApplicationException)) {
// UNEXPECTED EXCEPTION managing it as WebApplicationException
String error = "Error occurred on creating the Analytics for the request "+body+". Please, contact the support!";
String error = "Error occurred on creating the Analytics for the request " + body
+ ". Please, contact the support!";
if (e.getCause() != null)
error += "\n\nCaused: " + e.getCause().getMessage();
throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI);
@ -233,9 +256,9 @@ public class AnalyticsCreateResolver {
}
}
/**
* Reads the Application Token from Service Endpoint {@link AnalyticsCreateResolver#ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME}
* Reads the Application Token from Service Endpoint
* {@link AnalyticsCreateResolver#ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME}
*
* @param req the req
* @param scope the scope
@ -248,7 +271,8 @@ public class AnalyticsCreateResolver {
try {
callerScope = ScopeProvider.instance.get();
ScopeProvider.instance.set(scope);
logger.info("Searching SE "+ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME+" configurations in the scope: "+ScopeProvider.instance.get());
logger.info("Searching SE " + ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME + " configurations in the scope: "
+ ScopeProvider.instance.get());
SimpleQuery query = queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Name/text() eq '" + ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME + "'");
@ -260,12 +284,13 @@ public class AnalyticsCreateResolver {
logger.info("The query returned " + toReturn.size() + " ServiceEndpoint/s");
if (toReturn.size() == 0) {
String errorMessage = "No "+ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME+" registered in the scope: "+ScopeProvider.instance.get();
String errorMessage = "No " + ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME + " registered in the scope: "
+ ScopeProvider.instance.get();
logger.error(errorMessage);
throw ExceptionManager.internalErrorException(req, errorMessage, AnalyticsCreateResolver.class, helpURI);
throw ExceptionManager.internalErrorException(req, errorMessage, AnalyticsCreateResolver.class,
helpURI);
}
ServiceEndpoint se = toReturn.get(0);
Collection<AccessPoint> theAccessPoints = se.profile().accessPoints().asCollection();
for (AccessPoint accessPoint : theAccessPoints) {
@ -284,18 +309,21 @@ public class AnalyticsCreateResolver {
if (gCubeAppToken != null) {
String decryptedPassword = StringEncrypter.getEncrypter().decrypt(gCubeAppToken);
logger.info("Returning decrypted Application Token registered into "+ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME +" SE: "+decryptedPassword.substring(0,decryptedPassword.length()/2)+"....");
logger.info("Returning decrypted Application Token registered into "
+ ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME + " SE: "
+ decryptedPassword.substring(0, decryptedPassword.length() / 2) + "....");
return decryptedPassword;
}
String errorMessage = "No "+GCUBE_TOKEN+" as Property saved in the "+ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME+" SE registered in the scope: "+ScopeProvider.instance.get();
String errorMessage = "No " + GCUBE_TOKEN + " as Property saved in the "
+ ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME + " SE registered in the scope: "
+ ScopeProvider.instance.get();
logger.error(errorMessage);
throw ExceptionManager.internalErrorException(req, errorMessage, AnalyticsCreateResolver.class, helpURI);
} catch (Exception e) {
String errorMessage = "Error occurred on reading the "+ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME+" SE registered in the scope: "+ScopeProvider.instance.get();
String errorMessage = "Error occurred on reading the " + ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME
+ " SE registered in the scope: " + ScopeProvider.instance.get();
logger.error(errorMessage, e);
throw ExceptionManager.internalErrorException(req, errorMessage, AnalyticsCreateResolver.class, helpURI);
@ -311,7 +339,6 @@ public class AnalyticsCreateResolver {
}
/**
* Creates the temp file.
*
@ -331,7 +358,6 @@ public class AnalyticsCreateResolver {
return file;
}
/**
* Creates the dm invocation file name.
*
@ -347,12 +373,4 @@ public class AnalyticsCreateResolver {
fileName += "-" + System.currentTimeMillis();
return fileName;
}
// public static void main(String[] args) {
//
// System.out.println(readApplicationTokenFromSE(null, "/gcube"));
//
// }
}

View File

@ -23,20 +23,19 @@ import org.slf4j.LoggerFactory;
import com.google.common.cache.CacheLoader.InvalidCacheLoadException;
/**
* The Class AnalyticsGetResolver.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Dec 13, 2018
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Mar 24, 2022
*/
@Path("analytics")
public class AnalyticsGetResolver {
private static Logger logger = LoggerFactory.getLogger(AnalyticsGetResolver.class);
private static final String ORG_GCUBE_PORTLETS_USER_DATAMINERMANAGER_SERVER_DATA_MINER_MANAGER_SERVICE_IMPL =
"org.gcube.portlets.user.dataminermanager.server.DataMinerManagerServiceImpl";
private static final String ORG_GCUBE_PORTLETS_USER_DATAMINERMANAGER_SERVER_DATA_MINER_MANAGER_SERVICE_IMPL = "org.gcube.portlets.user.dataminermanager.server.DataMinerManagerServiceImpl";
private static final String APPLICATION_PROFILE = "ApplicationProfile";
@ -44,23 +43,25 @@ public class AnalyticsGetResolver {
private static final String ANALYTICS_EXECUTOR_PORTLET_NAME = "Analytics Executor";
/**
* Resolve analytics url.
*
* @param req the req
* @param vreName the vre name
* @return the response
* @throws WebApplicationException the web application exception
*/
@GET
@Path("/get/{vreName}")
public Response resolveAnalyticsURL(@Context HttpServletRequest req, @PathParam("vreName") String vreName) throws WebApplicationException{
public Response resolveAnalyticsURL(@Context HttpServletRequest req, @PathParam("vreName") String vreName)
throws WebApplicationException {
logger.info(this.getClass().getSimpleName() + " GET starts...");
try {
if (vreName == null || vreName.isEmpty()) {
logger.error("The path parameter 'vreName' not found or empty in the path");
throw ExceptionManager.badRequestException(req, "Mandatory path parameter 'vreName' not found or empty", this.getClass(), helpURI);
throw ExceptionManager.badRequestException(req, "Mandatory path parameter 'vreName' not found or empty",
this.getClass(), helpURI);
}
ScopeBean fullScopeBean = null;
@ -70,22 +71,30 @@ public class AnalyticsGetResolver {
fullScopeBean = LoadingMapOfScopeCache.get(vreName);
} catch (ExecutionException | InvalidCacheLoadException e) {
logger.error("Error on getting the fullscope from cache for vreName " + vreName, e);
throw ExceptionManager.wrongParameterException(req, "Error on getting full scope for the VRE name "+vreName+". Is it registered as VRE in the D4Science Infrastructure System?", this.getClass(), helpURI);
throw ExceptionManager.wrongParameterException(req,
"Error on getting full scope for the VRE name " + vreName
+ ". Is it registered as VRE in the D4Science Infrastructure System?",
this.getClass(), helpURI);
}
ApplicationProfileReader reader = null;
try {
reader = new ApplicationProfileReader(fullScopeBean.toString(), APPLICATION_PROFILE, ORG_GCUBE_PORTLETS_USER_DATAMINERMANAGER_SERVER_DATA_MINER_MANAGER_SERVICE_IMPL, false);
reader = new ApplicationProfileReader(fullScopeBean.toString(), APPLICATION_PROFILE,
ORG_GCUBE_PORTLETS_USER_DATAMINERMANAGER_SERVER_DATA_MINER_MANAGER_SERVICE_IMPL, false);
} catch (Exception e) {
logger.error("Error on reading the "+APPLICATION_PROFILE+" with APPID: "+ORG_GCUBE_PORTLETS_USER_DATAMINERMANAGER_SERVER_DATA_MINER_MANAGER_SERVICE_IMPL, e);
throw ExceptionManager.internalErrorException(req, "Error on reading the Application Profile for the "+ANALYTICS_EXECUTOR_PORTLET_NAME+". Please contact the support", this.getClass(), helpURI);
logger.error("Error on reading the " + APPLICATION_PROFILE + " with APPID: "
+ ORG_GCUBE_PORTLETS_USER_DATAMINERMANAGER_SERVER_DATA_MINER_MANAGER_SERVICE_IMPL, e);
throw ExceptionManager.internalErrorException(req, "Error on reading the Application Profile for the "
+ ANALYTICS_EXECUTOR_PORTLET_NAME + ". Please contact the support", this.getClass(), helpURI);
}
//READ THE DATAMINER URL PORTLET FROM APPLICATION PROFRILE IN THE SCOPE fullScope
// READ THE DATAMINER URL PORTLET FROM APPLICATION PROFRILE IN THE SCOPE
// fullScope
String analyticsExecutorEndPoint = reader.getApplicationProfile().getUrl();
// CHECKING THE QUERY STRING
String queryString = req.getQueryString() != null ? req.getQueryString() : "";
String analitycsExecutorURL = String.format("%s?%s", analyticsExecutorEndPoint, queryString);
logger.info("Resolving the request with the "+ANALYTICS_EXECUTOR_PORTLET_NAME+" URL: "+analitycsExecutorURL);
logger.info("Resolving the request with the " + ANALYTICS_EXECUTOR_PORTLET_NAME + " URL: "
+ analitycsExecutorURL);
return Response.seeOther(new URI(analitycsExecutorURL)).build();
} catch (Exception e) {

View File

@ -52,10 +52,19 @@ import eu.trentorise.opendata.jackan.model.CkanDataset;
@Path("{entityContext:ctlg(-(o|g|p|d))?}")
public class CatalogueResolver {
private static Logger logger = LoggerFactory.getLogger(CatalogueResolver.class);
private static String helpURI = "https://wiki.gcube-system.org/gcube/URI_Resolver#CATALOGUE_Resolver";
private static enum SCOPE_STATUS {ACTIVE, DETACHED}
/**
* The Enum SCOPE_STATUS.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Mar 24, 2022
*/
private static enum SCOPE_STATUS {
ACTIVE, DETACHED
}
/**
* Resolve catalogue.
@ -65,13 +74,13 @@ public class CatalogueResolver {
* @param vreName the vre name
* @param entityContext the entity context
* @return the response
* @throws WebApplicationException the web application exception
*/
@GET
@Path("/{vreName}/{entityName}")
public Response resolveCatalogue(@Context HttpServletRequest req,
@PathParam("entityName") String entityName,
@PathParam("vreName") String vreName,
@PathParam("entityContext") String entityContext) throws WebApplicationException{
public Response resolveCatalogue(@Context HttpServletRequest req, @PathParam("entityName") String entityName,
@PathParam("vreName") String vreName, @PathParam("entityContext") String entityContext)
throws WebApplicationException {
logger.info(this.getClass().getSimpleName() + " GET starts...");
@ -82,17 +91,22 @@ public class CatalogueResolver {
String itemCatalogueURL;
if (itemCatalogueURLs.isPublicItem()) {
logger.info("The dataset "+itemCatalogueURLs.getItemName()+" was detected as public item (not private to VRE)");
if(itemCatalogueURLs.getPublicVRECataloguePortletURL()!=null && !itemCatalogueURLs.getPublicVRECataloguePortletURL().isEmpty()) {
logger.info("The dataset " + itemCatalogueURLs.getItemName()
+ " was detected as public item (not private to VRE)");
if (itemCatalogueURLs.getPublicVRECataloguePortletURL() != null
&& !itemCatalogueURLs.getPublicVRECataloguePortletURL().isEmpty()) {
itemCatalogueURL = itemCatalogueURLs.getPublicVRECataloguePortletURL();
logger.info("I found the public VRE catalogue URL, so using public access to it: "+itemCatalogueURL);
logger.info(
"I found the public VRE catalogue URL, so using public access to it: " + itemCatalogueURL);
} else {
itemCatalogueURL = itemCatalogueURLs.getPublicGatewayCataloguePortletURL();
logger.info("No public VRE catalogue URL found, so using public access to gateway CKAN portlet: "+itemCatalogueURL);
logger.info("No public VRE catalogue URL found, so using public access to gateway CKAN portlet: "
+ itemCatalogueURL);
}
} else {
itemCatalogueURL = itemCatalogueURLs.getPrivateVRECataloguePortletURL();
logger.info("The dataset "+itemCatalogueURLs.getItemName()+" is a private item (to VRE) so using protected access to CKAN portlet: "+itemCatalogueURL);
logger.info("The dataset " + itemCatalogueURLs.getItemName()
+ " is a private item (to VRE) so using protected access to CKAN portlet: " + itemCatalogueURL);
}
return Response.seeOther(new URL(itemCatalogueURL).toURI()).build();
@ -117,12 +131,14 @@ public class CatalogueResolver {
* @param req the req
* @param jsonRequest the json request
* @return the response
* @throws WebApplicationException the web application exception
*/
@POST
@Path("")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.TEXT_PLAIN)
public Response postCatalogue(@Context HttpServletRequest req, CatalogueRequest jsonRequest) throws WebApplicationException{
public Response postCatalogue(@Context HttpServletRequest req, CatalogueRequest jsonRequest)
throws WebApplicationException {
logger.info(this.getClass().getSimpleName() + " POST starts...");
try {
@ -139,7 +155,8 @@ public class CatalogueResolver {
String serverUrl = Util.getServerURL(req);
final String vreName = scope.substring(scope.lastIndexOf(ConstantsResolver.SCOPE_SEPARATOR)+1, scope.length());
final String vreName = scope.substring(scope.lastIndexOf(ConstantsResolver.SCOPE_SEPARATOR) + 1,
scope.length());
ScopeBean fullScope = null;
// CHECK IF THE vreName has a valid scope, so it is a valid VRE
@ -147,16 +164,22 @@ public class CatalogueResolver {
fullScope = LoadingMapOfScopeCache.get(vreName);
} catch (ExecutionException e) {
logger.error("Error on getting the fullscope from cache for vreName " + vreName, e);
throw ExceptionManager.wrongParameterException(req, "Error on getting full scope for the VRE name "+vreName+". Is it registered as VRE in the D4Science Infrastructure System?", this.getClass(), helpURI);
throw ExceptionManager.wrongParameterException(req,
"Error on getting full scope for the VRE name " + vreName
+ ". Is it registered as VRE in the D4Science Infrastructure System?",
this.getClass(), helpURI);
}
if (fullScope == null)
throw ExceptionManager.notFoundException(req, "The scope '"+scope+"' does not matching any scope in the infrastructure. Is it valid?", this.getClass(), helpURI);
throw ExceptionManager.notFoundException(req,
"The scope '" + scope + "' does not matching any scope in the infrastructure. Is it valid?",
this.getClass(), helpURI);
ResourceCatalogueCodes rc = ResourceCatalogueCodes.valueOfCodeValue(jsonRequest.getEntity_context());
if (rc == null) {
logger.error("Entity context is null/malformed");
throw ExceptionManager.badRequestException(req, "Entity context is null/malformed", this.getClass(), helpURI);
throw ExceptionManager.badRequestException(req, "Entity context is null/malformed", this.getClass(),
helpURI);
}
String linkURL = String.format("%s/%s/%s/%s", serverUrl, rc.getId(), vreName, jsonRequest.getEntity_name());
@ -186,7 +209,8 @@ public class CatalogueResolver {
* @return the item catalogue UR ls
* @throws Exception the exception
*/
protected static ItemCatalogueURLs getItemCatalogueURLs(HttpServletRequest req, String scopeName, String entityContext, String entityName) throws Exception{
protected static ItemCatalogueURLs getItemCatalogueURLs(HttpServletRequest req, String scopeName,
String entityContext, String entityName) throws Exception {
try {
String entityContextValue = ResourceCatalogueCodes.valueOfCodeId(entityContext).getValue();
@ -196,7 +220,9 @@ public class CatalogueResolver {
try {
scopeBean = LoadingMapOfScopeCache.get(scopeName);
} catch (ExecutionException | InvalidCacheLoadException e) {
logger.error("Error on getting the fullscope from cache for scopeName {}. Tryng to load it from DetachedRE",scopeName);
logger.error(
"Error on getting the fullscope from cache for scopeName {}. Tryng to load it from DetachedRE",
scopeName);
boolean isScopeDetached = false;
try {
@ -206,25 +232,32 @@ public class CatalogueResolver {
logger.info("I loaded a valid VRE obj for scope name {}", scopeName);
isScopeDetached = true;
} catch (Exception e1) {
logger.warn("I was not able to load a detached VRE for vreName {}. Going to error for wrong scope",scopeName);
logger.warn("I was not able to load a detached VRE for vreName {}. Going to error for wrong scope",
scopeName);
}
// If is not a cas of scope detached, going to error for wrong scope
if (!isScopeDetached) {
logger.error("Error on getting the fullscope from cache for scopeName " + scopeName, e);
throw ExceptionManager.wrongParameterException(req, "Error on getting full scope for the scope name '"+scopeName+"'. Is it registered as a valid Scope in the D4Science Infrastructure System?", CatalogueResolver.class, helpURI);
throw ExceptionManager.wrongParameterException(req,
"Error on getting full scope for the scope name '" + scopeName
+ "'. Is it registered as a valid Scope in the D4Science Infrastructure System?",
CatalogueResolver.class, helpURI);
}
}
String fullScope = scopeBean.toString();
logger.info("Read fullScope: "+fullScope + " for SCOPE name: "+scopeName +" from cache created by: "+GetAllInfrastructureScopes.class.getSimpleName());
logger.info("Read fullScope: " + fullScope + " for SCOPE name: " + scopeName + " from cache created by: "
+ GetAllInfrastructureScopes.class.getSimpleName());
if (scopeBean.is(Type.VO)) {
logger.info("It is a {} scope", Type.VO);
logger.warn("The Catalogue can't work at {} level, I'm overriding the scope to {} level", Type.VO, Type.INFRASTRUCTURE);
logger.warn("The Catalogue can't work at {} level, I'm overriding the scope to {} level", Type.VO,
Type.INFRASTRUCTURE);
String[] splitScope = fullScope.split(ConstantsResolver.SCOPE_SEPARATOR);
fullScope = ConstantsResolver.SCOPE_SEPARATOR + splitScope[1]; // THIS IS THE INFRASTRUCTURE SCOPE
logger.info("Overriden the input scope {} with {} as type: {}", scopeBean.toString(), Type.INFRASTRUCTURE, fullScope);
logger.info("Overriden the input scope {} with {} as type: {}", scopeBean.toString(),
Type.INFRASTRUCTURE, fullScope);
}
ScopeProvider.instance.set(fullScope);
@ -236,20 +269,25 @@ public class CatalogueResolver {
String privatePortletURL = vreDetached.getCatalogPortletURL();
// The private portlet URL
Map<ACCESS_LEVEL_TO_CATALOGUE_PORTLET, String> mapAccessURLToCatalogue = new HashMap<ACCESS_LEVEL_TO_CATALOGUE_PORTLET, String>(3);
Map<ACCESS_LEVEL_TO_CATALOGUE_PORTLET, String> mapAccessURLToCatalogue = new HashMap<ACCESS_LEVEL_TO_CATALOGUE_PORTLET, String>(
3);
mapAccessURLToCatalogue.put(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PRIVATE_VRE, privatePortletURL);
// Building the gateway catalogue public URL from private VRE Portlet URL
URI toURL = new URI(privatePortletURL);
String publicURL = privatePortletURL.startsWith("https://")?"https://"+toURL.getHost():"http://"+toURL.getHost();
String publicURL = privatePortletURL.startsWith("https://") ? "https://" + toURL.getHost()
: "http://" + toURL.getHost();
// It returns the string "catalogue"
CatalogueStaticConfigurations staticConf = new CatalogueStaticConfigurations();
//Replacing for example "ckan-bb" with "[PREFIXES-TO-CATALOGUE-URL]-bb" (e.g catalogue-bb)
String relativeURLWithCatalogueName = staticConf.buildRelativeURLToPublicCatalogueGateway(vreDetached.getCatalogUrl());
// Replacing for example "ckan-bb" with "[PREFIXES-TO-CATALOGUE-URL]-bb" (e.g
// catalogue-bb)
String relativeURLWithCatalogueName = staticConf
.buildRelativeURLToPublicCatalogueGateway(vreDetached.getCatalogUrl());
String toGatewayPortletURL = String.format("%s/%s", publicURL, relativeURLWithCatalogueName);
mapAccessURLToCatalogue.put(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PUBLIC_GATEWAY, toGatewayPortletURL);
ckanCatalogueReference = new GatewayCKANCatalogueReference(fullScope, vreDetached.getCatalogUrl(), mapAccessURLToCatalogue);
ckanCatalogueReference = new GatewayCKANCatalogueReference(fullScope, vreDetached.getCatalogUrl(),
mapAccessURLToCatalogue);
break;
case ACTIVE:
default:
@ -258,7 +296,6 @@ public class CatalogueResolver {
break;
}
logger.info("For scope " + fullScope + " loaded end points: " + ckanCatalogueReference);
// IS THE PRODUCT PLUBLIC OR PRIVATE?
@ -266,7 +303,8 @@ public class CatalogueResolver {
boolean isPublicItem = false;
if (ckanCatalogueReference.getCkanURL() != null) {
try {
CkanDataset dataset = CkanCatalogueConfigurationsReader.getDataset(datasetName, ckanCatalogueReference.getCkanURL());
CkanDataset dataset = CkanCatalogueConfigurationsReader.getDataset(datasetName,
ckanCatalogueReference.getCkanURL());
if (dataset != null) {
isPublicItem = true;
// ckanPorltetUrl = ckanCatalogueReference.getPublicPortletURL();
@ -280,25 +318,23 @@ public class CatalogueResolver {
String publicGatewayPorltetURL = String.format("%s?path=/%s/%s",
ckanCatalogueReference.getCatalogueURL(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PUBLIC_GATEWAY),
entityContextValue,
entityName);
entityContextValue, entityName);
String privateVREPortletURL = String.format("%s?path=/%s/%s",
ckanCatalogueReference.getCatalogueURL(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PRIVATE_VRE),
entityContextValue,
entityName);
entityContextValue, entityName);
// Checking if the public VRE portlet URL is available (so it was read from GR)
String publicVREPortletURL = null;
String toCheckPublicVREPortletURL = ckanCatalogueReference.getCatalogueURL(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PUBLIC_VRE);
String toCheckPublicVREPortletURL = ckanCatalogueReference
.getCatalogueURL(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PUBLIC_VRE);
if (toCheckPublicVREPortletURL != null && !toCheckPublicVREPortletURL.isEmpty()) {
// here the catalogue is available/deployed as public at VRE level
publicVREPortletURL = String.format("%s?path=/%s/%s",
toCheckPublicVREPortletURL,
entityContextValue,
publicVREPortletURL = String.format("%s?path=/%s/%s", toCheckPublicVREPortletURL, entityContextValue,
entityName);
}
return new ItemCatalogueURLs(entityName, isPublicItem, privateVREPortletURL, publicVREPortletURL, publicGatewayPorltetURL);
return new ItemCatalogueURLs(entityName, isPublicItem, privateVREPortletURL, publicVREPortletURL,
publicGatewayPorltetURL);
} catch (Exception e) {
logger.error("Error when resolving CatalogueURL:", e);
throw e;
@ -306,5 +342,4 @@ public class CatalogueResolver {
}
}

View File

@ -32,8 +32,6 @@ import org.slf4j.LoggerFactory;
import com.google.common.cache.CacheLoader.InvalidCacheLoadException;
/**
* The Class GisResolver.
*
@ -53,7 +51,6 @@ public class GisResolver {
public static final String SCOPE = "scope";
public static final String GEO_EXPLORER_LAYER_UUID = "geo-exp";
/**
* Submit get.
*
@ -66,10 +63,9 @@ public class GisResolver {
*/
@GET
@Path("")
public Response submitGet(@Context HttpServletRequest req, @
QueryParam(SCOPE) String scope,
@QueryParam(GIS_UUID) String gisUUID,
@QueryParam(GEO_EXPLORER_LAYER_UUID) String geoExplorerUUID) throws WebApplicationException{
public Response submitGet(@Context HttpServletRequest req, @QueryParam(SCOPE) String scope,
@QueryParam(GIS_UUID) String gisUUID, @QueryParam(GEO_EXPLORER_LAYER_UUID) String geoExplorerUUID)
throws WebApplicationException {
logger.info(this.getClass().getSimpleName() + " GET starts...");
@ -79,12 +75,14 @@ public class GisResolver {
if (scope == null || scope.isEmpty()) {
logger.error("Query Parameter 'scope' not found");
throw ExceptionManager.badRequestException(req, "Missing mandatory query parameter 'scope'", this.getClass(), help);
throw ExceptionManager.badRequestException(req, "Missing mandatory query parameter 'scope'",
this.getClass(), help);
}
if (gisUUID == null || gisUUID.isEmpty()) {
logger.error("Path Parameter 'gis-UUID' not found");
throw ExceptionManager.badRequestException(req, "Missing mandatory query parameter 'gis-UUID'", this.getClass(), help);
throw ExceptionManager.badRequestException(req, "Missing mandatory query parameter 'gis-UUID'",
this.getClass(), help);
} else
isGisLink = true;
@ -104,8 +102,6 @@ public class GisResolver {
throw ExceptionManager.badRequestException(req, err, this.getClass(), help);
}
if (isGisLink) {
ScopeProvider.instance.set(scope);
// ServerParameters geonetworkParams = getCachedServerParameters(scope);
@ -125,16 +121,22 @@ public class GisResolver {
gisViewerPortletUrl = LoadingGisViewerApplicationURLCache.get(scope);
} catch (ExecutionException | InvalidCacheLoadException e) {
logger.error("Error on getting the GisViewer Applicaton URL from cache for scope " + scope, e);
throw ExceptionManager.wrongParameterException(req, "Error on getting the GisViewer Applicaton URL from cache for scope "+scope+".\nIs the Application Profile with APPID "+UriResolverSmartGearManagerInit.getGisViewerProfile().getAppId()+" registered for this scope: "+scope+"?", this.getClass(), help);
throw ExceptionManager.wrongParameterException(req,
"Error on getting the GisViewer Applicaton URL from cache for scope " + scope
+ ".\nIs the Application Profile with APPID "
+ UriResolverSmartGearManagerInit.getGisViewerProfile().getAppId()
+ " registered for this scope: " + scope + "?",
this.getClass(), help);
}
// CHECKING IF THE GisViewer Portlet URL is valid
if (gisViewerPortletUrl == null || gisViewerPortletUrl.isEmpty())
throw ExceptionManager.notFoundException(req, "GisViewer Portlet URL not found in the scope: "+scope +". Please contact the support", this.getClass(), help);
throw ExceptionManager.notFoundException(req,
"GisViewer Portlet URL not found in the scope: " + scope + ". Please contact the support",
this.getClass(), help);
logger.info("Gis Viewer Application url is: " + gisViewerPortletUrl);
gisViewerPortletUrl+="?rid="+new Random().nextLong()
+"&wmsrequest="+wmsRequest
+"&uuid="+URLEncoder.encode(gisUUID, UTF_8);
gisViewerPortletUrl += "?rid=" + new Random().nextLong() + "&wmsrequest=" + wmsRequest + "&uuid="
+ URLEncoder.encode(gisUUID, UTF_8);
if (layerTitle != null)
gisViewerPortletUrl += "&layertitle=" + layerTitle;
@ -152,26 +154,36 @@ public class GisResolver {
geoExplorerPortletUrl = LoadingGeoExplorerApplicationURLCache.get(scope);
} catch (ExecutionException e) {
logger.error("Error on getting the GeoExplorer Applicaton URL from cache for scope " + scope, e);
throw ExceptionManager.wrongParameterException(req, "Error on getting the GeoExplorer Applicaton URL from cache for scope "+scope+".\nIs the Application Profile with APPID "+UriResolverSmartGearManagerInit.getGeoExplorerProfile().getAppId()+" registered for this scope: "+scope+"?", this.getClass(), help);
throw ExceptionManager.wrongParameterException(req,
"Error on getting the GeoExplorer Applicaton URL from cache for scope " + scope
+ ".\nIs the Application Profile with APPID "
+ UriResolverSmartGearManagerInit.getGeoExplorerProfile().getAppId()
+ " registered for this scope: " + scope + "?",
this.getClass(), help);
}
// CHECKING IF THE GeoExplorer Portlet URL is valid
if (geoExplorerPortletUrl == null || geoExplorerPortletUrl.isEmpty())
throw ExceptionManager.notFoundException(req, "GeoExplorer Portlet URL not found in the scope: "+scope +". Please contact the support", this.getClass(), help);
throw ExceptionManager.notFoundException(req,
"GeoExplorer Portlet URL not found in the scope: " + scope + ". Please contact the support",
this.getClass(), help);
logger.info("GeoExplorer Application url is: " + geoExplorerPortletUrl);
geoExplorerPortletUrl+="?rid="+new Random().nextLong()
+"&luuid="+URLEncoder.encode(geoExplorerUUID, UTF_8);
geoExplorerPortletUrl += "?rid=" + new Random().nextLong() + "&luuid="
+ URLEncoder.encode(geoExplorerUUID, UTF_8);
// urlRedirect(req, resp, geoExplorerPortletUrl);
return Response.seeOther(new URI(geoExplorerPortletUrl)).build();
}
throw ExceptionManager.badRequestException(req, GIS_UUID+" or "+GEO_EXPLORER_LAYER_UUID+" not found or empty in the query string", this.getClass(), help);
throw ExceptionManager.badRequestException(req,
GIS_UUID + " or " + GEO_EXPLORER_LAYER_UUID + " not found or empty in the query string",
this.getClass(), help);
} catch (Exception e) {
if (!(e instanceof WebApplicationException)) {
// UNEXPECTED EXCEPTION managing it as WebApplicationException
String error = "Sorry, an error occurred on resolving request with UUID "+gisUUID+" and scope "+scope+". Please, contact support!";
String error = "Sorry, an error occurred on resolving request with UUID " + gisUUID + " and scope "
+ scope + ". Please, contact support!";
if (e.getCause() != null)
error += "\n\nCaused: " + e.getCause().getMessage();
throw ExceptionManager.internalErrorException(req, error, this.getClass(), help);
@ -183,7 +195,6 @@ public class GisResolver {
}
/**
* Gets the gis layer for layer uuid.
*
@ -202,13 +213,17 @@ public class GisResolver {
} catch (ExecutionException | InvalidCacheLoadException e) {
logger.error("Error on getting the Geonetwork Instance from cache for scope " + scope, e);
throw ExceptionManager.wrongParameterException(req, "Error on getting the Geonetwork Instance from cache for scope "+scope+". Is it registered for this scope: "+scope+"?", this.getClass(), help);
throw ExceptionManager.wrongParameterException(req,
"Error on getting the Geonetwork Instance from cache for scope " + scope
+ ". Is it registered for this scope: " + scope + "?",
this.getClass(), help);
}
if (gi == null)
throw new Exception("GeonetworkInstance not instanciable in the scope: " + scope);
LoginLevel toLoginLevel = LoginLevel.SCOPE;
logger.info("Performing authentication on GN with "+LoginLevel.class.getSimpleName()+" "+toLoginLevel);
logger.info(
"Performing authentication on GN with " + LoginLevel.class.getSimpleName() + " " + toLoginLevel);
gi.getGeonetworkPublisher().login(toLoginLevel);
GisLayerItem gisLayerItem = MetadataConverter.getWMSOnLineResource(gi, gisUUID);
@ -216,12 +231,13 @@ public class GisResolver {
// TODO CREATE A BEAN ADDING WMS REQUEST AND LAYER TITLE MetadataConverter.
} catch (GeonetworkInstanceException e) {
logger.error("An error occurred when instancing geonetowrk gis layer with UUID " + gisUUID, e);
throw new IllegalArgumentException("Sorry, An error occurred when instancing geonetwork with UUID: "+gisUUID);
throw new IllegalArgumentException(
"Sorry, An error occurred when instancing geonetwork with UUID: " + gisUUID);
} catch (Exception e) {
logger.error("An error occurred when retrieving gis layer with UUID " + gisUUID, e);
throw new IllegalArgumentException("Sorry, An error occurred when retrieving gis layer with UUID "+gisUUID);
throw new IllegalArgumentException(
"Sorry, An error occurred when retrieving gis layer with UUID " + gisUUID);
}
}
}

View File

@ -23,11 +23,12 @@ import org.gcube.datatransfer.resolver.util.Util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class KnimeCreateResolver.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Dec 13, 2018
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Mar 24, 2022
*/
@Path("knime")
public class KnimeCreateResolver {
@ -36,7 +37,6 @@ public class KnimeCreateResolver {
private static String helpURI = "https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#KNIME_Resolver";
/**
* Creates the knime URL.
*
@ -61,8 +61,10 @@ public class KnimeCreateResolver {
String appToken = req.getServletContext().getInitParameter(RequestHandler.ROOT_APP_TOKEN);
if (contextToken.compareTo(appToken) == 0) {
logger.error("Token not passed, SecurityTokenProvider contains the root app token: "+appToken.substring(0,10)+"...");
throw ExceptionManager.unauthorizedException(req, "You are not authorized. You must pass a token of VRE", this.getClass(), helpURI);
logger.error("Token not passed, SecurityTokenProvider contains the root app token: "
+ appToken.substring(0, 10) + "...");
throw ExceptionManager.unauthorizedException(req,
"You are not authorized. You must pass a token of VRE", this.getClass(), helpURI);
}
ScopeBean scopeBean = new ScopeBean(scope);
@ -81,7 +83,9 @@ public class KnimeCreateResolver {
} else {
logger.error("The input scope " + scope + " is not a VRE");
throw ExceptionManager.badRequestException(req, "Working in the "+scope+" scope that is not a VRE. Use a token of VRE", this.getClass(), helpURI);
throw ExceptionManager.badRequestException(req,
"Working in the " + scope + " scope that is not a VRE. Use a token of VRE", this.getClass(),
helpURI);
}
} catch (Exception e) {

View File

@ -19,11 +19,12 @@ import org.gcube.datatransfer.resolver.util.ValidateContentDisposition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class SMPIDResolver.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Oct 22, 2018
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Mar 24, 2022
*/
@Path("id")
public class SMPIDResolver {
@ -37,7 +38,6 @@ public class SMPIDResolver {
private static Logger logger = LoggerFactory.getLogger(SMPIDResolver.class);
/**
* Gets the smpid.
*
@ -45,14 +45,14 @@ public class SMPIDResolver {
* @param smpId the smp id
* @param fileName the file name
* @param contentType the content type
* @param contentDisposition the content disposition
* @param validation the validation
* @return the smpid
* @throws WebApplicationException the web application exception
*/
@GET
@Path("")
public Response getSMPID(@Context HttpServletRequest req,
@QueryParam(SMP_ID) @Nullable String smpId,
public Response getSMPID(@Context HttpServletRequest req, @QueryParam(SMP_ID) @Nullable String smpId,
@QueryParam(ConstantsResolver.QUERY_PARAM_FILE_NAME) String fileName,
@QueryParam(ConstantsResolver.QUERY_PARAM_CONTENT_TYPE) String contentType,
@QueryParam(ConstantsResolver.QUERY_PARAM_CONTENTDISPOSITION) String contentDisposition,
@ -64,10 +64,10 @@ public class SMPIDResolver {
// Checking mandatory parameter smpId
if (smpId == null || smpId.isEmpty()) {
logger.error(SMP_ID + " not found");
throw ExceptionManager.badRequestException(req, "Missing mandatory parameter "+SMP_ID, SMPIDResolver.class, helpURI);
throw ExceptionManager.badRequestException(req, "Missing mandatory parameter " + SMP_ID,
SMPIDResolver.class, helpURI);
}
// Checking the optional parameter "Content-Disposition"
CONTENT_DISPOSITION_VALUE dispositionValue = CONTENT_DISPOSITION_VALUE.attachment;
// Validating the Content-Disposition value
@ -79,7 +79,8 @@ public class SMPIDResolver {
if (!(e instanceof WebApplicationException)) {
// UNEXPECTED EXCEPTION managing it as WebApplicationException
String error = "Error occurred on resolving the "+SMP_ID+": "+smpId+". Please, contact the support!";
String error = "Error occurred on resolving the " + SMP_ID + ": " + smpId
+ ". Please, contact the support!";
if (e.getCause() != null)
error += "\n\nCaused: " + e.getCause().getMessage();
throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI);

View File

@ -19,12 +19,12 @@ import org.gcube.datatransfer.resolver.util.ValidateContentDisposition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class SMPResolver.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Dec 14, 2018
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Mar 24, 2022
*/
@Path("smp")
public class SMPResolver {
@ -45,15 +45,14 @@ public class SMPResolver {
* @param smpURI the smp uri
* @param fileName the file name
* @param contentType the content type
* @param contentDisposition the content disposition
* @param validation the validation
* @return the smpuri
* @throws WebApplicationException the web application exception
*/
@GET
@Path("")
public Response getSMPURI(@Context HttpServletRequest req,
@QueryParam(SMP_URI) @Nullable
String smpURI,
public Response getSMPURI(@Context HttpServletRequest req, @QueryParam(SMP_URI) @Nullable String smpURI,
@QueryParam(ConstantsResolver.QUERY_PARAM_FILE_NAME) String fileName,
@QueryParam(ConstantsResolver.QUERY_PARAM_CONTENT_TYPE) String contentType,
@QueryParam(ConstantsResolver.QUERY_PARAM_CONTENTDISPOSITION) String contentDisposition,
@ -65,7 +64,8 @@ public class SMPResolver {
// Checking mandatory parameter smpURI
if (smpURI == null || smpURI.isEmpty()) {
logger.error(SMP_URI + " not found");
throw ExceptionManager.badRequestException(req, "Missing mandatory parameter "+SMP_URI, SMPResolver.class, helpURI);
throw ExceptionManager.badRequestException(req, "Missing mandatory parameter " + SMP_URI,
SMPResolver.class, helpURI);
}
// Checking the optional parameter "Content-Disposition"

View File

@ -27,7 +27,6 @@ import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
import org.gcube.datatransfer.resolver.ConstantsResolver;
import org.gcube.datatransfer.resolver.ConstantsResolver.CONTENT_DISPOSITION_VALUE;
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
import org.gcube.datatransfer.resolver.storage.StorageClientInstance;
import org.gcube.datatransfer.resolver.storage.StorageMetadataFile;
import org.gcube.datatransfer.resolver.util.SingleFileStreamingOutput;
import org.gcube.datatransfer.resolver.util.ValidateContentDisposition;

View File

@ -20,14 +20,24 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class UriResolverDocs.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Oct 22, 2018
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Mar 24, 2022
*/
@Path("docs")
public class UriResolverDocs {
private static Logger logger = LoggerFactory.getLogger(UriResolverDocs.class);
/**
* To doc.
*
* @param req the req
* @return the input stream
* @throws WebApplicationException the web application exception
*/
@GET
@Produces({ MediaType.TEXT_HTML })
@Path("/{any: .*}")
@ -58,6 +68,13 @@ public class UriResolverDocs {
}
}
/**
* Index.
*
* @param req the req
* @return the input stream
* @throws WebApplicationException the web application exception
*/
@GET
@Produces({ MediaType.TEXT_HTML })
@Path("")

View File

@ -20,15 +20,24 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class UriResolverIndex.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Oct 22, 2018
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Mar 24, 2022
*/
@Path("index")
public class UriResolverIndex {
private static Logger logger = LoggerFactory.getLogger(UriResolverIndex.class);
/**
* Index.
*
* @param req the req
* @return the input stream
* @throws WebApplicationException the web application exception
*/
@GET
@Produces({ MediaType.TEXT_HTML })
@Path("")
@ -53,4 +62,3 @@ public class UriResolverIndex {
}
}
}

View File

@ -14,13 +14,22 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
/**
* The Class UriResolverInfo.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Oct 22, 2018
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Mar 24, 2022
*/
@Path("info")
public class UriResolverInfo {
/**
* Info.
*
* @param req the req
* @return the input stream
* @throws WebApplicationException the web application exception
*/
@GET
@Produces({ MediaType.TEXT_HTML })
@Path("")
@ -28,4 +37,3 @@ public class UriResolverInfo {
return new UriResolverIndex().index(req);
}
}

View File

@ -20,12 +20,12 @@ import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
/**
* The Class ResourceListingResource.
* The Class UriResolverResources.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Feb 14, 2019
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Mar 24, 2022
*/
@Path("resources")
@Singleton

View File

@ -35,13 +35,12 @@ import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class WekeoResolver.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Mar 30, 2021
* Mar 24, 2022
*/
@Path("wekeo")
public class WekeoResolver {
@ -53,8 +52,6 @@ public class WekeoResolver {
private static String helpURI = "https://wiki.gcube-system.org/gcube/URI_Resolver#Wekeo_Resolver";
/**
* Gets the token.
*
@ -78,8 +75,10 @@ public class WekeoResolver {
String appToken = req.getServletContext().getInitParameter(RequestHandler.ROOT_APP_TOKEN);
if (contextToken.compareTo(appToken) == 0) {
logger.error("Token not passed, SecurityTokenProvider contains the root app token: "+appToken.substring(0,10)+"...");
throw ExceptionManager.unauthorizedException(req, "You are not authorized. You must pass a token of VRE", this.getClass(), helpURI);
logger.error("Token not passed, SecurityTokenProvider contains the root app token: "
+ appToken.substring(0, 10) + "...");
throw ExceptionManager.unauthorizedException(req,
"You are not authorized. You must pass a token of VRE", this.getClass(), helpURI);
}
StringBuilder wekeoResponse = new StringBuilder();
@ -164,8 +163,8 @@ public class WekeoResolver {
// to be sure
if (wekeoResponse.length() == 0) {
String error = String
.format("Sorry an error occured on getting the access token from Wekeo. Please, retry the request");
String error = String.format(
"Sorry an error occured on getting the access token from Wekeo. Please, retry the request");
throw new Exception(error);
}
@ -180,6 +179,13 @@ public class WekeoResolver {
}
}
/**
* Index.
*
* @param req the req
* @return the input stream
* @throws WebApplicationException the web application exception
*/
@GET
@Produces({ MediaType.TEXT_HTML })
@Path("")
@ -205,7 +211,8 @@ public class WekeoResolver {
}
/**
* Reads the wekeo endpoint information from IS. {The SE name is: @link WekeoResolver#RUNTIME_WKEO_RESOURCE_NAME}
* Reads the wekeo endpoint information from IS. {The SE name is: @link
* WekeoResolver#RUNTIME_WKEO_RESOURCE_NAME}
*
* @param req the req
* @param scope the scope
@ -217,7 +224,8 @@ public class WekeoResolver {
try {
callerScope = ScopeProvider.instance.get();
ScopeProvider.instance.set(scope);
logger.info("Searching SE "+RUNTIME_WKEO_RESOURCE_NAME+" configurations in the scope: "+ScopeProvider.instance.get());
logger.info("Searching SE " + RUNTIME_WKEO_RESOURCE_NAME + " configurations in the scope: "
+ ScopeProvider.instance.get());
SimpleQuery query = queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Name/text() eq '" + RUNTIME_WKEO_RESOURCE_NAME + "'");
@ -229,7 +237,9 @@ public class WekeoResolver {
logger.info("The query returned " + toReturn.size() + " ServiceEndpoint/s");
if (toReturn.size() == 0) {
String errorMessage = String.format("Missing the RR with Name '%s' and Category '%s' in the scope '%s'. Please contact the support.",RUNTIME_WKEO_RESOURCE_NAME,CATEGORY_WEKEO_TYPE,ScopeProvider.instance.get());
String errorMessage = String.format(
"Missing the RR with Name '%s' and Category '%s' in the scope '%s'. Please contact the support.",
RUNTIME_WKEO_RESOURCE_NAME, CATEGORY_WEKEO_TYPE, ScopeProvider.instance.get());
logger.error(errorMessage);
throw ExceptionManager.notFoundException(req, errorMessage, WekeoResolver.class, helpURI);
@ -256,7 +266,8 @@ public class WekeoResolver {
if (e instanceof NotFoundException)
throw e;
String errorMessage = "Error occurred on reading the "+RUNTIME_WKEO_RESOURCE_NAME+" SE registered in the scope: "+ScopeProvider.instance.get();
String errorMessage = "Error occurred on reading the " + RUNTIME_WKEO_RESOURCE_NAME
+ " SE registered in the scope: " + ScopeProvider.instance.get();
logger.error(errorMessage, e);
throw ExceptionManager.internalErrorException(req, errorMessage, WekeoResolver.class, helpURI);