First load folder then file
diff --git a/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/util/FileHelper.java b/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/util/FileHelper.java
index ddddd0b..9eb91a0 100644
--- a/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/util/FileHelper.java
+++ b/oKBereitschaftsplanungBackend/src/main/java/org/eclipse/openk/sp/util/FileHelper.java
@@ -81,33 +81,57 @@
return file;
}
}
-
- public File loadFileFromFileSystemOrResource(String folder, String filename, boolean exists) {
+
+ public File loadFileFromFileSystemOrResource(String folder) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
try {
// The name of a resource is a '/'-separated path name that identifies the
// resource.
- return new File(classLoader.getResource(folder + "/" + filename).getPath());
+ return new File(classLoader.getResource(folder).getPath());
} catch (Exception e) {
- LOGGER.info("File not found in resource. Searching in file system..");
- File file = new File(folder + File.separator + filename);
+ LOGGER.info("Folder: " + folder + " not found in resource. Searching in file system.");
+ }
+
+ try {
+ // The name of a resource is a '/'-separated path name that identifies the
+ // resource.
+ return new File(folder);
+ } catch (Exception e) {
+ LOGGER.info("Folder: " + folder + " not found in file system.");
+ }
+
+
+ return null;
+ }
- try {
+ public File loadFileFromFileSystemOrResource(String folder, String filename, boolean exists) {
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+
+ File file = null;
+
+ try {
+
+ File dirFile = loadFileFromFileSystemOrResource(folder);
+
+ if (dirFile != null && dirFile.exists()) {
+ file = new File(dirFile, filename);
+
if (exists && !file.exists()) {
LOGGER.error("The System couldnt find the file or has no access rights to it: [" + folder + "/"
+ filename + "]");
+
throw new FileNotFoundException();
+
}
- } catch (FileNotFoundException e1) {
- LOGGER.error("The System couldnt find the file or has no access rights to it: [" + folder + "/"
- + filename + "]");
- LOGGER.warn("Exception while reading the file", e1);
- return null;
+
}
- return file;
+ } catch (FileNotFoundException e) {
+ LOGGER.info("File: " + filename + " not found in resource.");
}
+
+ return file;
}
public String getProperty(String filename, String property) throws IOException {