Added SmartGear Init implementing ApplicationManager
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@174158 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
26ca78b976
commit
0e571e0963
17
pom.xml
17
pom.xml
|
@ -54,13 +54,6 @@
|
||||||
<artifactId>common-authorization</artifactId>
|
<artifactId>common-authorization</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- <dependency> -->
|
|
||||||
<!-- <groupId>org.apache.tomcat</groupId> -->
|
|
||||||
<!-- <artifactId>catalina</artifactId> -->
|
|
||||||
<!-- <version>6.0.16</version> -->
|
|
||||||
<!-- </dependency> -->
|
|
||||||
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.contentmanagement</groupId>
|
<groupId>org.gcube.contentmanagement</groupId>
|
||||||
<artifactId>storage-manager-wrapper</artifactId>
|
<artifactId>storage-manager-wrapper</artifactId>
|
||||||
|
@ -103,11 +96,11 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- jersey -->
|
<!-- jersey -->
|
||||||
<!-- <dependency> -->
|
<!-- <dependency> -->
|
||||||
<!-- <groupId>org.glassfish.jersey.ext</groupId> -->
|
<!-- <groupId>org.glassfish.jersey.ext</groupId> -->
|
||||||
<!-- <artifactId>jersey-mvc-jsp</artifactId> -->
|
<!-- <artifactId>jersey-mvc-jsp</artifactId> -->
|
||||||
<!-- <version>2.13</version> -->
|
<!-- <version>2.13</version> -->
|
||||||
<!-- </dependency> -->
|
<!-- </dependency> -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.ws.rs</groupId>
|
<groupId>javax.ws.rs</groupId>
|
||||||
<artifactId>javax.ws.rs-api</artifactId>
|
<artifactId>javax.ws.rs-api</artifactId>
|
||||||
|
|
|
@ -10,6 +10,14 @@ import javax.ws.rs.core.StreamingOutput;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class SingleFileStreamingOutput.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
* Nov 15, 2018
|
||||||
|
*/
|
||||||
public class SingleFileStreamingOutput implements StreamingOutput {
|
public class SingleFileStreamingOutput implements StreamingOutput {
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(SingleFileStreamingOutput.class);
|
private static final Logger log = LoggerFactory.getLogger(SingleFileStreamingOutput.class);
|
||||||
|
@ -17,6 +25,11 @@ public class SingleFileStreamingOutput implements StreamingOutput {
|
||||||
|
|
||||||
InputStream streamToWrite;
|
InputStream streamToWrite;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new single file streaming output.
|
||||||
|
*
|
||||||
|
* @param streamToWrite the stream to write
|
||||||
|
*/
|
||||||
public SingleFileStreamingOutput(InputStream streamToWrite) {
|
public SingleFileStreamingOutput(InputStream streamToWrite) {
|
||||||
super();
|
super();
|
||||||
this.streamToWrite = streamToWrite;
|
this.streamToWrite = streamToWrite;
|
||||||
|
@ -24,9 +37,10 @@ public class SingleFileStreamingOutput implements StreamingOutput {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overriding the write method to write request data directly to Jersey outputStream .
|
* Overriding the write method to write request data directly to Jersey outputStream .
|
||||||
* @param outputStream
|
*
|
||||||
* @throws IOException
|
* @param outputStream the output stream
|
||||||
* @throws WebApplicationException
|
* @throws IOException Signals that an I/O exception has occurred.
|
||||||
|
* @throws WebApplicationException the web application exception
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void write(OutputStream outputStream) throws IOException, WebApplicationException {
|
public void write(OutputStream outputStream) throws IOException, WebApplicationException {
|
||||||
|
@ -35,6 +49,13 @@ public class SingleFileStreamingOutput implements StreamingOutput {
|
||||||
log.debug("StreamOutput written");
|
log.debug("StreamOutput written");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy.
|
||||||
|
*
|
||||||
|
* @param in the in
|
||||||
|
* @param out the out
|
||||||
|
* @throws IOException Signals that an I/O exception has occurred.
|
||||||
|
*/
|
||||||
private void copy(InputStream in, OutputStream out) throws IOException {
|
private void copy(InputStream in, OutputStream out) throws IOException {
|
||||||
byte[] buffer = new byte[2048];
|
byte[] buffer = new byte[2048];
|
||||||
int readcount = 0;
|
int readcount = 0;
|
||||||
|
|
|
@ -2,6 +2,8 @@ package org.gcube.datatransfer.resolver;
|
||||||
|
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
|
|
||||||
|
import org.gcube.datatransfer.resolver.requesthandler.TokenSetter;
|
||||||
|
import org.gcube.datatransfer.resolver.services.CatalogueResolver;
|
||||||
import org.glassfish.jersey.server.ResourceConfig;
|
import org.glassfish.jersey.server.ResourceConfig;
|
||||||
|
|
||||||
@Path("uri-resolver")
|
@Path("uri-resolver")
|
||||||
|
@ -9,9 +11,7 @@ public class UriResolver extends ResourceConfig {
|
||||||
|
|
||||||
public UriResolver() {
|
public UriResolver() {
|
||||||
// Register all resources present under the package.
|
// Register all resources present under the package.
|
||||||
packages("org.gcube.datatransfer.resolver.services","org.gcube.datatransfer.resolver.requesthandler");
|
packages(CatalogueResolver.class.getPackage().getName(), TokenSetter.class.getPackage().getName());
|
||||||
// register(JspMvcFeature.class);
|
|
||||||
// property(MvcFeature.TEMPLATE_BASE_PATH, "/WEB-INF/jsp");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ package org.gcube.datatransfer.resolver.caches;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.gcube.datatransfer.resolver.applicationprofile.ApplicationProfileReader;
|
import org.gcube.datatransfer.resolver.applicationprofile.ApplicationProfileReader;
|
||||||
import org.gcube.datatransfer.resolver.listeners.UriResolverStartupListener;
|
import org.gcube.datatransfer.resolver.init.UriResolverSmartGearInit;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ public class LoadingGeoExplorerApplicationURLCache {
|
||||||
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");
|
||||||
|
|
||||||
ApplicationProfileReader reader = new ApplicationProfileReader(scope, UriResolverStartupListener.getGeoExplorerProfile().getGenericResource(), UriResolverStartupListener.getGeoExplorerProfile().getAppId(), false);
|
ApplicationProfileReader reader = new ApplicationProfileReader(scope, UriResolverSmartGearInit.getGeoExplorerProfile().getGenericResource(), UriResolverSmartGearInit.getGeoExplorerProfile().getAppId(), false);
|
||||||
String url = reader.getApplicationProfile().getUrl();
|
String url = reader.getApplicationProfile().getUrl();
|
||||||
logger.info("With scope "+scope+" loaded the GeoExplorer Application URL "+url);
|
logger.info("With scope "+scope+" loaded the GeoExplorer Application URL "+url);
|
||||||
return url;
|
return url;
|
||||||
|
|
|
@ -7,7 +7,7 @@ package org.gcube.datatransfer.resolver.caches;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.gcube.datatransfer.resolver.applicationprofile.ApplicationProfileReader;
|
import org.gcube.datatransfer.resolver.applicationprofile.ApplicationProfileReader;
|
||||||
import org.gcube.datatransfer.resolver.listeners.UriResolverStartupListener;
|
import org.gcube.datatransfer.resolver.init.UriResolverSmartGearInit;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -80,10 +80,10 @@ public class LoadingGisViewerApplicationURLCache {
|
||||||
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");
|
||||||
|
|
||||||
ApplicationProfileReader reader = new ApplicationProfileReader(scope, UriResolverStartupListener.getGisViewerProfile().getGenericResource(), UriResolverStartupListener.getGisViewerProfile().getAppId(), false);
|
ApplicationProfileReader reader = new ApplicationProfileReader(scope, UriResolverSmartGearInit.getGisViewerProfile().getGenericResource(), UriResolverSmartGearInit.getGisViewerProfile().getAppId(), false);
|
||||||
|
|
||||||
if(reader.getApplicationProfile()==null){
|
if(reader.getApplicationProfile()==null){
|
||||||
logger.error("NO Appllication Profile "+UriResolverStartupListener.getGisViewerProfile().getAppId()+" found in the scope: "+scope+", returning null!");
|
logger.error("NO Appllication Profile "+UriResolverSmartGearInit.getGisViewerProfile().getAppId()+" found in the scope: "+scope+", returning null!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String url = reader.getApplicationProfile().getUrl();
|
String url = reader.getApplicationProfile().getUrl();
|
||||||
|
|
|
@ -8,7 +8,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.datatransfer.resolver.catalogue.resource.GetAllInfrastructureVREs;
|
import org.gcube.datatransfer.resolver.catalogue.resource.GetAllInfrastructureVREs;
|
||||||
import org.gcube.datatransfer.resolver.listeners.UriResolverStartupListener;
|
import org.gcube.datatransfer.resolver.init.UriResolverSmartGearInit;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -76,8 +76,8 @@ public class LoadingVREsScopeCache {
|
||||||
try{
|
try{
|
||||||
//POPULATE THE CACHE READING THE RESOURCE "CATALOGUE-RESOLVER"
|
//POPULATE THE CACHE READING THE RESOURCE "CATALOGUE-RESOLVER"
|
||||||
logger.info("Trying to pre-populate VRE Names to Scope cache");
|
logger.info("Trying to pre-populate VRE Names to Scope cache");
|
||||||
ScopeProvider.instance.set(UriResolverStartupListener.getRootContextScope());
|
ScopeProvider.instance.set(UriResolverSmartGearInit.getRootContextScope());
|
||||||
Map<String, String> map = GetAllInfrastructureVREs.loadMapOFVreNameToScope(UriResolverStartupListener.getRootContextScope());
|
Map<String, String> map = GetAllInfrastructureVREs.loadMapOFVreNameToScope(UriResolverSmartGearInit.getRootContextScope());
|
||||||
vresNameToScope.asMap().putAll(map);
|
vresNameToScope.asMap().putAll(map);
|
||||||
logger.info("Cache populated with: "+vresNameToScope.asMap().toString());
|
logger.info("Cache populated with: "+vresNameToScope.asMap().toString());
|
||||||
//logger.info("Pre-Loaded CatalogueApplicationProfiles cache is: "+catalogueApplicationProfiles.asMap().toString());
|
//logger.info("Pre-Loaded CatalogueApplicationProfiles cache is: "+catalogueApplicationProfiles.asMap().toString());
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.gcube.datatransfer.resolver;
|
package org.gcube.datatransfer.resolver.catalogue;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.gcube.datatransfer.resolver;
|
package org.gcube.datatransfer.resolver.gis.geonetwork;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,6 +14,4 @@ public interface GeonetworkRequestFilterParameters {
|
||||||
public static enum MODE {HARVEST, VRE};
|
public static enum MODE {HARVEST, VRE};
|
||||||
public static enum VISIBILITY {PUB, PRV};
|
public static enum VISIBILITY {PUB, PRV};
|
||||||
public static String REQUEST_DELIMITIER = "/$$";
|
public static String REQUEST_DELIMITIER = "/$$";
|
||||||
|
|
||||||
public static String OWNER_PARAM = "OWNER";
|
|
||||||
}
|
}
|
|
@ -0,0 +1,65 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.datatransfer.resolver.init;
|
||||||
|
|
||||||
|
import javax.servlet.ServletContext;
|
||||||
|
import javax.servlet.ServletContextEvent;
|
||||||
|
import javax.servlet.ServletContextListener;
|
||||||
|
import javax.servlet.annotation.WebListener;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The listener interface for receiving uriResolverServletContext events.
|
||||||
|
* The class that is interested in processing a uriResolverServletContext
|
||||||
|
* event implements this interface, and the object created
|
||||||
|
* with that class is registered with a component using the
|
||||||
|
* component's <code>addUriResolverServletContextListener<code> method. When
|
||||||
|
* the uriResolverServletContext event occurs, that object's appropriate
|
||||||
|
* method is invoked.
|
||||||
|
*
|
||||||
|
* @see UriResolverServletContextEvent
|
||||||
|
*/
|
||||||
|
@WebListener
|
||||||
|
public class UriResolverServletContextListener implements ServletContextListener {
|
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(UriResolverServletContextListener.class);
|
||||||
|
|
||||||
|
|
||||||
|
private static ServletContext servletContext;
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void contextInitialized(ServletContextEvent event) {
|
||||||
|
|
||||||
|
servletContext = event.getServletContext();
|
||||||
|
log.info("Context Initialized at context path: "+servletContext.getContextPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void contextDestroyed(ServletContextEvent event) {
|
||||||
|
// Perform action during application's shutdown
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the servlet context.
|
||||||
|
*
|
||||||
|
* @return the servlet context
|
||||||
|
*/
|
||||||
|
public static ServletContext getServletContext() {
|
||||||
|
|
||||||
|
return servletContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.gcube.datatransfer.resolver.listeners;
|
package org.gcube.datatransfer.resolver.init;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
@ -10,40 +10,30 @@ import java.io.IOException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.ServletContextEvent;
|
|
||||||
import javax.servlet.ServletContextListener;
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.annotation.WebListener;
|
|
||||||
|
|
||||||
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.common.scope.impl.ScopeBean;
|
||||||
|
import org.gcube.common.scope.impl.ScopeBean.Type;
|
||||||
import org.gcube.datatransfer.resolver.caches.LoadingGeonetworkInstanceCache;
|
import org.gcube.datatransfer.resolver.caches.LoadingGeonetworkInstanceCache;
|
||||||
import org.gcube.datatransfer.resolver.caches.LoadingGisViewerApplicationURLCache;
|
import org.gcube.datatransfer.resolver.caches.LoadingGisViewerApplicationURLCache;
|
||||||
import org.gcube.datatransfer.resolver.caches.LoadingVREsScopeCache;
|
import org.gcube.datatransfer.resolver.caches.LoadingVREsScopeCache;
|
||||||
import org.gcube.datatransfer.resolver.gis.property.ApplicationProfilePropertyReader;
|
import org.gcube.datatransfer.resolver.gis.property.ApplicationProfilePropertyReader;
|
||||||
import org.gcube.datatransfer.resolver.gis.property.PropertyFileNotFoundException;
|
import org.gcube.datatransfer.resolver.gis.property.PropertyFileNotFoundException;
|
||||||
import org.gcube.smartgears.ContextProvider;
|
import org.gcube.smartgears.ApplicationManager;
|
||||||
import org.gcube.smartgears.configuration.container.ContainerConfiguration;
|
|
||||||
import org.gcube.smartgears.context.application.ApplicationContext;
|
|
||||||
import org.gcube.smartgears.context.container.ContainerContext;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The listener interface for receiving startup events.
|
* The Class UriResolverSmartGearInit.
|
||||||
* The class that is interested in processing a startup
|
|
||||||
* event implements this interface, and the object created
|
|
||||||
* with that class is registered with a component using the
|
|
||||||
* component's <code>addStartupListener<code> method. When
|
|
||||||
* the startup event occurs, that object's appropriate
|
|
||||||
* method is invoked.
|
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
* Nov 2, 2018
|
* Nov 15, 2018
|
||||||
*/
|
*/
|
||||||
@WebListener
|
public class UriResolverSmartGearInit implements ApplicationManager {
|
||||||
public class UriResolverStartupListener implements ServletContextListener {
|
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(UriResolverStartupListener.class);
|
private static Logger logger = LoggerFactory.getLogger(UriResolverSmartGearInit.class);
|
||||||
|
|
||||||
public static final String GIS_VIEWER_GENERIC_RESOURCE_GCUBE_APPS_PROPERTIES = "gisviewerappgenericresource.properties";
|
public static final String GIS_VIEWER_GENERIC_RESOURCE_GCUBE_APPS_PROPERTIES = "gisviewerappgenericresource.properties";
|
||||||
public static final String GEO_EXPLORER_GENERIC_RESOURCE_GCUBE_APPS_PROPERTIES = "geoexplorerappgenericresource.properties";
|
public static final String GEO_EXPLORER_GENERIC_RESOURCE_GCUBE_APPS_PROPERTIES = "geoexplorerappgenericresource.properties";
|
||||||
|
@ -53,57 +43,67 @@ public class UriResolverStartupListener implements ServletContextListener {
|
||||||
|
|
||||||
public static final String ENV_SCOPE = "SCOPE"; //Environment Variable
|
public static final String ENV_SCOPE = "SCOPE"; //Environment Variable
|
||||||
|
|
||||||
|
|
||||||
private static String rootContextScope = null;
|
private static String rootContextScope = null;
|
||||||
|
|
||||||
private static ApplicationProfilePropertyReader gisViewerProfile;
|
private static ApplicationProfilePropertyReader gisViewerProfile;
|
||||||
private static ApplicationProfilePropertyReader geoExplorerProfile;
|
private static ApplicationProfilePropertyReader geoExplorerProfile;
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void contextInitialized(ServletContextEvent event) {
|
|
||||||
|
|
||||||
try {
|
/* (non-Javadoc)
|
||||||
rootContextScope = loadScopeFromEnvironment();
|
* @see org.gcube.smartgears.ApplicationManager#onInit()
|
||||||
ApplicationContext ctx = ContextProvider.get();
|
*/
|
||||||
ContainerContext container = ctx.container();
|
@Override
|
||||||
logger.info("Is ContainerContext null? "+(container==null));
|
public void onInit() {
|
||||||
ContainerConfiguration contConfiguration = container.configuration();
|
|
||||||
logger.info("Is ContainerConfiguration null? "+(contConfiguration==null));
|
|
||||||
|
|
||||||
String rootScope = ctx.container().configuration().infrastructure();
|
try {
|
||||||
logger.info("Is infrastructure null? "+(rootScope==null));
|
|
||||||
|
|
||||||
logger.info("The ContextProvider read the infrastructure name: "+rootScope);
|
if(rootContextScope==null){
|
||||||
|
logger.info("The RootContextScope is null, getting it from ScopeProvider");
|
||||||
|
String scope = ScopeProvider.instance.get();
|
||||||
|
ScopeBean theScopeBean = new ScopeBean(scope);
|
||||||
|
logger.info("The ScopeBean is: "+theScopeBean.toString());
|
||||||
|
if(theScopeBean.is(Type.INFRASTRUCTURE)){
|
||||||
|
rootContextScope = theScopeBean.name();
|
||||||
|
rootContextScope = rootContextScope.startsWith("/")?rootContextScope:"/"+rootContextScope;
|
||||||
|
logger.info("The RootContextScope has value: "+rootContextScope);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
|
||||||
|
//THE ROOT SCOPE has been initialized
|
||||||
|
|
||||||
|
gisViewerProfile = loadApplicationProfile(UriResolverServletContextListener.getServletContext(), GIS_VIEWER_GENERIC_RESOURCE_GCUBE_APPS_PROPERTIES);
|
||||||
|
geoExplorerProfile = loadApplicationProfile(UriResolverServletContextListener.getServletContext(), GEO_EXPLORER_GENERIC_RESOURCE_GCUBE_APPS_PROPERTIES);
|
||||||
|
//init the caches
|
||||||
|
new LoadingGeonetworkInstanceCache();
|
||||||
|
new LoadingGisViewerApplicationURLCache();
|
||||||
|
new LoadingVREsScopeCache();
|
||||||
|
//new LoadingCatalogueApplicationProfilesCache();
|
||||||
|
|
||||||
|
logger.info("Context initialized with: ");
|
||||||
|
logger.info("Scope: "+rootContextScope);
|
||||||
|
logger.info("GisViewerProfile [ID: "+gisViewerProfile.getAppId() + ", Generic Resource Type: "+gisViewerProfile.getGenericResource()+"]");
|
||||||
|
logger.info("GeoExplorerProfile [ID: "+geoExplorerProfile. getAppId() + ", Generic Resource Type: "+geoExplorerProfile.getGenericResource()+"]");
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
//
|
//
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
gisViewerProfile = loadApplicationProfile(event.getServletContext(), GIS_VIEWER_GENERIC_RESOURCE_GCUBE_APPS_PROPERTIES);
|
|
||||||
geoExplorerProfile = loadApplicationProfile(event.getServletContext(), GEO_EXPLORER_GENERIC_RESOURCE_GCUBE_APPS_PROPERTIES);
|
|
||||||
//init the caches
|
|
||||||
new LoadingGeonetworkInstanceCache();
|
|
||||||
new LoadingGisViewerApplicationURLCache();
|
|
||||||
new LoadingVREsScopeCache();
|
|
||||||
//new LoadingCatalogueApplicationProfilesCache();
|
|
||||||
|
|
||||||
logger.info("Context initialized with: ");
|
|
||||||
logger.info("Scope: "+rootContextScope);
|
|
||||||
logger.info("GisViewerProfile [ID: "+gisViewerProfile.getAppId() + ", Generic Resource Type: "+gisViewerProfile.getGenericResource()+"]");
|
|
||||||
logger.info("GeoExplorerProfile [ID: "+geoExplorerProfile. getAppId() + ", Generic Resource Type: "+geoExplorerProfile.getGenericResource()+"]");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
|
/* (non-Javadoc)
|
||||||
*/
|
* @see org.gcube.smartgears.ApplicationManager#onShutdown()
|
||||||
@Override
|
*/
|
||||||
public void contextDestroyed(ServletContextEvent event) {
|
@Override
|
||||||
// Perform action during application's shutdown
|
public void onShutdown() {
|
||||||
}
|
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the currency.
|
* Gets the currency.
|
||||||
|
@ -143,7 +143,7 @@ public class UriResolverStartupListener implements ServletContextListener {
|
||||||
String scopeFromEnv = System.getenv(ENV_SCOPE);
|
String scopeFromEnv = System.getenv(ENV_SCOPE);
|
||||||
|
|
||||||
if(scopeFromEnv == null || scopeFromEnv.isEmpty())
|
if(scopeFromEnv == null || scopeFromEnv.isEmpty())
|
||||||
throw new ServletException(UriResolverStartupListener.class.getName() +" cannot read scope from Environment Variable: "+ENV_SCOPE+", It is null or empty");
|
throw new ServletException(UriResolverServletContextListener.class.getName() +" cannot read scope from Environment Variable: "+ENV_SCOPE+", It is null or empty");
|
||||||
|
|
||||||
logger.info("Read scope: "+scopeFromEnv+" from Environment Variable: "+ENV_SCOPE);
|
logger.info("Read scope: "+scopeFromEnv+" from Environment Variable: "+ENV_SCOPE);
|
||||||
return scopeFromEnv;
|
return scopeFromEnv;
|
||||||
|
@ -183,5 +183,4 @@ public class UriResolverStartupListener implements ServletContextListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
|
|
@ -17,9 +17,9 @@ import javax.ws.rs.core.Response;
|
||||||
import javax.ws.rs.core.Response.Status;
|
import javax.ws.rs.core.Response.Status;
|
||||||
|
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.datatransfer.resolver.ResourceCatalogueCodes;
|
|
||||||
import org.gcube.datatransfer.resolver.caches.LoadingVREsScopeCache;
|
import org.gcube.datatransfer.resolver.caches.LoadingVREsScopeCache;
|
||||||
import org.gcube.datatransfer.resolver.catalogue.CatalogueRequest;
|
import org.gcube.datatransfer.resolver.catalogue.CatalogueRequest;
|
||||||
|
import org.gcube.datatransfer.resolver.catalogue.ResourceCatalogueCodes;
|
||||||
import org.gcube.datatransfer.resolver.catalogue.resource.CkanCatalogueConfigurationsReader;
|
import org.gcube.datatransfer.resolver.catalogue.resource.CkanCatalogueConfigurationsReader;
|
||||||
import org.gcube.datatransfer.resolver.catalogue.resource.GatewayCKANCatalogueReference;
|
import org.gcube.datatransfer.resolver.catalogue.resource.GatewayCKANCatalogueReference;
|
||||||
import org.gcube.datatransfer.resolver.catalogue.resource.GetAllInfrastructureVREs;
|
import org.gcube.datatransfer.resolver.catalogue.resource.GetAllInfrastructureVREs;
|
||||||
|
|
|
@ -26,8 +26,6 @@ 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.GeonetworkRequestFilterParameters.MODE;
|
|
||||||
import org.gcube.datatransfer.resolver.GeonetworkRequestFilterParameters.VISIBILITY;
|
|
||||||
import org.gcube.datatransfer.resolver.SingleFileStreamingOutput;
|
import org.gcube.datatransfer.resolver.SingleFileStreamingOutput;
|
||||||
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;
|
||||||
|
@ -35,6 +33,8 @@ import org.gcube.datatransfer.resolver.gis.GeonetworkServiceInterface;
|
||||||
import org.gcube.datatransfer.resolver.gis.exception.GeonetworkInstanceException;
|
import org.gcube.datatransfer.resolver.gis.exception.GeonetworkInstanceException;
|
||||||
import org.gcube.datatransfer.resolver.gis.geonetwork.FilterGetRecords;
|
import org.gcube.datatransfer.resolver.gis.geonetwork.FilterGetRecords;
|
||||||
import org.gcube.datatransfer.resolver.gis.geonetwork.GNAuthentication;
|
import org.gcube.datatransfer.resolver.gis.geonetwork.GNAuthentication;
|
||||||
|
import org.gcube.datatransfer.resolver.gis.geonetwork.GeonetworkRequestFilterParameters.MODE;
|
||||||
|
import org.gcube.datatransfer.resolver.gis.geonetwork.GeonetworkRequestFilterParameters.VISIBILITY;
|
||||||
import org.gcube.datatransfer.resolver.gis.geonetwork.ReusableInputStream;
|
import org.gcube.datatransfer.resolver.gis.geonetwork.ReusableInputStream;
|
||||||
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
||||||
import org.gcube.datatransfer.resolver.services.exceptions.InternalServerException;
|
import org.gcube.datatransfer.resolver.services.exceptions.InternalServerException;
|
||||||
|
|
|
@ -62,7 +62,6 @@ public class StorageIDResolver {
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("{storage-id}")
|
@Path("{storage-id}")
|
||||||
//@Path("{storage-id}")
|
|
||||||
public Response getStorageId(@Context HttpServletRequest httpRequest, @PathParam(STORAGE_ID) String storageId, @QueryParam(ConstantsResolver.QUERY_PARAM_FILE_NAME) String fileName, @QueryParam(ConstantsResolver.QUERY_PARAM_CONTENT_TYPE) String contentType, @QueryParam(ConstantsResolver.QUERY_PARAM_VALIDATION) Boolean validation) {
|
public Response getStorageId(@Context HttpServletRequest httpRequest, @PathParam(STORAGE_ID) String storageId, @QueryParam(ConstantsResolver.QUERY_PARAM_FILE_NAME) String fileName, @QueryParam(ConstantsResolver.QUERY_PARAM_CONTENT_TYPE) String contentType, @QueryParam(ConstantsResolver.QUERY_PARAM_VALIDATION) Boolean validation) {
|
||||||
logger.info(this.getClass().getSimpleName()+" GET starts...");
|
logger.info(this.getClass().getSimpleName()+" GET starts...");
|
||||||
//Checking mandatory parameter storageId
|
//Checking mandatory parameter storageId
|
||||||
|
|
|
@ -19,7 +19,6 @@ import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
import org.gcube.datatransfer.resolver.util.HTTPCallsUtils;
|
import org.gcube.datatransfer.resolver.util.HTTPCallsUtils;
|
||||||
import org.junit.Test;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -254,7 +253,7 @@ public class TestResolvers {
|
||||||
*
|
*
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
@Test
|
//Test
|
||||||
public void testCatalogueResolverCreatePubrivatItemURL() throws Exception{
|
public void testCatalogueResolverCreatePubrivatItemURL() throws Exception{
|
||||||
|
|
||||||
String entityName = "dynamic_reporting";
|
String entityName = "dynamic_reporting";
|
||||||
|
|
Loading…
Reference in New Issue