managed the cache exceptions
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@174926 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
63a1755653
commit
e36d718fda
|
@ -1,119 +0,0 @@
|
||||||
///**
|
|
||||||
// *
|
|
||||||
// */
|
|
||||||
//package org.gcube.datatransfer.resolver.caches;
|
|
||||||
//
|
|
||||||
//import java.util.concurrent.TimeUnit;
|
|
||||||
//
|
|
||||||
//import org.gcube.common.scope.api.ScopeProvider;
|
|
||||||
//import org.gcube.datatransfer.resolver.catalogue.resource.ApplicationProfileReaderForCatalogueResolver;
|
|
||||||
//import org.gcube.datatransfer.resolver.listeners.UriResolverStartupListener;
|
|
||||||
//import org.slf4j.Logger;
|
|
||||||
//import org.slf4j.LoggerFactory;
|
|
||||||
//
|
|
||||||
//import com.google.common.cache.CacheBuilder;
|
|
||||||
//import com.google.common.cache.CacheLoader;
|
|
||||||
//import com.google.common.cache.LoadingCache;
|
|
||||||
//import com.google.common.cache.RemovalListener;
|
|
||||||
//import com.google.common.cache.RemovalNotification;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * The Class LoadingCatalogueApplicationProfilesCache.
|
|
||||||
// *
|
|
||||||
// * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
|
||||||
// * Nov 5, 2018
|
|
||||||
// */
|
|
||||||
//public class LoadingCatalogueApplicationProfilesCache {
|
|
||||||
//
|
|
||||||
// private static Logger logger = LoggerFactory.getLogger(LoadingCatalogueApplicationProfilesCache.class);
|
|
||||||
// private static LoadingCache<String, String> catalogueApplicationProfiles;
|
|
||||||
//
|
|
||||||
// static{
|
|
||||||
//
|
|
||||||
// CacheLoader<String, String> loader = new CacheLoader<String, String>(){
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public String load(String vreName)
|
|
||||||
// throws Exception {
|
|
||||||
//
|
|
||||||
// logger.info("Loading the cache for vreName: "+vreName);
|
|
||||||
// String fullScope = loadFullScopeByApplicationProfile(vreName);
|
|
||||||
// logger.info("Returning fullScope: "+fullScope+ " for the VRE name: "+vreName);
|
|
||||||
// return fullScope;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// RemovalListener<String, String> removalListener = new RemovalListener<String, String>() {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onRemoval(RemovalNotification<String, String> arg0) {
|
|
||||||
//
|
|
||||||
// logger.info("cache expired");
|
|
||||||
// //prePopulateCache();
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// catalogueApplicationProfiles = CacheBuilder.newBuilder().maximumSize(100).expireAfterWrite(
|
|
||||||
// 1, TimeUnit.DAYS).removalListener(removalListener).
|
|
||||||
// build(loader);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// //Populating the cache at init stage
|
|
||||||
// populateTheCache();
|
|
||||||
// logger.info("Pre-Loaded CatalogueApplicationProfiles cache with: "+catalogueApplicationProfiles.asMap().size()+" item/s");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Populate the cache.
|
|
||||||
// */
|
|
||||||
// private static void populateTheCache(){
|
|
||||||
// try{
|
|
||||||
// //POPULATE THE CACHE READING THE RESOURCE "CATALOGUE-RESOLVER"
|
|
||||||
// logger.info("Trying to pre-populate catalogue resolver cache");
|
|
||||||
// ScopeProvider.instance.set(UriResolverStartupListener.getRootContextScope());
|
|
||||||
// ApplicationProfileReaderForCatalogueResolver appPrCatResolver = new ApplicationProfileReaderForCatalogueResolver(UriResolverStartupListener.getRootContextScope(), true);
|
|
||||||
// catalogueApplicationProfiles.asMap().putAll(appPrCatResolver.getHashVreNameScope());
|
|
||||||
// logger.info("Cache populated with: "+catalogueApplicationProfiles.asMap().toString());
|
|
||||||
// //logger.info("Pre-Loaded CatalogueApplicationProfiles cache is: "+catalogueApplicationProfiles.asMap().toString());
|
|
||||||
// }catch(Exception e){
|
|
||||||
//
|
|
||||||
// }finally{
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Gets the cache.
|
|
||||||
// *
|
|
||||||
// * @return the cache
|
|
||||||
// */
|
|
||||||
// public static LoadingCache<String, String> getCache(){
|
|
||||||
// return catalogueApplicationProfiles;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Load application profiles.
|
|
||||||
// *
|
|
||||||
// * @param vreName the vre name
|
|
||||||
// * @return the string
|
|
||||||
// */
|
|
||||||
// public static String loadFullScopeByApplicationProfile(String vreName){
|
|
||||||
//
|
|
||||||
// //THIS CHECK SHOULD BE NOT NEEDED
|
|
||||||
// String fullScope = catalogueApplicationProfiles.getIfPresent(vreName);
|
|
||||||
//
|
|
||||||
// if(fullScope==null){
|
|
||||||
// populateTheCache();
|
|
||||||
// fullScope = catalogueApplicationProfiles.getIfPresent(vreName);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return fullScope;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
package org.gcube.datatransfer.resolver.caches;
|
package org.gcube.datatransfer.resolver.caches;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.gcube.datatransfer.resolver.applicationprofile.ApplicationProfileReader;
|
import org.gcube.datatransfer.resolver.applicationprofile.ApplicationProfileReader;
|
||||||
|
@ -58,13 +59,15 @@ public class LoadingGeoExplorerApplicationURLCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the cache.
|
* Gets the.
|
||||||
*
|
*
|
||||||
* @return the cache
|
* @param scope the scope
|
||||||
|
* @return the string
|
||||||
|
* @throws ExecutionException the execution exception
|
||||||
*/
|
*/
|
||||||
public static LoadingCache<String, String> getCache() {
|
public static String get(String scope) throws ExecutionException{
|
||||||
|
|
||||||
return geoExplorerApplicationURLCache;
|
return geoExplorerApplicationURLCache.get(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,7 +78,7 @@ public class LoadingGeoExplorerApplicationURLCache {
|
||||||
* @param scope the scope
|
* @param scope the scope
|
||||||
* @return the string
|
* @return the string
|
||||||
*/
|
*/
|
||||||
public static String loadGeoExplorerApplicationURL(String scope){
|
protected static String loadGeoExplorerApplicationURL(String scope){
|
||||||
|
|
||||||
if (scope == null || scope.isEmpty())
|
if (scope == null || scope.isEmpty())
|
||||||
logger.warn("Scope is null or ermpty, skipping loadGisViewerApplicationURL");
|
logger.warn("Scope is null or ermpty, skipping loadGisViewerApplicationURL");
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
package org.gcube.datatransfer.resolver.caches;
|
package org.gcube.datatransfer.resolver.caches;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.gcube.datatransfer.resolver.gis.GeonetworkAccessParameter;
|
import org.gcube.datatransfer.resolver.gis.GeonetworkAccessParameter;
|
||||||
|
@ -60,13 +61,15 @@ public class LoadingGeonetworkInstanceCache {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the cache.
|
* Gets the.
|
||||||
*
|
*
|
||||||
* @return the cache
|
* @param scope the scope
|
||||||
|
* @return the geonetwork instance
|
||||||
|
* @throws ExecutionException the execution exception
|
||||||
*/
|
*/
|
||||||
public static LoadingCache<String, GeonetworkInstance> getCache() {
|
public static GeonetworkInstance get(String scope) throws ExecutionException{
|
||||||
|
|
||||||
return geonetworkInstancesCache;
|
return geonetworkInstancesCache.get(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,7 +80,7 @@ public class LoadingGeonetworkInstanceCache {
|
||||||
* @return the geonetwork instance
|
* @return the geonetwork instance
|
||||||
* @throws GeonetworkInstanceException the geonetwork instance exception
|
* @throws GeonetworkInstanceException the geonetwork instance exception
|
||||||
*/
|
*/
|
||||||
public static GeonetworkInstance loadGeonetworkInstance(String scope)
|
protected static GeonetworkInstance loadGeonetworkInstance(String scope)
|
||||||
throws GeonetworkInstanceException {
|
throws GeonetworkInstanceException {
|
||||||
|
|
||||||
if (scope == null || scope.isEmpty()){
|
if (scope == null || scope.isEmpty()){
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
package org.gcube.datatransfer.resolver.caches;
|
package org.gcube.datatransfer.resolver.caches;
|
||||||
|
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.gcube.datatransfer.resolver.applicationprofile.ApplicationProfileReader;
|
import org.gcube.datatransfer.resolver.applicationprofile.ApplicationProfileReader;
|
||||||
|
@ -59,23 +60,26 @@ public class LoadingGisViewerApplicationURLCache {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the cache.
|
* Gets the.
|
||||||
*
|
*
|
||||||
* @return the cache
|
* @param scope the scope
|
||||||
|
* @return the string
|
||||||
|
* @throws ExecutionException the execution exception
|
||||||
*/
|
*/
|
||||||
public static LoadingCache<String, String> getCache() {
|
public static String get(String scope) throws ExecutionException{
|
||||||
|
|
||||||
return gisViewerApplicationURLCache;
|
return gisViewerApplicationURLCache.get(scope);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load gis viewer application url.
|
* Load gis viewer application url.
|
||||||
*
|
*
|
||||||
* @param scope the scope
|
* @param scope the scope
|
||||||
* @return the string
|
* @return the string
|
||||||
*/
|
*/
|
||||||
public static String loadGisViewerApplicationURL(String scope){
|
protected static String loadGisViewerApplicationURL(String scope){
|
||||||
|
|
||||||
if (scope == null || scope.isEmpty())
|
if (scope == null || scope.isEmpty())
|
||||||
logger.warn("Scope is null or ermpty, skipping loadGisViewerApplicationURL");
|
logger.warn("Scope is null or ermpty, skipping loadGisViewerApplicationURL");
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
package org.gcube.datatransfer.resolver.caches;
|
package org.gcube.datatransfer.resolver.caches;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
@ -94,15 +95,18 @@ public class LoadingVREsScopeCache {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the cache.
|
|
||||||
*
|
|
||||||
* @return the cache
|
|
||||||
*/
|
|
||||||
public static LoadingCache<String, String> getCache(){
|
|
||||||
return vresNameToScope;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the.
|
||||||
|
*
|
||||||
|
* @param vreName the vre name
|
||||||
|
* @return the string
|
||||||
|
* @throws ExecutionException
|
||||||
|
*/
|
||||||
|
public static String get(String vreName) throws ExecutionException{
|
||||||
|
|
||||||
|
return vresNameToScope.get(vreName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,7 +115,7 @@ public class LoadingVREsScopeCache {
|
||||||
* @param vreName the vre name
|
* @param vreName the vre name
|
||||||
* @return the string
|
* @return the string
|
||||||
*/
|
*/
|
||||||
public static String loadFullScopeforVreName(String vreName){
|
protected static String loadFullScopeforVreName(String vreName){
|
||||||
|
|
||||||
//THIS CHECK SHOULD BE NOT NEEDED
|
//THIS CHECK SHOULD BE NOT NEEDED
|
||||||
String fullScope = vresNameToScope.getIfPresent(vreName);
|
String fullScope = vresNameToScope.getIfPresent(vreName);
|
||||||
|
|
|
@ -60,29 +60,30 @@ public class AnalyticsGetResolver {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String fullScope = "";
|
||||||
|
|
||||||
|
//CHECKING IF THE INPUT VRE NAME IS REGISTRED IN THE INFRASTRUCTURE...
|
||||||
try{
|
try{
|
||||||
String fullScope = LoadingVREsScopeCache.getCache().get(vreName);
|
fullScope = LoadingVREsScopeCache.get(vreName);
|
||||||
ApplicationProfileReader reader = null;
|
}catch(ExecutionException e){
|
||||||
try{
|
logger.error("Error on getting the fullscope from cache for vreName "+vreName, e);
|
||||||
reader = new ApplicationProfileReader(fullScope, APPLICATION_PROFILE, ORG_GCUBE_PORTLETS_USER_DATAMINERMANAGER_SERVER_DATA_MINER_MANAGER_SERVICE_IMPL, false);
|
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);
|
||||||
}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);
|
|
||||||
}
|
|
||||||
|
|
||||||
//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);
|
|
||||||
return Response.seeOther(new URI(analitycsExecutorURL)).build();
|
|
||||||
|
|
||||||
}catch (ExecutionException e) {
|
|
||||||
logger.error("The input VRE Name "+vreName+" not found", e);
|
|
||||||
throw ExceptionManager.badRequestException(req, "The input 'VRE Name' "+"+vreName+"+ "not found on Informatiion System. Is it a valid VRE?", this.getClass(), helpURI);
|
|
||||||
//throw new BadRequestException(req, Status.BAD_REQUEST, "", this.getClass(), null);
|
|
||||||
}
|
}
|
||||||
|
ApplicationProfileReader reader = null;
|
||||||
|
try{
|
||||||
|
reader = new ApplicationProfileReader(fullScope, 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
//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);
|
||||||
|
return Response.seeOther(new URI(analitycsExecutorURL)).build();
|
||||||
|
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class CatalogueResolver {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
InnerMethodName.instance.set("resolveCataloguePublicLink");
|
InnerMethodName.instance.set("resolveCataloguePublicLink");
|
||||||
ItemCatalogueURLs itemCatalogueURLs = getItemCatalogueURLs(vreName, entityContext, entityName);
|
ItemCatalogueURLs itemCatalogueURLs = getItemCatalogueURLs(req, vreName, entityContext, entityName);
|
||||||
|
|
||||||
String itemCatalogueURL;
|
String itemCatalogueURL;
|
||||||
|
|
||||||
|
@ -121,12 +121,13 @@ public class CatalogueResolver {
|
||||||
|
|
||||||
final String vreName = scope.substring(scope.lastIndexOf("/")+1, scope.length());
|
final String vreName = scope.substring(scope.lastIndexOf("/")+1, scope.length());
|
||||||
String fullScope = null;
|
String fullScope = null;
|
||||||
|
|
||||||
//CHECK IF THE vreName has a valid scope, so it is a valid VRE
|
//CHECK IF THE vreName has a valid scope, so it is a valid VRE
|
||||||
try {
|
try {
|
||||||
fullScope = LoadingVREsScopeCache.getCache().get(vreName);
|
fullScope = LoadingVREsScopeCache.get(vreName);
|
||||||
}
|
}catch(ExecutionException e){
|
||||||
catch (ExecutionException e1) {
|
logger.error("Error on getting the fullscope from cache for vreName "+vreName, e);
|
||||||
logger.error("Error on getting full scope for vre name: "+vreName, e1);
|
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)
|
if(fullScope==null)
|
||||||
|
@ -159,18 +160,24 @@ public class CatalogueResolver {
|
||||||
/**
|
/**
|
||||||
* Gets the item catalogue url.
|
* Gets the item catalogue url.
|
||||||
*
|
*
|
||||||
|
* @param req the req
|
||||||
* @param vreName the vre name
|
* @param vreName the vre name
|
||||||
* @param entityContext the entity context
|
* @param entityContext the entity context
|
||||||
* @param entityName the entity name
|
* @param entityName the entity name
|
||||||
* @return the item catalogue url
|
* @return the item catalogue url
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
protected static ItemCatalogueURLs getItemCatalogueURLs(String vreName, String entityContext, String entityName) throws Exception{
|
protected static ItemCatalogueURLs getItemCatalogueURLs(HttpServletRequest req, String vreName, String entityContext, String entityName) throws Exception{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String entityContextValue = ResourceCatalogueCodes.valueOfCodeId(entityContext).getValue();
|
String entityContextValue = ResourceCatalogueCodes.valueOfCodeId(entityContext).getValue();
|
||||||
|
String fullScope = "";
|
||||||
String fullScope = LoadingVREsScopeCache.getCache().get(vreName);
|
try{
|
||||||
|
fullScope = LoadingVREsScopeCache.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?", CatalogueResolver.class, helpURI);
|
||||||
|
}
|
||||||
logger.info("Read fullScope: "+fullScope + " for VRE_NAME: "+vreName +" from cache created by: "+GetAllInfrastructureVREs.class.getSimpleName());
|
logger.info("Read fullScope: "+fullScope + " for VRE_NAME: "+vreName +" from cache created by: "+GetAllInfrastructureVREs.class.getSimpleName());
|
||||||
|
|
||||||
ScopeProvider.instance.set(fullScope);
|
ScopeProvider.instance.set(fullScope);
|
||||||
|
|
|
@ -6,6 +6,7 @@ package org.gcube.datatransfer.resolver.services;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
|
@ -23,12 +24,11 @@ import org.gcube.datatransfer.resolver.gis.GeonetworkInstance;
|
||||||
import org.gcube.datatransfer.resolver.gis.MetadataConverter;
|
import org.gcube.datatransfer.resolver.gis.MetadataConverter;
|
||||||
import org.gcube.datatransfer.resolver.gis.entity.GisLayerItem;
|
import org.gcube.datatransfer.resolver.gis.entity.GisLayerItem;
|
||||||
import org.gcube.datatransfer.resolver.gis.exception.GeonetworkInstanceException;
|
import org.gcube.datatransfer.resolver.gis.exception.GeonetworkInstanceException;
|
||||||
|
import org.gcube.datatransfer.resolver.init.UriResolverSmartGearManagerInit;
|
||||||
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.google.common.cache.CacheLoader.InvalidCacheLoadException;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,7 +106,7 @@ public class GisResolver {
|
||||||
if(isGisLink){
|
if(isGisLink){
|
||||||
ScopeProvider.instance.set(scope);
|
ScopeProvider.instance.set(scope);
|
||||||
//ServerParameters geonetworkParams = getCachedServerParameters(scope);
|
//ServerParameters geonetworkParams = getCachedServerParameters(scope);
|
||||||
GisLayerItem gisLayerItem = getGisLayerForLayerUUID(scope, gisUUID);
|
GisLayerItem gisLayerItem = getGisLayerForLayerUUID(req, scope, gisUUID);
|
||||||
|
|
||||||
logger.info("wms url is: " + gisLayerItem.getFullWmsUrlRequest());
|
logger.info("wms url is: " + gisLayerItem.getFullWmsUrlRequest());
|
||||||
String wmsRequest = URLEncoder.encode(gisLayerItem.getFullWmsUrlRequest(), UTF_8);
|
String wmsRequest = URLEncoder.encode(gisLayerItem.getFullWmsUrlRequest(), UTF_8);
|
||||||
|
@ -117,47 +117,49 @@ public class GisResolver {
|
||||||
layerTitle = URLEncoder.encode(gisLayerItem.getCitationTitle(), UTF_8);
|
layerTitle = URLEncoder.encode(gisLayerItem.getCitationTitle(), UTF_8);
|
||||||
|
|
||||||
logger.info("layer Title encoded is: " + layerTitle);
|
logger.info("layer Title encoded is: " + layerTitle);
|
||||||
|
String gisViewerPortletUrl = null;
|
||||||
try{
|
try{
|
||||||
String gisViewerPortletUrl = LoadingGisViewerApplicationURLCache.getCache().get(scope);
|
gisViewerPortletUrl = LoadingGisViewerApplicationURLCache.get(scope);
|
||||||
//CHECKING IF THE GisViewer Portlet URL is valid
|
}catch(ExecutionException e){
|
||||||
if(gisViewerPortletUrl==null || gisViewerPortletUrl.isEmpty())
|
logger.error("Error on getting the GisViewer Applicaton URL from cache for scope "+scope, e);
|
||||||
throw ExceptionManager.notFoundException(req, "GisViewer Portlet URL not found in the scope: "+scope +". Please contact the support", 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);
|
||||||
|
|
||||||
logger.info("Gis Viewer Application url is: " + gisViewerPortletUrl);
|
|
||||||
gisViewerPortletUrl+="?rid="+new Random().nextLong()
|
|
||||||
+"&wmsrequest="+wmsRequest
|
|
||||||
+"&uuid="+URLEncoder.encode(gisUUID, UTF_8);
|
|
||||||
|
|
||||||
if(layerTitle!=null)
|
|
||||||
gisViewerPortletUrl+="&layertitle="+layerTitle;
|
|
||||||
|
|
||||||
logger.info("Redirecting to: "+gisViewerPortletUrl);
|
|
||||||
return Response.seeOther(new URI(gisViewerPortletUrl)).build();
|
|
||||||
|
|
||||||
}catch (InvalidCacheLoadException e) {
|
|
||||||
logger.error("Error on getting GisViewer Portlet URL for scope: "+scope, e);
|
|
||||||
//ExceptionManager.throwNotFoundException(req, "GisViewer Portlet URL not found in the scope: "+scope +". Please add it or contact the support", 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);
|
||||||
|
|
||||||
|
logger.info("Gis Viewer Application url is: " + gisViewerPortletUrl);
|
||||||
|
gisViewerPortletUrl+="?rid="+new Random().nextLong()
|
||||||
|
+"&wmsrequest="+wmsRequest
|
||||||
|
+"&uuid="+URLEncoder.encode(gisUUID, UTF_8);
|
||||||
|
|
||||||
|
if(layerTitle!=null)
|
||||||
|
gisViewerPortletUrl+="&layertitle="+layerTitle;
|
||||||
|
|
||||||
|
logger.info("Redirecting to: "+gisViewerPortletUrl);
|
||||||
|
return Response.seeOther(new URI(gisViewerPortletUrl)).build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isGeoExplorerLink){
|
if(isGeoExplorerLink){
|
||||||
ScopeProvider.instance.set(scope);
|
|
||||||
try{
|
|
||||||
String geoExplorerPortletUrl = LoadingGeoExplorerApplicationURLCache.getCache().get(scope);
|
|
||||||
//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);
|
|
||||||
|
|
||||||
logger.info("GeoExplorer Application url is: " + geoExplorerPortletUrl);
|
ScopeProvider.instance.set(scope);
|
||||||
geoExplorerPortletUrl+="?rid="+new Random().nextLong()
|
String geoExplorerPortletUrl = null;
|
||||||
+"&luuid="+URLEncoder.encode(geoExplorerUUID, UTF_8);
|
try{
|
||||||
//urlRedirect(req, resp, geoExplorerPortletUrl);
|
geoExplorerPortletUrl = LoadingGeoExplorerApplicationURLCache.get(scope);
|
||||||
return Response.seeOther(new URI(geoExplorerPortletUrl)).build();
|
}catch(ExecutionException e){
|
||||||
}catch (InvalidCacheLoadException e) {
|
logger.error("Error on getting the GeoExplorer Applicaton URL from cache for scope "+scope, e);
|
||||||
logger.error("Error on getting GeoExplorer Portlet URL 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.notFoundException(req, "GeoExplorer Portlet URL not found in the scope: "+scope +". Please add it or contact the support", 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);
|
||||||
|
|
||||||
|
logger.info("GeoExplorer Application url is: " + geoExplorerPortletUrl);
|
||||||
|
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);
|
||||||
|
@ -178,18 +180,26 @@ public class GisResolver {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the gis layer for layer uuid.
|
* Gets the gis layer for layer uuid.
|
||||||
*
|
*
|
||||||
|
* @param req the req
|
||||||
* @param scope the scope
|
* @param scope the scope
|
||||||
* @param gisUUID the gis uuid
|
* @param gisUUID the gis uuid
|
||||||
* @return the gis layer for layer uuid
|
* @return the gis layer for layer uuid
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
protected GisLayerItem getGisLayerForLayerUUID(String scope, String gisUUID) throws Exception{
|
protected GisLayerItem getGisLayerForLayerUUID(HttpServletRequest req, String scope, String gisUUID) throws Exception{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
GeonetworkInstance gi = LoadingGeonetworkInstanceCache.getCache().get(scope);
|
GeonetworkInstance gi = null;
|
||||||
|
try {
|
||||||
|
gi = LoadingGeonetworkInstanceCache.get(scope);
|
||||||
|
}catch(ExecutionException 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);
|
||||||
|
}
|
||||||
if(gi==null)
|
if(gi==null)
|
||||||
throw new Exception("GeonetworkInstance not instanciable in the scope: "+scope);
|
throw new Exception("GeonetworkInstance not instanciable in the scope: "+scope);
|
||||||
|
|
||||||
|
|
|
@ -59,28 +59,28 @@ public class KnimeGetResolver {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String fullScope = "";
|
||||||
try{
|
try{
|
||||||
String fullScope = LoadingVREsScopeCache.getCache().get(vreName);
|
fullScope = LoadingVREsScopeCache.get(vreName);
|
||||||
ApplicationProfileReader reader = null;
|
}catch(ExecutionException e){
|
||||||
try{
|
logger.error("Error on getting the fullscope from cache for vreName "+vreName, e);
|
||||||
reader = new ApplicationProfileReader(fullScope, APPLICATION_PROFILE, ORG_GCUBE_PORTLETS_USER_KNIMEMODELSIMULATION_MANAGER_SERVICE_IMPL, false);
|
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);
|
||||||
}catch(Exception e){
|
|
||||||
logger.error("Error on reading the "+APPLICATION_PROFILE+" with APPID: "+ORG_GCUBE_PORTLETS_USER_KNIMEMODELSIMULATION_MANAGER_SERVICE_IMPL, e);
|
|
||||||
throw ExceptionManager.internalErrorException(req, "Error on reading the Application Profile for the "+KNIME_EXECUTOR_APPLICATION+". Please contact the support", this.getClass(), helpURI);
|
|
||||||
}
|
|
||||||
|
|
||||||
//READ THE KNIME URL PORTLET FROM APPLICATION PROFRILE IN THE SCOPE fullScope
|
|
||||||
String knimeExecutorEndPoint = reader.getApplicationProfile().getUrl();
|
|
||||||
//CHECKING THE QUERY STRING
|
|
||||||
String queryString = req.getQueryString()!=null?req.getQueryString():"";
|
|
||||||
String knimeExecutorURL = String.format("%s?%s", knimeExecutorEndPoint, queryString);
|
|
||||||
logger.info("Resolving the Knime URL with: "+knimeExecutorURL);
|
|
||||||
return Response.seeOther(new URI(knimeExecutorURL)).build();
|
|
||||||
|
|
||||||
}catch (ExecutionException e) {
|
|
||||||
logger.error("The input VRE Name "+vreName+" not found", e);
|
|
||||||
throw ExceptionManager.badRequestException(req, "The input 'VRE Name' "+"+vreName+"+ "not found on Informatiion System. Is it a valid VRE?", this.getClass(), helpURI);
|
|
||||||
}
|
}
|
||||||
|
ApplicationProfileReader reader = null;
|
||||||
|
try{
|
||||||
|
reader = new ApplicationProfileReader(fullScope, APPLICATION_PROFILE, ORG_GCUBE_PORTLETS_USER_KNIMEMODELSIMULATION_MANAGER_SERVICE_IMPL, false);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("Error on reading the "+APPLICATION_PROFILE+" with APPID: "+ORG_GCUBE_PORTLETS_USER_KNIMEMODELSIMULATION_MANAGER_SERVICE_IMPL, e);
|
||||||
|
throw ExceptionManager.internalErrorException(req, "Error on reading the Application Profile for the "+KNIME_EXECUTOR_APPLICATION+". Please contact the support", this.getClass(), helpURI);
|
||||||
|
}
|
||||||
|
|
||||||
|
//READ THE KNIME URL PORTLET FROM APPLICATION PROFRILE IN THE SCOPE fullScope
|
||||||
|
String knimeExecutorEndPoint = reader.getApplicationProfile().getUrl();
|
||||||
|
//CHECKING THE QUERY STRING
|
||||||
|
String queryString = req.getQueryString()!=null?req.getQueryString():"";
|
||||||
|
String knimeExecutorURL = String.format("%s?%s", knimeExecutorEndPoint, queryString);
|
||||||
|
logger.info("Resolving the Knime URL with: "+knimeExecutorURL);
|
||||||
|
return Response.seeOther(new URI(knimeExecutorURL)).build();
|
||||||
|
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class PartheosRegistryResolver {
|
||||||
//APPLYING NAME TRANSFORMATION
|
//APPLYING NAME TRANSFORMATION
|
||||||
String normalizedEntityName = toNameForCatalogue(remainPathParthenosURL);
|
String normalizedEntityName = toNameForCatalogue(remainPathParthenosURL);
|
||||||
logger.info("Trying to resolve with Catalogue EntityName: "+normalizedEntityName);
|
logger.info("Trying to resolve with Catalogue EntityName: "+normalizedEntityName);
|
||||||
ItemCatalogueURLs itemCatalogueURLs = CatalogueResolver.getItemCatalogueURLs(UriResolverSmartGearManagerInit.getParthenosVREName(), ResourceCatalogueCodes.CTLGD.getId(), normalizedEntityName);
|
ItemCatalogueURLs itemCatalogueURLs = CatalogueResolver.getItemCatalogueURLs(req, UriResolverSmartGearManagerInit.getParthenosVREName(), ResourceCatalogueCodes.CTLGD.getId(), normalizedEntityName);
|
||||||
return Response.seeOther(new URL(itemCatalogueURLs.getPrivateCataloguePortletURL()).toURI()).build();
|
return Response.seeOther(new URL(itemCatalogueURLs.getPrivateCataloguePortletURL()).toURI()).build();
|
||||||
|
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
|
@ -126,7 +126,7 @@ public class PartheosRegistryResolver {
|
||||||
|
|
||||||
//APPLYING NAME TRANSFORMATION
|
//APPLYING NAME TRANSFORMATION
|
||||||
String normalizedEntityName = toNameForCatalogue(entityName);
|
String normalizedEntityName = toNameForCatalogue(entityName);
|
||||||
ItemCatalogueURLs itemCatalogueURLs = CatalogueResolver.getItemCatalogueURLs(UriResolverSmartGearManagerInit.getParthenosVREName(), ResourceCatalogueCodes.CTLGD.getId(), normalizedEntityName);
|
ItemCatalogueURLs itemCatalogueURLs = CatalogueResolver.getItemCatalogueURLs(req, UriResolverSmartGearManagerInit.getParthenosVREName(), ResourceCatalogueCodes.CTLGD.getId(), normalizedEntityName);
|
||||||
logger.info("Returining Catalogue URL: "+itemCatalogueURLs.getPrivateCataloguePortletURL());
|
logger.info("Returining Catalogue URL: "+itemCatalogueURLs.getPrivateCataloguePortletURL());
|
||||||
return Response.ok(normalizedEntityName).header("Location", itemCatalogueURLs.getPrivateCataloguePortletURL()).build();
|
return Response.ok(normalizedEntityName).header("Location", itemCatalogueURLs.getPrivateCataloguePortletURL()).build();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue