aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/gv/egiz')
-rw-r--r--src/main/java/at/gv/egiz/moazs/config/MoaSigConfig.java16
-rw-r--r--src/main/java/at/gv/egiz/moazs/util/FileUtils.java5
2 files changed, 12 insertions, 9 deletions
diff --git a/src/main/java/at/gv/egiz/moazs/config/MoaSigConfig.java b/src/main/java/at/gv/egiz/moazs/config/MoaSigConfig.java
index e02c11d..c2f06c2 100644
--- a/src/main/java/at/gv/egiz/moazs/config/MoaSigConfig.java
+++ b/src/main/java/at/gv/egiz/moazs/config/MoaSigConfig.java
@@ -13,6 +13,7 @@ import org.springframework.context.annotation.Configuration;
import java.io.File;
import java.io.FileNotFoundException;
+import java.io.IOException;
import java.util.function.Consumer;
@@ -36,7 +37,7 @@ public class MoaSigConfig {
@Value("${javax.net.ssl.keyStoreType}") String keyStoreType,
@Value("${moa.spss.server.default-trustprofile}") String defaultTrustProfile,
@Value("${moa.spss.server.configuration}") String spssConfigFilePath,
- @Autowired FileUtils fileUtils) throws FileNotFoundException {
+ @Autowired FileUtils fileUtils) throws IOException {
this.trustStoreType = trustStoreType;
this.keyStoreType = keyStoreType;
this.defaultTrustProfile = defaultTrustProfile;
@@ -46,18 +47,19 @@ public class MoaSigConfig {
fallBackToSpringEnvForJavaxNetSSLStoreTypeProperty();
}
- private void fallBackToSpringEnvForMoaSPSSConfigProperty() throws FileNotFoundException {
+ private void fallBackToSpringEnvForMoaSPSSConfigProperty() throws IOException {
log.info("value of spssConfigFilePath is {}", spssConfigFilePath);
if(System.getProperty(MOA_SPSS_CONFIG_FILE_PROPERTY) == null) {
- var realPath = fileUtils.determinePath(spssConfigFilePath);
- var realFile = new File(realPath);
+
+ var realFile = new File(fileUtils.determinePath(spssConfigFilePath));
+ log.info("spssConfigFilePath.getCanonicalPath(): ", realFile.getCanonicalPath());
if(realFile.exists() && realFile.canRead()) {
- log.info(SET_PROPERTY_MSG_TEMPLATE, MOA_SPSS_CONFIG_FILE_PROPERTY, realPath);
- System.getProperties().setProperty(MOA_SPSS_CONFIG_FILE_PROPERTY, realPath);
+ log.info(SET_PROPERTY_MSG_TEMPLATE, MOA_SPSS_CONFIG_FILE_PROPERTY, realFile.getCanonicalPath());
+ System.getProperties().setProperty(MOA_SPSS_CONFIG_FILE_PROPERTY, realFile.getCanonicalPath());
} else {
- throw new FileNotFoundException("File '" + realPath + "' does not exist or is not readable.");
+ throw new FileNotFoundException("File '" + realFile.getCanonicalPath() + "' does not exist or is not readable.");
}
}
}
diff --git a/src/main/java/at/gv/egiz/moazs/util/FileUtils.java b/src/main/java/at/gv/egiz/moazs/util/FileUtils.java
index 7e7723d..eb1b291 100644
--- a/src/main/java/at/gv/egiz/moazs/util/FileUtils.java
+++ b/src/main/java/at/gv/egiz/moazs/util/FileUtils.java
@@ -8,7 +8,7 @@ import java.io.File;
public class FileUtils {
/**
- * If path is relative, resolve path as classpath resource. If path is absolute,
+ * If path is relative, try to resolve path as classpath resource. If path is absolute,
* leave as-is.
*/
public String determinePath(String abstractPath) {
@@ -16,7 +16,8 @@ public class FileUtils {
return abstractPath;
} else {
//java.lang.Class needs relative resources to start with "/"
- return this.getClass().getResource("/" + abstractPath).getFile();
+ var resource = this.getClass().getResource("/" + abstractPath);
+ return resource == null ? abstractPath : resource.getFile();
}
}
}