2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import java.awt.Color;
24 import java.io.BufferedReader;
26 import java.io.FileInputStream;
27 import java.io.FileNotFoundException;
28 import java.io.FileOutputStream;
29 import java.io.IOException;
30 import java.io.InputStream;
31 import java.io.InputStreamReader;
32 import java.io.PrintWriter;
33 import java.io.StringWriter;
34 import java.net.Authenticator;
35 import java.net.PasswordAuthentication;
37 import java.text.DateFormat;
38 import java.text.SimpleDateFormat;
39 import java.util.ArrayList;
40 import java.util.Arrays;
41 import java.util.Collection;
42 import java.util.Collections;
43 import java.util.Date;
44 import java.util.Enumeration;
45 import java.util.HashMap;
46 import java.util.List;
47 import java.util.Locale;
49 import java.util.Properties;
50 import java.util.StringTokenizer;
51 import java.util.TreeSet;
53 import javax.swing.LookAndFeel;
54 import javax.swing.UIManager;
56 import jalview.analytics.Plausible;
57 import jalview.datamodel.PDBEntry;
58 import jalview.gui.Preferences;
59 import jalview.gui.UserDefinedColours;
60 import jalview.log.JLoggerLog4j;
61 import jalview.schemes.ColourSchemeLoader;
62 import jalview.schemes.ColourSchemes;
63 import jalview.schemes.UserColourScheme;
64 import jalview.structure.StructureImportSettings;
65 import jalview.urls.IdOrgSettings;
66 import jalview.util.ChannelProperties;
67 import jalview.util.ColorUtils;
68 import jalview.util.MessageManager;
69 import jalview.util.Platform;
70 import jalview.ws.sifts.SiftsSettings;
73 * Stores and retrieves Jalview Application Properties Lists and fields within
74 * list entries are separated by '|' symbols unless otherwise stated (|) clauses
75 * are alternative values for a tag. <br>
77 * Current properties include:
80 * logs.Axis.Level - one of the stringified Levels for log4j controlling the
81 * logging level for axis (used for web services) <br>
83 * <li>logs.Castor.Level - one of the stringified Levels for log4j controlling
84 * the logging level for castor (used for serialization) <br>
86 * <li>logs.Jalview.Level - Cache.log stringified level. <br>
88 * <li>SCREEN_WIDTH</li>
89 * <li>SCREEN_HEIGHT</li>
90 * <li>SCREEN_Y=285</li>
91 * <li>SCREEN_X=371</li>
92 * <li>SHOW_FULLSCREEN boolean</li>
93 * <li>FONT_NAME java font name for alignment text display</li>
94 * <li>FONT_SIZE size of displayed alignment text</li>
95 * <li>FONT_STYLE style of font displayed (sequence labels are always
97 * <li>GAP_SYMBOL character to treat as gap symbol (usually -,.,' ')</li>
98 * <li>LAST_DIRECTORY last directory for browsing alignment</li>
99 * <li>USER_DEFINED_COLOURS list of user defined colour scheme files</li>
100 * <li>SHOW_FULL_ID show id with '/start-end' numbers appended</li>
101 * <li>SHOW_IDENTITY show percentage identity annotation</li>
102 * <li>SHOW_QUALITY show alignment quality annotation</li>
103 * <li>SHOW_ANNOTATIONS show alignment annotation rows</li>
104 * <li>SHOW_CONSERVATION show alignment conservation annotation</li>
105 * <li>SORT_ANNOTATIONS currently either SEQUENCE_AND_LABEL or
106 * LABEL_AND_SEQUENCE</li>
107 * <li>SHOW_AUTOCALC_ABOVE true to show autocalculated annotations above
108 * sequence annotations</li>
109 * <li>CENTRE_COLUMN_LABELS centre the labels at each column in a displayed
110 * annotation row</li>
111 * <li>DEFAULT_COLOUR default colour scheme to apply for a new alignment</li>
112 * <li>DEFAULT_FILE_FORMAT file format used to save</li>
113 * <li>STARTUP_FILE file loaded on startup (may be a fully qualified url)</li>
114 * <li>SHOW_STARTUP_FILE flag to control loading of startup file</li>
115 * <li>VERSION the version of the jalview build</li>
116 * <li>BUILD_DATE date of this build</li>
117 * <li>LATEST_VERSION the latest jalview version advertised on the
118 * www.jalview.org</li>
119 * <li>PIR_MODELLER boolean indicating if PIR files are written with MODELLER
121 * <li>(FASTA,MSF,PILEUP,CLUSTAL,BLC,PIR,PFAM)_JVSUFFIX boolean for adding jv
122 * suffix to file</li>
123 * <li>RECENT_URL list of recently retrieved URLs</li>
124 * <li>RECENT_FILE list of recently opened files</li>
125 * <li>USE_PROXY flag for whether a http proxy is to be used</li>
126 * <li>PROXY_SERVER the proxy</li>
127 * <li>PROXY_PORT</li>
128 * <li>NOQUESTIONNAIRES true to prevent jalview from checking the questionnaire
130 * <li>QUESTIONNAIRE last questionnaire:responder id string from questionnaire
132 * <li>USAGESTATS (false - user prompted) Enable analytics tracker for
133 * collecting usage statistics</li>
134 * <li>SHOW_OVERVIEW boolean for overview window display</li>
135 * <li>ANTI_ALIAS boolean for smooth fonts</li>
136 * <li>RIGHT_ALIGN_IDS boolean</li>
137 * <li>AUTO_CALC_CONSENSUS boolean for automatic recalculation of consensus</li>
138 * <li>PAD_GAPS boolean</li>
139 * <li>ID_ITALICS boolean</li>
140 * <li>SHOW_JV_SUFFIX</li>
141 * <li>WRAP_ALIGNMENT</li>
142 * <li>EPS_RENDERING (Prompt each time|Lineart|Text) default for EPS rendering
144 * <li>SORT_ALIGNMENT (No sort|Id|Pairwise Identity)</li>
145 * <li>SEQUENCE_LINKS list of name|URL pairs for opening a url with
147 * <li>STORED_LINKS list of name|url pairs which user has entered but are not
149 * <li>DEFAULT_LINK name of single url to be used when user double clicks a
150 * sequence id (must be in SEQUENCE_LINKS or STORED_LINKS)
151 * <li>GROUP_LINKS list of name|URL[|<separator>] tuples - see
152 * jalview.utils.GroupURLLink for more info</li>
153 * <li>DEFAULT_BROWSER for unix</li>
154 * <li>SHOW_MEMUSAGE boolean show memory usage and warning indicator on desktop
156 * <li>VERSION_CHECK (true) check for the latest release version from
157 * www.jalview.org (or the alias given by the www.jalview.org property)</li>
158 * <li>SHOW_NPFEATS_TOOLTIP (true) show non-positional features in the Sequence
160 * <li>SHOW_DBREFS_TOOLTIP (true) show Database Cross References in the Sequence
162 * <li>SHOW_UNCONSERVED (false) only render unconserved residues - conserved
163 * displayed as '.'</li>
164 * <li>SORT_BY_TREE (false) sort the current alignment view according to the
165 * order of a newly displayed tree</li>
166 * <li>DBFETCH_USEPICR (false) use PICR to recover valid DB references from
167 * sequence ID strings before attempting retrieval from any datasource</li>
168 * <li>SHOW_GROUP_CONSENSUS (false) Show consensus annotation for groups in the
170 * <li>SHOW_GROUP_CONSERVATION (false) Show conservation annotation for groups
171 * in the alignment.</li>
172 * <li>SHOW_CONSENSUS_HISTOGRAM (false) Show consensus annotation row's
174 * <li>SHOW_CONSENSUS_LOGO (false) Show consensus annotation row's sequence
176 * <li>NORMALISE_CONSENSUS_LOGO (false) Show consensus annotation row's sequence
177 * logo normalised to row height rather than histogram height.</li>
178 * <li>FOLLOW_SELECTIONS (true) Controls whether a new alignment view should
179 * respond to selections made in other alignments containing the same sequences.
181 * <li>SHOW_JWS2_SERVICES (true) when set to false, jalview will not
182 * auto-discover JABAWS services</li>
183 * <li>JWS2HOSTURLS comma-separated list of URLs to try for JABAWS services</li>
184 * <li>SHOW_WSDISCOVERY_ERRORS (true) Controls if the web service URL discovery
185 * warning dialog box is displayed.</li>
186 * <li>ANNOTATIONCOLOUR_MIN (orange) Shade used for minimum value of annotation
187 * when shading by annotation</li>
188 * <li>ANNOTATIONCOLOUR_MAX (red) Shade used for maximum value of annotation
189 * when shading by annotation</li>
190 * <li>www.jalview.org (https://www.jalview.org) a property enabling all HTTP
191 * requests to be redirected to a mirror of https://www.jalview.org</li>
192 * <li>FIGURE_AUTOIDWIDTH (false) Expand the left hand column of an exported
193 * alignment figure to accommodate even the longest sequence ID or annotation
195 * <li>FIGURE_FIXEDIDWIDTH Specifies the width to use for the left-hand column
196 * when exporting an alignment as a figure (setting FIGURE_AUTOIDWIDTH to true
197 * will override this).</li>
198 * <li>STRUCT_FROM_PDB (false) derive secondary structure annotation from PDB
200 * <li>USE_RNAVIEW (false) use RNAViewer to derive secondary structure</li>
201 * <li>ADD_SS_ANN (false) add secondary structure annotation to alignment
203 * <li>ADD_TEMPFACT_ANN (false) add Temperature Factor annotation to alignment
205 * <li>STRUCTURE_DISPLAY choose from JMOL (default) or CHIMERA for 3D structure
207 * <li>CHIMERA_PATH specify full path to Chimera program (if non-standard)</li>
208 * <li>ID_ORG_HOSTURL location of jalview service providing identifiers.org urls
210 * <li>NONEWS - when set disables Jalview News from automatically appearing</li>
211 * <li>NOHTMLTEMPLATES - when set, the
212 * https://github.com/jalview/exporter-templates/tree/master/biojs repository is
213 * not downloaded automatically</li>
214 * <li>NOIDENTIFIERSSERVICE - when set, jalview won't automatically download
215 * available URL linkouts via www.jalview.org/services/identifiers</li>
218 * Deprecated settings:
221 * <li>DISCOVERY_START - Boolean - controls if discovery services are queried on
222 * startup (JWS1 services only)</li>
223 * <li>DISCOVERY_URLS - comma separated list of Discovery Service endpoints.
224 * (JWS1 services only)</li>
225 * <li>SHOW_JWS1_SERVICES (true) enable or disable the original Jalview 2
226 * services in the desktop GUI</li>
227 * <li>ENABLE_RSBS_EDITOR (false for 2.7 release) enable or disable RSBS editing
228 * panel in web service preferences</li>
232 * @version $Revision$
237 * property giving log4j level for CASTOR loggers
239 public static final String CASTORLOGLEVEL = "logs.Castor.level";
242 * property giving log4j level for AXIS loggers
244 public static final String AXISLOGLEVEL = "logs.Axis.level";
247 * property giving log4j level for Jalview Log
249 public static final String JALVIEWLOGLEVEL = "logs.Jalview.level";
252 public static final String BOOTSTRAP_TEST = "BOOTSTRAP_TEST";
257 public static final String DEFAULT_SIFTS_DOWNLOAD_DIR = System
258 .getProperty("user.home") + File.separatorChar
259 + ".sifts_downloads" + File.separatorChar;
261 private final static String DEFAULT_CACHE_THRESHOLD_IN_DAYS = "2";
263 private final static String DEFAULT_FAIL_SAFE_PID_THRESHOLD = "30";
266 * Identifiers.org download settings
268 private static final String ID_ORG_FILE = System.getProperty("user.home")
269 + File.separatorChar + ".identifiers.org.ids.json";
272 * Allowed values are PDB or mmCIF
274 private final static String PDB_DOWNLOAD_FORMAT = PDBEntry.Type.MMCIF
277 private final static String DEFAULT_PDB_FILE_PARSER = StructureImportSettings.StructureParser.JMOL_PARSER
281 * a date formatter using a fixed (rather than the user's) locale;
282 * this ensures that date properties can be written and re-read successfully
283 * even if the user changes their locale setting
285 private static final DateFormat date_format = SimpleDateFormat
286 .getDateTimeInstance(SimpleDateFormat.MEDIUM,
287 SimpleDateFormat.MEDIUM, Locale.UK);
290 * Initialises the Jalview Application Log
293 public final static String JALVIEW_LOGGER_NAME = "JalviewLogger";
295 // save the proxy properties set at startup
296 public final static String[] startupProxyProperties = {
297 System.getProperty("http.proxyHost"),
298 System.getProperty("http.proxyPort"),
299 System.getProperty("https.proxyHost"),
300 System.getProperty("https.proxyPort"),
301 System.getProperty("http.proxyUser"),
302 System.getProperty("http.proxyPassword"),
303 System.getProperty("https.proxyUser"),
304 System.getProperty("https.proxyPassword"),
305 System.getProperty("http.nonProxyHosts") };
307 public final static String PROXYTYPE_NONE = "none";
309 // "false" and "true" for backward compatibility
310 public final static String PROXYTYPE_SYSTEM = "false";
312 public final static String PROXYTYPE_CUSTOM = "true";
314 // in-memory only storage of proxy password, safer to use char array
315 public static char[] proxyAuthPassword = null;
318 * Session properties, set by command line, try not to affect stored
321 private static Map<String, String> sessionProperties = new HashMap<>();
323 private static boolean bypassSessionProperties = false;
325 public static void enableSessionProperties()
327 bypassSessionProperties = false;
330 public static void disableSessionProperties()
332 bypassSessionProperties = true;
335 /** Jalview Properties */
336 public static Properties applicationProperties = new Properties()
338 // override results in properties output in alphabetical order
340 public synchronized Enumeration<Object> keys()
342 return Collections.enumeration(new TreeSet<>(super.keySet()));
346 /* build Properties (not all saved to .jalview_properties) */
347 public static Properties buildProperties = new Properties();
349 /** Default file is ~/.jalview_properties */
350 static String propertiesFile;
352 private static final String fallbackPropertiesFile = ".jalview_properties";
354 private static boolean propsAreReadOnly = Platform.isJS();
356 public static boolean isPropsAreReadOnly()
358 return propsAreReadOnly;
361 public static void setPropsAreReadOnly(boolean propsAreReadOnly)
363 Cache.propsAreReadOnly = propsAreReadOnly;
366 private final static String JS_PROPERTY_PREFIX = "jalview_";
369 * Loads properties from the given properties file. Any existing properties
372 public static void loadProperties(String propsFile)
374 propertiesFile = propsFile;
375 String releasePropertiesFile = null;
376 boolean defaultProperties = false;
377 if (propsFile == null && !propsAreReadOnly)
379 String channelPrefsFilename = ChannelProperties
380 .getProperty("preferences.filename");
381 String releasePrefsFilename = fallbackPropertiesFile;
382 propertiesFile = System.getProperty("user.home") + File.separatorChar
383 + channelPrefsFilename;
384 releasePropertiesFile = System.getProperty("user.home")
385 + File.separatorChar + releasePrefsFilename;
386 defaultProperties = true;
390 // don't corrupt the file we've been given.
391 propsAreReadOnly = true;
394 if (propertiesFile == null)
396 Platform.readInfoProperties(JS_PROPERTY_PREFIX,
397 applicationProperties);
406 // props file provided as URL
407 fis = new URL(propertiesFile).openStream();
408 if (!Jalview.quiet())
411 "Loading jalview properties from : " + propertiesFile);
413 "Disabling Jalview writing to user's local properties file.");
415 propsAreReadOnly = true;
416 } catch (Exception ex)
422 String readPropertiesFile = propertiesFile;
423 // if we're using the usual properties file and the channel properties
424 // file doesn't exist, read .jalview_properties
425 // (but we'll still save to the channel properties file).
426 if (defaultProperties && (!new File(propertiesFile).exists())
427 && (new File(releasePropertiesFile).exists()))
429 readPropertiesFile = releasePropertiesFile;
431 fis = new FileInputStream(readPropertiesFile);
433 applicationProperties.clear();
434 applicationProperties.load(fis);
436 // remove any old build properties
438 deleteBuildProperties();
440 } catch (Exception ex)
442 if (!Jalview.quiet())
443 System.out.println("Error reading properties file: " + ex);
447 /* TO BE REPLACED WITH PROXY_TYPE SETTINGS
448 if (getDefault("USE_PROXY", false))
450 String proxyServer = getDefault("PROXY_SERVER", ""),
451 proxyPort = getDefault("PROXY_PORT", "8080");
455 // PROXY TYPE settings (now three options "none", "false", "true", but using
456 // backward compatible strings)
457 String proxyType = getDefault("USE_PROXY", PROXYTYPE_SYSTEM);
458 // default to upgrading old settings
462 clearProxyProperties();
464 case PROXYTYPE_SYSTEM: // use system settings
465 resetProxyProperties();
467 case PROXYTYPE_CUSTOM: // use specified proxy settings
468 String httpHost = getDefault("PROXY_SERVER", "");
469 String httpPort = getDefault("PROXY_PORT", "8080");
470 String httpsHost = getDefault("PROXY_SERVER_HTTPS", httpHost);
471 String httpsPort = getDefault("PROXY_PORT_HTTPS", httpPort);
472 String httpUser = getDefault("PROXY_AUTH_USER", null);
473 // https.proxyUser and https.proxyPassword are not able to be
474 // independently set in Preferences yet (or http.nonProxyHosts)
475 String httpsUser = getDefault("PROXY_AUTH_USER_HTTPS", httpUser);
476 setProxyProperties(httpHost, httpPort, httpsHost, httpsPort, httpUser,
477 proxyAuthPassword, httpsUser, proxyAuthPassword, "localhost");
480 String message = "Incorrect PROXY_TYPE - should be 'none' (clear proxy properties), 'false' (system settings), 'true' (custom settings): "
482 Console.warn(message);
485 // LOAD THE AUTHORS FROM THE authors.props file
486 String authorDetails = resolveResourceURLFor("/authors.props");
490 if (authorDetails != null)
492 URL localJarFileURL = new URL(authorDetails);
493 InputStream in = localJarFileURL.openStream();
494 applicationProperties.load(in);
497 } catch (Exception ex)
499 if (!Jalview.quiet())
500 System.out.println("Error reading author details: " + ex);
501 authorDetails = null;
503 if (authorDetails == null)
505 applicationProperties.remove("AUTHORS");
506 applicationProperties.remove("AUTHORFNAMES");
507 applicationProperties.remove("YEAR");
510 loadBuildProperties(false);
513 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
515 SiftsSettings.setSiftDownloadDirectory(Cache
516 .getDefault("sifts_download_dir", DEFAULT_SIFTS_DOWNLOAD_DIR));
518 SiftsSettings.setFailSafePIDThreshold(
519 Cache.getDefault("sifts_fail_safe_pid_threshold",
520 DEFAULT_FAIL_SAFE_PID_THRESHOLD));
522 SiftsSettings.setCacheThresholdInDays(
523 Cache.getDefault("sifts_cache_threshold_in_days",
524 DEFAULT_CACHE_THRESHOLD_IN_DAYS));
526 IdOrgSettings.setUrl(getDefault("ID_ORG_HOSTURL",
527 "https://www.jalview.org/services/identifiers"));
528 IdOrgSettings.setDownloadLocation(ID_ORG_FILE);
530 StructureImportSettings.setDefaultStructureFileFormat(
531 Cache.getDefault("PDB_DOWNLOAD_FORMAT", PDB_DOWNLOAD_FORMAT));
532 StructureImportSettings
533 .setDefaultPDBFileParser(DEFAULT_PDB_FILE_PARSER);
534 // StructureImportSettings
535 // .setDefaultPDBFileParser(Cache.getDefault(
536 // "DEFAULT_PDB_FILE_PARSER", DEFAULT_PDB_FILE_PARSER));
538 String jnlpVersion = System.getProperty("jalview.version");
540 // jnlpVersion will be null if a latest version check for the channel needs
542 // Dont do this check if running in headless mode
544 if (jnlpVersion == null && getDefault("VERSION_CHECK", true)
545 && (System.getProperty("java.awt.headless") == null || System
546 .getProperty("java.awt.headless").equals("false")))
549 class VersionChecker extends Thread
555 String remoteBuildPropertiesUrl = Cache
556 .getAppbaseBuildProperties();
558 String orgtimeout = System
559 .getProperty("sun.net.client.defaultConnectTimeout");
560 if (orgtimeout == null)
563 Console.debug("Setting default net timeout to " + orgtimeout
566 String remoteVersion = null;
567 if (remoteBuildPropertiesUrl.startsWith("http"))
571 System.setProperty("sun.net.client.defaultConnectTimeout",
574 URL url = new URL(remoteBuildPropertiesUrl);
576 BufferedReader in = new BufferedReader(
577 new InputStreamReader(url.openStream()));
579 Properties remoteBuildProperties = new Properties();
580 remoteBuildProperties.load(in);
581 remoteVersion = remoteBuildProperties.getProperty("VERSION");
582 } catch (Exception ex)
584 if (!Jalview.quiet())
587 "Non-fatal exception when checking version at "
588 + remoteBuildPropertiesUrl + ":");
589 System.out.println(ex);
591 remoteVersion = getProperty("VERSION");
594 System.setProperty("sun.net.client.defaultConnectTimeout",
597 setProperty("LATEST_VERSION", remoteVersion);
601 VersionChecker vc = new VersionChecker();
606 if (jnlpVersion != null)
608 setProperty("LATEST_VERSION", jnlpVersion);
612 applicationProperties.remove("LATEST_VERSION");
616 // LOAD USERDEFINED COLOURS
617 Cache.initUserColourSchemes(getProperty("USER_DEFINED_COLOURS"));
618 jalview.io.PIRFile.useModellerOutput = Cache.getDefault("PIR_MODELLER",
623 * construct a resource URL for the given absolute resource pathname
625 * @param resourcePath
628 private static String resolveResourceURLFor(String resourcePath)
631 if (Platform.isJS() || !Cache.class.getProtectionDomain()
632 .getCodeSource().getLocation().toString().endsWith(".jar"))
636 url = Cache.class.getResource(resourcePath).toString();
637 } catch (Exception ex)
639 System.err.println("Failed to resolve resource " + resourcePath
640 + ": " + ex.getMessage());
645 url = "jar:".concat(Cache.class.getProtectionDomain().getCodeSource()
646 .getLocation().toString().concat("!" + resourcePath));
651 public static void loadBuildProperties(boolean reportVersion)
653 String codeInstallation = getProperty("INSTALLATION");
654 boolean printVersion = codeInstallation == null;
657 * read build properties - from the Jalview jar for a Java distribution,
658 * or from codebase file in test or JalviewJS context
662 String buildDetails = resolveResourceURLFor("/.build_properties");
663 URL localJarFileURL = new URL(buildDetails);
664 InputStream in = localJarFileURL.openStream();
665 buildProperties.load(in);
667 if (buildProperties.getProperty("BUILD_DATE", null) != null)
669 applicationProperties.put("BUILD_DATE",
670 buildProperties.getProperty("BUILD_DATE"));
672 if (buildProperties.getProperty("INSTALLATION", null) != null)
674 applicationProperties.put("INSTALLATION",
675 buildProperties.getProperty("INSTALLATION"));
677 if (buildProperties.getProperty("VERSION", null) != null)
679 applicationProperties.put("VERSION",
680 buildProperties.getProperty("VERSION"));
682 if (buildProperties.getProperty("JAVA_COMPILE_VERSION", null) != null)
684 applicationProperties.put("JAVA_COMPILE_VERSION",
685 buildProperties.getProperty("JAVA_COMPILE_VERSION"));
687 } catch (Exception ex)
689 if (!Jalview.quiet())
690 System.out.println("Error reading build details: " + ex);
691 applicationProperties.remove("VERSION");
693 String codeVersion = getProperty("VERSION");
694 codeInstallation = getProperty("INSTALLATION");
696 if (codeVersion == null)
698 // THIS SHOULD ONLY BE THE CASE WHEN TESTING!!
699 codeVersion = "Test";
700 codeInstallation = "";
704 codeInstallation = " (" + codeInstallation + ")";
706 setProperty("VERSION", codeVersion);
707 new BuildDetails(codeVersion, null, codeInstallation);
708 if (printVersion && reportVersion)
710 System.out.println(ChannelProperties.getProperty("app_name")
711 + " version: " + codeVersion + codeInstallation);
715 private static void deleteBuildProperties()
717 applicationProperties.remove("LATEST_VERSION");
718 applicationProperties.remove("VERSION");
719 applicationProperties.remove("AUTHORS");
720 applicationProperties.remove("AUTHORFNAMES");
721 applicationProperties.remove("YEAR");
722 applicationProperties.remove("BUILD_DATE");
723 applicationProperties.remove("INSTALLATION");
727 * Gets Jalview application property of given key. Returns null if key not
733 * @return Property value
735 public static String getProperty(String key)
737 return getProperty(key, false);
740 public static String getProperty(String key,
741 boolean skipSessionProperties)
744 if (!(skipSessionProperties || bypassSessionProperties))
746 prop = getSessionProperty(key);
750 prop = applicationProperties.getProperty(key);
752 if (prop == null && Platform.isJS())
754 prop = applicationProperties.getProperty(Platform.getUniqueAppletID()
755 + "_" + JS_PROPERTY_PREFIX + key);
761 * These methods are used when checking if the saved preference is different
762 * to the default setting
765 public static boolean getDefault(String property, boolean def)
767 String string = getProperty(property);
770 def = Boolean.valueOf(string).booleanValue();
776 public static int getDefault(String property, int def)
778 String string = getProperty(property);
783 def = Integer.parseInt(string);
784 } catch (NumberFormatException e)
786 if (!Jalview.quiet())
787 System.out.println("Error parsing int property '" + property
788 + "' with value '" + string + "'");
796 * Answers the value of the given property, or the supplied default value if
797 * the property is not set
799 public static String getDefault(String property, String def)
801 String value = getProperty(property);
802 return value == null ? def : value;
806 * Stores property in the file "HOME_DIR/.jalview_properties"
811 * String value of property
813 * @return previous value of property (or null)
815 public static Object setProperty(String key, String obj)
817 Object oldValue = null;
820 oldValue = applicationProperties.setProperty(key, obj);
821 if (propertiesFile != null && !propsAreReadOnly
822 // don't rewrite if new value is same as old value
823 && !((obj == null && oldValue == null)
824 || (obj != null && obj.equals(oldValue))))
826 // reset the session property too
827 if (sessionProperties.containsKey(key))
829 sessionProperties.remove(key);
831 FileOutputStream out = new FileOutputStream(propertiesFile);
832 applicationProperties.store(out, "---JalviewX Properties File---");
835 } catch (Exception ex)
837 if (!Jalview.quiet())
839 "Error setting property: " + key + " " + obj + "\n" + ex);
845 * remove the specified property from the jalview properties file
849 public static void removeProperty(String string)
851 applicationProperties.remove(string);
856 * save the properties to the jalview properties path
858 public static void saveProperties()
860 if (!propsAreReadOnly)
864 FileOutputStream out = new FileOutputStream(propertiesFile);
865 applicationProperties.store(out, "---JalviewX Properties File---");
867 } catch (Exception ex)
869 if (!Jalview.quiet())
870 System.out.println("Error saving properties: " + ex);
876 * internal vamsas class discovery state
878 private static int vamsasJarsArePresent = -1;
881 * Searches for vamsas client classes on class path.
883 * @return true if vamsas client is present on classpath
885 public static boolean vamsasJarsPresent()
887 if (vamsasJarsArePresent == -1)
891 if (jalview.jbgui.GDesktop.class.getClassLoader()
892 .loadClass("uk.ac.vamsas.client.VorbaId") != null)
895 "Found Vamsas Classes (uk.ac..vamsas.client.VorbaId can be loaded)");
896 vamsasJarsArePresent = 1;
897 JLoggerLog4j lvclient = JLoggerLog4j.getLogger("uk.ac.vamsas",
898 Console.getCachedLogLevel("logs.Vamsas.Level"));
899 JLoggerLog4j.addAppender(lvclient, Console.log,
900 JALVIEW_LOGGER_NAME);
901 // Tell the user that debug is enabled
902 lvclient.debug(ChannelProperties.getProperty("app_name")
903 + " Vamsas Client Debugging Output Follows.");
905 } catch (Exception e)
907 vamsasJarsArePresent = 0;
908 Console.debug("Vamsas Classes are not present");
911 return (vamsasJarsArePresent > 0);
915 * internal vamsas class discovery state
917 private static int groovyJarsArePresent = -1;
920 * Searches for vamsas client classes on class path.
922 * @return true if vamsas client is present on classpath
924 public static boolean groovyJarsPresent()
926 if (groovyJarsArePresent == -1)
930 if (Cache.class.getClassLoader()
931 .loadClass("groovy.lang.GroovyObject") != null)
934 "Found Groovy (groovy.lang.GroovyObject can be loaded)");
935 groovyJarsArePresent = 1;
936 JLoggerLog4j lgclient = JLoggerLog4j.getLogger("groovy",
937 Console.getCachedLogLevel("logs.Groovy.Level"));
938 JLoggerLog4j.addAppender(lgclient, Console.log,
939 JALVIEW_LOGGER_NAME);
940 // Tell the user that debug is enabled
941 lgclient.debug(ChannelProperties.getProperty("app_name")
942 + " Groovy Client Debugging Output Follows.");
946 groovyJarsArePresent = 0;
947 Console.debug("Groovy Classes are not present", e);
948 } catch (Exception e)
950 groovyJarsArePresent = 0;
951 Console.debug("Groovy Classes are not present");
954 return (groovyJarsArePresent > 0);
958 * Initialise the tracker if it is not done already.
960 public static void initAnalytics()
962 Plausible.setEnabled(true);
964 String appName = ChannelProperties.getProperty("app_name") + " Desktop";
965 String version = Cache.getProperty("VERSION") + "_"
966 + Cache.getDefault("BUILD_DATE", "unknown");
968 /* we don't want to encode ':' as "%3A" for backward compatibility with the UA setup
971 path = "/" + String.join("/", URLEncoder.encode(appName, "UTF-8"),
972 URLEncoder.encode(version, "UTF-8"),
973 URLEncoder.encode(APPLICATION_STARTED, "UTF-8"));
974 } catch (UnsupportedEncodingException e)
977 List<String> pathParts = new ArrayList<>();
978 pathParts.add(appName);
979 pathParts.add(version);
980 pathParts.add(APPLICATION_STARTED);
981 path = ("/" + String.join("/", pathParts)).replace(' ', '+');
985 Plausible plausible = Plausible.getInstance();
987 // This will send a new "application_launch" event with parameters
988 // including the old-style "path", the channel name and version
989 plausible.sendEvent("application_launch", path, true);
992 private static final String APPLICATION_STARTED = "Application Started";
995 * get the user's default colour if available
1001 public static Color getDefaultColour(String property, Color defcolour)
1003 String colprop = getProperty(property);
1004 if (colprop == null)
1008 Color col = ColorUtils.parseColourString(colprop);
1011 Console.warn("Couldn't parse '" + colprop + "' as a colour for "
1014 return (col == null) ? defcolour : col;
1018 * store a colour as a Jalview user default property
1023 public static void setColourProperty(String property, Color colour)
1025 setProperty(property, jalview.util.Format.getHexString(colour));
1029 * Stores a formatted date in a jalview property, using a fixed locale.
1031 * @param propertyName
1033 * @return the formatted date string
1035 public static String setDateProperty(String propertyName, Date date)
1037 String formatted = date_format.format(date);
1038 setProperty(propertyName, formatted);
1043 * Reads a date stored in a Jalview property, parses it (using a fixed locale
1044 * format) and returns as a Date, or null if parsing fails
1046 * @param propertyName
1050 public static Date getDateProperty(String propertyName)
1052 String val = getProperty(propertyName);
1057 return date_format.parse(val);
1058 } catch (Exception ex)
1060 System.err.println("Invalid or corrupt date in property '"
1061 + propertyName + "' : value was '" + val + "'");
1068 * get and parse a property as an integer. send any parsing problems to
1072 * @return null or Integer
1074 public static Integer getIntegerProperty(String property)
1076 String val = getProperty(property);
1077 if (val != null && (val = val.trim()).length() > 0)
1081 return Integer.valueOf(val);
1082 } catch (NumberFormatException x)
1084 System.err.println("Invalid integer in property '" + property
1085 + "' (value was '" + val + "')");
1092 * Set the specified value, or remove it if null or empty. Does not save the
1098 public static void setOrRemove(String propName, String value)
1100 if (propName == null)
1104 if (value == null || value.trim().length() < 1)
1106 Cache.applicationProperties.remove(propName);
1110 Cache.applicationProperties.setProperty(propName, value);
1115 * Loads in user colour schemes from files.
1118 * a '|'-delimited list of file paths
1120 public static void initUserColourSchemes(String files)
1122 if (files == null || files.length() == 0)
1127 // In case colours can't be loaded, we'll remove them
1128 // from the default list here.
1129 StringBuffer coloursFound = new StringBuffer();
1130 StringTokenizer st = new StringTokenizer(files, "|");
1131 while (st.hasMoreElements())
1133 String file = st.nextToken();
1136 UserColourScheme ucs = ColourSchemeLoader.loadColourScheme(file);
1139 if (coloursFound.length() > 0)
1141 coloursFound.append("|");
1143 coloursFound.append(file);
1144 ColourSchemes.getInstance().registerColourScheme(ucs);
1146 } catch (Exception ex)
1148 if (!Jalview.quiet())
1149 System.out.println("Error loading User ColourFile\n" + ex);
1152 if (!files.equals(coloursFound.toString()))
1154 if (coloursFound.toString().length() > 1)
1156 setProperty(UserDefinedColours.USER_DEFINED_COLOURS,
1157 coloursFound.toString());
1161 applicationProperties
1162 .remove(UserDefinedColours.USER_DEFINED_COLOURS);
1168 * Initial logging information helper for various versions output
1172 * @param defaultValue
1174 private static void appendIfNotNull(StringBuilder sb, String prefix,
1175 String value, String suffix, String defaultValue)
1177 if (value == null && defaultValue == null)
1183 sb.append(value == null ? defaultValue : value);
1190 * @return Jalview version, build details and JVM platform version for console
1192 public static String getVersionDetailsForConsole()
1194 StringBuilder sb = new StringBuilder();
1195 sb.append(ChannelProperties.getProperty("app_name"))
1196 .append(" Version: ");
1197 sb.append(Cache.getDefault("VERSION", "TEST"));
1199 sb.append(ChannelProperties.getProperty("app_name"))
1200 .append(" Installation: ");
1201 sb.append(Cache.getDefault("INSTALLATION", "unknown"));
1203 sb.append("Build Date: ");
1204 sb.append(Cache.getDefault("BUILD_DATE", "unknown"));
1206 sb.append("Java version: ");
1207 sb.append(System.getProperty("java.version"));
1209 sb.append("Java platform: ");
1210 sb.append(System.getProperty("os.arch"));
1212 sb.append(System.getProperty("os.name"));
1214 sb.append(System.getProperty("os.version"));
1216 appendIfNotNull(sb, "Install4j version: ",
1217 System.getProperty("sys.install4jVersion"), "\n", null);
1218 appendIfNotNull(sb, "Install4j template version: ",
1219 System.getProperty("installer_template_version"), "\n", null);
1220 appendIfNotNull(sb, "Launcher version: ",
1221 System.getProperty("launcher_version"), "\n", null);
1222 LookAndFeel laf = UIManager.getLookAndFeel();
1223 String lafName = laf == null ? "Not obtained" : laf.getName();
1224 String lafClass = laf == null ? "unknown" : laf.getClass().getName();
1225 sb.append("LookAndFeel: ");
1228 sb.append(lafClass);
1230 appendIfNotNull(sb, "Channel: ",
1231 ChannelProperties.getProperty("channel"), "\n", null);
1232 if (Console.isDebugEnabled()
1233 || !"release".equals(ChannelProperties.getProperty("channel")))
1235 appendIfNotNull(sb, "Getdown appdir: ",
1236 System.getProperty("getdowninstanceappdir"), "\n", null);
1237 appendIfNotNull(sb, "Getdown appbase: ",
1238 System.getProperty("getdowninstanceappbase"), "\n", null);
1239 appendIfNotNull(sb, "Java home: ", System.getProperty("java.home"),
1241 appendIfNotNull(sb, "Preferences file: ", propertiesFile, "\n",
1244 return sb.toString();
1249 * @return build details as reported in splashscreen
1251 public static String getBuildDetailsForSplash()
1253 // consider returning more human friendly info
1254 // eg 'built from Source' or update channel
1255 return Cache.getDefault("INSTALLATION", "unknown");
1258 public static String getStackTraceString(Throwable t)
1260 StringWriter sw = new StringWriter();
1261 PrintWriter pw = new PrintWriter(sw);
1262 t.printStackTrace(pw);
1263 return sw.toString();
1266 // proxy properties methods
1267 public static void clearProxyProperties()
1269 setProxyProperties(null, null, null, null, null, null, null, null,
1273 public static void resetProxyProperties()
1275 setProxyProperties(startupProxyProperties[0], startupProxyProperties[1],
1276 startupProxyProperties[2], startupProxyProperties[3],
1277 startupProxyProperties[4],
1278 startupProxyProperties[5] == null ? null
1279 : startupProxyProperties[5].toCharArray(),
1280 startupProxyProperties[6],
1281 startupProxyProperties[7] == null ? null
1282 : startupProxyProperties[7].toCharArray(),
1283 startupProxyProperties[8]);
1284 StringBuilder sb = new StringBuilder();
1285 sb.append("Setting proxy properties to: http.proxyHost=")
1286 .append(startupProxyProperties[0]).append(", http.proxyPort=")
1287 .append(startupProxyProperties[1])
1288 .append(startupProxyProperties[4] != null
1289 && !startupProxyProperties[4].isEmpty()
1290 ? " [" + startupProxyProperties[4] + "]"
1292 .append(", https.proxyHost=").append(startupProxyProperties[2])
1293 .append(", https.proxyPort=").append(startupProxyProperties[3])
1294 .append(startupProxyProperties[6] != null
1295 && !startupProxyProperties[6].isEmpty()
1296 ? " [" + startupProxyProperties[6] + "]"
1299 Console.debug(sb.toString());
1302 public static void setProxyPropertiesFromPreferences()
1304 setProxyPropertiesFromPreferences(Cache.PROXYTYPE_SYSTEM);
1307 public static void setProxyPropertiesFromPreferences(
1308 String previousProxyType)
1310 String proxyType = Cache.getDefault("USE_PROXY",
1311 Cache.PROXYTYPE_SYSTEM);
1312 if (previousProxyType != null
1313 && !proxyType.equals(Cache.PROXYTYPE_CUSTOM) // always apply
1315 && proxyType.equals(previousProxyType))
1322 case Cache.PROXYTYPE_NONE:
1323 if (!previousProxyType.equals(proxyType))
1325 Console.info("Setting no proxy settings");
1326 Cache.setProxyProperties(null, null, null, null, null, null, null,
1330 case Cache.PROXYTYPE_CUSTOM:
1331 // always re-set a custom proxy -- it might have changed, particularly
1333 Console.info("Setting custom proxy settings");
1334 boolean proxyAuthSet = Cache.getDefault("PROXY_AUTH", false);
1335 Cache.setProxyProperties(Cache.getDefault("PROXY_SERVER", null),
1336 Cache.getDefault("PROXY_PORT", null),
1337 Cache.getDefault("PROXY_SERVER_HTTPS", null),
1338 Cache.getDefault("PROXY_PORT_HTTPS", null),
1339 proxyAuthSet ? Cache.getDefault("PROXY_AUTH_USERNAME", "")
1341 proxyAuthSet ? Cache.proxyAuthPassword : null,
1342 proxyAuthSet ? Cache.getDefault("PROXY_AUTH_USERNAME", "")
1344 proxyAuthSet ? Cache.proxyAuthPassword : null, "localhost");
1346 default: // system proxy settings by default
1347 Console.info("Setting system proxy settings");
1348 Cache.resetProxyProperties();
1352 public static void setProxyProperties(String httpHost, String httpPort,
1353 String httpsHost, String httpsPort, String httpUser,
1354 char[] httpPassword, String httpsUser, char[] httpsPassword,
1355 String nonProxyHosts)
1357 setOrClearSystemProperty("http.proxyHost", httpHost);
1358 setOrClearSystemProperty("http.proxyPort", httpPort);
1359 setOrClearSystemProperty("https.proxyHost", httpsHost);
1360 setOrClearSystemProperty("https.proxyPort", httpsPort);
1361 setOrClearSystemProperty("http.proxyUser", httpUser);
1362 setOrClearSystemProperty("https.proxyUser", httpsUser);
1363 // note: passwords for http.proxyPassword and https.proxyPassword are sent
1364 // via the Authenticator, properties do not need to be set
1366 // are we using a custom proxy (password prompt might be required)?
1367 boolean customProxySet = getDefault("USE_PROXY", PROXYTYPE_SYSTEM)
1368 .equals(PROXYTYPE_CUSTOM);
1371 * A bug in Java means the AuthCache does not get reset, so once it has working credentials,
1372 * it never asks for more, so changing the Authenticator has no effect (as getPasswordAuthentication()
1373 * is not re-called).
1374 * This could lead to password leak to a hostile proxy server, so I'm putting in a hack to clear
1376 * see https://www.generacodice.com/en/articolo/154918/Reset-the-Authenticator-credentials
1378 * Turns out this is only accessible in Java 8, and not in Java 9 onwards, so commenting out
1383 sun.net.www.protocol.http.AuthCacheValue
1384 .setAuthCache(new sun.net.www.protocol.http.AuthCacheImpl());
1385 } catch (Throwable t)
1387 Cache.error(t.getMessage());
1388 Cache.debug(getStackTraceString(t));
1392 if (httpUser != null || httpsUser != null)
1396 char[] displayHttpPw = new char[httpPassword == null ? 0
1397 : httpPassword.length];
1398 Arrays.fill(displayHttpPw, '*');
1400 "CACHE Proxy: setting new Authenticator with httpUser='"
1401 + httpUser + "' httpPassword='" + displayHttpPw
1403 if (!Platform.isJS())
1405 * java.net.Authenticator not implemented in SwingJS yet
1411 Authenticator.setDefault(new Authenticator()
1414 protected PasswordAuthentication getPasswordAuthentication()
1416 if (getRequestorType() == RequestorType.PROXY)
1418 String protocol = getRequestingProtocol();
1419 boolean needProxyPasswordSet = false;
1420 if (customProxySet &&
1421 // we have a username but no password for the scheme being
1423 (protocol.equalsIgnoreCase("http")
1424 && (httpUser != null
1425 && httpUser.length() > 0
1426 && (httpPassword == null
1427 || httpPassword.length == 0)))
1428 || (protocol.equalsIgnoreCase("https")
1429 && (httpsUser != null
1430 && httpsUser.length() > 0
1431 && (httpsPassword == null
1432 || httpsPassword.length == 0))))
1434 // open Preferences -> Connections
1435 String message = MessageManager
1436 .getString("label.proxy_password_required");
1437 Preferences.openPreferences(
1438 Preferences.TabRef.CONNECTIONS_TAB, message);
1439 Preferences.getInstance()
1440 .proxyAuthPasswordCheckHighlight(true, true);
1446 if (protocol.equalsIgnoreCase("http")
1447 && getRequestingHost()
1448 .equalsIgnoreCase(httpHost)
1449 && getRequestingPort() == Integer
1453 "AUTHENTICATOR returning PasswordAuthentication(\""
1454 + httpUser + "\", '"
1455 + new String(displayHttpPw) + "')");
1456 return new PasswordAuthentication(httpUser,
1459 if (protocol.equalsIgnoreCase("https")
1460 && getRequestingHost()
1461 .equalsIgnoreCase(httpsHost)
1462 && getRequestingPort() == Integer
1463 .valueOf(httpsPort))
1465 char[] displayHttpsPw = new char[httpPassword.length];
1466 Arrays.fill(displayHttpsPw, '*');
1468 "AUTHENTICATOR returning PasswordAuthentication(\""
1469 + httpsUser + "\", '" + displayHttpsPw
1471 return new PasswordAuthentication(httpsUser,
1474 } catch (NumberFormatException e)
1476 Console.error("Problem with proxy port values [http:"
1477 + httpPort + ", https:" + httpsPort + "]");
1480 "AUTHENTICATOR after trying to get PasswordAuthentication");
1483 // non proxy request
1484 Console.debug("AUTHENTICATOR returning null");
1488 } // end of j2sIgnore for java.net.Authenticator
1490 // required to re-enable basic authentication (should be okay for a
1493 "AUTHENTICATOR setting property 'jdk.http.auth.tunneling.disabledSchemes' to \"\"");
1494 System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
1495 } catch (SecurityException e)
1497 Console.error("Could not set default Authenticator");
1498 Console.debug(getStackTraceString(e));
1503 // reset the Authenticator to protect http.proxyUser and
1504 // http.proxyPassword Just In Case
1505 /* as noted above, due to bug in java this doesn't work if the sun.net.www.protocol.http.AuthCache
1506 * has working credentials. No workaround for Java 11.
1508 if (!Platform.isJS())
1510 * java.net.Authenticator not implemented in SwingJS yet
1517 "AUTHENTICATOR setting default Authenticator to null");
1518 Authenticator.setDefault(null);
1522 // nonProxyHosts not currently configurable in Preferences
1524 "AUTHENTICATOR setting property 'http.nonProxyHosts' to \""
1525 + nonProxyHosts + "\"");
1526 setOrClearSystemProperty("http.nonProxyHosts", nonProxyHosts);
1529 public static void setOrClearSystemProperty(String key, char[] value)
1531 setOrClearSystemProperty(key,
1532 (value == null) ? null : new String(value));
1535 public static void setOrClearSystemProperty(String key, String value)
1543 System.clearProperty(key);
1547 System.setProperty(key, value);
1552 * Getdown appbase methods
1555 private static final String releaseAppbase;
1557 private static String getdownAppbase;
1559 private static String getdownDistDir;
1563 if (!Platform.isJS())
1565 Float specversion = Float
1566 .parseFloat(System.getProperty("java.specification.version"));
1567 releaseAppbase = (specversion < 9)
1568 ? "https://www.jalview.org/getdown/release/1.8"
1569 : "https://www.jalview.org/getdown/release/11";
1573 // this value currenly made up, can be changed to URL that will be
1574 // "https://www.jalview.org/jalview-js/swingjs/j2s/build_properties"
1575 releaseAppbase = "https://www.jalview.org/jalview-js";
1576 getdownAppbase = releaseAppbase;
1577 getdownDistDir = "/swingjs/j2s";
1581 // look for properties (passed in by getdown) otherwise default to release
1582 private static void setGetdownAppbase()
1584 if (getdownAppbase != null)
1588 String appbase = System.getProperty("getdownappbase");
1589 String distDir = System.getProperty("getdowndistdir");
1590 if (appbase == null)
1592 appbase = buildProperties.getProperty("GETDOWNAPPBASE");
1593 distDir = buildProperties.getProperty("GETDOWNAPPDISTDIR");
1595 if (appbase == null)
1597 appbase = releaseAppbase;
1598 distDir = "release";
1600 if (appbase.endsWith("/"))
1602 appbase = appbase.substring(0, appbase.length() - 1);
1604 if (distDir == null)
1606 distDir = appbase.equals(releaseAppbase) ? "release" : "alt";
1608 getdownAppbase = appbase;
1609 getdownDistDir = distDir;
1612 public static String getGetdownAppbase()
1614 setGetdownAppbase();
1615 return getdownAppbase;
1618 public static String getAppbaseBuildProperties()
1620 String appbase = getGetdownAppbase();
1621 return appbase + "/" + getdownDistDir + "/build_properties";
1624 private static final Collection<String> bootstrapProperties = new ArrayList<>(
1625 Arrays.asList(JALVIEWLOGLEVEL, BOOTSTRAP_TEST));
1627 public static Properties bootstrapProperties(String filename)
1629 Properties bootstrapProps = new Properties();
1631 if (filename != null)
1633 file = new File(filename);
1635 if (file == null || !file.exists())
1637 String channelPrefsFilename = ChannelProperties
1638 .getProperty("preferences.filename");
1639 String propertiesFilename = System.getProperty("user.home")
1640 + File.separatorChar + channelPrefsFilename;
1641 file = new File(propertiesFilename);
1643 if (file == null || !file.exists())
1645 String releasePrefsFilename = fallbackPropertiesFile;
1646 String releasePropertiesFilename = System.getProperty("user.home")
1647 + File.separatorChar + releasePrefsFilename;
1648 file = new File(releasePropertiesFilename);
1651 if (filename == null)
1655 System.err.println("Could not load bootstrap preferences file '"
1662 FileInputStream in = new FileInputStream(file.getAbsoluteFile());
1663 Properties props = new Properties();
1665 for (String prop : bootstrapProperties)
1667 if (props.containsKey(prop))
1668 bootstrapProps.put(prop, props.getProperty(prop));
1670 } catch (FileNotFoundException e)
1672 System.err.println("Could not find bootstrap preferences file '"
1673 + file.getAbsolutePath() + "'");
1674 } catch (IOException e)
1677 "IOException when loading bootstrap preferences file '"
1678 + file.getAbsolutePath() + "'");
1680 return bootstrapProps;
1683 public static void setSessionProperty(String key, String val)
1687 sessionProperties.put(key, val);
1691 public static String getSessionProperty(String key)
1693 return key == null ? null : sessionProperties.get(key);