X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2FCache.java;h=8412dabcc0bbd700627fdcb1189a00fa924fc774;hb=37de9310bec3501cbc6381e0c3dcb282fcaad812;hp=24ed1b4179fab2a284198e233698bcc1324c0343;hpb=4167762603a83df3e00713307e6522bb027bdd59;p=jalview.git diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 24ed1b4..8412dab 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) - * Copyright (C) 2014 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * @@ -20,8 +20,11 @@ */ package jalview.bin; +import jalview.datamodel.PDBEntry; +import jalview.structure.StructureImportSettings; import jalview.ws.dbsources.das.api.DasSourceRegistryI; import jalview.ws.dbsources.das.datamodel.DasSourceRegistry; +import jalview.ws.sifts.SiftsSettings; import java.awt.Color; import java.io.BufferedReader; @@ -35,6 +38,7 @@ import java.text.SimpleDateFormat; import java.util.Collections; import java.util.Date; import java.util.Enumeration; +import java.util.Locale; import java.util.Properties; import java.util.TreeSet; @@ -150,6 +154,7 @@ import org.apache.log4j.SimpleLayout; *
  • FOLLOW_SELECTIONS (true) Controls whether a new alignment view should * respond to selections made in other alignments containing the same sequences. *
  • + *
  • JWS2HOSTURLS comma-separated list of URLs to try for JABAWS services
  • *
  • SHOW_WSDISCOVERY_ERRORS (true) Controls if the web service URL discovery * warning dialog box is displayed.
  • *
  • ANNOTATIONCOLOUR_MIN (orange) Shade used for minimum value of annotation @@ -215,17 +220,46 @@ public class Cache public static final String DAS_ACTIVE_SOURCE = "DAS_ACTIVE_SOURCE"; + public static final String DEFAULT_SIFTS_DOWNLOAD_DIR = System + .getProperty("user.home") + + File.separatorChar + + ".sifts_downloads" + File.separatorChar; + + private final static String DEFAULT_CACHE_THRESHOLD_IN_DAYS = "2"; + + private final static String DEFAULT_FAIL_SAFE_PID_THRESHOLD = "30"; + + /** + * Allowed values are PDB or mmCIF + */ + private final static String PDB_DOWNLOAD_FORMAT = PDBEntry.Type.MMCIF + .toString(); + + private final static String DEFAULT_PDB_FILE_PARSER = StructureImportSettings.StructureParser.JMOL_PARSER + .toString(); + + /* + * a date formatter using a fixed (rather than the user's) locale; + * this ensures that date properties can be written and re-read successfully + * even if the user changes their locale setting + */ + private static final DateFormat date_format = SimpleDateFormat + .getDateTimeInstance(SimpleDateFormat.MEDIUM, + SimpleDateFormat.MEDIUM, Locale.UK); + /** * Initialises the Jalview Application Log */ public static Logger log; /** Jalview Properties */ - public static Properties applicationProperties = new Properties() { + public static Properties applicationProperties = new Properties() + { // override results in properties output in alphabetical order @Override - public synchronized Enumeration keys() { - return Collections.enumeration(new TreeSet(super.keySet())); + public synchronized Enumeration keys() + { + return Collections.enumeration(new TreeSet(super.keySet())); } }; @@ -314,9 +348,9 @@ public class Cache fis = new FileInputStream(propertiesFile); } applicationProperties.load(fis); - + // remove any old build properties - + deleteBuildProperties(); fis.close(); } catch (Exception ex) @@ -378,16 +412,44 @@ public class Cache String jnlpVersion = System.getProperty("jalview.version"); String codeVersion = getProperty("VERSION"); - + String codeInstallation = getProperty("INSTALLATION"); if (codeVersion == null) { // THIS SHOULD ONLY BE THE CASE WHEN TESTING!! codeVersion = "Test"; jnlpVersion = "Test"; + codeInstallation = ""; + } + else + { + codeInstallation = " (" + codeInstallation + ")"; } + new BuildDetails(codeVersion, null, codeInstallation); + + SiftsSettings + .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false)); + + 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)); - System.out.println("Jalview Version: " + codeVersion); + SiftsSettings.setCacheThresholdInDays(jalview.bin.Cache.getDefault( + "sifts_cache_threshold_in_days", + DEFAULT_CACHE_THRESHOLD_IN_DAYS)); + System.out + .println("Jalview Version: " + codeVersion + codeInstallation); + + StructureImportSettings.setDefaultStructureFileFormat(jalview.bin.Cache + .getDefault("PDB_DOWNLOAD_FORMAT", PDB_DOWNLOAD_FORMAT)); + StructureImportSettings + .setDefaultPDBFileParser(DEFAULT_PDB_FILE_PARSER); + // StructureImportSettings + // .setDefaultPDBFileParser(jalview.bin.Cache.getDefault( + // "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 @@ -398,6 +460,7 @@ public class Cache class VersionChecker extends Thread { + @Override public void run() { String orgtimeout = System @@ -408,7 +471,7 @@ public class Cache System.out.println("# INFO: Setting default net timeout to " + orgtimeout + " seconds."); } - String jnlpVersion = null; + String remoteVersion = null; try { System.setProperty("sun.net.client.defaultConnectTimeout", @@ -428,20 +491,20 @@ public class Cache line = line.substring(line.indexOf("value=") + 7); line = line.substring(0, line.lastIndexOf("\"")); - jnlpVersion = line; + remoteVersion = line; break; } } catch (Exception ex) { System.out - .println("Non-fatal exceptions when checking version at www.jalview.org :"); + .println("Non-fatal exception when checking version at www.jalview.org :"); System.out.println(ex); - jnlpVersion = getProperty("VERSION"); + remoteVersion = getProperty("VERSION"); } System.setProperty("sun.net.client.defaultConnectTimeout", orgtimeout); - setProperty("LATEST_VERSION", jnlpVersion); + setProperty("LATEST_VERSION", remoteVersion); } } @@ -476,6 +539,8 @@ public class Cache applicationProperties.remove("AUTHORS"); applicationProperties.remove("AUTHORFNAMES"); applicationProperties.remove("YEAR"); + applicationProperties.remove("BUILD_DATE"); + applicationProperties.remove("INSTALLATION"); } /** @@ -709,21 +774,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" }); + 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." }) }); + new Class[] { trackerfocus }).invoke( + tracker, + new Object[] { trackerfocus.getConstructor( + new Class[] { String.class }).newInstance( + new Object[] { "Application Started." }) }); } catch (RuntimeException e) { re = e; @@ -830,30 +896,31 @@ public class Cache setProperty(property, jalview.util.Format.getHexString(colour)); } - public static final DateFormat date_format = SimpleDateFormat - .getDateTimeInstance(); - /** - * store a date in a jalview property + * Stores a formatted date in a jalview property, using a fixed locale. * - * @param string - * @param time + * @param propertyName + * @param date + * @return the formatted date string */ - public static void setDateProperty(String property, Date time) + public static String setDateProperty(String propertyName, Date date) { - setProperty(property, date_format.format(time)); + String formatted = date_format.format(date); + setProperty(propertyName, formatted); + return formatted; } /** - * read a date stored in a jalview property + * Reads a date stored in a Jalview property, parses it (using a fixed locale + * format) and returns as a Date, or null if parsing fails * - * @param property - * @return valid date as stored by setDateProperty, or null + * @param propertyName + * @return * */ - public static Date getDateProperty(String property) + public static Date getDateProperty(String propertyName) { - String val = getProperty(property); + String val = getProperty(propertyName); if (val != null) { try @@ -862,7 +929,7 @@ public class Cache } catch (Exception ex) { System.err.println("Invalid or corrupt date in property '" - + property + "' : value was '" + val + "'"); + + propertyName + "' : value was '" + val + "'"); } } return null;