2017-03-30 15:31:39 +02:00
|
|
|
package org.gcube.spatial.data.sdi.engine.impl;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
2017-04-11 18:07:58 +02:00
|
|
|
import javax.inject.Inject;
|
2017-03-30 15:31:39 +02:00
|
|
|
import javax.inject.Singleton;
|
|
|
|
|
2017-04-11 18:07:58 +02:00
|
|
|
import org.gcube.spatial.data.geonetwork.utils.ScopeUtils;
|
|
|
|
import org.gcube.spatial.data.sdi.engine.GISManager;
|
|
|
|
import org.gcube.spatial.data.sdi.engine.GeoNetworkManager;
|
2017-03-30 15:31:39 +02:00
|
|
|
import org.gcube.spatial.data.sdi.engine.SDIManager;
|
2017-04-11 18:07:58 +02:00
|
|
|
import org.gcube.spatial.data.sdi.engine.ThreddsManager;
|
2017-03-30 15:31:39 +02:00
|
|
|
import org.gcube.spatial.data.sdi.model.ScopeConfiguration;
|
|
|
|
import org.gcube.spatial.data.sdi.model.credentials.AccessType;
|
|
|
|
import org.gcube.spatial.data.sdi.model.credentials.Credentials;
|
|
|
|
import org.gcube.spatial.data.sdi.model.service.GeoNetworkConfiguration;
|
|
|
|
import org.gcube.spatial.data.sdi.model.service.GeoServerClusterConfiguration;
|
|
|
|
import org.gcube.spatial.data.sdi.model.service.GeoServerConfiguration;
|
|
|
|
import org.gcube.spatial.data.sdi.model.service.ThreddsConfiguration;
|
|
|
|
import org.gcube.spatial.data.sdi.model.service.Version;
|
|
|
|
|
2017-04-11 18:07:58 +02:00
|
|
|
import lombok.extern.slf4j.Slf4j;
|
2017-03-30 15:31:39 +02:00
|
|
|
|
|
|
|
|
2017-04-11 18:07:58 +02:00
|
|
|
@Slf4j
|
2017-03-30 15:31:39 +02:00
|
|
|
@Singleton
|
|
|
|
public class SDIManagerImpl implements SDIManager {
|
|
|
|
|
2017-04-11 18:07:58 +02:00
|
|
|
// @Inject
|
|
|
|
GeoNetworkManager geonetworkManager;
|
|
|
|
// @Inject
|
|
|
|
ThreddsManager threddsManager;
|
|
|
|
// @Inject
|
|
|
|
GISManager gisManager;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Inject
|
|
|
|
public SDIManagerImpl(GeoNetworkManager geonetworkManager, ThreddsManager threddsManager, GISManager gisManager) {
|
|
|
|
super();
|
|
|
|
this.geonetworkManager = geonetworkManager;
|
|
|
|
this.threddsManager = threddsManager;
|
|
|
|
this.gisManager = gisManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-03-30 15:31:39 +02:00
|
|
|
@Override
|
|
|
|
public ScopeConfiguration getContextConfiguration() {
|
2017-04-11 18:07:58 +02:00
|
|
|
|
|
|
|
// TODO filter info by user role
|
2017-03-30 15:31:39 +02:00
|
|
|
|
2017-04-11 18:07:58 +02:00
|
|
|
ScopeConfiguration toReturn=new ScopeConfiguration();
|
|
|
|
toReturn.setContextName(ScopeUtils.getCurrentScopeName());
|
|
|
|
try{
|
|
|
|
toReturn.setGeonetworkConfiguration(geonetworkManager.getConfiguration());
|
|
|
|
}catch(Exception e){
|
|
|
|
log.warn("Scope is not well configured. Missing GeoNetwork. ",e);
|
|
|
|
}
|
2017-03-30 15:31:39 +02:00
|
|
|
|
2017-04-11 18:07:58 +02:00
|
|
|
try{
|
|
|
|
toReturn.setThreddsConfiguration(threddsManager.getConfiguration());
|
|
|
|
}catch(Exception e){
|
|
|
|
log.warn("THREDDS not found in current scope {} ",ScopeUtils.getCurrentScope());
|
|
|
|
}
|
|
|
|
|
|
|
|
try{
|
|
|
|
toReturn.setGeoserverClusterConfiguration(gisManager.getConfiguration());
|
|
|
|
}catch(Exception e){
|
|
|
|
log.warn("GeoServer not found in current scope {} ",ScopeUtils.getCurrentScope());
|
|
|
|
}
|
2017-03-30 15:31:39 +02:00
|
|
|
|
|
|
|
return toReturn;
|
|
|
|
}
|
2017-04-11 18:07:58 +02:00
|
|
|
|
2017-03-30 15:31:39 +02:00
|
|
|
}
|