JAL-3978 Using getdowninstanceappdir and getdowninstanceappbase to avoid conflict...
[jalview.git] / src / jalview / bin / Cache.java
index e10c9eb..0ec0e78 100755 (executable)
@@ -42,7 +42,6 @@ import java.util.Locale;
 import java.util.Properties;
 import java.util.StringTokenizer;
 import java.util.TreeSet;
-import java.util.regex.Pattern;
 
 import javax.swing.LookAndFeel;
 import javax.swing.UIManager;
@@ -519,25 +518,29 @@ public class Cache
                     + orgtimeout + " seconds.");
           }
           String remoteVersion = null;
-          try
+          if (remoteBuildPropertiesUrl.startsWith("http"))
           {
-            System.setProperty("sun.net.client.defaultConnectTimeout",
-                    "5000");
-            java.net.URL url = new java.net.URL(remoteBuildPropertiesUrl);
+            try
+            {
+              System.setProperty("sun.net.client.defaultConnectTimeout",
+                      "5000");
 
-            BufferedReader in = new BufferedReader(
-                    new InputStreamReader(url.openStream()));
+              URL url = new URL(remoteBuildPropertiesUrl);
 
-            Properties remoteBuildProperties = new Properties();
-            remoteBuildProperties.load(in);
-            remoteVersion = remoteBuildProperties.getProperty("VERSION");
-          } catch (Exception ex)
-          {
-            System.out
-                    .println("Non-fatal exception when checking version at "
-                            + remoteBuildPropertiesUrl + ":");
-            System.out.println(ex);
-            remoteVersion = getProperty("VERSION");
+              BufferedReader in = new BufferedReader(
+                      new InputStreamReader(url.openStream()));
+
+              Properties remoteBuildProperties = new Properties();
+              remoteBuildProperties.load(in);
+              remoteVersion = remoteBuildProperties.getProperty("VERSION");
+            } catch (Exception ex)
+            {
+              System.out.println(
+                      "Non-fatal exception when checking version at "
+                              + remoteBuildPropertiesUrl + ":");
+              System.out.println(ex);
+              remoteVersion = getProperty("VERSION");
+            }
           }
           System.setProperty("sun.net.client.defaultConnectTimeout",
                   orgtimeout);
@@ -808,11 +811,13 @@ public class Cache
         if (jalview.jbgui.GDesktop.class.getClassLoader()
                 .loadClass("uk.ac.vamsas.client.VorbaId") != null)
         {
-          Console.debug("Found Vamsas Classes (uk.ac..vamsas.client.VorbaId can be loaded)");
+          Console.debug(
+                  "Found Vamsas Classes (uk.ac..vamsas.client.VorbaId can be loaded)");
           vamsasJarsArePresent = 1;
           JLoggerLog4j lvclient = JLoggerLog4j.getLogger("uk.ac.vamsas",
                   Console.getCachedLogLevel("logs.Vamsas.Level"));
-          JLoggerLog4j.addAppender(lvclient, Console.log, JALVIEW_LOGGER_NAME);
+          JLoggerLog4j.addAppender(lvclient, Console.log,
+                  JALVIEW_LOGGER_NAME);
           // Tell the user that debug is enabled
           lvclient.debug(ChannelProperties.getProperty("app_name")
                   + " Vamsas Client Debugging Output Follows.");
@@ -845,11 +850,13 @@ public class Cache
         if (Cache.class.getClassLoader()
                 .loadClass("groovy.lang.GroovyObject") != null)
         {
-          Console.debug("Found Groovy (groovy.lang.GroovyObject can be loaded)");
+          Console.debug(
+                  "Found Groovy (groovy.lang.GroovyObject can be loaded)");
           groovyJarsArePresent = 1;
           JLoggerLog4j lgclient = JLoggerLog4j.getLogger("groovy",
                   Console.getCachedLogLevel("logs.Groovy.Level"));
-          JLoggerLog4j.addAppender(lgclient, Console.log, JALVIEW_LOGGER_NAME);
+          JLoggerLog4j.addAppender(lgclient, Console.log,
+                  JALVIEW_LOGGER_NAME);
           // Tell the user that debug is enabled
           lgclient.debug(ChannelProperties.getProperty("app_name")
                   + " Groovy Client Debugging Output Follows.");
@@ -895,7 +902,8 @@ public class Cache
                   .loadClass("com.boxysystems.jgoogleanalytics.FocusPoint");
         } catch (Exception e)
         {
-          Console.debug("com.boxysystems.jgoogleanalytics package is not present - tracking not enabled.");
+          Console.debug(
+                  "com.boxysystems.jgoogleanalytics package is not present - tracking not enabled.");
           tracker = null;
           jgoogleanalyticstracker = null;
           trackerfocus = null;
@@ -938,17 +946,22 @@ public class Cache
       {
         if (re != null)
         {
-          Console.debug("Caught runtime exception in googletracker init:", re);
+          Console.debug("Caught runtime exception in googletracker init:",
+                  re);
         }
         if (ex != null)
         {
-          Console.warn("Failed to initialise GoogleTracker for Jalview Desktop with version "
-                  + vrs, ex);
+          Console.warn(
+                  "Failed to initialise GoogleTracker for Jalview Desktop with version "
+                          + vrs,
+                  ex);
         }
         if (err != null)
         {
-          Console.error("Whilst initing GoogleTracker for Jalview Desktop version "
-                  + vrs, err);
+          Console.error(
+                  "Whilst initing GoogleTracker for Jalview Desktop version "
+                          + vrs,
+                  err);
         }
       }
       else
@@ -975,7 +988,8 @@ public class Cache
     Color col = ColorUtils.parseColourString(colprop);
     if (col == null)
     {
-      Console.warn("Couldn't parse '" + colprop + "' as a colour for " + property);
+      Console.warn("Couldn't parse '" + colprop + "' as a colour for "
+              + property);
     }
     return (col == null) ? defcolour : col;
   }
@@ -1143,8 +1157,11 @@ public class Cache
     {
       return;
     }
-    String line = prefix + (value != null ? value : defaultValue) + suffix;
-    sb.append(line);
+    if (prefix != null)
+      sb.append(prefix);
+    sb.append(value == null ? defaultValue : value);
+    if (suffix != null)
+      sb.append(suffix);
   }
 
   /**
@@ -1188,15 +1205,15 @@ public class Cache
     sb.append(" (");
     sb.append(lafClass);
     sb.append(")\n");
-    // Not displayed in release version ( determined by possible version number
-    // regex 9[9.]*9[.-_a9]* )
-    if (Pattern.matches("^\\d[\\d\\.]*\\d[\\.\\-\\w]*$",
-            Cache.getDefault("VERSION", "TEST")))
+    if (Console.isDebugEnabled()
+            || !"release".equals(ChannelProperties.getProperty("channel")))
     {
+      appendIfNotNull(sb, "Channel: ",
+              ChannelProperties.getProperty("channel"), "\n", null);
       appendIfNotNull(sb, "Getdown appdir: ",
-              System.getProperty("getdownappdir"), "\n", null);
+              System.getProperty("getdowninstanceappdir"), "\n", null);
       appendIfNotNull(sb, "Getdown appbase: ",
-              System.getProperty("getdownappbase"), "\n", null);
+              System.getProperty("getdowninstanceappbase"), "\n", null);
       appendIfNotNull(sb, "Java home: ", System.getProperty("java.home"),
               "\n", "unknown");
     }
@@ -1355,8 +1372,10 @@ public class Cache
         char[] displayHttpPw = new char[httpPassword == null ? 0
                 : httpPassword.length];
         Arrays.fill(displayHttpPw, '*');
-        Console.debug("CACHE Proxy: setting new Authenticator with httpUser='"
-                + httpUser + "' httpPassword='" + displayHttpPw + "'");
+        Console.debug(
+                "CACHE Proxy: setting new Authenticator with httpUser='"
+                        + httpUser + "' httpPassword='" + displayHttpPw
+                        + "'");
         if (!Platform.isJS())
         /* *
          * java.net.Authenticator not implemented in SwingJS yet
@@ -1469,14 +1488,16 @@ public class Cache
        * 
        */
       {
-        Console.debug("AUTHENTICATOR setting default Authenticator to null");
+        Console.debug(
+                "AUTHENTICATOR setting default Authenticator to null");
         Authenticator.setDefault(null);
       }
     }
 
     // nonProxyHosts not currently configurable in Preferences
-    Console.debug("AUTHENTICATOR setting property 'http.nonProxyHosts' to \""
-            + nonProxyHosts + "\"");
+    Console.debug(
+            "AUTHENTICATOR setting property 'http.nonProxyHosts' to \""
+                    + nonProxyHosts + "\"");
     setOrClearSystemProperty("http.nonProxyHosts", nonProxyHosts);
   }