handled GisResolver errors

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@173981 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-11-06 13:24:33 +00:00
parent ff223b3b16
commit c8b415bebd
4 changed files with 41 additions and 46 deletions

View File

@ -38,7 +38,7 @@ public class LoadingGeoExplorerApplicationURLCache {
@Override
public String load(String scope)
throws Exception {
logger.info(LoadingGeoExplorerApplicationURLCache.class.getSimpleName() +" loaded");
logger.info("Loading the cache for scope: "+scope);
return loadGeoExplorerApplicationURL(scope);
}
};

View File

@ -39,7 +39,7 @@ public class LoadingGeonetworkInstanceCache {
@Override
public GeonetworkInstance load(String scope)
throws Exception {
logger.info(LoadingGeonetworkInstanceCache.class.getSimpleName() +" loaded");
logger.info("Loading the cache for scope: "+scope);
return loadGeonetworkInstance(scope);
}
};
@ -80,8 +80,10 @@ public class LoadingGeonetworkInstanceCache {
public static GeonetworkInstance loadGeonetworkInstance(String scope)
throws GeonetworkInstanceException {
if (scope == null || scope.isEmpty())
logger.warn("Scope is null or ermpty, skipping loadGeonetworkInstance");
if (scope == null || scope.isEmpty()){
logger.warn("Scope is null or empty, returning GeonetworkInstance as null");
return null;
}
GeonetworkAccessParameter gntwAccess = new GeonetworkAccessParameter(scope);
GeonetworkInstance gnInstance = gntwAccess.getGeonetworkInstance(true, GeonetworkLoginLevel.ADMIN);

View File

@ -48,26 +48,6 @@ public class GeonetworkInstance {
this(scope, false, null, null);
}
// /**
// * Creates a new configuration for Gis publisher with parameter passed in input. Executes the login on geonetwork instance if authenticate param is true, no otherwise
// * Use scope found in ScopeProvider
// *
// * @param authenticate the authenticate
// * @param level the level
// * @throws Exception the exception
// */
// public GeonetworkInstance(boolean authenticate, LoginLevel level) throws Exception {
// try {
// this.level = level;
// createInstanceGeonetworkPublisher(authenticate, level);
// } catch (Exception e) {
// logger.error("Sorry, an error occurred in getting geonetwork instance",e);
// throw new Exception("Sorry, an error occurred in getting geonetwork instance",e);
// }
// }
/**
* Instantiates a new geonetwork instance.
*

View File

@ -26,6 +26,8 @@ import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.cache.CacheLoader.InvalidCacheLoadException;
/**
* The Class GisResolver.
@ -108,6 +110,8 @@ public class GisResolver {
layerTitle = URLEncoder.encode(gisLayerItem.getCitationTitle(), UTF_8);
logger.info("layer Title encoded is: " + layerTitle);
try{
String gisViewerPortletUrl = LoadingGisViewerApplicationURLCache.getCache().get(scope);
//CHECKING IF THE GisViewer Portlet URL is valid
if(gisViewerPortletUrl==null || gisViewerPortletUrl.isEmpty())
@ -123,11 +127,16 @@ public class GisResolver {
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);
}
}
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())
@ -138,6 +147,10 @@ public class GisResolver {
+"&luuid="+URLEncoder.encode(geoExplorerUUID, UTF_8);
//urlRedirect(req, resp, geoExplorerPortletUrl);
return Response.seeOther(new URI(geoExplorerPortletUrl)).build();
}catch (InvalidCacheLoadException e) {
logger.error("Error on getting GeoExplorer Portlet URL for scope: "+scope, e);
ExceptionManager.throwNotFoundException(req, "GeoExplorer Portlet URL not found in the scope: "+scope +". Please add it or contact the support", this.getClass(), help);
}
}
ExceptionManager.throwBadRequestException(req, GIS_UUID+" or "+GEO_EXPLORER_LAYER_UUID+" not found or empty in the query string", this.getClass(), help);