X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fbin%2FCache.java;h=4a83b35c81d95e0b2443caebabe91f514f7da569;hb=5d501d5230ad1c42f1e17a485cb86a04ba8b538a;hp=153eaffd12cd301667e50ee2c13daf97d965bb07;hpb=f7791271668cdcf6e87b638f0e6475ccdea6a3f9;p=jalview.git diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 153eaff..4a83b35 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -310,6 +310,9 @@ public class Cache } }; + /* build Properties (not all saved to .jalview_properties) */ + public static Properties buildProperties = new Properties(); + /** Default file is ~/.jalview_properties */ static String propertiesFile; @@ -527,9 +530,13 @@ public class Cache class VersionChecker extends Thread { + @Override public void run() { + String remoteBuildPropertiesUrl = Cache + .getAppbaseBuildProperties(); + String orgtimeout = System .getProperty("sun.net.client.defaultConnectTimeout"); if (orgtimeout == null) @@ -543,28 +550,19 @@ public class Cache { System.setProperty("sun.net.client.defaultConnectTimeout", "5000"); - java.net.URL url = new java.net.URL(Cache - .getDefault("www.jalview.org", "http://www.jalview.org") - + "/webstart/jalview.jnlp"); + java.net.URL url = new java.net.URL(remoteBuildPropertiesUrl); + BufferedReader in = new BufferedReader( new InputStreamReader(url.openStream())); - String line = null; - while ((line = in.readLine()) != null) - { - if (line.indexOf("jalview.version") == -1) - { - continue; - } - line = line.substring(line.indexOf("value=") + 7); - line = line.substring(0, line.lastIndexOf("\"")); - remoteVersion = line; - break; - } + Properties remoteBuildProperties = new Properties(); + remoteBuildProperties.load(in); + remoteVersion = remoteBuildProperties.getProperty("VERSION"); } catch (Exception ex) { - System.out.println( - "Non-fatal exception when checking version at www.jalview.org :"); + System.out + .println("Non-fatal exception when checking version at " + + remoteBuildPropertiesUrl + ":"); System.out.println(ex); remoteVersion = getProperty("VERSION"); } @@ -639,8 +637,23 @@ public class Cache String buildDetails = resolveResourceURLFor("/.build_properties"); URL localJarFileURL = new URL(buildDetails); InputStream in = localJarFileURL.openStream(); - applicationProperties.load(in); + buildProperties.load(in); in.close(); + 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); @@ -1251,6 +1264,8 @@ public class Cache { appendIfNotNull(sb, "Getdown appdir: ", System.getProperty("getdownappdir"), "\n", null); + appendIfNotNull(sb, "Getdown appbase: ", + System.getProperty("getdownappbase"), "\n", null); appendIfNotNull(sb, "Java home: ", System.getProperty("java.home"), "\n", "unknown"); } @@ -1624,4 +1639,77 @@ public class Cache { println(ERROR, message); } -} \ No newline at end of file + + /** + * Getdown appbase methods + */ + + private static final String releaseAppbase; + + private static String getdownAppbase; + + private static String getdownDistDir; + + static + { + 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 + private static void setGetdownAppbase() + { + if (getdownAppbase != null) + { + return; + } + String appbase = System.getProperty("getdownappbase"); + String distDir = System.getProperty("getdowndistdir"); + if (appbase == null) + { + appbase = buildProperties.getProperty("GETDOWNAPPBASE"); + distDir = buildProperties.getProperty("GETDOWNAPPDISTDIR"); + } + if (appbase == null) + { + appbase = releaseAppbase; + distDir = "release"; + } + if (appbase.endsWith("/")) + { + appbase = appbase.substring(0, appbase.length() - 1); + } + if (distDir == null) + { + distDir = appbase.equals(releaseAppbase) ? "release" : "alt"; + } + getdownAppbase = appbase; + getdownDistDir = distDir; + } + + public static String getGetdownAppbase() + { + setGetdownAppbase(); + return getdownAppbase; + } + + public static String getAppbaseBuildProperties() + { + String appbase = getGetdownAppbase(); + return appbase + "/" + getdownDistDir + "/build_properties"; + } +}