From 5d501d5230ad1c42f1e17a485cb86a04ba8b538a Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Mon, 14 Dec 2020 23:18:04 +0000 Subject: [PATCH] JAL-3280 Fixed the version checking URL formulation (getdown build_properties) for jalviewjs, can also use it for jalviewjs in future --- src/jalview/bin/Cache.java | 48 ++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 50db03b..4a83b35 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -534,7 +534,8 @@ public class Cache @Override public void run() { - String buildPropertiesUrl = Cache.getAppbaseBuildProperties(); + String remoteBuildPropertiesUrl = Cache + .getAppbaseBuildProperties(); String orgtimeout = System .getProperty("sun.net.client.defaultConnectTimeout"); @@ -549,7 +550,7 @@ public class Cache { System.setProperty("sun.net.client.defaultConnectTimeout", "5000"); - java.net.URL url = new java.net.URL(buildPropertiesUrl); + java.net.URL url = new java.net.URL(remoteBuildPropertiesUrl); BufferedReader in = new BufferedReader( new InputStreamReader(url.openStream())); @@ -561,7 +562,7 @@ public class Cache { System.out .println("Non-fatal exception when checking version at " - + buildPropertiesUrl + ":"); + + remoteBuildPropertiesUrl + ":"); System.out.println(ex); remoteVersion = getProperty("VERSION"); } @@ -638,11 +639,21 @@ public class Cache InputStream in = localJarFileURL.openStream(); buildProperties.load(in); in.close(); - applicationProperties.put("BUILD_DATE", - buildProperties.get("BUILD_DATE")); - applicationProperties.put("INSTALLATION", - buildProperties.get("INSTALLATION")); - applicationProperties.put("VERSION", buildProperties.get("VERSION")); + if (buildProperties.getProperty("BUILD_DATE", null) != null) + { + applicationProperties.put("BUILD_DATE", + buildProperties.getProperty("BUILD_DATE")); + } + if (buildProperties.getProperty("INSTALLATION", null) != null) + { + applicationProperties.put("INSTALLATION", + buildProperties.getProperty("INSTALLATION")); + } + if (buildProperties.getProperty("VERSION", null) != null) + { + applicationProperties.put("VERSION", + buildProperties.getProperty("VERSION")); + } } catch (Exception ex) { System.out.println("Error reading build details: " + ex); @@ -1641,11 +1652,22 @@ public class Cache static { - Float specversion = Float - .parseFloat(System.getProperty("java.specification.version")); - releaseAppbase = (specversion < 9) - ? "https://www.jalview.org/getdown/release/1.8" - : "https://www.jalview.org/getdown/release/11"; + if (!Platform.isJS()) + { + Float specversion = Float + .parseFloat(System.getProperty("java.specification.version")); + releaseAppbase = (specversion < 9) + ? "https://www.jalview.org/getdown/release/1.8" + : "https://www.jalview.org/getdown/release/11"; + } + else + { + // this value currenly made up, can be changed to URL that will be + // "https://www.jalview.org/jalview-js/swingjs/j2s/build_properties" + releaseAppbase = "https://www.jalview.org/jalview-js"; + getdownAppbase = releaseAppbase; + getdownDistDir = "/swingjs/j2s"; + } } // look for properties (passed in by getdown) otherwise default to release -- 1.7.10.2