config Path can be set from EnvManager

This commit is contained in:
user1 2020-11-20 16:25:19 +01:00
parent 0a1de08b27
commit 279535c13a
6 changed files with 55 additions and 39 deletions

View File

@ -21,11 +21,13 @@
<attributes> <attributes>
<attribute name="optional" value="true"/> <attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">

View File

@ -7,6 +7,9 @@ org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.compiler.source=1.8

View File

@ -1,7 +1,11 @@
# Changelog # Changelog
## [v1.6.0] [r4.23.0] - 2020-05-12 ## [v1.76.0] - 2020-11-20
- Config path passed as parameter
## [v1.6.0] - 2020-05-12
### Fixes ### Fixes

40
pom.xml
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.6.0</version> <version>1.7.0-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>
@ -46,6 +46,23 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties> </properties>
<dependencyManagement>
<!-- Old solution <dependencies> <dependency> <groupId>org.gcube.distribution</groupId>
<artifactId>maven-smartgears-bom</artifactId> <version>2.1.0</version> <type>pom</type>
<scope>import</scope> </dependency> </dependencies> -->
<dependencies>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-bom</artifactId>
<version>2.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies> <dependencies>
<!-- https://mvnrepository.com/artifact/org.reflections/reflections-maven --> <!-- https://mvnrepository.com/artifact/org.reflections/reflections-maven -->
<dependency> <dependency>
@ -162,7 +179,6 @@
<dependency> <dependency>
<groupId>org.gcube.accounting</groupId> <groupId>org.gcube.accounting</groupId>
<artifactId>accounting-lib</artifactId> <artifactId>accounting-lib</artifactId>
<version>[3.0.0,4.0.0-SNAPSHOT)</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
@ -174,31 +190,11 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration> <configuration>
<skipTests>true</skipTests> <skipTests>true</skipTests>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>descriptor.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>servicearchive</id>
<phase>install</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>
<repositories> <repositories>

View File

@ -28,6 +28,8 @@ public class ConfigurationManager {
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;
@ -84,6 +86,7 @@ public class ConfigurationManager {
maxComputations = env.getMaxComputation(); maxComputations = env.getMaxComputation();
useStorage = env.isSaveOnStorage(); useStorage = env.isSaveOnStorage();
simulationMode = env.isSimulationMode(); simulationMode = env.isSimulationMode();
baseConfigPath = env.getConfigPath();
} }
} }
@ -103,33 +106,35 @@ public class ConfigurationManager {
// selecting persistence path // selecting persistence path
// String persistencePath = File.createTempFile("wpsstatcheck", ".sm").getParent() + "/../cfg/"; // String persistencePath = File.createTempFile("wpsstatcheck", ".sm").getParent() + "/../cfg/";
//TODO: REMOVE this shit (the persistence must be the persistence dir of the webapp) //String webperspath = baseConfigPath + "/persistence/";
String persistencePath = WPSConfig.getConfigDir() + "../ecocfg/";
String configPath = persistencePath; //String persistencePath = baseConfigPath; WPSConfig.getConfigDir() + "../ecocfg/";
if (!new File(configPath).isDirectory()) { String configPath = baseConfigPath + "/ecocfg/"; //persistencePath;
/*if (!new File(configPath).isDirectory()) {
configPath = "./cfg/"; configPath = "./cfg/";
persistencePath = "./"; persistencePath = "./";
} }*/
logger.debug("Taking configuration from " + (new File(configPath).getAbsolutePath()) + " and persistence in " + persistencePath); logger.debug("Taking configuration from {}", configPath);
//+ " and persistence in " + persistencePath);
// setting configuration and logger // setting configuration and logger
config.setPersistencePath(persistencePath); config.setPersistencePath(configPath);
config.setConfigPath(configPath); config.setConfigPath(configPath);
config.setNumberOfResources(1); config.setNumberOfResources(1);
// setting application paths // setting application paths
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: " + host + " Port: " + port + " Webapp: " + 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);
// 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("/"))
@ -138,8 +143,8 @@ 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");
@ -152,7 +157,7 @@ public class ConfigurationManager {
config.setGcubeToken(token); config.setGcubeToken(token);
// DONE get username from request // DONE get username from request
config.setParam(serviceUserNameParameterVariable, username); config.setParam(serviceUserNameParameterVariable, username);
config.setParam(processingSessionVariable, "" + UUID.randomUUID()); config.setParam(processingSessionVariable, UUID.randomUUID().toString());
config.setParam(webpathVariable, webPath); config.setParam(webpathVariable, webPath);
config.setParam(webPersistencePathVariable, webperspath); config.setParam(webPersistencePathVariable, webperspath);

View File

@ -4,13 +4,15 @@ import java.util.List;
public class EnvironmentVariableManager { public class EnvironmentVariableManager {
public EnvironmentVariableManager(int maxComputation, boolean saveOnStorage, boolean simulationMode, List<String> shubUsersExcluded) { public EnvironmentVariableManager(int maxComputation, boolean saveOnStorage, boolean simulationMode, List<String> shubUsersExcluded, String configPath ) {
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;
private boolean saveOnStorage; private boolean saveOnStorage;
private boolean simulationMode; private boolean simulationMode;
@ -20,6 +22,8 @@ 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;
} }
@ -34,5 +38,7 @@ public class EnvironmentVariableManager {
return shubUsersExcluded; return shubUsersExcluded;
} }
public String getConfigPath() {
return configPath;
}
} }