sdi-service/src/main/java/org/gcube/spatial/data/sdi/SDIService.java

112 lines
3.3 KiB
Java

package org.gcube.spatial.data.sdi;
import java.net.URL;
import javax.ws.rs.ApplicationPath;
import org.gcube.smartgears.ContextProvider;
import org.gcube.smartgears.configuration.container.ContainerConfiguration;
import org.gcube.smartgears.context.application.ApplicationContext;
import org.gcube.spatial.data.sdi.model.ServiceConstants;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.glassfish.jersey.server.ResourceConfig;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@ApplicationPath(ServiceConstants.APPLICATION)
public class SDIService extends ResourceConfig{
// @Inject
// MetadataTemplateManager templateManager;
// @Inject
// TemporaryPersistence persistence;
//
public SDIService() {
super();
log.warn("Initializing App : Properties.. ");
ApplicationContext context=ContextProvider.get();
ContainerConfiguration configuration=context.container().configuration();
try{
URL resourceUrl = context.application().getResource("/WEB-INF/config.properties");
LocalConfiguration.init(resourceUrl).
setTemplateConfigurationObject(ContextProvider.get());
}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);
}
packages("org.gcube.spatial.data");
// log.warn("Initializing App : Binders");
//
// AbstractBinder binder = new AbstractBinder() {
// @Override
// protected void configure() {
// bindFactory(SDIManagerImpl.class).to(SDIManager.class);
// bindFactory(CapabilitiesProviderFactory.class).to(CapabilitiesProvider.class);
// bindFactory(PersistenceProviderFactory.class).to(PersistenceProvider.class);
// bindFactory(PluginManagerFactory.class).to(PluginManager.class);
// bindFactory(RequestManagerFactory.class).to(RequestManager.class);
// bindFactory(TicketManagerFactory.class).to(TicketManager.class);
// }
// };
// register(binder);
register(MultiPartFeature.class);
// register(MoxyXmlFeature.class);
// String hostName=configuration.hostname();
// Integer port=configuration.port();
//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());
// beanConfig.setTitle("SDI Service");
// beanConfig.setDescription("REST Interface towards SDI facilities");
// beanConfig.setPrettyPrint(true);
// beanConfig.setScan(true);
//
// System.out.println("********************** SDI INIT *****************************");
//
// log.debug("Initializing persistence manager.. {} :",persistence);
//
// try {
// persistence.init();
// } catch (Throwable t) {
// throw new RuntimeException("Unabel to init persistence. ",t);
// }
// log.debug("Initializing template manager.. {} : ",templateManager);
//
// ApplicationContext ctx = ContextProvider.get();
// templateManager.init(ctx);
//
}
}