From bc70e34dd80a03dd8069c2c0491be491a148d1d1 Mon Sep 17 00:00:00 2001 From: Will Ezell Date: Tue, 2 May 2017 18:26:21 -0400 Subject: [PATCH] #10370 load defualt props first, then load custom props and pass them all to felix --- .../java/com/dotmarketing/util/OSGIUtil.java | 44 +++---------------- 1 file changed, 6 insertions(+), 38 deletions(-) diff --git a/dotCMS/src/main/java/com/dotmarketing/util/OSGIUtil.java b/dotCMS/src/main/java/com/dotmarketing/util/OSGIUtil.java index 852b5afe1ba9..0ad75fe083cd 100644 --- a/dotCMS/src/main/java/com/dotmarketing/util/OSGIUtil.java +++ b/dotCMS/src/main/java/com/dotmarketing/util/OSGIUtil.java @@ -133,9 +133,7 @@ public synchronized Framework initializeFramework(ServletContextEvent context) { Properties felixProps = loadConfig(); // fetch the 'felix.base.dir' property and check if exists. On the props file the prop needs to - for(String key :FELIX_DIRECTORIES ){ - if( new File(felixProps.getProperty(key)).mkdirs()){ Logger.info(this.getClass(), "Building Directory:" +felixProps.getProperty(key) ); } @@ -270,16 +268,12 @@ private Properties loadConfig() { Properties properties = defaultProperties(); Iterator it = Config.getKeys(); while (it.hasNext()) { - String key = it.next(); - if (key == null) - continue; - if (key.startsWith("felix.felix.")) { - properties.put(key.substring(6), Config.getStringProperty(key)); - Logger.info(this, "Loading property " + key + "=" + properties.getProperty(key)); - } else if (key.startsWith("felix.")) { - // Allow the property in the file to be felix.base.dir - properties.put(key, Config.getStringProperty(key)); - Logger.info(this, "Loading property " + key + "=" + properties.getProperty(key)); + final String key = it.next(); + if(key != null && key.startsWith("felix.")) { + String value = (UtilMethods.isSet(Config.getStringProperty(key, null))) ? Config.getStringProperty(key) : null; + String felixKey = key.substring(6) ; + properties.put(felixKey, value); + Logger.info(OSGIUtil.class, "Found property " + felixKey + "=" + value); } } return properties; @@ -361,24 +355,7 @@ public String getExtraOSGIPackages() throws IOException { return extraPackages; } - /** - * Transform a given Properties object into a Map - * - * @param props - * @return - */ - private Map propertiesToMap(Properties props) { - - HashMap propertiesMap = new HashMap(); - Enumeration e = props.keys(); - while (e.hasMoreElements()) { - String s = (String) e.nextElement(); - propertiesMap.put(s, props.getProperty(s)); - } - - return propertiesMap; - } /** * Fetches the Felix Path based on the input param property value. If property is not found, then @@ -424,15 +401,6 @@ private String getFelixPath(String felixDirProperty, String manualDefaultPath) { return felixPath; } - /** - * Verifies the folder exists. If it does not exists then tries to create it - * - * @param path The path to verify - * @return boolean true when path exists or it was created successfully - */ - private boolean verifyOrCreateFelixFolder(String path) { - return new File(path).exists() || createFolder(path); - } /** * Create the path if it does not exist. Required for felix install and undeploy folder