Commit 79736b7a authored by Simon Reis's avatar Simon Reis
Browse files

Merge branch 'master' into 'master'

Changes Cloud

See merge request !2
parents 05bfd0d1 f9745a49
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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;
+4 −3
Original line number Diff line number Diff line
@@ -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 {

+4 −0
Original line number Diff line number Diff line
@@ -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);
    }

+10 −0
Original line number Diff line number Diff line
@@ -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;