Merge remote-tracking branch 'origin/releases/Release_2_10_2b1_Branch'
[jalview.git] / src / jalview / bin / Cache.java
index da3cb92..dc50843 100755 (executable)
@@ -77,7 +77,8 @@ import org.apache.log4j.SimpleLayout;
  * <li>SHOW_FULLSCREEN boolean</li>
  * <li>FONT_NAME java font name for alignment text display</li>
  * <li>FONT_SIZE size of displayed alignment text</li>
- * <li>FONT_STYLE style of font displayed (sequence labels are always italic)</li>
+ * <li>FONT_STYLE style of font displayed (sequence labels are always
+ * italic)</li>
  * <li>GAP_SYMBOL character to treat as gap symbol (usually -,.,' ')</li>
  * <li>LAST_DIRECTORY last directory for browsing alignment</li>
  * <li>USER_DEFINED_COLOURS list of user defined colour scheme files</li>
@@ -237,8 +238,7 @@ public class Cache
    * Sifts settings
    */
   public static final String DEFAULT_SIFTS_DOWNLOAD_DIR = System
-          .getProperty("user.home")
-          + File.separatorChar
+          .getProperty("user.home") + File.separatorChar
           + ".sifts_downloads" + File.separatorChar;
 
   private final static String DEFAULT_CACHE_THRESHOLD_IN_DAYS = "2";
@@ -310,8 +310,8 @@ public class Cache
       Logger lcastor = Logger.getLogger("org.exolab.castor");
       jalview.bin.Cache.log = Logger.getLogger("jalview.bin.Jalview");
 
-      laxis.setLevel(Level.toLevel(Cache.getDefault("logs.Axis.Level",
-              Level.INFO.toString())));
+      laxis.setLevel(Level.toLevel(
+              Cache.getDefault("logs.Axis.Level", Level.INFO.toString())));
       lcastor.setLevel(Level.toLevel(Cache.getDefault("logs.Castor.Level",
               Level.INFO.toString())));
       lcastor = Logger.getLogger("org.exolab.castor.xml");
@@ -320,8 +320,8 @@ public class Cache
       // lcastor = Logger.getLogger("org.exolab.castor.xml.Marshaller");
       // lcastor.setLevel(Level.toLevel(Cache.getDefault("logs.Castor.Level",
       // Level.INFO.toString())));
-      jalview.bin.Cache.log.setLevel(Level.toLevel(Cache.getDefault(
-              "logs.Jalview.level", Level.INFO.toString())));
+      jalview.bin.Cache.log.setLevel(Level.toLevel(Cache
+              .getDefault("logs.Jalview.level", Level.INFO.toString())));
       // laxis.addAppender(ap);
       // lcastor.addAppender(ap);
       // jalview.bin.Cache.log.addAppender(ap);
@@ -355,10 +355,10 @@ public class Cache
       try
       {
         fis = new java.net.URL(propertiesFile).openStream();
-        System.out.println("Loading jalview properties from : "
-                + propertiesFile);
-        System.out
-                .println("Disabling Jalview writing to user's local properties file.");
+        System.out.println(
+                "Loading jalview properties from : " + propertiesFile);
+        System.out.println(
+                "Disabling Jalview writing to user's local properties file.");
         propsAreReadOnly = true;
 
       } catch (Exception ex)
@@ -382,8 +382,8 @@ public class Cache
 
     if (getDefault("USE_PROXY", false))
     {
-      String proxyServer = getDefault("PROXY_SERVER", ""), proxyPort = getDefault(
-              "PROXY_PORT", "8080");
+      String proxyServer = getDefault("PROXY_SERVER", ""),
+              proxyPort = getDefault("PROXY_PORT", "8080");
 
       System.out.println("Using proxyServer: " + proxyServer
               + " proxyPort: " + proxyPort);
@@ -395,9 +395,9 @@ public class Cache
     // LOAD THE AUTHORS FROM THE authors.props file
     try
     {
-      String authorDetails = "jar:".concat(Cache.class
-              .getProtectionDomain().getCodeSource().getLocation()
-              .toString().concat("!/authors.props"));
+      String authorDetails = "jar:"
+              .concat(Cache.class.getProtectionDomain().getCodeSource()
+                      .getLocation().toString().concat("!/authors.props"));
 
       java.net.URL localJarFileURL = new java.net.URL(authorDetails);
 
@@ -451,16 +451,16 @@ public class Cache
     SiftsSettings
             .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
 
-    SiftsSettings.setSiftDownloadDirectory(jalview.bin.Cache.getDefault(
-            "sifts_download_dir", DEFAULT_SIFTS_DOWNLOAD_DIR));
+    SiftsSettings.setSiftDownloadDirectory(jalview.bin.Cache
+            .getDefault("sifts_download_dir", DEFAULT_SIFTS_DOWNLOAD_DIR));
 
-    SiftsSettings.setFailSafePIDThreshold(jalview.bin.Cache.getDefault(
-            "sifts_fail_safe_pid_threshold",
-            DEFAULT_FAIL_SAFE_PID_THRESHOLD));
+    SiftsSettings.setFailSafePIDThreshold(
+            jalview.bin.Cache.getDefault("sifts_fail_safe_pid_threshold",
+                    DEFAULT_FAIL_SAFE_PID_THRESHOLD));
 
-    SiftsSettings.setCacheThresholdInDays(jalview.bin.Cache.getDefault(
-            "sifts_cache_threshold_in_days",
-            DEFAULT_CACHE_THRESHOLD_IN_DAYS));
+    SiftsSettings.setCacheThresholdInDays(
+            jalview.bin.Cache.getDefault("sifts_cache_threshold_in_days",
+                    DEFAULT_CACHE_THRESHOLD_IN_DAYS));
 
     IdOrgSettings.setUrl(getDefault("ID_ORG_HOSTURL",
             "http://www.jalview.org/services/identifiers"));
@@ -478,8 +478,7 @@ public class Cache
     // "DEFAULT_PDB_FILE_PARSER", DEFAULT_PDB_FILE_PARSER));
     // jnlpVersion will be null if we're using InstallAnywhere
     // Dont do this check if running in headless mode
-    if (jnlpVersion == null
-            && getDefault("VERSION_CHECK", true)
+    if (jnlpVersion == null && getDefault("VERSION_CHECK", true)
             && (System.getProperty("java.awt.headless") == null || System
                     .getProperty("java.awt.headless").equals("false")))
     {
@@ -502,11 +501,11 @@ 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")
+            java.net.URL url = new java.net.URL(Cache
+                    .getDefault("www.jalview.org", "http://www.jalview.org")
                     + "/webstart/jalview.jnlp");
-            BufferedReader in = new BufferedReader(new InputStreamReader(
-                    url.openStream()));
+            BufferedReader in = new BufferedReader(
+                    new InputStreamReader(url.openStream()));
             String line = null;
             while ((line = in.readLine()) != null)
             {
@@ -522,8 +521,8 @@ public class Cache
             }
           } 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 www.jalview.org :");
             System.out.println(ex);
             remoteVersion = getProperty("VERSION");
           }
@@ -638,8 +637,8 @@ public class Cache
       }
     } catch (Exception ex)
     {
-      System.out.println("Error setting property: " + key + " " + obj
-              + "\n" + ex);
+      System.out.println(
+              "Error setting property: " + key + " " + obj + "\n" + ex);
     }
     return obj;
   }
@@ -690,15 +689,15 @@ public class Cache
     {
       try
       {
-        if (jalview.jbgui.GDesktop.class.getClassLoader().loadClass(
-                "uk.ac.vamsas.client.VorbaId") != null)
+        if (jalview.jbgui.GDesktop.class.getClassLoader()
+                .loadClass("uk.ac.vamsas.client.VorbaId") != null)
         {
-          jalview.bin.Cache.log
-                  .debug("Found Vamsas Classes (uk.ac..vamsas.client.VorbaId can be loaded)");
+          jalview.bin.Cache.log.debug(
+                  "Found Vamsas Classes (uk.ac..vamsas.client.VorbaId can be loaded)");
           vamsasJarsArePresent = 1;
           Logger lvclient = Logger.getLogger("uk.ac.vamsas");
-          lvclient.setLevel(Level.toLevel(Cache.getDefault(
-                  "logs.Vamsas.Level", Level.INFO.toString())));
+          lvclient.setLevel(Level.toLevel(Cache
+                  .getDefault("logs.Vamsas.Level", Level.INFO.toString())));
 
           lvclient.addAppender(log.getAppender("JalviewLogger"));
           // Tell the user that debug is enabled
@@ -729,15 +728,15 @@ public class Cache
     {
       try
       {
-        if (Cache.class.getClassLoader().loadClass(
-                "groovy.lang.GroovyObject") != null)
+        if (Cache.class.getClassLoader()
+                .loadClass("groovy.lang.GroovyObject") != null)
         {
-          jalview.bin.Cache.log
-                  .debug("Found Groovy (groovy.lang.GroovyObject can be loaded)");
+          jalview.bin.Cache.log.debug(
+                  "Found Groovy (groovy.lang.GroovyObject can be loaded)");
           groovyJarsArePresent = 1;
           Logger lgclient = Logger.getLogger("groovy");
-          lgclient.setLevel(Level.toLevel(Cache.getDefault(
-                  "logs.Groovy.Level", Level.INFO.toString())));
+          lgclient.setLevel(Level.toLevel(Cache
+                  .getDefault("logs.Groovy.Level", Level.INFO.toString())));
 
           lgclient.addAppender(log.getAppender("JalviewLogger"));
           // Tell the user that debug is enabled
@@ -778,15 +777,14 @@ public class Cache
         // try to get the tracker class
         try
         {
-          jgoogleanalyticstracker = Cache.class
-                  .getClassLoader()
-                  .loadClass(
-                          "com.boxysystems.jgoogleanalytics.JGoogleAnalyticsTracker");
-          trackerfocus = Cache.class.getClassLoader().loadClass(
-                  "com.boxysystems.jgoogleanalytics.FocusPoint");
+          jgoogleanalyticstracker = Cache.class.getClassLoader().loadClass(
+                  "com.boxysystems.jgoogleanalytics.JGoogleAnalyticsTracker");
+          trackerfocus = Cache.class.getClassLoader()
+                  .loadClass("com.boxysystems.jgoogleanalytics.FocusPoint");
         } catch (Exception e)
         {
-          log.debug("com.boxysystems.jgoogleanalytics package is not present - tracking not enabled.");
+          log.debug(
+                  "com.boxysystems.jgoogleanalytics package is not present - tracking not enabled.");
           tracker = null;
           jgoogleanalyticstracker = null;
           trackerfocus = null;
@@ -800,22 +798,22 @@ public class Cache
       try
       {
         // Google analytics tracking code for Library Finder
-        tracker = jgoogleanalyticstracker.getConstructor(
-                new Class[] { String.class, String.class, String.class })
-                .newInstance(
-                        new Object[] {
-                            "Jalview Desktop",
-                            (vrs = jalview.bin.Cache.getProperty("VERSION")
-                                    + "_"
-                                    + jalview.bin.Cache.getDefault(
-                                            "BUILD_DATE", "unknown")),
-                            "UA-9060947-1" });
-        jgoogleanalyticstracker.getMethod("trackAsynchronously",
-                new Class[] { trackerfocus }).invoke(
-                tracker,
-                new Object[] { trackerfocus.getConstructor(
-                        new Class[] { String.class }).newInstance(
-                        new Object[] { "Application Started." }) });
+        tracker = jgoogleanalyticstracker
+                .getConstructor(new Class[]
+                { String.class, String.class, String.class })
+                .newInstance(new Object[]
+                { "Jalview Desktop",
+                    (vrs = jalview.bin.Cache.getProperty("VERSION") + "_"
+                            + jalview.bin.Cache.getDefault("BUILD_DATE",
+                                    "unknown")),
+                    "UA-9060947-1" });
+        jgoogleanalyticstracker
+                .getMethod("trackAsynchronously", new Class[]
+                { trackerfocus })
+                .invoke(tracker, new Object[]
+                { trackerfocus.getConstructor(new Class[] { String.class })
+                        .newInstance(new Object[]
+                        { "Application Started." }) });
       } catch (RuntimeException e)
       {
         re = e;
@@ -832,42 +830,45 @@ public class Cache
         {
           if (re != null)
           {
-            log.debug("Caught runtime exception in googletracker init:", re);
+            log.debug("Caught runtime exception in googletracker init:",
+                    re);
           }
           if (ex != null)
           {
             log.warn(
                     "Failed to initialise GoogleTracker for Jalview Desktop with version "
-                            + vrs, ex);
+                            + vrs,
+                    ex);
           }
           if (err != null)
           {
             log.error(
                     "Whilst initing GoogleTracker for Jalview Desktop version "
-                            + vrs, err);
+                            + vrs,
+                    err);
           }
         }
         else
         {
           if (re != null)
           {
-            System.err
-                    .println("Debug: Caught runtime exception in googletracker init:"
+            System.err.println(
+                    "Debug: Caught runtime exception in googletracker init:"
                             + vrs);
             re.printStackTrace();
           }
           if (ex != null)
           {
-            System.err
-                    .println("Warning:  Failed to initialise GoogleTracker for Jalview Desktop with version "
+            System.err.println(
+                    "Warning:  Failed to initialise GoogleTracker for Jalview Desktop with version "
                             + vrs);
             ex.printStackTrace();
           }
 
           if (err != null)
           {
-            System.err
-                    .println("ERROR: Whilst initing GoogleTracker for Jalview Desktop version "
+            System.err.println(
+                    "ERROR: Whilst initing GoogleTracker for Jalview Desktop version "
                             + vrs);
             err.printStackTrace();
           }
@@ -1028,7 +1029,7 @@ public class Cache
     {
       return;
     }
-  
+
     // In case colours can't be loaded, we'll remove them
     // from the default list here.
     StringBuffer coloursFound = new StringBuffer();
@@ -1057,11 +1058,13 @@ public class Cache
     {
       if (coloursFound.toString().length() > 1)
       {
-        setProperty(UserDefinedColours.USER_DEFINED_COLOURS, coloursFound.toString());
+        setProperty(UserDefinedColours.USER_DEFINED_COLOURS,
+                coloursFound.toString());
       }
       else
       {
-        applicationProperties.remove(UserDefinedColours.USER_DEFINED_COLOURS);
+        applicationProperties
+                .remove(UserDefinedColours.USER_DEFINED_COLOURS);
       }
     }
   }