Updated to fix protocol parameters when persistence is disabled

This commit is contained in:
Giancarlo Panichi 2022-03-21 15:57:29 +01:00
parent 5f1fee5ca9
commit 6d74cf7fc3
3 changed files with 31 additions and 22 deletions

View File

@ -2,6 +2,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
# Changelog for "dataminer"
## [v1.8.1-SNAPSHOT] - 2022-03-21
### Fixes
- Fixed protocol parameter when persistence is disabled
## [v1.8.0] - 2022-01-24

View File

@ -9,7 +9,7 @@
</parent>
<groupId>org.gcube.dataanalysis</groupId>
<artifactId>dataminer</artifactId>
<version>1.8.0</version>
<version>1.8.1-SNAPSHOT</version>
<name>dataminer</name>
<description>An e-Infrastructure service providing state-of-the art DataMining algorithms and ecological modelling approaches under the Web Processing Service (WPS) standard.</description>
@ -55,7 +55,7 @@
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-bom</artifactId>
<version>2.0.2</version>
<version>2.1.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>

View File

@ -22,25 +22,24 @@ public class ConfigurationManager {
public static String usernameParameter = "user.name";
public static String scopeParameter = "scope";
public static String tokenParameter = "usertoken";
public static String defaultScope= "/gcube/devsec";
public static String defaultUsername= "statistical.wps";
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;
EnvironmentVariableManager env = null;
public static synchronized Integer getMaxComputations(){
public static synchronized Integer getMaxComputations() {
return maxComputations;
}
public static synchronized Boolean useStorage(){
public static synchronized Boolean useStorage() {
return useStorage;
}
public static synchronized Boolean isSimulationMode(){
public static synchronized Boolean isSimulationMode() {
return simulationMode;
}
@ -57,12 +56,12 @@ public class ConfigurationManager {
options.load(is);
is.close();
maxComputations = Integer.parseInt(options.getProperty("maxcomputations"));
logger.info("setting max computation to {}",maxComputations);
logger.info("setting max computation to {}", maxComputations);
useStorage = Boolean.parseBoolean(options.getProperty("saveond4sstorage"));
simulationMode=Boolean.parseBoolean(options.getProperty("simulationMode"));
simulationMode = Boolean.parseBoolean(options.getProperty("simulationMode"));
}
} catch (Exception e) {
logger.error("error initializing properties",e);
logger.error("error initializing properties", e);
}
}
@ -80,7 +79,8 @@ public class ConfigurationManager {
}
public ConfigurationManager(EnvironmentVariableManager env) {
if (env == null) inizializePropertiesUsingTemplateFile();
if (env == null)
inizializePropertiesUsingTemplateFile();
else {
maxComputations = env.getMaxComputation();
useStorage = env.isSaveOnStorage();
@ -92,7 +92,7 @@ public class ConfigurationManager {
return config;
}
public void setComputationId(String computationId){
public void setComputationId(String computationId) {
config.setTaskID(computationId);
}
@ -109,28 +109,30 @@ public class ConfigurationManager {
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);
config.setNumberOfResources(1);
// setting application paths
String protocol = WPSConfig.getInstance().getWPSConfig().getServer().getProtocol();
String webapp = WPSConfig.getInstance().getWPSConfig().getServer().getWebappPath();
String host = WPSConfig.getInstance().getWPSConfig().getServer().getHostname();
String port = WPSConfig.getInstance().getWPSConfig().getServer().getHostport();
logger.debug("Host: {} Port: {} Webapp: {} ", host, port, webapp );
logger.debug("Web persistence path:{} ", webperspath);
logger.debug("Protocol: {} , Host: {} , Port: {} , Webapp: {} ", protocol, host, port, webapp);
logger.info("Web Path Persistence: {}", webperspath);
String webPath = "http://" + host + ":" + port + "/" + webapp + "/persistence/";
String webPath = protocol + "://" + host + ":" + port + "/" + webapp + "/persistence/";
// logger.debug("Env Vars: \n"+System.getenv());
logger.debug("Web app path: {} ", webPath);
logger.info("Web Path Persistence Url: {}", webPath);
// retrieving scope
scope = (String) inputs.get(scopeParameter);
logger.debug("Retrieved scope: {} ", scope);
if (scope == null)
throw new Exception("Error: scope parameter (scope) not set! This violates e-Infrastructure security policies");
throw new Exception(
"Error: scope parameter (scope) not set! This violates e-Infrastructure security policies");
if (!scope.startsWith("/"))
scope = "/" + scope;
@ -141,7 +143,8 @@ public class ConfigurationManager {
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");
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");