- 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
## [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

View File

@ -101,12 +101,12 @@
<dependency>
<groupId>org.gcube.dataanalysis</groupId>
<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>
<groupId>org.gcube.dataanalysis</groupId>
<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>
<exclusion>
<artifactId>log4j</artifactId>
@ -117,12 +117,12 @@
<dependency>
<groupId>org.gcube.dataanalysis</groupId>
<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>
<groupId>org.gcube.dataanalysis</groupId>
<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>
<exclusion>
<groupId>org.glassfish.jersey.core</groupId>

View File

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