- EnviromentalVariableManager reverted

- import range changed for ecological-engine libraries
This commit is contained in:
lucio.lelii 2020-11-30 17:39:25 +01:00
parent 279535c13a
commit d9a6eb21be
4 changed files with 30 additions and 42 deletions

View File

@ -1,9 +1,9 @@
# Changelog # Changelog
## [v1.76.0] - 2020-11-20 ## [v1.7.0-SNAPSHOT] - 2020-11-20
- Config path passed as parameter - import range modified to resolve old repositories invalid url
## [v1.6.0] - 2020-05-12 ## [v1.6.0] - 2020-05-12

View File

@ -101,12 +101,12 @@
<dependency> <dependency>
<groupId>org.gcube.dataanalysis</groupId> <groupId>org.gcube.dataanalysis</groupId>
<artifactId>ecological-engine-wps-extension</artifactId> <artifactId>ecological-engine-wps-extension</artifactId>
<version>[1.0.4,2.0.0-SNAPSHOT)</version> <version>[1.0.5,2.0.0-SNAPSHOT)</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.dataanalysis</groupId> <groupId>org.gcube.dataanalysis</groupId>
<artifactId>ecological-engine-geospatial-extensions</artifactId> <artifactId>ecological-engine-geospatial-extensions</artifactId>
<version>[1.5.0,2.0.0-SNAPSHOT)</version> <version>[1.5.2,2.0.0-SNAPSHOT)</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<artifactId>log4j</artifactId> <artifactId>log4j</artifactId>
@ -117,12 +117,12 @@
<dependency> <dependency>
<groupId>org.gcube.dataanalysis</groupId> <groupId>org.gcube.dataanalysis</groupId>
<artifactId>ecological-engine-external-algorithms</artifactId> <artifactId>ecological-engine-external-algorithms</artifactId>
<version>[1.2.0,2.0.0-SNAPSHOT)</version> <version>[1.2.1,2.0.0-SNAPSHOT)</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.dataanalysis</groupId> <groupId>org.gcube.dataanalysis</groupId>
<artifactId>ecological-engine-smart-executor</artifactId> <artifactId>ecological-engine-smart-executor</artifactId>
<version>[1.6.2,2.0.0-SNAPSHOT)</version> <version>[1.6.4,2.0.0-SNAPSHOT)</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
<groupId>org.glassfish.jersey.core</groupId> <groupId>org.glassfish.jersey.core</groupId>

View File

@ -14,7 +14,7 @@ import org.slf4j.LoggerFactory;
public class ConfigurationManager { public class ConfigurationManager {
private static final Logger logger = LoggerFactory.getLogger(ConfigurationManager.class); private static final Logger logger = LoggerFactory.getLogger(ConfigurationManager.class);
public static String serviceUserNameParameterVariable = "ServiceUserName"; public static String serviceUserNameParameterVariable = "ServiceUserName";
public static String processingSessionVariable = "Session"; public static String processingSessionVariable = "Session";
public static String webpathVariable = "WebPath"; public static String webpathVariable = "WebPath";
@ -24,30 +24,29 @@ public class ConfigurationManager {
public static String tokenParameter = "usertoken"; public static String tokenParameter = "usertoken";
public static String defaultScope= "/gcube/devsec"; public static String defaultScope= "/gcube/devsec";
public static String defaultUsername= "statistical.wps"; public static String defaultUsername= "statistical.wps";
private static Integer maxComputations = null; private static Integer maxComputations = null;
private static Boolean useStorage = null; private static Boolean useStorage = null;
static boolean simulationMode = false; static boolean simulationMode = false;
private String baseConfigPath;
EnvironmentVariableManager env = null; EnvironmentVariableManager env = null;
public static synchronized Integer getMaxComputations(){ public static synchronized Integer getMaxComputations(){
return maxComputations; return maxComputations;
} }
public static synchronized Boolean useStorage(){ public static synchronized Boolean useStorage(){
return useStorage; return useStorage;
} }
public static synchronized Boolean isSimulationMode(){ public static synchronized Boolean isSimulationMode(){
return simulationMode; return simulationMode;
} }
@Deprecated @Deprecated
public void getInitializationProperties() { public void getInitializationProperties() {
} }
private void inizializePropertiesUsingTemplateFile() { private void inizializePropertiesUsingTemplateFile() {
@ -66,7 +65,7 @@ public class ConfigurationManager {
logger.error("error initializing properties",e); logger.error("error initializing properties",e);
} }
} }
private AlgorithmConfiguration config; private AlgorithmConfiguration config;
private String scope; private String scope;
private String username; private String username;
@ -86,10 +85,9 @@ public class ConfigurationManager {
maxComputations = env.getMaxComputation(); maxComputations = env.getMaxComputation();
useStorage = env.isSaveOnStorage(); useStorage = env.isSaveOnStorage();
simulationMode = env.isSimulationMode(); simulationMode = env.isSimulationMode();
baseConfigPath = env.getConfigPath();
} }
} }
public AlgorithmConfiguration getConfig() { public AlgorithmConfiguration getConfig() {
return config; return config;
} }
@ -97,25 +95,21 @@ public class ConfigurationManager {
public void setComputationId(String computationId){ public void setComputationId(String computationId){
config.setTaskID(computationId); config.setTaskID(computationId);
} }
public void configAlgorithmEnvironment(LinkedHashMap<String, Object> inputs) throws Exception { public void configAlgorithmEnvironment(LinkedHashMap<String, Object> inputs) throws Exception {
// set config container // set config container
config = new AlgorithmConfiguration(); config = new AlgorithmConfiguration();
config.setAlgorithmClassLoader(Thread.currentThread().getContextClassLoader()); config.setAlgorithmClassLoader(Thread.currentThread().getContextClassLoader());
String webperspath = WPSConfig.getConfigDir() + "../persistence/"; String webperspath = WPSConfig.getConfigDir() + "../persistence/";
// selecting persistence path // selecting persistence path
// String persistencePath = File.createTempFile("wpsstatcheck", ".sm").getParent() + "/../cfg/"; String persistencePath = WPSConfig.getConfigDir() + "../ecocfg/";
String configPath = persistencePath;
//String webperspath = baseConfigPath + "/persistence/"; if (!new File(configPath).isDirectory()) {
//String persistencePath = baseConfigPath; WPSConfig.getConfigDir() + "../ecocfg/";
String configPath = baseConfigPath + "/ecocfg/"; //persistencePath;
/*if (!new File(configPath).isDirectory()) {
configPath = "./cfg/"; configPath = "./cfg/";
persistencePath = "./"; persistencePath = "./";
}*/ }
logger.debug("Taking configuration from {}", configPath); logger.debug("Taking configuration from {}", configPath);
//+ " and persistence in " + persistencePath); //+ " and persistence in " + persistencePath);
// setting configuration and logger // setting configuration and logger
config.setPersistencePath(configPath); config.setPersistencePath(configPath);
config.setConfigPath(configPath); config.setConfigPath(configPath);
@ -126,9 +120,9 @@ public class ConfigurationManager {
String port = WPSConfig.getInstance().getWPSConfig().getServer().getHostport(); String port = WPSConfig.getInstance().getWPSConfig().getServer().getHostport();
logger.debug("Host: {} Port: {} Webapp: {} ", host, port, webapp ); logger.debug("Host: {} Port: {} Webapp: {} ", host, port, webapp );
logger.debug("Web persistence path:{} ", webperspath); logger.debug("Web persistence path:{} ", webperspath);
String webPath = "http://" + host + ":" + port + "/" + webapp + "/persistence/"; String webPath = "http://" + host + ":" + port + "/" + webapp + "/persistence/";
// logger.debug("Env Vars: \n"+System.getenv()); // logger.debug("Env Vars: \n"+System.getenv());
logger.debug("Web app path: {} ", webPath); logger.debug("Web app path: {} ", webPath);
@ -142,13 +136,13 @@ public class ConfigurationManager {
username = (String) inputs.get(usernameParameter); username = (String) inputs.get(usernameParameter);
token = (String) inputs.get(tokenParameter); token = (String) inputs.get(tokenParameter);
logger.debug("User name used by the client:{} ", username); logger.debug("User name used by the client:{} ", username);
logger.debug("User token used by the client:{} ", token); logger.debug("User token used by the client:{} ", token);
if (username == null || username.trim().length() == 0) if (username == null || username.trim().length() == 0)
throw new Exception("Error: user name parameter (user.name) not set! This violates e-Infrastructure security policies"); throw new Exception("Error: user name parameter (user.name) not set! This violates e-Infrastructure security policies");
if (token == null || token.trim().length() == 0) if (token == null || token.trim().length() == 0)
throw new Exception("Error: token parameter not set! This violates e-Infrastructure security policies"); throw new Exception("Error: token parameter not set! This violates e-Infrastructure security policies");

View File

@ -4,13 +4,12 @@ import java.util.List;
public class EnvironmentVariableManager { public class EnvironmentVariableManager {
public EnvironmentVariableManager(int maxComputation, boolean saveOnStorage, boolean simulationMode, List<String> shubUsersExcluded, String configPath ) { public EnvironmentVariableManager(int maxComputation, boolean saveOnStorage, boolean simulationMode, List<String> shubUsersExcluded) {
super(); super();
this.maxComputation = maxComputation; this.maxComputation = maxComputation;
this.saveOnStorage = saveOnStorage; this.saveOnStorage = saveOnStorage;
this.simulationMode = simulationMode; this.simulationMode = simulationMode;
this.shubUsersExcluded = shubUsersExcluded; this.shubUsersExcluded = shubUsersExcluded;
this.configPath = configPath;
} }
private int maxComputation; private int maxComputation;
@ -22,8 +21,6 @@ public class EnvironmentVariableManager {
//filled: users reported will not write on Shub //filled: users reported will not write on Shub
private List<String> shubUsersExcluded; private List<String> shubUsersExcluded;
private String configPath;
public int getMaxComputation() { public int getMaxComputation() {
return maxComputation; return maxComputation;
} }
@ -37,8 +34,5 @@ public class EnvironmentVariableManager {
public List<String> getShubUsersExcluded() { public List<String> getShubUsersExcluded() {
return shubUsersExcluded; return shubUsersExcluded;
} }
public String getConfigPath() {
return configPath;
}
} }