JAL-3280 Fixed the version checking URL formulation (getdown build_properties) for...
[jalview.git] / src / jalview / bin / Cache.java
index ef42589..4a83b35 100755 (executable)
@@ -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;
 
@@ -531,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");
@@ -546,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()));
@@ -558,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");
           }
@@ -633,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);
@@ -1633,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
@@ -1651,6 +1681,11 @@ public class Cache
     String distDir = System.getProperty("getdowndistdir");
     if (appbase == null)
     {
+      appbase = buildProperties.getProperty("GETDOWNAPPBASE");
+      distDir = buildProperties.getProperty("GETDOWNAPPDISTDIR");
+    }
+    if (appbase == null)
+    {
       appbase = releaseAppbase;
       distDir = "release";
     }
@@ -1666,13 +1701,13 @@ public class Cache
     getdownDistDir = distDir;
   }
 
-  private static String getGetdownAppbase()
+  public static String getGetdownAppbase()
   {
     setGetdownAppbase();
     return getdownAppbase;
   }
 
-  private static String getAppbaseBuildProperties()
+  public static String getAppbaseBuildProperties()
   {
     String appbase = getGetdownAppbase();
     return appbase + "/" + getdownDistDir + "/build_properties";