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" # Changelog for "dataminer"
## [v1.8.1-SNAPSHOT] - 2022-03-21
### Fixes
- Fixed protocol parameter when persistence is disabled
## [v1.8.0] - 2022-01-24 ## [v1.8.0] - 2022-01-24

View File

@ -9,7 +9,7 @@
</parent> </parent>
<groupId>org.gcube.dataanalysis</groupId> <groupId>org.gcube.dataanalysis</groupId>
<artifactId>dataminer</artifactId> <artifactId>dataminer</artifactId>
<version>1.8.0</version> <version>1.8.1-SNAPSHOT</version>
<name>dataminer</name> <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> <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> <dependency>
<groupId>org.gcube.distribution</groupId> <groupId>org.gcube.distribution</groupId>
<artifactId>gcube-bom</artifactId> <artifactId>gcube-bom</artifactId>
<version>2.0.2</version> <version>2.1.0-SNAPSHOT</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>

View File

@ -22,25 +22,24 @@ public class ConfigurationManager {
public static String usernameParameter = "user.name"; public static String usernameParameter = "user.name";
public static String scopeParameter = "scope"; public static String scopeParameter = "scope";
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;
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;
} }
@ -57,12 +56,12 @@ public class ConfigurationManager {
options.load(is); options.load(is);
is.close(); is.close();
maxComputations = Integer.parseInt(options.getProperty("maxcomputations")); 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")); useStorage = Boolean.parseBoolean(options.getProperty("saveond4sstorage"));
simulationMode=Boolean.parseBoolean(options.getProperty("simulationMode")); simulationMode = Boolean.parseBoolean(options.getProperty("simulationMode"));
} }
} catch (Exception e) { } 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) { public ConfigurationManager(EnvironmentVariableManager env) {
if (env == null) inizializePropertiesUsingTemplateFile(); if (env == null)
inizializePropertiesUsingTemplateFile();
else { else {
maxComputations = env.getMaxComputation(); maxComputations = env.getMaxComputation();
useStorage = env.isSaveOnStorage(); useStorage = env.isSaveOnStorage();
@ -92,7 +92,7 @@ public class ConfigurationManager {
return config; return config;
} }
public void setComputationId(String computationId){ public void setComputationId(String computationId) {
config.setTaskID(computationId); config.setTaskID(computationId);
} }
@ -109,28 +109,30 @@ public class ConfigurationManager {
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);
config.setNumberOfResources(1); config.setNumberOfResources(1);
// setting application paths // setting application paths
String protocol = WPSConfig.getInstance().getWPSConfig().getServer().getProtocol();
String webapp = WPSConfig.getInstance().getWPSConfig().getServer().getWebappPath(); String webapp = WPSConfig.getInstance().getWPSConfig().getServer().getWebappPath();
String host = WPSConfig.getInstance().getWPSConfig().getServer().getHostname(); String host = WPSConfig.getInstance().getWPSConfig().getServer().getHostname();
String port = WPSConfig.getInstance().getWPSConfig().getServer().getHostport(); String port = WPSConfig.getInstance().getWPSConfig().getServer().getHostport();
logger.debug("Host: {} Port: {} Webapp: {} ", host, port, webapp ); logger.debug("Protocol: {} , Host: {} , Port: {} , Webapp: {} ", protocol, host, port, webapp);
logger.debug("Web persistence path:{} ", webperspath); 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("Env Vars: \n"+System.getenv());
logger.debug("Web app path: {} ", webPath); logger.info("Web Path Persistence Url: {}", webPath);
// retrieving scope // retrieving scope
scope = (String) inputs.get(scopeParameter); scope = (String) inputs.get(scopeParameter);
logger.debug("Retrieved scope: {} ", scope); logger.debug("Retrieved scope: {} ", scope);
if (scope == null) 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("/")) if (!scope.startsWith("/"))
scope = "/" + scope; scope = "/" + scope;
@ -141,7 +143,8 @@ public class ConfigurationManager {
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");