JAL-3247 JAL-3254 JAL-3260 Fixed: JVL file jalview.apparg args. File association...
[jalview.git] / getdown / src / getdown / core / src / main / java / com / threerings / getdown / data / Application.java
index 17e98f8..25cd109 100644 (file)
@@ -597,6 +597,11 @@ public class Application
         // process, our caller can use the appbase to download a new configuration file
         _appbase = config.getString("appbase");
         
+        // see if locatorConfig override
+        if (locatorConfig != null && !StringUtil.isBlank(locatorConfig.getString("appbase"))) {
+          _appbase = locatorConfig.getString("appbase");
+        }
+        
         if (_appbase == null) {
             throw new RuntimeException("m.missing_appbase");
         }
@@ -1844,7 +1849,6 @@ public class Application
     public static void addStartupFile(String filename) {
       _startupFiles.add(new File(filename));
     }
-
     
     private Config createLocatorConfig(Config.ParseOpts opts) {
       if (_locatorFile == null) {
@@ -1861,19 +1865,24 @@ public class Application
           log.warning("Given locator file does not exist", "file", _locatorFile);
         }
         
-        // appbase is sanitised in HostWhitelist and here!
-        Map<String, Object> tmpdata = new HashMap<>();
-        tmpdata.put("appbase", tmpConfig.getString("appbase"));
-        tmpdata.put("appargs", tmpConfig.getString("appargs"));
-        tmpdata.put("jvmargs", tmpConfig.getString("jvmargs"));
-        tmpdata.put(LOCATOR_FILE_EXTENSION+"replace", tmpConfig.getString(LOCATOR_FILE_EXTENSION+"replace"));
-        tmpdata.put(LOCATOR_FILE_EXTENSION+"merge", tmpConfig.getString(LOCATOR_FILE_EXTENSION+"merge"));
-        locatorConfig = new Config(tmpdata);
+        // appbase is sanitised in HostWhitelist
+        Map<String, Object> tmpData = new HashMap<>();
+        for (Map.Entry<String, Object> entry : tmpConfig.getData().entrySet()) {
+          String key = entry.getKey();
+          Object value = entry.getValue();
+          String mkey = key.indexOf('.') > -1 ? key.substring(key.indexOf('.') + 1) : key;
+          if (Config.allowedReplaceKeys.contains(mkey) || Config.allowedMergeKeys.contains(mkey)) {
+            tmpData.put(key, value);
+          }
+        }
+        locatorConfig = new Config(tmpData);
         
       } catch (Exception e) {
         log.warning("Failure reading locator file",  "file", _locatorFile, e);
       }
       
+      log.info("Returning locatorConfig", locatorConfig);
+      
       return locatorConfig;
     }