Skip to content
Snippets Groups Projects
Commit f9745a49 authored by Tino Harnisch's avatar Tino Harnisch
Browse files

Changes Cloud

parent 05bfd0d1
No related branches found
No related merge requests found
......@@ -12,6 +12,7 @@
package org.eclipse.openk.portal.common;
import org.eclipse.openk.portal.common.util.ResourceLoaderBase;
import org.apache.log4j.Logger;
public class BackendConfig {
private static String configFileName = "backendConfigDevLocal.json";
......@@ -26,11 +27,18 @@ public class BackendConfig {
private static BackendConfig instance;
private static final Logger LOGGER = Logger.getLogger(BackendConfig.class.getName());
private BackendConfig() {}
public static synchronized BackendConfig getInstance() {
if (instance == null) {
String jsonConfig = loadJsonConfig();
if (jsonConfig == null || jsonConfig.isEmpty()) {
LOGGER.error("FileNotFound: jsonConfig is empty or NULL");
} else {
LOGGER.info("backendConfigFile " + configFileName + " successfully loaded.");
}
instance = JsonGeneratorBase.getGson().fromJson(jsonConfig, BackendConfig.class);
}
......@@ -39,8 +47,10 @@ public class BackendConfig {
private static String loadJsonConfig() {
ResourceLoaderBase resourceLoaderBase = new ResourceLoaderBase();
LOGGER.info("backendConfigFile is: " + configFileName);
String jsonConfig = resourceLoaderBase.loadStringFromResource(configFileName);
if (jsonConfig == null || jsonConfig.isEmpty()) {
LOGGER.info("backendConfigFile not found in resources, loading from external path now...");
jsonConfig = resourceLoaderBase.loadFromPath(configFileName);
}
return jsonConfig;
......
......@@ -11,11 +11,12 @@
*/
package org.eclipse.openk.portal.common;
import java.util.Timer;
import java.util.TimerTask;
import org.apache.log4j.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import org.apache.log4j.Logger;
import java.util.Timer;
import java.util.TimerTask;
public class InitUserCacheJob extends HttpServlet {
......
......@@ -57,6 +57,10 @@ public class ResourceLoaderBase {
public String loadStringFromResource(String filename) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
InputStream jsonstream = classLoader.getResourceAsStream(filename);
if (jsonstream==null){
LOGGER.error("Datei nicht gefunden: " + filename);
return null;
}
return stream2String(jsonstream);
}
......
......@@ -11,6 +11,7 @@
*/
package org.eclipse.openk.portal.viewmodel;
import org.apache.log4j.Logger;
import org.eclipse.openk.portal.common.JsonGeneratorBase;
import org.eclipse.openk.portal.common.util.ResourceLoaderBase;
......@@ -27,9 +28,16 @@ public class UserModule {
private static UserModule[] instance;
private static final Logger LOGGER = Logger.getLogger(UserModule.class.getName());
public static synchronized UserModule[] getInstance() {
if (instance == null) {
String jsonConfig = loadJsonConfig();
if (jsonConfig == null || jsonConfig.isEmpty()) {
LOGGER.error("FileNotFound: jsonConfig is empty or NULL");
} else {
LOGGER.info("usermoduleConfigFile " + configFileName + " successfully loaded.");
}
instance = JsonGeneratorBase.getGson().fromJson(jsonConfig, UserModule[].class);
}
......@@ -38,8 +46,10 @@ public class UserModule {
private static String loadJsonConfig() {
ResourceLoaderBase resourceLoaderBase = new ResourceLoaderBase();
LOGGER.info("usermoduleConfigFile is: " + configFileName);
String jsonConfig = resourceLoaderBase.loadStringFromResource(configFileName);
if (jsonConfig == null || jsonConfig.isEmpty()) {
LOGGER.info("usermoduleConfigFile not found in resources, loading from external path now...");
jsonConfig = resourceLoaderBase.loadFromPath(configFileName);
}
return jsonConfig;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment