performed refactor

fixed onInit

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@174166 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-11-15 15:21:31 +00:00
parent 25dd2e78b1
commit 29aad548c9
6 changed files with 18 additions and 11 deletions

View File

@ -1,7 +1,7 @@
/** /**
* *
*/ */
package org.gcube.datatransfer.resolver.services; package org.gcube.datatransfer.resolver;
/** /**
@ -18,7 +18,7 @@ public class ConstantsResolver {
public static final String CONTENT_LENGTH = "Content-Length"; public static final String CONTENT_LENGTH = "Content-Length";
public static final String CONTENT_TYPE= "Content-Type"; public static final String CONTENT_TYPE= "Content-Type";
protected static final String HPC = "hproxycheck"; //for hproxycheck public static final String HPC = "hproxycheck"; //for hproxycheck
public static final String QUERY_PARAM_VALIDATION = "validation"; public static final String QUERY_PARAM_VALIDATION = "validation";
public static final String QUERY_PARAM_CONTENT_TYPE = "contentType"; public static final String QUERY_PARAM_CONTENT_TYPE = "contentType";

View File

@ -54,34 +54,37 @@ public class UriResolverSmartGearManagerInit implements ApplicationManager {
*/ */
@Override @Override
public void onInit() { public void onInit() {
log.debug("init called"); log.info("init called with scope: "+ScopeProvider.instance.get());
try { try {
boolean initContextPerformed = false; boolean initRootContextPerformed = false;
if(rootContextScope==null){ if(rootContextScope==null){
log.info("The RootContextScope is null, getting it from ScopeProvider"); log.debug("The rootContextScope is null, getting it from ScopeProvider");
String scope = ScopeProvider.instance.get(); String scope = ScopeProvider.instance.get();
ScopeBean theScopeBean = new ScopeBean(scope); ScopeBean theScopeBean = new ScopeBean(scope);
log.info("The ScopeBean is: "+theScopeBean.toString()); log.debug("The ScopeBean is: "+theScopeBean.toString());
if(theScopeBean.is(Type.INFRASTRUCTURE)){ if(theScopeBean.is(Type.INFRASTRUCTURE)){
rootContextScope = theScopeBean.name(); rootContextScope = theScopeBean.name();
rootContextScope = rootContextScope.startsWith("/")?rootContextScope:"/"+rootContextScope; rootContextScope = rootContextScope.startsWith("/")?rootContextScope:"/"+rootContextScope;
log.info("The RootContextScope has value: "+rootContextScope); log.info("The rootContextScope has value: "+rootContextScope);
//THE ROOT SCOPE has been initialized //THE ROOT SCOPE has been initialized
initContextPerformed = true; initRootContextPerformed = true;
} }
} }
if(gisViewerProfile==null || geoExplorerProfile==null){ //JUST ONCE AND TO BE SURE WITH THE ROOT SCOPE INITIALIZED
if(initRootContextPerformed && (gisViewerProfile==null || geoExplorerProfile==null)){
log.info("init Profiles...");
gisViewerProfile = loadApplicationProfile(UriResolverServletContextListener.getServletContext(), GIS_VIEWER_GENERIC_RESOURCE_GCUBE_APPS_PROPERTIES); gisViewerProfile = loadApplicationProfile(UriResolverServletContextListener.getServletContext(), GIS_VIEWER_GENERIC_RESOURCE_GCUBE_APPS_PROPERTIES);
geoExplorerProfile = loadApplicationProfile(UriResolverServletContextListener.getServletContext(), GEO_EXPLORER_GENERIC_RESOURCE_GCUBE_APPS_PROPERTIES); geoExplorerProfile = loadApplicationProfile(UriResolverServletContextListener.getServletContext(), GEO_EXPLORER_GENERIC_RESOURCE_GCUBE_APPS_PROPERTIES);
log.info("GisViewerProfile [ID: "+gisViewerProfile.getAppId() + ", Generic Resource Type: "+gisViewerProfile.getGenericResource()+"]"); log.info("GisViewerProfile [ID: "+gisViewerProfile.getAppId() + ", Generic Resource Type: "+gisViewerProfile.getGenericResource()+"]");
log.info("GeoExplorerProfile [ID: "+geoExplorerProfile. getAppId() + ", Generic Resource Type: "+geoExplorerProfile.getGenericResource()+"]"); log.info("GeoExplorerProfile [ID: "+geoExplorerProfile. getAppId() + ", Generic Resource Type: "+geoExplorerProfile.getGenericResource()+"]");
} }
if(gisViewerProfile!=null && geoExplorerProfile!=null & initContextPerformed){ //JUST ONCE AND TO BE SURE WITH THE ROOT SCOPE INITIALIZED
log.info("Pre-Loading caches... using RootContextScope: "+rootContextScope); if(initRootContextPerformed && gisViewerProfile!=null && geoExplorerProfile!=null){
log.info("Pre-Loading caches... using rootContextScope: "+rootContextScope);
//init the caches //init the caches
new LoadingGeonetworkInstanceCache(); new LoadingGeonetworkInstanceCache();

View File

@ -26,6 +26,7 @@ import javax.ws.rs.core.StreamingOutput;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.datatransfer.resolver.ConstantsResolver;
import org.gcube.datatransfer.resolver.gis.GeonetworkAccessParameter; import org.gcube.datatransfer.resolver.gis.GeonetworkAccessParameter;
import org.gcube.datatransfer.resolver.gis.GeonetworkInstance; import org.gcube.datatransfer.resolver.gis.GeonetworkInstance;
import org.gcube.datatransfer.resolver.gis.GeonetworkServiceInterface; import org.gcube.datatransfer.resolver.gis.GeonetworkServiceInterface;

View File

@ -11,6 +11,7 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import org.gcube.datatransfer.resolver.ConstantsResolver;
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;

View File

@ -11,6 +11,7 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import org.gcube.datatransfer.resolver.ConstantsResolver;
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;

View File

@ -22,6 +22,7 @@ import org.gcube.contentmanagement.blobstorage.service.IClient;
import org.gcube.contentmanager.storageclient.wrapper.AccessType; import org.gcube.contentmanager.storageclient.wrapper.AccessType;
import org.gcube.contentmanager.storageclient.wrapper.MemoryType; import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
import org.gcube.contentmanager.storageclient.wrapper.StorageClient; import org.gcube.contentmanager.storageclient.wrapper.StorageClient;
import org.gcube.datatransfer.resolver.ConstantsResolver;
import org.gcube.datatransfer.resolver.services.error.ExceptionManager; import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
import org.gcube.datatransfer.resolver.util.SingleFileStreamingOutput; import org.gcube.datatransfer.resolver.util.SingleFileStreamingOutput;
import org.slf4j.Logger; import org.slf4j.Logger;