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.FileOutputStream;
28 import java.io.InputStream;
29 import java.io.InputStreamReader;
30 import java.io.PrintWriter;
31 import java.io.StringWriter;
32 import java.net.Authenticator;
33 import java.net.PasswordAuthentication;
35 import java.text.DateFormat;
36 import java.text.SimpleDateFormat;
37 import java.util.Arrays;
38 import java.util.Collections;
39 import java.util.Date;
40 import java.util.Enumeration;
41 import java.util.Locale;
42 import java.util.Properties;
43 import java.util.StringTokenizer;
44 import java.util.TreeSet;
45 import java.util.regex.Pattern;
47 import javax.swing.LookAndFeel;
48 import javax.swing.UIManager;
50 import org.apache.log4j.ConsoleAppender;
51 import org.apache.log4j.Level;
52 import org.apache.log4j.Logger;
53 import org.apache.log4j.SimpleLayout;
54 import org.apache.log4j.builders.appender.ConsoleAppenderBuilder;
55 import org.apache.logging.log4j.core.config.Configurator;
56 import org.apache.logging.log4j.core.config.builder.api.AppenderComponentBuilder;
57 import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilder;
58 import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory;
59 import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration;
61 import jalview.datamodel.PDBEntry;
62 import jalview.gui.Preferences;
63 import jalview.gui.UserDefinedColours;
64 import jalview.schemes.ColourSchemeLoader;
65 import jalview.schemes.ColourSchemes;
66 import jalview.schemes.UserColourScheme;
67 import jalview.structure.StructureImportSettings;
68 import jalview.urls.IdOrgSettings;
69 import jalview.util.ChannelProperties;
70 import jalview.util.ColorUtils;
71 import jalview.util.MessageManager;
72 import jalview.util.Platform;
73 import jalview.ws.sifts.SiftsSettings;
76 * Stores and retrieves Jalview Application Properties Lists and fields within
77 * list entries are separated by '|' symbols unless otherwise stated (|) clauses
78 * are alternative values for a tag. <br>
80 * Current properties include:
83 * logs.Axis.Level - one of the stringified Levels for log4j controlling the
84 * logging level for axis (used for web services) <br>
86 * <li>logs.Castor.Level - one of the stringified Levels for log4j controlling
87 * the logging level for castor (used for serialization) <br>
89 * <li>logs.Jalview.Level - Cache.log stringified level. <br>
91 * <li>SCREEN_WIDTH</li>
92 * <li>SCREEN_HEIGHT</li>
93 * <li>SCREEN_Y=285</li>
94 * <li>SCREEN_X=371</li>
95 * <li>SHOW_FULLSCREEN boolean</li>
96 * <li>FONT_NAME java font name for alignment text display</li>
97 * <li>FONT_SIZE size of displayed alignment text</li>
98 * <li>FONT_STYLE style of font displayed (sequence labels are always
100 * <li>GAP_SYMBOL character to treat as gap symbol (usually -,.,' ')</li>
101 * <li>LAST_DIRECTORY last directory for browsing alignment</li>
102 * <li>USER_DEFINED_COLOURS list of user defined colour scheme files</li>
103 * <li>SHOW_FULL_ID show id with '/start-end' numbers appended</li>
104 * <li>SHOW_IDENTITY show percentage identity annotation</li>
105 * <li>SHOW_QUALITY show alignment quality annotation</li>
106 * <li>SHOW_ANNOTATIONS show alignment annotation rows</li>
107 * <li>SHOW_CONSERVATION show alignment conservation annotation</li>
108 * <li>SORT_ANNOTATIONS currently either SEQUENCE_AND_LABEL or
109 * LABEL_AND_SEQUENCE</li>
110 * <li>SHOW_AUTOCALC_ABOVE true to show autocalculated annotations above
111 * sequence annotations</li>
112 * <li>CENTRE_COLUMN_LABELS centre the labels at each column in a displayed
113 * annotation row</li>
114 * <li>DEFAULT_COLOUR default colour scheme to apply for a new alignment</li>
115 * <li>DEFAULT_FILE_FORMAT file format used to save</li>
116 * <li>STARTUP_FILE file loaded on startup (may be a fully qualified url)</li>
117 * <li>SHOW_STARTUP_FILE flag to control loading of startup file</li>
118 * <li>VERSION the version of the jalview build</li>
119 * <li>BUILD_DATE date of this build</li>
120 * <li>LATEST_VERSION the latest jalview version advertised on the
121 * www.jalview.org</li>
122 * <li>PIR_MODELLER boolean indicating if PIR files are written with MODELLER
124 * <li>(FASTA,MSF,PILEUP,CLUSTAL,BLC,PIR,PFAM)_JVSUFFIX boolean for adding jv
125 * suffix to file</li>
126 * <li>RECENT_URL list of recently retrieved URLs</li>
127 * <li>RECENT_FILE list of recently opened files</li>
128 * <li>USE_PROXY flag for whether a http proxy is to be used</li>
129 * <li>PROXY_SERVER the proxy</li>
130 * <li>PROXY_PORT</li>
131 * <li>NOQUESTIONNAIRES true to prevent jalview from checking the questionnaire
133 * <li>QUESTIONNAIRE last questionnaire:responder id string from questionnaire
135 * <li>USAGESTATS (false - user prompted) Enable google analytics tracker for
136 * collecting usage statistics</li>
137 * <li>SHOW_OVERVIEW boolean for overview window display</li>
138 * <li>ANTI_ALIAS boolean for smooth fonts</li>
139 * <li>RIGHT_ALIGN_IDS boolean</li>
140 * <li>AUTO_CALC_CONSENSUS boolean for automatic recalculation of consensus</li>
141 * <li>PAD_GAPS boolean</li>
142 * <li>ID_ITALICS boolean</li>
143 * <li>SHOW_JV_SUFFIX</li>
144 * <li>WRAP_ALIGNMENT</li>
145 * <li>EPS_RENDERING (Prompt each time|Lineart|Text) default for EPS rendering
147 * <li>SORT_ALIGNMENT (No sort|Id|Pairwise Identity)</li>
148 * <li>SEQUENCE_LINKS list of name|URL pairs for opening a url with
150 * <li>STORED_LINKS list of name|url pairs which user has entered but are not
152 * <li>DEFAULT_LINK name of single url to be used when user double clicks a
153 * sequence id (must be in SEQUENCE_LINKS or STORED_LINKS)
154 * <li>GROUP_LINKS list of name|URL[|<separator>] tuples - see
155 * jalview.utils.GroupURLLink for more info</li>
156 * <li>DEFAULT_BROWSER for unix</li>
157 * <li>SHOW_MEMUSAGE boolean show memory usage and warning indicator on desktop
159 * <li>VERSION_CHECK (true) check for the latest release version from
160 * www.jalview.org (or the alias given by the www.jalview.org property)</li>
161 * <li>SHOW_NPFEATS_TOOLTIP (true) show non-positional features in the Sequence
163 * <li>SHOW_DBREFS_TOOLTIP (true) show Database Cross References in the Sequence
165 * <li>SHOW_UNCONSERVED (false) only render unconserved residues - conserved
166 * displayed as '.'</li>
167 * <li>SORT_BY_TREE (false) sort the current alignment view according to the
168 * order of a newly displayed tree</li>
169 * <li>DBFETCH_USEPICR (false) use PICR to recover valid DB references from
170 * sequence ID strings before attempting retrieval from any datasource</li>
171 * <li>SHOW_GROUP_CONSENSUS (false) Show consensus annotation for groups in the
173 * <li>SHOW_GROUP_CONSERVATION (false) Show conservation annotation for groups
174 * in the alignment.</li>
175 * <li>SHOW_CONSENSUS_HISTOGRAM (false) Show consensus annotation row's
177 * <li>SHOW_CONSENSUS_LOGO (false) Show consensus annotation row's sequence
179 * <li>NORMALISE_CONSENSUS_LOGO (false) Show consensus annotation row's sequence
180 * logo normalised to row height rather than histogram height.</li>
181 * <li>FOLLOW_SELECTIONS (true) Controls whether a new alignment view should
182 * respond to selections made in other alignments containing the same sequences.
184 * <li>JWS2HOSTURLS comma-separated list of URLs to try for JABAWS services</li>
185 * <li>SHOW_WSDISCOVERY_ERRORS (true) Controls if the web service URL discovery
186 * warning dialog box is displayed.</li>
187 * <li>ANNOTATIONCOLOUR_MIN (orange) Shade used for minimum value of annotation
188 * when shading by annotation</li>
189 * <li>ANNOTATIONCOLOUR_MAX (red) Shade used for maximum value of annotation
190 * when shading by annotation</li>
191 * <li>www.jalview.org (https://www.jalview.org) a property enabling all HTTP
192 * requests to be redirected to a mirror of https://www.jalview.org</li>
193 * <li>FIGURE_AUTOIDWIDTH (false) Expand the left hand column of an exported
194 * alignment figure to accommodate even the longest sequence ID or annotation
196 * <li>FIGURE_FIXEDIDWIDTH Specifies the width to use for the left-hand column
197 * when exporting an alignment as a figure (setting FIGURE_AUTOIDWIDTH to true
198 * will override this).</li>
199 * <li>STRUCT_FROM_PDB (false) derive secondary structure annotation from PDB
201 * <li>USE_RNAVIEW (false) use RNAViewer to derive secondary structure</li>
202 * <li>ADD_SS_ANN (false) add secondary structure annotation to alignment
204 * <li>ADD_TEMPFACT_ANN (false) add Temperature Factor annotation to alignment
206 * <li>STRUCTURE_DISPLAY choose from JMOL (default) or CHIMERA for 3D structure
208 * <li>CHIMERA_PATH specify full path to Chimera program (if non-standard)</li>
209 * <li>ID_ORG_HOSTURL location of jalview service providing identifiers.org urls
213 * Deprecated settings:
216 * <li>DISCOVERY_START - Boolean - controls if discovery services are queried on
217 * startup (JWS1 services only)</li>
218 * <li>DISCOVERY_URLS - comma separated list of Discovery Service endpoints.
219 * (JWS1 services only)</li>
220 * <li>SHOW_JWS1_SERVICES (true) enable or disable the original Jalview 2
221 * services in the desktop GUI</li>
222 * <li>ENABLE_RSBS_EDITOR (false for 2.7 release) enable or disable RSBS editing
223 * panel in web service preferences</li>
227 * @version $Revision$
232 * property giving log4j level for CASTOR loggers
234 public static final String CASTORLOGLEVEL = "logs.Castor.level";
237 * property giving log4j level for AXIS loggers
239 public static final String AXISLOGLEVEL = "logs.Axis.level";
242 * property giving log4j level for Jalview Log
244 public static final String JALVIEWLOGLEVEL = "logs.Jalview.level";
249 public static final String DEFAULT_SIFTS_DOWNLOAD_DIR = System
250 .getProperty("user.home") + File.separatorChar
251 + ".sifts_downloads" + File.separatorChar;
253 private final static String DEFAULT_CACHE_THRESHOLD_IN_DAYS = "2";
255 private final static String DEFAULT_FAIL_SAFE_PID_THRESHOLD = "30";
258 * Identifiers.org download settings
260 private static final String ID_ORG_FILE = System.getProperty("user.home")
261 + File.separatorChar + ".identifiers.org.ids.json";
264 * Allowed values are PDB or mmCIF
266 private final static String PDB_DOWNLOAD_FORMAT = PDBEntry.Type.MMCIF
269 private final static String DEFAULT_PDB_FILE_PARSER = StructureImportSettings.StructureParser.JMOL_PARSER
273 * a date formatter using a fixed (rather than the user's) locale;
274 * this ensures that date properties can be written and re-read successfully
275 * even if the user changes their locale setting
277 private static final DateFormat date_format = SimpleDateFormat
278 .getDateTimeInstance(SimpleDateFormat.MEDIUM,
279 SimpleDateFormat.MEDIUM, Locale.UK);
282 * Initialises the Jalview Application Log
284 public static Logger log;
286 // save the proxy properties set at startup
287 public final static String[] startupProxyProperties = {
288 System.getProperty("http.proxyHost"),
289 System.getProperty("http.proxyPort"),
290 System.getProperty("https.proxyHost"),
291 System.getProperty("https.proxyPort"),
292 System.getProperty("http.proxyUser"),
293 System.getProperty("http.proxyPassword"),
294 System.getProperty("https.proxyUser"),
295 System.getProperty("https.proxyPassword"),
296 System.getProperty("http.nonProxyHosts") };
298 public final static String PROXYTYPE_NONE = "none";
300 // "false" and "true" for backward compatibility
301 public final static String PROXYTYPE_SYSTEM = "false";
303 public final static String PROXYTYPE_CUSTOM = "true";
305 // in-memory only storage of proxy password, safer to use char array
306 public static char[] proxyAuthPassword = null;
308 /** Jalview Properties */
309 public static Properties applicationProperties = new Properties()
311 // override results in properties output in alphabetical order
313 public synchronized Enumeration<Object> keys()
315 return Collections.enumeration(new TreeSet<>(super.keySet()));
319 /* build Properties (not all saved to .jalview_properties) */
320 public static Properties buildProperties = new Properties();
322 /** Default file is ~/.jalview_properties */
323 static String propertiesFile;
325 private static boolean propsAreReadOnly = Platform.isJS();
327 private final static String JS_PROPERTY_PREFIX = "jalview_";
329 public static void initLogger()
337 // configure the root logger to stderr
338 ConfigurationBuilder<BuiltConfiguration> builder = ConfigurationBuilderFactory.newConfigurationBuilder();
339 AppenderComponentBuilder consoleApp = builder.newAppender("stderr", "Console");
340 builder.add(consoleApp);
341 Configurator.initialize(builder.build());
343 Logger laxis = Logger.getLogger("org.apache.axis");
344 jalview.bin.Cache.log = Logger.getLogger("jalview.bin.Jalview");
346 laxis.setLevel(Level.toLevel(
347 Cache.getDefault("logs.Axis.Level", Level.INFO.toString())));
348 // lcastor = Logger.getLogger("org.exolab.castor.xml.Marshaller");
349 // lcastor.setLevel(Level.toLevel(Cache.getDefault("logs.Castor.Level",
350 // Level.INFO.toString())));
351 // we shouldn't need to do this
352 org.apache.log4j.Logger.getRootLogger()
353 .setLevel(org.apache.log4j.Level.INFO);
355 jalview.bin.Cache.log.setLevel(Level.toLevel(Cache
356 .getDefault("logs.Jalview.level", Level.INFO.toString())));
357 // laxis.addAppender(ap);
358 // lcastor.addAppender(ap);
359 // jalview.bin.Cache.log.addAppender(ap);
360 // Tell the user that debug is enabled
361 jalview.bin.Cache.log.debug(ChannelProperties.getProperty("app_name")
362 + " Debugging Output Follows.");
363 } catch (Exception ex)
365 System.err.println("Problems initializing the log4j system\n");
366 ex.printStackTrace(System.err);
371 * Loads properties from the given properties file. Any existing properties are
374 public static void loadProperties(String propsFile)
376 propertiesFile = propsFile;
377 String releasePropertiesFile = null;
378 boolean defaultProperties = false;
379 if (propsFile == null && !propsAreReadOnly)
381 String channelPrefsFilename = ChannelProperties
382 .getProperty("preferences.filename");
383 String releasePrefsFilename = ".jalview_properties";
384 propertiesFile = System.getProperty("user.home") + File.separatorChar
385 + channelPrefsFilename;
386 releasePropertiesFile = System.getProperty("user.home")
387 + File.separatorChar + releasePrefsFilename;
388 defaultProperties = true;
392 // don't corrupt the file we've been given.
393 propsAreReadOnly = true;
396 if (propertiesFile == null)
398 Platform.readInfoProperties(JS_PROPERTY_PREFIX,
399 applicationProperties);
408 // props file provided as URL
409 fis = new URL(propertiesFile).openStream();
411 "Loading jalview properties from : " + propertiesFile);
413 "Disabling Jalview writing to user's local properties file.");
414 propsAreReadOnly = true;
415 } catch (Exception ex)
421 String readPropertiesFile = propertiesFile;
422 // if we're using the usual properties file and the channel properties
423 // file doesn't exist, read .jalview_properties
424 // (but we'll still save to the channel properties file).
425 if (defaultProperties && (!new File(propertiesFile).exists())
426 && (new File(releasePropertiesFile).exists()))
428 readPropertiesFile = releasePropertiesFile;
430 fis = new FileInputStream(readPropertiesFile);
432 applicationProperties.clear();
433 applicationProperties.load(fis);
435 // remove any old build properties
437 deleteBuildProperties();
439 } catch (Exception ex)
441 System.out.println("Error reading properties file: " + ex);
445 /* TO BE REPLACED WITH PROXY_TYPE SETTINGS
446 if (getDefault("USE_PROXY", false))
448 String proxyServer = getDefault("PROXY_SERVER", ""),
449 proxyPort = getDefault("PROXY_PORT", "8080");
453 // PROXY TYPE settings (now three options "none", "false", "true", but using
454 // backward compatible strings)
455 String proxyType = getDefault("USE_PROXY", PROXYTYPE_SYSTEM);
456 // default to upgrading old settings
460 clearProxyProperties();
462 case PROXYTYPE_SYSTEM: // use system settings
463 resetProxyProperties();
465 case PROXYTYPE_CUSTOM: // use specified proxy settings
466 String httpHost = getDefault("PROXY_SERVER", "");
467 String httpPort = getDefault("PROXY_PORT", "8080");
468 String httpsHost = getDefault("PROXY_SERVER_HTTPS", httpHost);
469 String httpsPort = getDefault("PROXY_PORT_HTTPS", httpPort);
470 String httpUser = getDefault("PROXY_AUTH_USER", null);
471 // https.proxyUser and https.proxyPassword are not able to be
472 // independently set in Preferences yet (or http.nonProxyHosts)
473 String httpsUser = getDefault("PROXY_AUTH_USER_HTTPS", httpUser);
474 setProxyProperties(httpHost, httpPort, httpsHost, httpsPort, httpUser,
475 proxyAuthPassword, httpsUser, proxyAuthPassword, "localhost");
478 String message = "Incorrect PROXY_TYPE - should be 'none' (clear proxy properties), 'false' (system settings), 'true' (custom settings): "
483 // LOAD THE AUTHORS FROM THE authors.props file
484 String authorDetails = resolveResourceURLFor("/authors.props");
488 if (authorDetails != null)
490 URL localJarFileURL = new URL(authorDetails);
491 InputStream in = localJarFileURL.openStream();
492 applicationProperties.load(in);
495 } catch (Exception ex)
497 System.out.println("Error reading author details: " + ex);
498 authorDetails = null;
500 if (authorDetails == null)
502 applicationProperties.remove("AUTHORS");
503 applicationProperties.remove("AUTHORFNAMES");
504 applicationProperties.remove("YEAR");
507 loadBuildProperties(false);
510 .setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false));
512 SiftsSettings.setSiftDownloadDirectory(jalview.bin.Cache
513 .getDefault("sifts_download_dir", DEFAULT_SIFTS_DOWNLOAD_DIR));
515 SiftsSettings.setFailSafePIDThreshold(
516 jalview.bin.Cache.getDefault("sifts_fail_safe_pid_threshold",
517 DEFAULT_FAIL_SAFE_PID_THRESHOLD));
519 SiftsSettings.setCacheThresholdInDays(
520 jalview.bin.Cache.getDefault("sifts_cache_threshold_in_days",
521 DEFAULT_CACHE_THRESHOLD_IN_DAYS));
523 IdOrgSettings.setUrl(getDefault("ID_ORG_HOSTURL",
524 "https://www.jalview.org/services/identifiers"));
525 IdOrgSettings.setDownloadLocation(ID_ORG_FILE);
527 StructureImportSettings.setDefaultStructureFileFormat(jalview.bin.Cache
528 .getDefault("PDB_DOWNLOAD_FORMAT", PDB_DOWNLOAD_FORMAT));
529 StructureImportSettings
530 .setDefaultPDBFileParser(DEFAULT_PDB_FILE_PARSER);
531 // StructureImportSettings
532 // .setDefaultPDBFileParser(jalview.bin.Cache.getDefault(
533 // "DEFAULT_PDB_FILE_PARSER", DEFAULT_PDB_FILE_PARSER));
535 String jnlpVersion = System.getProperty("jalview.version");
537 // jnlpVersion will be null if a latest version check for the channel needs
539 // Dont do this check if running in headless mode
541 if (jnlpVersion == null && getDefault("VERSION_CHECK", true)
542 && (System.getProperty("java.awt.headless") == null || System
543 .getProperty("java.awt.headless").equals("false")))
546 class VersionChecker extends Thread
552 String remoteBuildPropertiesUrl = Cache
553 .getAppbaseBuildProperties();
555 String orgtimeout = System
556 .getProperty("sun.net.client.defaultConnectTimeout");
557 if (orgtimeout == null)
560 System.out.println("# INFO: Setting default net timeout to "
561 + orgtimeout + " seconds.");
563 String remoteVersion = null;
566 System.setProperty("sun.net.client.defaultConnectTimeout",
568 java.net.URL url = new java.net.URL(remoteBuildPropertiesUrl);
570 BufferedReader in = new BufferedReader(
571 new InputStreamReader(url.openStream()));
573 Properties remoteBuildProperties = new Properties();
574 remoteBuildProperties.load(in);
575 remoteVersion = remoteBuildProperties.getProperty("VERSION");
576 } catch (Exception ex)
579 .println("Non-fatal exception when checking version at "
580 + remoteBuildPropertiesUrl + ":");
581 System.out.println(ex);
582 remoteVersion = getProperty("VERSION");
584 System.setProperty("sun.net.client.defaultConnectTimeout",
587 setProperty("LATEST_VERSION", remoteVersion);
591 VersionChecker vc = new VersionChecker();
596 if (jnlpVersion != null)
598 setProperty("LATEST_VERSION", jnlpVersion);
602 applicationProperties.remove("LATEST_VERSION");
606 // LOAD USERDEFINED COLOURS
607 Cache.initUserColourSchemes(getProperty("USER_DEFINED_COLOURS"));
608 jalview.io.PIRFile.useModellerOutput = Cache.getDefault("PIR_MODELLER",
613 * construct a resource URL for the given absolute resource pathname
615 * @param resourcePath
618 private static String resolveResourceURLFor(String resourcePath)
621 if (Platform.isJS() || !Cache.class.getProtectionDomain()
622 .getCodeSource().getLocation().toString().endsWith(".jar"))
626 url = Cache.class.getResource(resourcePath).toString();
627 } catch (Exception ex)
629 System.err.println("Failed to resolve resource " + resourcePath
630 + ": " + ex.getMessage());
635 url = "jar:".concat(Cache.class.getProtectionDomain().getCodeSource()
636 .getLocation().toString().concat("!" + resourcePath));
641 public static void loadBuildProperties(boolean reportVersion)
643 String codeInstallation = getProperty("INSTALLATION");
644 boolean printVersion = codeInstallation == null;
647 * read build properties - from the Jalview jar for a Java distribution,
648 * or from codebase file in test or JalviewJS context
652 String buildDetails = resolveResourceURLFor("/.build_properties");
653 URL localJarFileURL = new URL(buildDetails);
654 InputStream in = localJarFileURL.openStream();
655 buildProperties.load(in);
657 if (buildProperties.getProperty("BUILD_DATE", null) != null)
659 applicationProperties.put("BUILD_DATE",
660 buildProperties.getProperty("BUILD_DATE"));
662 if (buildProperties.getProperty("INSTALLATION", null) != null)
664 applicationProperties.put("INSTALLATION",
665 buildProperties.getProperty("INSTALLATION"));
667 if (buildProperties.getProperty("VERSION", null) != null)
669 applicationProperties.put("VERSION",
670 buildProperties.getProperty("VERSION"));
672 } catch (Exception ex)
674 System.out.println("Error reading build details: " + ex);
675 applicationProperties.remove("VERSION");
677 String codeVersion = getProperty("VERSION");
678 codeInstallation = getProperty("INSTALLATION");
680 if (codeVersion == null)
682 // THIS SHOULD ONLY BE THE CASE WHEN TESTING!!
683 codeVersion = "Test";
684 codeInstallation = "";
688 codeInstallation = " (" + codeInstallation + ")";
690 setProperty("VERSION", codeVersion);
691 new BuildDetails(codeVersion, null, codeInstallation);
692 if (printVersion && reportVersion)
694 System.out.println(ChannelProperties.getProperty("app_name")
695 + " Version: " + codeVersion + codeInstallation);
699 private static void deleteBuildProperties()
701 applicationProperties.remove("LATEST_VERSION");
702 applicationProperties.remove("VERSION");
703 applicationProperties.remove("AUTHORS");
704 applicationProperties.remove("AUTHORFNAMES");
705 applicationProperties.remove("YEAR");
706 applicationProperties.remove("BUILD_DATE");
707 applicationProperties.remove("INSTALLATION");
711 * Gets Jalview application property of given key. Returns null if key not found
716 * @return Property value
718 public static String getProperty(String key)
720 String prop = applicationProperties.getProperty(key);
721 if (prop == null && Platform.isJS())
723 prop = applicationProperties.getProperty(Platform.getUniqueAppletID()
724 + "_" + JS_PROPERTY_PREFIX + key);
730 * These methods are used when checking if the saved preference is different to
731 * the default setting
734 public static boolean getDefault(String property, boolean def)
736 String string = getProperty(property);
739 def = Boolean.valueOf(string).booleanValue();
745 public static int getDefault(String property, int def)
747 String string = getProperty(property);
752 def = Integer.parseInt(string);
753 } catch (NumberFormatException e)
755 System.out.println("Error parsing int property '" + property
756 + "' with value '" + string + "'");
764 * Answers the value of the given property, or the supplied default value if the
765 * property is not set
767 public static String getDefault(String property, String def)
769 String value = getProperty(property);
770 return value == null ? def : value;
774 * Stores property in the file "HOME_DIR/.jalview_properties"
779 * String value of property
781 * @return previous value of property (or null)
783 public static Object setProperty(String key, String obj)
785 Object oldValue = null;
788 oldValue = applicationProperties.setProperty(key, obj);
789 if (propertiesFile != null && !propsAreReadOnly)
791 FileOutputStream out = new FileOutputStream(propertiesFile);
792 applicationProperties.store(out, "---JalviewX Properties File---");
795 } catch (Exception ex)
798 "Error setting property: " + key + " " + obj + "\n" + ex);
804 * remove the specified property from the jalview properties file
808 public static void removeProperty(String string)
810 applicationProperties.remove(string);
815 * save the properties to the jalview properties path
817 public static void saveProperties()
819 if (!propsAreReadOnly)
823 FileOutputStream out = new FileOutputStream(propertiesFile);
824 applicationProperties.store(out, "---JalviewX Properties File---");
826 } catch (Exception ex)
828 System.out.println("Error saving properties: " + ex);
834 * internal vamsas class discovery state
836 private static int vamsasJarsArePresent = -1;
839 * Searches for vamsas client classes on class path.
841 * @return true if vamsas client is present on classpath
843 public static boolean vamsasJarsPresent()
845 if (vamsasJarsArePresent == -1)
849 if (jalview.jbgui.GDesktop.class.getClassLoader()
850 .loadClass("uk.ac.vamsas.client.VorbaId") != null)
852 jalview.bin.Cache.log.debug(
853 "Found Vamsas Classes (uk.ac..vamsas.client.VorbaId can be loaded)");
854 vamsasJarsArePresent = 1;
855 Logger lvclient = Logger.getLogger("uk.ac.vamsas");
856 lvclient.setLevel(Level.toLevel(Cache
857 .getDefault("logs.Vamsas.Level", Level.INFO.toString())));
859 lvclient.addAppender(log.getAppender("JalviewLogger"));
860 // Tell the user that debug is enabled
861 lvclient.debug(ChannelProperties.getProperty("app_name")
862 + " Vamsas Client Debugging Output Follows.");
864 } catch (Exception e)
866 vamsasJarsArePresent = 0;
867 jalview.bin.Cache.log.debug("Vamsas Classes are not present");
870 return (vamsasJarsArePresent > 0);
874 * internal vamsas class discovery state
876 private static int groovyJarsArePresent = -1;
879 * Searches for vamsas client classes on class path.
881 * @return true if vamsas client is present on classpath
883 public static boolean groovyJarsPresent()
885 if (groovyJarsArePresent == -1)
889 if (Cache.class.getClassLoader()
890 .loadClass("groovy.lang.GroovyObject") != null)
892 jalview.bin.Cache.log.debug(
893 "Found Groovy (groovy.lang.GroovyObject can be loaded)");
894 groovyJarsArePresent = 1;
895 Logger lgclient = Logger.getLogger("groovy");
896 lgclient.setLevel(Level.toLevel(Cache
897 .getDefault("logs.Groovy.Level", Level.INFO.toString())));
899 lgclient.addAppender(log.getAppender("JalviewLogger"));
900 // Tell the user that debug is enabled
901 lgclient.debug(ChannelProperties.getProperty("app_name")
902 + " Groovy Client Debugging Output Follows.");
906 groovyJarsArePresent = 0;
907 jalview.bin.Cache.log.debug("Groovy Classes are not present", e);
908 } catch (Exception e)
910 groovyJarsArePresent = 0;
911 jalview.bin.Cache.log.debug("Groovy Classes are not present");
914 return (groovyJarsArePresent > 0);
918 * GA tracker object - actually JGoogleAnalyticsTracker null if tracking not
921 protected static Object tracker = null;
923 protected static Class trackerfocus = null;
925 protected static Class jgoogleanalyticstracker = null;
928 * Initialise the google tracker if it is not done already.
930 public static void initGoogleTracker()
934 if (jgoogleanalyticstracker == null)
936 // try to get the tracker class
939 jgoogleanalyticstracker = Cache.class.getClassLoader().loadClass(
940 "com.boxysystems.jgoogleanalytics.JGoogleAnalyticsTracker");
941 trackerfocus = Cache.class.getClassLoader()
942 .loadClass("com.boxysystems.jgoogleanalytics.FocusPoint");
943 } catch (Exception e)
946 "com.boxysystems.jgoogleanalytics package is not present - tracking not enabled.");
948 jgoogleanalyticstracker = null;
953 // now initialise tracker
954 Exception re = null, ex = null;
956 String vrs = "No Version Accessible";
959 // Google analytics tracking code for Library Finder
960 tracker = jgoogleanalyticstracker
961 .getConstructor(new Class[]
962 { String.class, String.class, String.class })
963 .newInstance(new Object[]
964 { ChannelProperties.getProperty("app_name") + " Desktop",
965 (vrs = jalview.bin.Cache.getProperty("VERSION") + "_"
966 + jalview.bin.Cache.getDefault("BUILD_DATE",
969 jgoogleanalyticstracker
970 .getMethod("trackAsynchronously", new Class[]
972 .invoke(tracker, new Object[]
973 { trackerfocus.getConstructor(new Class[] { String.class })
974 .newInstance(new Object[]
975 { "Application Started." }) });
976 } catch (RuntimeException e)
979 } catch (Exception e)
986 if (re != null || ex != null || err != null)
992 log.debug("Caught runtime exception in googletracker init:",
998 "Failed to initialise GoogleTracker for Jalview Desktop with version "
1005 "Whilst initing GoogleTracker for Jalview Desktop version "
1015 "Debug: Caught runtime exception in googletracker init:"
1017 re.printStackTrace();
1022 "Warning: Failed to initialise GoogleTracker for Jalview Desktop with version "
1024 ex.printStackTrace();
1030 "ERROR: Whilst initing GoogleTracker for Jalview Desktop version "
1032 err.printStackTrace();
1038 log.debug("Successfully initialised tracker.");
1044 * get the user's default colour if available
1050 public static Color getDefaultColour(String property, Color defcolour)
1052 String colprop = getProperty(property);
1053 if (colprop == null)
1057 Color col = ColorUtils.parseColourString(colprop);
1060 log.warn("Couldn't parse '" + colprop + "' as a colour for "
1063 return (col == null) ? defcolour : col;
1067 * store a colour as a Jalview user default property
1072 public static void setColourProperty(String property, Color colour)
1074 setProperty(property, jalview.util.Format.getHexString(colour));
1078 * Stores a formatted date in a jalview property, using a fixed locale.
1080 * @param propertyName
1082 * @return the formatted date string
1084 public static String setDateProperty(String propertyName, Date date)
1086 String formatted = date_format.format(date);
1087 setProperty(propertyName, formatted);
1092 * Reads a date stored in a Jalview property, parses it (using a fixed locale
1093 * format) and returns as a Date, or null if parsing fails
1095 * @param propertyName
1099 public static Date getDateProperty(String propertyName)
1101 String val = getProperty(propertyName);
1106 return date_format.parse(val);
1107 } catch (Exception ex)
1109 System.err.println("Invalid or corrupt date in property '"
1110 + propertyName + "' : value was '" + val + "'");
1117 * get and parse a property as an integer. send any parsing problems to
1121 * @return null or Integer
1123 public static Integer getIntegerProperty(String property)
1125 String val = getProperty(property);
1126 if (val != null && (val = val.trim()).length() > 0)
1130 return Integer.valueOf(val);
1131 } catch (NumberFormatException x)
1133 System.err.println("Invalid integer in property '" + property
1134 + "' (value was '" + val + "')");
1141 * Set the specified value, or remove it if null or empty. Does not save the
1147 public static void setOrRemove(String propName, String value)
1149 if (propName == null)
1153 if (value == null || value.trim().length() < 1)
1155 Cache.applicationProperties.remove(propName);
1159 Cache.applicationProperties.setProperty(propName, value);
1164 * Loads in user colour schemes from files.
1167 * a '|'-delimited list of file paths
1169 public static void initUserColourSchemes(String files)
1171 if (files == null || files.length() == 0)
1176 // In case colours can't be loaded, we'll remove them
1177 // from the default list here.
1178 StringBuffer coloursFound = new StringBuffer();
1179 StringTokenizer st = new StringTokenizer(files, "|");
1180 while (st.hasMoreElements())
1182 String file = st.nextToken();
1185 UserColourScheme ucs = ColourSchemeLoader.loadColourScheme(file);
1188 if (coloursFound.length() > 0)
1190 coloursFound.append("|");
1192 coloursFound.append(file);
1193 ColourSchemes.getInstance().registerColourScheme(ucs);
1195 } catch (Exception ex)
1197 System.out.println("Error loading User ColourFile\n" + ex);
1200 if (!files.equals(coloursFound.toString()))
1202 if (coloursFound.toString().length() > 1)
1204 setProperty(UserDefinedColours.USER_DEFINED_COLOURS,
1205 coloursFound.toString());
1209 applicationProperties
1210 .remove(UserDefinedColours.USER_DEFINED_COLOURS);
1216 * Initial logging information helper for various versions output
1220 * @param defaultValue
1222 private static void appendIfNotNull(StringBuilder sb, String prefix,
1223 String value, String suffix, String defaultValue)
1225 if (value == null && defaultValue == null)
1229 String line = prefix + (value != null ? value : defaultValue) + suffix;
1235 * @return Jalview version, build details and JVM platform version for console
1237 public static String getVersionDetailsForConsole()
1239 StringBuilder sb = new StringBuilder();
1240 sb.append(ChannelProperties.getProperty("app_name"))
1241 .append(" Version: ");
1242 sb.append(jalview.bin.Cache.getDefault("VERSION", "TEST"));
1244 sb.append(ChannelProperties.getProperty("app_name"))
1245 .append(" Installation: ");
1246 sb.append(jalview.bin.Cache.getDefault("INSTALLATION", "unknown"));
1248 sb.append("Build Date: ");
1249 sb.append(jalview.bin.Cache.getDefault("BUILD_DATE", "unknown"));
1251 sb.append("Java version: ");
1252 sb.append(System.getProperty("java.version"));
1254 sb.append(System.getProperty("os.arch"));
1256 sb.append(System.getProperty("os.name"));
1258 sb.append(System.getProperty("os.version"));
1260 appendIfNotNull(sb, "Install4j version: ",
1261 System.getProperty("sys.install4jVersion"), "\n", null);
1262 appendIfNotNull(sb, "Install4j template version: ",
1263 System.getProperty("installer_template_version"), "\n", null);
1264 appendIfNotNull(sb, "Launcher version: ",
1265 System.getProperty("launcher_version"), "\n", null);
1266 LookAndFeel laf = UIManager.getLookAndFeel();
1267 String lafName = laf == null ? "Not obtained" : laf.getName();
1268 String lafClass = laf == null ? "unknown" : laf.getClass().getName();
1269 sb.append("LookAndFeel: ");
1272 sb.append(lafClass);
1274 // Not displayed in release version ( determined by possible version number
1275 // regex 9[9.]*9[.-_a9]* )
1276 if (Pattern.matches("^\\d[\\d\\.]*\\d[\\.\\-\\w]*$",
1277 jalview.bin.Cache.getDefault("VERSION", "TEST")))
1279 appendIfNotNull(sb, "Getdown appdir: ",
1280 System.getProperty("getdownappdir"), "\n", null);
1281 appendIfNotNull(sb, "Getdown appbase: ",
1282 System.getProperty("getdownappbase"), "\n", null);
1283 appendIfNotNull(sb, "Java home: ", System.getProperty("java.home"),
1286 return sb.toString();
1291 * @return build details as reported in splashscreen
1293 public static String getBuildDetailsForSplash()
1295 // consider returning more human friendly info
1296 // eg 'built from Source' or update channel
1297 return jalview.bin.Cache.getDefault("INSTALLATION", "unknown");
1300 public static String getStackTraceString(Throwable t)
1302 StringWriter sw = new StringWriter();
1303 PrintWriter pw = new PrintWriter(sw);
1304 t.printStackTrace(pw);
1305 return sw.toString();
1308 // proxy properties methods
1309 public static void clearProxyProperties()
1311 setProxyProperties(null, null, null, null, null, null, null, null,
1315 public static void resetProxyProperties()
1317 setProxyProperties(startupProxyProperties[0], startupProxyProperties[1],
1318 startupProxyProperties[2], startupProxyProperties[3],
1319 startupProxyProperties[4],
1320 startupProxyProperties[5] == null ? null
1321 : startupProxyProperties[5].toCharArray(),
1322 startupProxyProperties[6],
1323 startupProxyProperties[7] == null ? null
1324 : startupProxyProperties[7].toCharArray(),
1325 startupProxyProperties[8]);
1326 StringBuilder sb = new StringBuilder();
1327 sb.append("Setting proxy properties to: http.proxyHost=")
1328 .append(startupProxyProperties[0]).append(", http.proxyPort=")
1329 .append(startupProxyProperties[1])
1330 .append(startupProxyProperties[4] != null
1331 && !startupProxyProperties[4].isEmpty()
1332 ? " [" + startupProxyProperties[4] + "]"
1334 .append(", https.proxyHost=").append(startupProxyProperties[2])
1335 .append(", https.proxyPort=").append(startupProxyProperties[3])
1336 .append(startupProxyProperties[6] != null
1337 && !startupProxyProperties[6].isEmpty()
1338 ? " [" + startupProxyProperties[6] + "]"
1341 Cache.debug(sb.toString());
1344 public static void setProxyPropertiesFromPreferences()
1346 setProxyPropertiesFromPreferences(Cache.PROXYTYPE_SYSTEM);
1349 public static void setProxyPropertiesFromPreferences(
1350 String previousProxyType)
1352 String proxyType = Cache.getDefault("USE_PROXY",
1353 Cache.PROXYTYPE_SYSTEM);
1354 if (previousProxyType != null
1355 && !proxyType.equals(Cache.PROXYTYPE_CUSTOM) // always apply
1357 && proxyType.equals(previousProxyType))
1364 case Cache.PROXYTYPE_NONE:
1365 if (!previousProxyType.equals(proxyType))
1367 Cache.log.info("Setting no proxy settings");
1368 Cache.setProxyProperties(null, null, null, null, null, null, null,
1372 case Cache.PROXYTYPE_CUSTOM:
1373 // always re-set a custom proxy -- it might have changed, particularly
1375 Cache.log.info("Setting custom proxy settings");
1376 boolean proxyAuthSet = Cache.getDefault("PROXY_AUTH", false);
1377 Cache.setProxyProperties(Cache.getDefault("PROXY_SERVER", null),
1378 Cache.getDefault("PROXY_PORT", null),
1379 Cache.getDefault("PROXY_SERVER_HTTPS", null),
1380 Cache.getDefault("PROXY_PORT_HTTPS", null),
1381 proxyAuthSet ? Cache.getDefault("PROXY_AUTH_USERNAME", "")
1383 proxyAuthSet ? Cache.proxyAuthPassword : null,
1384 proxyAuthSet ? Cache.getDefault("PROXY_AUTH_USERNAME", "")
1386 proxyAuthSet ? Cache.proxyAuthPassword : null, "localhost");
1388 default: // system proxy settings by default
1389 Cache.log.info("Setting system proxy settings");
1390 Cache.resetProxyProperties();
1394 public static void setProxyProperties(String httpHost, String httpPort,
1395 String httpsHost, String httpsPort, String httpUser,
1396 char[] httpPassword, String httpsUser, char[] httpsPassword,
1397 String nonProxyHosts)
1399 setOrClearSystemProperty("http.proxyHost", httpHost);
1400 setOrClearSystemProperty("http.proxyPort", httpPort);
1401 setOrClearSystemProperty("https.proxyHost", httpsHost);
1402 setOrClearSystemProperty("https.proxyPort", httpsPort);
1403 setOrClearSystemProperty("http.proxyUser", httpUser);
1404 setOrClearSystemProperty("https.proxyUser", httpsUser);
1405 // note: passwords for http.proxyPassword and https.proxyPassword are sent
1406 // via the Authenticator, properties do not need to be set
1408 // are we using a custom proxy (password prompt might be required)?
1409 boolean customProxySet = getDefault("USE_PROXY", PROXYTYPE_SYSTEM)
1410 .equals(PROXYTYPE_CUSTOM);
1413 * A bug in Java means the AuthCache does not get reset, so once it has working credentials,
1414 * it never asks for more, so changing the Authenticator has no effect (as getPasswordAuthentication()
1415 * is not re-called).
1416 * This could lead to password leak to a hostile proxy server, so I'm putting in a hack to clear
1418 * see https://www.generacodice.com/en/articolo/154918/Reset-the-Authenticator-credentials
1420 * Turns out this is only accessible in Java 8, and not in Java 9 onwards, so commenting out
1425 sun.net.www.protocol.http.AuthCacheValue
1426 .setAuthCache(new sun.net.www.protocol.http.AuthCacheImpl());
1427 } catch (Throwable t)
1429 Cache.error(t.getMessage());
1430 Cache.debug(getStackTraceString(t));
1434 if (httpUser != null || httpsUser != null)
1438 char[] displayHttpPw = new char[httpPassword == null ? 0
1439 : httpPassword.length];
1440 Arrays.fill(displayHttpPw, '*');
1441 Cache.debug("CACHE Proxy: setting new Authenticator with httpUser='"
1442 + httpUser + "' httpPassword='" + displayHttpPw + "'");
1443 if (!Platform.isJS())
1445 * java.net.Authenticator not implemented in SwingJS yet
1451 Authenticator.setDefault(new Authenticator()
1454 protected PasswordAuthentication getPasswordAuthentication()
1456 if (getRequestorType() == RequestorType.PROXY)
1458 String protocol = getRequestingProtocol();
1459 boolean needProxyPasswordSet = false;
1460 if (customProxySet &&
1461 // we have a username but no password for the scheme being
1463 (protocol.equalsIgnoreCase("http")
1464 && (httpUser != null && httpUser.length() > 0
1465 && (httpPassword == null
1466 || httpPassword.length == 0)))
1467 || (protocol.equalsIgnoreCase("https")
1468 && (httpsUser != null
1469 && httpsUser.length() > 0
1470 && (httpsPassword == null
1471 || httpsPassword.length == 0))))
1473 // open Preferences -> Connections
1474 String message = MessageManager
1475 .getString("label.proxy_password_required");
1476 Preferences.openPreferences(
1477 Preferences.TabRef.CONNECTIONS_TAB, message);
1478 Preferences.getInstance()
1479 .proxyAuthPasswordCheckHighlight(true, true);
1485 if (protocol.equalsIgnoreCase("http")
1486 && getRequestingHost()
1487 .equalsIgnoreCase(httpHost)
1488 && getRequestingPort() == Integer
1492 "AUTHENTICATOR returning PasswordAuthentication(\""
1493 + httpUser + "\", '"
1494 + new String(displayHttpPw) + "')");
1495 return new PasswordAuthentication(httpUser,
1498 if (protocol.equalsIgnoreCase("https")
1499 && getRequestingHost()
1500 .equalsIgnoreCase(httpsHost)
1501 && getRequestingPort() == Integer
1502 .valueOf(httpsPort))
1504 char[] displayHttpsPw = new char[httpPassword.length];
1505 Arrays.fill(displayHttpsPw, '*');
1507 "AUTHENTICATOR returning PasswordAuthentication(\""
1508 + httpsUser + "\", '" + displayHttpsPw
1510 return new PasswordAuthentication(httpsUser,
1513 } catch (NumberFormatException e)
1515 Cache.error("Problem with proxy port values [http:"
1516 + httpPort + ", https:" + httpsPort + "]");
1519 "AUTHENTICATOR after trying to get PasswordAuthentication");
1522 // non proxy request
1523 Cache.debug("AUTHENTICATOR returning null");
1527 } // end of j2sIgnore for java.net.Authenticator
1529 // required to re-enable basic authentication (should be okay for a
1532 "AUTHENTICATOR setting property 'jdk.http.auth.tunneling.disabledSchemes' to \"\"");
1533 System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");
1534 } catch (SecurityException e)
1536 Cache.error("Could not set default Authenticator");
1537 Cache.debug(getStackTraceString(e));
1542 // reset the Authenticator to protect http.proxyUser and
1543 // http.proxyPassword Just In Case
1544 /* as noted above, due to bug in java this doesn't work if the sun.net.www.protocol.http.AuthCache
1545 * has working credentials. No workaround for Java 11.
1547 if (!Platform.isJS())
1549 * java.net.Authenticator not implemented in SwingJS yet
1555 Cache.debug("AUTHENTICATOR setting default Authenticator to null");
1556 Authenticator.setDefault(null);
1560 // nonProxyHosts not currently configurable in Preferences
1561 Cache.debug("AUTHENTICATOR setting property 'http.nonProxyHosts' to \""
1562 + nonProxyHosts + "\"");
1563 setOrClearSystemProperty("http.nonProxyHosts", nonProxyHosts);
1566 public static void setOrClearSystemProperty(String key, char[] value)
1568 setOrClearSystemProperty(key,
1569 (value == null) ? null : new String(value));
1572 public static void setOrClearSystemProperty(String key, String value)
1580 System.clearProperty(key);
1584 System.setProperty(key, value);
1588 public final static int TRACE = 10;
1590 public final static int DEBUG = 20;
1592 public final static int INFO = 30;
1594 public final static int WARN = 40;
1596 public final static int ERROR = 50;
1598 public static boolean println(int level, String message)
1600 if (Cache.log == null)
1603 System.err.println(message);
1604 else if (level >= INFO)
1605 System.out.println(message);
1606 // not printing debug or trace messages
1611 Cache.log.error(message);
1613 else if (level >= WARN)
1615 Cache.log.warn(message);
1617 else if (level >= INFO)
1619 Cache.log.info(message);
1621 else if (level >= DEBUG)
1623 Cache.log.debug(message);
1627 Cache.log.trace(message);
1632 public static void trace(String message)
1634 println(TRACE, message);
1637 public static void debug(String message)
1639 println(DEBUG, message);
1642 public static void info(String message)
1644 println(INFO, message);
1647 public static void warn(String message)
1649 println(WARN, message);
1652 public static void error(String message)
1654 println(ERROR, message);
1658 * Getdown appbase methods
1661 private static final String releaseAppbase;
1663 private static String getdownAppbase;
1665 private static String getdownDistDir;
1669 if (!Platform.isJS())
1671 Float specversion = Float
1672 .parseFloat(System.getProperty("java.specification.version"));
1673 releaseAppbase = (specversion < 9)
1674 ? "https://www.jalview.org/getdown/release/1.8"
1675 : "https://www.jalview.org/getdown/release/11";
1679 // this value currenly made up, can be changed to URL that will be
1680 // "https://www.jalview.org/jalview-js/swingjs/j2s/build_properties"
1681 releaseAppbase = "https://www.jalview.org/jalview-js";
1682 getdownAppbase = releaseAppbase;
1683 getdownDistDir = "/swingjs/j2s";
1687 // look for properties (passed in by getdown) otherwise default to release
1688 private static void setGetdownAppbase()
1690 if (getdownAppbase != null)
1694 String appbase = System.getProperty("getdownappbase");
1695 String distDir = System.getProperty("getdowndistdir");
1696 if (appbase == null)
1698 appbase = buildProperties.getProperty("GETDOWNAPPBASE");
1699 distDir = buildProperties.getProperty("GETDOWNAPPDISTDIR");
1701 if (appbase == null)
1703 appbase = releaseAppbase;
1704 distDir = "release";
1706 if (appbase.endsWith("/"))
1708 appbase = appbase.substring(0, appbase.length() - 1);
1710 if (distDir == null)
1712 distDir = appbase.equals(releaseAppbase) ? "release" : "alt";
1714 getdownAppbase = appbase;
1715 getdownDistDir = distDir;
1718 public static String getGetdownAppbase()
1720 setGetdownAppbase();
1721 return getdownAppbase;
1724 public static String getAppbaseBuildProperties()
1726 String appbase = getGetdownAppbase();
1727 return appbase + "/" + getdownDistDir + "/build_properties";