2017-03-21 18:01:31 +01:00
|
|
|
package org.gcube.spatial.data.sdi;
|
|
|
|
|
2017-04-11 18:07:58 +02:00
|
|
|
import java.net.URL;
|
|
|
|
|
2017-03-21 18:01:31 +01:00
|
|
|
import javax.ws.rs.ApplicationPath;
|
|
|
|
|
2017-03-22 17:48:16 +01:00
|
|
|
import org.gcube.smartgears.ContextProvider;
|
|
|
|
import org.gcube.smartgears.configuration.container.ContainerConfiguration;
|
|
|
|
import org.gcube.smartgears.context.application.ApplicationContext;
|
2017-07-05 18:42:04 +02:00
|
|
|
import org.gcube.spatial.data.sdi.model.ServiceConstants;
|
2017-03-22 17:48:16 +01:00
|
|
|
import org.gcube.spatial.data.sdi.rest.GeoNetwork;
|
2017-03-21 18:01:31 +01:00
|
|
|
import org.glassfish.jersey.server.ResourceConfig;
|
|
|
|
|
2017-03-22 17:48:16 +01:00
|
|
|
import io.swagger.jaxrs.config.BeanConfig;
|
2017-04-11 18:07:58 +02:00
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
@Slf4j
|
2017-07-05 18:42:04 +02:00
|
|
|
@ApplicationPath(ServiceConstants.APPLICATION)
|
2017-03-21 18:01:31 +01:00
|
|
|
public class SDIService extends ResourceConfig{
|
|
|
|
|
|
|
|
public SDIService() {
|
|
|
|
super();
|
|
|
|
packages("org.gcube.spatial.data");
|
2017-03-22 17:48:16 +01:00
|
|
|
register(io.swagger.jaxrs.listing.ApiListingResource.class);
|
|
|
|
register(io.swagger.jaxrs.listing.SwaggerSerializers.class);
|
|
|
|
|
|
|
|
|
|
|
|
ApplicationContext context=ContextProvider.get();
|
|
|
|
ContainerConfiguration configuration=context.container().configuration();
|
|
|
|
|
|
|
|
String hostName=configuration.hostname();
|
|
|
|
Integer port=configuration.port();
|
|
|
|
|
2017-04-11 18:07:58 +02:00
|
|
|
try{
|
|
|
|
URL resourceUrl = context.application().getResource("/WEB-INF/config.properties");
|
|
|
|
LocalConfiguration.init(resourceUrl);
|
|
|
|
}catch(Throwable t){
|
|
|
|
log.debug("Listing available paths");
|
|
|
|
for(Object obj:context.application().getResourcePaths("/WEB-INF"))
|
|
|
|
log.debug("OBJ : {} ",obj);
|
|
|
|
|
|
|
|
throw new RuntimeException("Unable to load configuration properties",t);
|
|
|
|
}
|
2017-03-22 17:48:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//SWAGGER
|
|
|
|
BeanConfig beanConfig = new BeanConfig();
|
|
|
|
beanConfig.setVersion("1.0.0");
|
|
|
|
beanConfig.setSchemes(new String[]{"http","https"});
|
|
|
|
beanConfig.setHost(hostName+":"+port);
|
|
|
|
beanConfig.setBasePath("/gcube/service/");
|
|
|
|
beanConfig.setResourcePackage(GeoNetwork.class.getPackage().getName());
|
2017-03-28 15:20:10 +02:00
|
|
|
beanConfig.setTitle("SDI Service");
|
|
|
|
beanConfig.setDescription("REST Interface towards SDI facilities");
|
|
|
|
beanConfig.setPrettyPrint(true);
|
2017-03-22 17:48:16 +01:00
|
|
|
beanConfig.setScan(true);
|
|
|
|
|
2017-03-21 18:01:31 +01:00
|
|
|
}
|
|
|
|
|
2017-03-22 17:48:16 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-21 18:01:31 +01:00
|
|
|
}
|