| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.bin; |
| 22 |
|
|
| 23 |
|
import java.awt.Color; |
| 24 |
|
import java.io.BufferedReader; |
| 25 |
|
import java.io.File; |
| 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; |
| 36 |
|
import java.net.URL; |
| 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; |
| 48 |
|
import java.util.Map; |
| 49 |
|
import java.util.Properties; |
| 50 |
|
import java.util.StringTokenizer; |
| 51 |
|
import java.util.TreeSet; |
| 52 |
|
|
| 53 |
|
import javax.swing.LookAndFeel; |
| 54 |
|
import javax.swing.UIManager; |
| 55 |
|
|
| 56 |
|
import jalview.analytics.Plausible; |
| 57 |
|
import jalview.bin.argparser.Arg; |
| 58 |
|
import jalview.bin.argparser.ArgParser; |
| 59 |
|
import jalview.datamodel.PDBEntry; |
| 60 |
|
import jalview.gui.Preferences; |
| 61 |
|
import jalview.gui.UserDefinedColours; |
| 62 |
|
import jalview.log.JLoggerLog4j; |
| 63 |
|
import jalview.schemes.ColourSchemeLoader; |
| 64 |
|
import jalview.schemes.ColourSchemes; |
| 65 |
|
import jalview.schemes.UserColourScheme; |
| 66 |
|
import jalview.structure.StructureImportSettings; |
| 67 |
|
import jalview.urls.IdOrgSettings; |
| 68 |
|
import jalview.util.ChannelProperties; |
| 69 |
|
import jalview.util.ColorUtils; |
| 70 |
|
import jalview.util.HttpUtils; |
| 71 |
|
import jalview.util.LaunchUtils; |
| 72 |
|
import jalview.util.MessageManager; |
| 73 |
|
import jalview.util.Platform; |
| 74 |
|
import jalview.ws.sifts.SiftsSettings; |
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
|
|
| 91 |
|
|
| 92 |
|
|
| 93 |
|
|
| 94 |
|
|
| 95 |
|
|
| 96 |
|
|
| 97 |
|
|
| 98 |
|
|
| 99 |
|
|
| 100 |
|
|
| 101 |
|
|
| 102 |
|
|
| 103 |
|
|
| 104 |
|
|
| 105 |
|
|
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| 115 |
|
|
| 116 |
|
|
| 117 |
|
|
| 118 |
|
|
| 119 |
|
|
| 120 |
|
|
| 121 |
|
|
| 122 |
|
|
| 123 |
|
|
| 124 |
|
|
| 125 |
|
|
| 126 |
|
|
| 127 |
|
|
| 128 |
|
|
| 129 |
|
|
| 130 |
|
|
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
| 135 |
|
|
| 136 |
|
|
| 137 |
|
|
| 138 |
|
|
| 139 |
|
|
| 140 |
|
|
| 141 |
|
|
| 142 |
|
|
| 143 |
|
|
| 144 |
|
|
| 145 |
|
|
| 146 |
|
|
| 147 |
|
|
| 148 |
|
|
| 149 |
|
|
| 150 |
|
|
| 151 |
|
|
| 152 |
|
|
| 153 |
|
|
| 154 |
|
|
| 155 |
|
|
| 156 |
|
|
| 157 |
|
|
| 158 |
|
|
| 159 |
|
|
| 160 |
|
|
| 161 |
|
|
| 162 |
|
|
| 163 |
|
|
| 164 |
|
|
| 165 |
|
|
| 166 |
|
|
| 167 |
|
|
| 168 |
|
|
| 169 |
|
|
| 170 |
|
|
| 171 |
|
|
| 172 |
|
|
| 173 |
|
|
| 174 |
|
|
| 175 |
|
|
| 176 |
|
|
| 177 |
|
|
| 178 |
|
|
| 179 |
|
|
| 180 |
|
|
| 181 |
|
|
| 182 |
|
|
| 183 |
|
|
| 184 |
|
|
| 185 |
|
|
| 186 |
|
|
| 187 |
|
|
| 188 |
|
|
| 189 |
|
|
| 190 |
|
|
| 191 |
|
|
| 192 |
|
|
| 193 |
|
|
| 194 |
|
|
| 195 |
|
|
| 196 |
|
|
| 197 |
|
|
| 198 |
|
|
| 199 |
|
|
| 200 |
|
|
| 201 |
|
|
| 202 |
|
|
| 203 |
|
|
| 204 |
|
|
| 205 |
|
|
| 206 |
|
|
| 207 |
|
|
| 208 |
|
|
| 209 |
|
|
| 210 |
|
|
| 211 |
|
|
| 212 |
|
|
| 213 |
|
|
| 214 |
|
|
| 215 |
|
|
| 216 |
|
|
| 217 |
|
|
| 218 |
|
|
| 219 |
|
|
| 220 |
|
|
| 221 |
|
|
| 222 |
|
|
| 223 |
|
|
| 224 |
|
|
| 225 |
|
|
| 226 |
|
|
| 227 |
|
|
| 228 |
|
|
| 229 |
|
|
| 230 |
|
|
| 231 |
|
|
| 232 |
|
|
| 233 |
|
|
| 234 |
|
|
| 235 |
|
|
| 236 |
|
|
| 237 |
|
|
| 238 |
|
|
| 239 |
|
|
| 240 |
|
|
| 241 |
|
@author |
| 242 |
|
@version |
| 243 |
|
|
| |
|
| 58.3% |
Uncovered Elements: 303 (726) |
Complexity: 216 |
Complexity Density: 0.46 |
|
| 244 |
|
public class Cache |
| 245 |
|
{ |
| 246 |
|
|
| 247 |
|
|
| 248 |
|
|
| 249 |
|
public static final String CASTORLOGLEVEL = "logs.Castor.level"; |
| 250 |
|
|
| 251 |
|
|
| 252 |
|
|
| 253 |
|
|
| 254 |
|
public static final String AXISLOGLEVEL = "logs.Axis.level"; |
| 255 |
|
|
| 256 |
|
|
| 257 |
|
|
| 258 |
|
|
| 259 |
|
public static final String JALVIEWLOGLEVEL = "logs.Jalview.level"; |
| 260 |
|
|
| 261 |
|
|
| 262 |
|
public static final String BOOTSTRAP_TEST = "BOOTSTRAP_TEST"; |
| 263 |
|
|
| 264 |
|
|
| 265 |
|
|
| 266 |
|
|
| 267 |
|
public static final String DEFAULT_SIFTS_DOWNLOAD_DIR = System |
| 268 |
|
.getProperty("user.home") + File.separatorChar |
| 269 |
|
+ ".sifts_downloads" + File.separatorChar; |
| 270 |
|
|
| 271 |
|
private final static String DEFAULT_CACHE_THRESHOLD_IN_DAYS = "2"; |
| 272 |
|
|
| 273 |
|
private final static String DEFAULT_FAIL_SAFE_PID_THRESHOLD = "30"; |
| 274 |
|
|
| 275 |
|
|
| 276 |
|
|
| 277 |
|
|
| 278 |
|
private static final String ID_ORG_FILE = System.getProperty("user.home") |
| 279 |
|
+ File.separatorChar + ".identifiers.org.ids.json"; |
| 280 |
|
|
| 281 |
|
|
| 282 |
|
|
| 283 |
|
|
| 284 |
|
private final static String PDB_DOWNLOAD_FORMAT = PDBEntry.Type.MMCIF |
| 285 |
|
.toString(); |
| 286 |
|
|
| 287 |
|
private final static String DEFAULT_PDB_FILE_PARSER = StructureImportSettings.StructureParser.JMOL_PARSER |
| 288 |
|
.toString(); |
| 289 |
|
|
| 290 |
|
|
| 291 |
|
|
| 292 |
|
|
| 293 |
|
|
| 294 |
|
|
| 295 |
|
private static final DateFormat date_format = SimpleDateFormat |
| 296 |
|
.getDateTimeInstance(SimpleDateFormat.MEDIUM, |
| 297 |
|
SimpleDateFormat.MEDIUM, Locale.UK); |
| 298 |
|
|
| 299 |
|
|
| 300 |
|
|
| 301 |
|
|
| 302 |
|
|
| 303 |
|
public final static String JALVIEW_LOGGER_NAME = "JalviewLogger"; |
| 304 |
|
|
| 305 |
|
|
| 306 |
|
public final static String[] startupProxyProperties = { |
| 307 |
|
System.getProperty("http.proxyHost"), |
| 308 |
|
System.getProperty("http.proxyPort"), |
| 309 |
|
System.getProperty("https.proxyHost"), |
| 310 |
|
System.getProperty("https.proxyPort"), |
| 311 |
|
System.getProperty("http.proxyUser"), |
| 312 |
|
System.getProperty("http.proxyPassword"), |
| 313 |
|
System.getProperty("https.proxyUser"), |
| 314 |
|
System.getProperty("https.proxyPassword"), |
| 315 |
|
System.getProperty("http.nonProxyHosts") }; |
| 316 |
|
|
| 317 |
|
public final static String PROXYTYPE_NONE = "none"; |
| 318 |
|
|
| 319 |
|
|
| 320 |
|
public final static String PROXYTYPE_SYSTEM = "false"; |
| 321 |
|
|
| 322 |
|
public final static String PROXYTYPE_CUSTOM = "true"; |
| 323 |
|
|
| 324 |
|
|
| 325 |
|
public static char[] proxyAuthPassword = null; |
| 326 |
|
|
| 327 |
|
|
| 328 |
|
|
| 329 |
|
|
| 330 |
|
|
| 331 |
|
private static Map<String, String> sessionProperties = new HashMap<>(); |
| 332 |
|
|
| 333 |
|
private static boolean bypassSessionProperties = false; |
| 334 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 335 |
10 |
public static void enableSessionProperties()... |
| 336 |
|
{ |
| 337 |
10 |
bypassSessionProperties = false; |
| 338 |
|
} |
| 339 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 340 |
10 |
public static void disableSessionProperties()... |
| 341 |
|
{ |
| 342 |
10 |
bypassSessionProperties = true; |
| 343 |
|
} |
| 344 |
|
|
| 345 |
|
|
| 346 |
|
public static Properties applicationProperties = new Properties() |
| 347 |
|
{ |
| 348 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 349 |
0 |
@Override... |
| 350 |
|
public synchronized Enumeration<Object> keys() |
| 351 |
|
{ |
| 352 |
0 |
return Collections.enumeration(new TreeSet<>(super.keySet())); |
| 353 |
|
} |
| 354 |
|
}; |
| 355 |
|
|
| 356 |
|
|
| 357 |
|
public static Properties buildProperties = new Properties(); |
| 358 |
|
|
| 359 |
|
|
| 360 |
|
static String propertiesFile; |
| 361 |
|
|
| 362 |
|
private static final String fallbackPropertiesFile = ".jalview_properties"; |
| 363 |
|
|
| 364 |
|
private static boolean propsAreReadOnly = Platform.isJS(); |
| 365 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 366 |
0 |
public static boolean isPropsAreReadOnly()... |
| 367 |
|
{ |
| 368 |
0 |
return propsAreReadOnly; |
| 369 |
|
} |
| 370 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 371 |
32 |
public static void setPropsAreReadOnly(boolean propsAreReadOnly)... |
| 372 |
|
{ |
| 373 |
32 |
Cache.propsAreReadOnly = propsAreReadOnly; |
| 374 |
|
} |
| 375 |
|
|
| 376 |
|
private final static String JS_PROPERTY_PREFIX = "jalview_"; |
| 377 |
|
|
| 378 |
|
|
| 379 |
|
|
| 380 |
|
|
| 381 |
|
|
| |
|
| 65.1% |
Uncovered Elements: 37 (106) |
Complexity: 24 |
Complexity Density: 0.29 |
|
| 382 |
325 |
public static void loadProperties(String propsFile)... |
| 383 |
|
{ |
| 384 |
325 |
propertiesFile = propsFile; |
| 385 |
325 |
String releasePropertiesFile = null; |
| 386 |
325 |
boolean defaultProperties = false; |
| 387 |
325 |
if (propsFile == null && !propsAreReadOnly) |
| 388 |
|
{ |
| 389 |
42 |
String channelPrefsFilename = ChannelProperties |
| 390 |
|
.getProperty("preferences.filename"); |
| 391 |
42 |
String releasePrefsFilename = fallbackPropertiesFile; |
| 392 |
42 |
propertiesFile = System.getProperty("user.home") + File.separatorChar |
| 393 |
|
+ channelPrefsFilename; |
| 394 |
42 |
releasePropertiesFile = System.getProperty("user.home") |
| 395 |
|
+ File.separatorChar + releasePrefsFilename; |
| 396 |
42 |
defaultProperties = true; |
| 397 |
|
} |
| 398 |
|
else |
| 399 |
|
{ |
| 400 |
|
|
| 401 |
283 |
propsAreReadOnly = true; |
| 402 |
|
} |
| 403 |
|
|
| 404 |
325 |
if (propertiesFile == null) |
| 405 |
|
{ |
| 406 |
59 |
Platform.readInfoProperties(JS_PROPERTY_PREFIX, |
| 407 |
|
applicationProperties); |
| 408 |
|
} |
| 409 |
|
else |
| 410 |
|
{ |
| 411 |
266 |
try |
| 412 |
|
{ |
| 413 |
266 |
InputStream fis; |
| 414 |
266 |
try |
| 415 |
|
{ |
| 416 |
|
|
| 417 |
266 |
fis = HttpUtils.openStream(new URL(propertiesFile)); |
| 418 |
0 |
if (!Jalview.quiet()) |
| 419 |
|
{ |
| 420 |
0 |
jalview.bin.Console.outPrintln( |
| 421 |
|
"Loading jalview properties from : " + propertiesFile); |
| 422 |
0 |
jalview.bin.Console.outPrintln( |
| 423 |
|
"Disabling Jalview writing to user's local properties file."); |
| 424 |
|
} |
| 425 |
0 |
propsAreReadOnly = true; |
| 426 |
|
} catch (Exception ex) |
| 427 |
|
{ |
| 428 |
266 |
fis = null; |
| 429 |
|
} |
| 430 |
266 |
if (fis == null) |
| 431 |
|
{ |
| 432 |
266 |
String readPropertiesFile = propertiesFile; |
| 433 |
|
|
| 434 |
|
|
| 435 |
|
|
| 436 |
266 |
if (defaultProperties && (!new File(propertiesFile).exists()) |
| 437 |
|
&& (new File(releasePropertiesFile).exists())) |
| 438 |
|
{ |
| 439 |
0 |
readPropertiesFile = releasePropertiesFile; |
| 440 |
|
} |
| 441 |
266 |
fis = new FileInputStream(readPropertiesFile); |
| 442 |
|
} |
| 443 |
265 |
applicationProperties.clear(); |
| 444 |
265 |
applicationProperties.load(fis); |
| 445 |
|
|
| 446 |
|
|
| 447 |
|
|
| 448 |
265 |
deleteBuildProperties(); |
| 449 |
265 |
fis.close(); |
| 450 |
|
} catch (Exception ex) |
| 451 |
|
{ |
| 452 |
1 |
if (!Jalview.quiet()) |
| 453 |
1 |
jalview.bin.Console |
| 454 |
|
.outPrintln("Error reading properties file: " + ex); |
| 455 |
|
} |
| 456 |
|
} |
| 457 |
|
|
| 458 |
|
|
| 459 |
|
|
| 460 |
|
|
| 461 |
|
|
| 462 |
|
|
| 463 |
|
|
| 464 |
|
|
| 465 |
|
|
| 466 |
|
|
| 467 |
|
|
| 468 |
325 |
String proxyType = getDefault("USE_PROXY", PROXYTYPE_SYSTEM); |
| 469 |
|
|
| 470 |
325 |
switch (proxyType) |
| 471 |
|
{ |
| 472 |
0 |
case PROXYTYPE_NONE: |
| 473 |
0 |
clearProxyProperties(); |
| 474 |
0 |
break; |
| 475 |
325 |
case PROXYTYPE_SYSTEM: |
| 476 |
325 |
resetProxyProperties(); |
| 477 |
325 |
break; |
| 478 |
0 |
case PROXYTYPE_CUSTOM: |
| 479 |
0 |
String httpHost = getDefault("PROXY_SERVER", ""); |
| 480 |
0 |
String httpPort = getDefault("PROXY_PORT", "8080"); |
| 481 |
0 |
String httpsHost = getDefault("PROXY_SERVER_HTTPS", httpHost); |
| 482 |
0 |
String httpsPort = getDefault("PROXY_PORT_HTTPS", httpPort); |
| 483 |
0 |
String httpUser = getDefault("PROXY_AUTH_USER", null); |
| 484 |
|
|
| 485 |
|
|
| 486 |
0 |
String httpsUser = getDefault("PROXY_AUTH_USER_HTTPS", httpUser); |
| 487 |
0 |
setProxyProperties(httpHost, httpPort, httpsHost, httpsPort, httpUser, |
| 488 |
|
proxyAuthPassword, httpsUser, proxyAuthPassword, "localhost"); |
| 489 |
0 |
break; |
| 490 |
0 |
default: |
| 491 |
0 |
String message = "Incorrect PROXY_TYPE - should be 'none' (clear proxy properties), 'false' (system settings), 'true' (custom settings): " |
| 492 |
|
+ proxyType; |
| 493 |
0 |
Console.warn(message); |
| 494 |
|
} |
| 495 |
|
|
| 496 |
|
|
| 497 |
325 |
String authorDetails = resolveResourceURLFor("/authors.props"); |
| 498 |
|
|
| 499 |
325 |
try |
| 500 |
|
{ |
| 501 |
325 |
if (authorDetails != null) |
| 502 |
|
{ |
| 503 |
325 |
URL localJarFileURL = new URL(authorDetails); |
| 504 |
325 |
InputStream in = localJarFileURL.openStream(); |
| 505 |
325 |
applicationProperties.load(in); |
| 506 |
325 |
in.close(); |
| 507 |
|
} |
| 508 |
|
} catch (Exception ex) |
| 509 |
|
{ |
| 510 |
0 |
if (!Jalview.quiet()) |
| 511 |
0 |
jalview.bin.Console |
| 512 |
|
.outPrintln("Error reading author details: " + ex); |
| 513 |
0 |
authorDetails = null; |
| 514 |
|
} |
| 515 |
325 |
if (authorDetails == null) |
| 516 |
|
{ |
| 517 |
0 |
applicationProperties.remove("AUTHORS"); |
| 518 |
0 |
applicationProperties.remove("AUTHORFNAMES"); |
| 519 |
0 |
applicationProperties.remove("YEAR"); |
| 520 |
|
} |
| 521 |
|
|
| 522 |
325 |
loadBuildProperties(false); |
| 523 |
|
|
| 524 |
325 |
SiftsSettings |
| 525 |
|
.setMapWithSifts(Cache.getDefault("MAP_WITH_SIFTS", false)); |
| 526 |
|
|
| 527 |
325 |
SiftsSettings.setSiftDownloadDirectory(Cache |
| 528 |
|
.getDefault("sifts_download_dir", DEFAULT_SIFTS_DOWNLOAD_DIR)); |
| 529 |
|
|
| 530 |
325 |
SiftsSettings.setFailSafePIDThreshold( |
| 531 |
|
Cache.getDefault("sifts_fail_safe_pid_threshold", |
| 532 |
|
DEFAULT_FAIL_SAFE_PID_THRESHOLD)); |
| 533 |
|
|
| 534 |
325 |
SiftsSettings.setCacheThresholdInDays( |
| 535 |
|
Cache.getDefault("sifts_cache_threshold_in_days", |
| 536 |
|
DEFAULT_CACHE_THRESHOLD_IN_DAYS)); |
| 537 |
|
|
| 538 |
325 |
IdOrgSettings.setUrl(getDefault("ID_ORG_HOSTURL", |
| 539 |
|
"https://www.jalview.org/services/identifiers")); |
| 540 |
325 |
IdOrgSettings.setDownloadLocation(ID_ORG_FILE); |
| 541 |
|
|
| 542 |
325 |
StructureImportSettings.setDefaultStructureFileFormat( |
| 543 |
|
Cache.getDefault("PDB_DOWNLOAD_FORMAT", PDB_DOWNLOAD_FORMAT)); |
| 544 |
325 |
StructureImportSettings |
| 545 |
|
.setDefaultPDBFileParser(DEFAULT_PDB_FILE_PARSER); |
| 546 |
|
|
| 547 |
|
|
| 548 |
|
|
| 549 |
|
|
| 550 |
325 |
String jnlpVersion = System.getProperty("jalview.version"); |
| 551 |
|
|
| 552 |
|
|
| 553 |
|
|
| 554 |
|
|
| 555 |
|
|
| 556 |
325 |
if (jnlpVersion == null && getDefault("VERSION_CHECK", true) |
| 557 |
|
&& (System.getProperty("java.awt.headless") == null || System |
| 558 |
|
.getProperty("java.awt.headless").equals("false"))) |
| 559 |
|
{ |
| 560 |
|
|
| |
|
| 74.1% |
Uncovered Elements: 7 (27) |
Complexity: 5 |
Complexity Density: 0.25 |
|
| 561 |
|
class VersionChecker extends Thread |
| 562 |
|
{ |
| 563 |
|
|
| |
|
| 73.1% |
Uncovered Elements: 7 (26) |
Complexity: 5 |
Complexity Density: 0.25 |
|
| 564 |
126 |
@Override... |
| 565 |
|
public void run() |
| 566 |
|
{ |
| 567 |
126 |
String remoteBuildPropertiesUrl = Cache |
| 568 |
|
.getAppbaseBuildProperties(); |
| 569 |
|
|
| 570 |
126 |
String orgtimeout = System |
| 571 |
|
.getProperty("sun.net.client.defaultConnectTimeout"); |
| 572 |
126 |
if (orgtimeout == null) |
| 573 |
|
{ |
| 574 |
18 |
orgtimeout = "30"; |
| 575 |
18 |
Console.debug("Setting default net timeout to " + orgtimeout |
| 576 |
|
+ " seconds."); |
| 577 |
|
} |
| 578 |
126 |
String remoteVersion = null; |
| 579 |
126 |
if (remoteBuildPropertiesUrl.startsWith("http")) |
| 580 |
|
{ |
| 581 |
126 |
try |
| 582 |
|
{ |
| 583 |
126 |
System.setProperty("sun.net.client.defaultConnectTimeout", |
| 584 |
|
"5000"); |
| 585 |
|
|
| 586 |
126 |
URL url = new URL(remoteBuildPropertiesUrl); |
| 587 |
|
|
| 588 |
126 |
BufferedReader in = new BufferedReader( |
| 589 |
|
new InputStreamReader(HttpUtils.openStream(url))); |
| 590 |
|
|
| 591 |
125 |
Properties remoteBuildProperties = new Properties(); |
| 592 |
125 |
remoteBuildProperties.load(in); |
| 593 |
125 |
remoteVersion = remoteBuildProperties.getProperty("VERSION"); |
| 594 |
|
} catch (Exception ex) |
| 595 |
|
{ |
| 596 |
0 |
if (!Jalview.quiet()) |
| 597 |
|
{ |
| 598 |
0 |
jalview.bin.Console.errPrintln( |
| 599 |
|
"Non-fatal exception when checking version at " |
| 600 |
|
+ remoteBuildPropertiesUrl + ":"); |
| 601 |
0 |
jalview.bin.Console.printStackTrace(ex); |
| 602 |
|
} |
| 603 |
0 |
remoteVersion = getProperty("VERSION"); |
| 604 |
|
} |
| 605 |
|
} |
| 606 |
125 |
System.setProperty("sun.net.client.defaultConnectTimeout", |
| 607 |
|
orgtimeout); |
| 608 |
|
|
| 609 |
125 |
setProperty("LATEST_VERSION", remoteVersion); |
| 610 |
|
} |
| 611 |
|
} |
| 612 |
|
|
| 613 |
126 |
VersionChecker vc = new VersionChecker(); |
| 614 |
126 |
vc.start(); |
| 615 |
|
} |
| 616 |
|
else |
| 617 |
|
{ |
| 618 |
199 |
if (jnlpVersion != null) |
| 619 |
|
{ |
| 620 |
0 |
setProperty("LATEST_VERSION", jnlpVersion); |
| 621 |
|
} |
| 622 |
|
else |
| 623 |
|
{ |
| 624 |
199 |
applicationProperties.remove("LATEST_VERSION"); |
| 625 |
|
} |
| 626 |
|
} |
| 627 |
|
|
| 628 |
|
|
| 629 |
325 |
Cache.initUserColourSchemes(getProperty("USER_DEFINED_COLOURS")); |
| 630 |
325 |
jalview.io.PIRFile.useModellerOutput = Cache.getDefault("PIR_MODELLER", |
| 631 |
|
false); |
| 632 |
|
} |
| 633 |
|
|
| 634 |
|
|
| 635 |
|
|
| 636 |
|
|
| 637 |
|
@param |
| 638 |
|
@return |
| 639 |
|
|
| |
|
| 66.7% |
Uncovered Elements: 3 (9) |
Complexity: 4 |
Complexity Density: 0.57 |
|
| 640 |
799 |
private static String resolveResourceURLFor(String resourcePath)... |
| 641 |
|
{ |
| 642 |
799 |
String url = null; |
| 643 |
799 |
if (Platform.isJS() || !Cache.class.getProtectionDomain() |
| 644 |
|
.getCodeSource().getLocation().toString().endsWith(".jar")) |
| 645 |
|
{ |
| 646 |
799 |
try |
| 647 |
|
{ |
| 648 |
799 |
url = Cache.class.getResource(resourcePath).toString(); |
| 649 |
|
} catch (Exception ex) |
| 650 |
|
{ |
| 651 |
0 |
jalview.bin.Console.errPrintln("Failed to resolve resource " |
| 652 |
|
+ resourcePath + ": " + ex.getMessage()); |
| 653 |
|
} |
| 654 |
|
} |
| 655 |
|
else |
| 656 |
|
{ |
| 657 |
0 |
url = "jar:".concat(Cache.class.getProtectionDomain().getCodeSource() |
| 658 |
|
.getLocation().toString().concat("!" + resourcePath)); |
| 659 |
|
} |
| 660 |
799 |
return url; |
| 661 |
|
} |
| 662 |
|
|
| |
|
| 72.1% |
Uncovered Elements: 12 (43) |
Complexity: 10 |
Complexity Density: 0.34 |
|
| 663 |
474 |
public static void loadBuildProperties(boolean reportVersion)... |
| 664 |
|
{ |
| 665 |
474 |
String codeInstallation = getProperty("INSTALLATION"); |
| 666 |
474 |
boolean printVersion = codeInstallation == null; |
| 667 |
|
|
| 668 |
|
|
| 669 |
|
|
| 670 |
|
|
| 671 |
|
|
| 672 |
474 |
try |
| 673 |
|
{ |
| 674 |
474 |
String buildDetails = resolveResourceURLFor("/.build_properties"); |
| 675 |
474 |
URL localJarFileURL = new URL(buildDetails); |
| 676 |
474 |
InputStream in = localJarFileURL.openStream(); |
| 677 |
474 |
buildProperties.load(in); |
| 678 |
474 |
in.close(); |
| 679 |
474 |
if (buildProperties.getProperty("BUILD_DATE", null) != null) |
| 680 |
|
{ |
| 681 |
474 |
applicationProperties.put("BUILD_DATE", |
| 682 |
|
buildProperties.getProperty("BUILD_DATE")); |
| 683 |
|
} |
| 684 |
474 |
if (buildProperties.getProperty("INSTALLATION", null) != null) |
| 685 |
|
{ |
| 686 |
474 |
applicationProperties.put("INSTALLATION", |
| 687 |
|
buildProperties.getProperty("INSTALLATION")); |
| 688 |
|
} |
| 689 |
474 |
if (buildProperties.getProperty("VERSION", null) != null) |
| 690 |
|
{ |
| 691 |
474 |
applicationProperties.put("VERSION", |
| 692 |
|
buildProperties.getProperty("VERSION")); |
| 693 |
|
} |
| 694 |
474 |
if (buildProperties.getProperty("JAVA_COMPILE_VERSION", null) != null) |
| 695 |
|
{ |
| 696 |
474 |
applicationProperties.put("JAVA_COMPILE_VERSION", |
| 697 |
|
buildProperties.getProperty("JAVA_COMPILE_VERSION")); |
| 698 |
|
} |
| 699 |
|
} catch (Exception ex) |
| 700 |
|
{ |
| 701 |
0 |
if (!Jalview.quiet()) |
| 702 |
0 |
jalview.bin.Console |
| 703 |
|
.outPrintln("Error reading build details: " + ex); |
| 704 |
0 |
applicationProperties.remove("VERSION"); |
| 705 |
|
} |
| 706 |
474 |
String codeVersion = getProperty("VERSION"); |
| 707 |
474 |
codeInstallation = getProperty("INSTALLATION"); |
| 708 |
|
|
| 709 |
474 |
if (codeVersion == null) |
| 710 |
|
{ |
| 711 |
|
|
| 712 |
0 |
codeVersion = "Test"; |
| 713 |
0 |
codeInstallation = ""; |
| 714 |
|
} |
| 715 |
|
else |
| 716 |
|
{ |
| 717 |
474 |
codeInstallation = " (" + codeInstallation + ")"; |
| 718 |
|
} |
| 719 |
474 |
setProperty("VERSION", codeVersion); |
| 720 |
474 |
new BuildDetails(codeVersion, null, codeInstallation); |
| 721 |
474 |
if (printVersion && reportVersion) |
| 722 |
|
{ |
| 723 |
51 |
jalview.bin.Console |
| 724 |
|
.outPrintln(ChannelProperties.getProperty("app_name") |
| 725 |
|
+ " version: " + codeVersion + codeInstallation); |
| 726 |
|
} |
| 727 |
|
} |
| 728 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
| 729 |
265 |
private static void deleteBuildProperties()... |
| 730 |
|
{ |
| 731 |
265 |
applicationProperties.remove("LATEST_VERSION"); |
| 732 |
265 |
applicationProperties.remove("VERSION"); |
| 733 |
265 |
applicationProperties.remove("AUTHORS"); |
| 734 |
265 |
applicationProperties.remove("AUTHORFNAMES"); |
| 735 |
265 |
applicationProperties.remove("YEAR"); |
| 736 |
265 |
applicationProperties.remove("BUILD_DATE"); |
| 737 |
265 |
applicationProperties.remove("INSTALLATION"); |
| 738 |
|
} |
| 739 |
|
|
| 740 |
|
|
| 741 |
|
|
| 742 |
|
|
| 743 |
|
|
| 744 |
|
@param |
| 745 |
|
|
| 746 |
|
|
| 747 |
|
@return |
| 748 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 749 |
464556 |
public static String getProperty(String key)... |
| 750 |
|
{ |
| 751 |
464557 |
return getProperty(key, false); |
| 752 |
|
} |
| 753 |
|
|
| |
|
| 78.6% |
Uncovered Elements: 3 (14) |
Complexity: 6 |
Complexity Density: 0.75 |
|
| 754 |
464557 |
public static String getProperty(String key,... |
| 755 |
|
boolean skipSessionProperties) |
| 756 |
|
{ |
| 757 |
464558 |
String prop = null; |
| 758 |
464562 |
if (!(skipSessionProperties || bypassSessionProperties)) |
| 759 |
|
{ |
| 760 |
464463 |
prop = getSessionProperty(key); |
| 761 |
|
} |
| 762 |
464564 |
if (prop == null) |
| 763 |
|
{ |
| 764 |
464565 |
prop = applicationProperties.getProperty(key); |
| 765 |
|
} |
| 766 |
464566 |
if (prop == null && Platform.isJS()) |
| 767 |
|
{ |
| 768 |
0 |
prop = applicationProperties.getProperty(Platform.getUniqueAppletID() |
| 769 |
|
+ "_" + JS_PROPERTY_PREFIX + key); |
| 770 |
|
} |
| 771 |
464566 |
return prop; |
| 772 |
|
} |
| 773 |
|
|
| 774 |
|
|
| 775 |
|
|
| 776 |
|
|
| 777 |
|
|
| 778 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
| 779 |
445199 |
public static boolean getDefault(String property, boolean def)... |
| 780 |
|
{ |
| 781 |
445199 |
String string = getProperty(property); |
| 782 |
445207 |
if (string != null) |
| 783 |
|
{ |
| 784 |
350785 |
def = Boolean.valueOf(string).booleanValue(); |
| 785 |
|
} |
| 786 |
|
|
| 787 |
445206 |
return def; |
| 788 |
|
} |
| 789 |
|
|
| |
|
| 63.6% |
Uncovered Elements: 4 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
| 790 |
302 |
public static int getDefault(String property, int def)... |
| 791 |
|
{ |
| 792 |
302 |
String string = getProperty(property); |
| 793 |
302 |
if (string != null) |
| 794 |
|
{ |
| 795 |
8 |
try |
| 796 |
|
{ |
| 797 |
8 |
def = Integer.parseInt(string); |
| 798 |
|
} catch (NumberFormatException e) |
| 799 |
|
{ |
| 800 |
0 |
if (!Jalview.quiet()) |
| 801 |
0 |
jalview.bin.Console.errPrintln("Error parsing int property '" |
| 802 |
|
+ property + "' with value '" + string + "'"); |
| 803 |
|
} |
| 804 |
|
} |
| 805 |
|
|
| 806 |
302 |
return def; |
| 807 |
|
} |
| 808 |
|
|
| |
|
| 63.6% |
Uncovered Elements: 4 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
| 809 |
43 |
public static float getDefault(String property, float def)... |
| 810 |
|
{ |
| 811 |
43 |
String string = getProperty(property); |
| 812 |
43 |
if (string != null) |
| 813 |
|
{ |
| 814 |
4 |
try |
| 815 |
|
{ |
| 816 |
4 |
def = Float.parseFloat(string); |
| 817 |
|
} catch (NumberFormatException e) |
| 818 |
|
{ |
| 819 |
0 |
if (!Jalview.quiet()) |
| 820 |
0 |
jalview.bin.Console.errPrintln("Error parsing float property '" |
| 821 |
|
+ property + "' with value '" + string + "'"); |
| 822 |
|
} |
| 823 |
|
} |
| 824 |
|
|
| 825 |
43 |
return def; |
| 826 |
|
} |
| 827 |
|
|
| 828 |
|
|
| 829 |
|
|
| 830 |
|
|
| 831 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 832 |
12516 |
public static String getDefault(String property, String def)... |
| 833 |
|
{ |
| 834 |
12516 |
String value = getProperty(property); |
| 835 |
12516 |
return value == null ? def : value; |
| 836 |
|
} |
| 837 |
|
|
| 838 |
|
|
| 839 |
|
|
| 840 |
|
|
| 841 |
|
@param |
| 842 |
|
|
| 843 |
|
@param |
| 844 |
|
|
| 845 |
|
|
| 846 |
|
@return |
| 847 |
|
|
| |
|
| 66.7% |
Uncovered Elements: 6 (18) |
Complexity: 10 |
Complexity Density: 0.83 |
|
| 848 |
2774 |
public static Object setProperty(String key, String obj)... |
| 849 |
|
{ |
| 850 |
2774 |
Object oldValue = null; |
| 851 |
2774 |
try |
| 852 |
|
{ |
| 853 |
2774 |
oldValue = applicationProperties.setProperty(key, obj); |
| 854 |
2774 |
if (propertiesFile != null && !propsAreReadOnly |
| 855 |
|
|
| 856 |
|
&& !((obj == null && oldValue == null) |
| 857 |
|
|| (obj != null && obj.equals(oldValue)))) |
| 858 |
|
{ |
| 859 |
|
|
| 860 |
16 |
if (sessionProperties.containsKey(key)) |
| 861 |
|
{ |
| 862 |
0 |
sessionProperties.remove(key); |
| 863 |
|
} |
| 864 |
16 |
FileOutputStream out = new FileOutputStream(propertiesFile); |
| 865 |
16 |
applicationProperties.store(out, "---JalviewX Properties File---"); |
| 866 |
16 |
out.close(); |
| 867 |
|
} |
| 868 |
|
} catch (Exception ex) |
| 869 |
|
{ |
| 870 |
0 |
if (!Jalview.quiet()) |
| 871 |
0 |
jalview.bin.Console.errPrintln( |
| 872 |
|
"Error setting property: " + key + " " + obj + "\n" + ex); |
| 873 |
|
} |
| 874 |
2774 |
return oldValue; |
| 875 |
|
} |
| 876 |
|
|
| 877 |
|
|
| 878 |
|
|
| 879 |
|
|
| 880 |
|
@param |
| 881 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 882 |
27 |
public static void removeProperty(String string)... |
| 883 |
|
{ |
| 884 |
27 |
applicationProperties.remove(string); |
| 885 |
27 |
saveProperties(); |
| 886 |
|
} |
| 887 |
|
|
| 888 |
|
|
| 889 |
|
|
| 890 |
|
|
| |
|
| 18.2% |
Uncovered Elements: 9 (11) |
Complexity: 4 |
Complexity Density: 0.57 |
|
| 891 |
27 |
public static void saveProperties()... |
| 892 |
|
{ |
| 893 |
27 |
if (!propsAreReadOnly) |
| 894 |
|
{ |
| 895 |
0 |
try |
| 896 |
|
{ |
| 897 |
0 |
FileOutputStream out = new FileOutputStream(propertiesFile); |
| 898 |
0 |
applicationProperties.store(out, "---JalviewX Properties File---"); |
| 899 |
0 |
out.close(); |
| 900 |
|
} catch (Exception ex) |
| 901 |
|
{ |
| 902 |
0 |
if (!Jalview.quiet()) |
| 903 |
0 |
jalview.bin.Console.errPrintln("Error saving properties: " + ex); |
| 904 |
|
} |
| 905 |
|
} |
| 906 |
|
} |
| 907 |
|
|
| 908 |
|
|
| 909 |
|
|
| 910 |
|
|
| 911 |
|
private static int vamsasJarsArePresent = -1; |
| 912 |
|
|
| 913 |
|
|
| 914 |
|
|
| 915 |
|
|
| 916 |
|
@return |
| 917 |
|
|
| |
|
| 0% |
Uncovered Elements: 15 (15) |
Complexity: 4 |
Complexity Density: 0.36 |
|
| 918 |
0 |
public static boolean vamsasJarsPresent()... |
| 919 |
|
{ |
| 920 |
0 |
if (vamsasJarsArePresent == -1) |
| 921 |
|
{ |
| 922 |
0 |
try |
| 923 |
|
{ |
| 924 |
0 |
if (jalview.jbgui.GDesktop.class.getClassLoader() |
| 925 |
|
.loadClass("uk.ac.vamsas.client.VorbaId") != null) |
| 926 |
|
{ |
| 927 |
0 |
Console.debug( |
| 928 |
|
"Found Vamsas Classes (uk.ac..vamsas.client.VorbaId can be loaded)"); |
| 929 |
0 |
vamsasJarsArePresent = 1; |
| 930 |
0 |
JLoggerLog4j lvclient = JLoggerLog4j.getLogger("uk.ac.vamsas", |
| 931 |
|
Console.getCachedLogLevel("logs.Vamsas.Level")); |
| 932 |
0 |
JLoggerLog4j.addAppender(lvclient, Console.log, |
| 933 |
|
JALVIEW_LOGGER_NAME); |
| 934 |
|
|
| 935 |
0 |
lvclient.debug(ChannelProperties.getProperty("app_name") |
| 936 |
|
+ " Vamsas Client Debugging Output Follows."); |
| 937 |
|
} |
| 938 |
|
} catch (Exception e) |
| 939 |
|
{ |
| 940 |
0 |
vamsasJarsArePresent = 0; |
| 941 |
0 |
Console.debug("Vamsas Classes are not present"); |
| 942 |
|
} |
| 943 |
|
} |
| 944 |
0 |
return (vamsasJarsArePresent > 0); |
| 945 |
|
} |
| 946 |
|
|
| 947 |
|
|
| 948 |
|
|
| 949 |
|
|
| 950 |
|
private static int groovyJarsArePresent = -1; |
| 951 |
|
|
| 952 |
|
|
| 953 |
|
|
| 954 |
|
|
| 955 |
|
@return |
| 956 |
|
|
| |
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 5 |
Complexity Density: 0.38 |
|
| 957 |
0 |
public static boolean groovyJarsPresent()... |
| 958 |
|
{ |
| 959 |
0 |
if (groovyJarsArePresent == -1) |
| 960 |
|
{ |
| 961 |
0 |
try |
| 962 |
|
{ |
| 963 |
0 |
if (Cache.class.getClassLoader() |
| 964 |
|
.loadClass("groovy.lang.GroovyObject") != null) |
| 965 |
|
{ |
| 966 |
0 |
Console.debug( |
| 967 |
|
"Found Groovy (groovy.lang.GroovyObject can be loaded)"); |
| 968 |
0 |
groovyJarsArePresent = 1; |
| 969 |
0 |
JLoggerLog4j lgclient = JLoggerLog4j.getLogger("groovy", |
| 970 |
|
Console.getCachedLogLevel("logs.Groovy.Level")); |
| 971 |
0 |
JLoggerLog4j.addAppender(lgclient, Console.log, |
| 972 |
|
JALVIEW_LOGGER_NAME); |
| 973 |
|
|
| 974 |
0 |
lgclient.debug(ChannelProperties.getProperty("app_name") |
| 975 |
|
+ " Groovy Client Debugging Output Follows."); |
| 976 |
|
} |
| 977 |
|
} catch (Error e) |
| 978 |
|
{ |
| 979 |
0 |
groovyJarsArePresent = 0; |
| 980 |
0 |
Console.debug("Groovy Classes are not present", e); |
| 981 |
|
} catch (Exception e) |
| 982 |
|
{ |
| 983 |
0 |
groovyJarsArePresent = 0; |
| 984 |
0 |
Console.debug("Groovy Classes are not present"); |
| 985 |
|
} |
| 986 |
|
} |
| 987 |
0 |
return (groovyJarsArePresent > 0); |
| 988 |
|
} |
| 989 |
|
|
| 990 |
|
|
| 991 |
|
|
| 992 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
|
| 993 |
1 |
public static void initAnalytics()... |
| 994 |
|
{ |
| 995 |
1 |
Plausible.setEnabled(true); |
| 996 |
|
|
| 997 |
1 |
String appName = ChannelProperties.getProperty("app_name") + " Desktop"; |
| 998 |
1 |
String version = Cache.getProperty("VERSION") + "_" |
| 999 |
|
+ Cache.getDefault("BUILD_DATE", "unknown"); |
| 1000 |
1 |
String path; |
| 1001 |
|
|
| 1002 |
|
|
| 1003 |
|
|
| 1004 |
|
|
| 1005 |
|
|
| 1006 |
|
|
| 1007 |
|
|
| 1008 |
|
|
| 1009 |
|
|
| 1010 |
1 |
List<String> pathParts = new ArrayList<>(); |
| 1011 |
1 |
pathParts.add(appName); |
| 1012 |
1 |
pathParts.add(version); |
| 1013 |
1 |
pathParts.add(APPLICATION_STARTED); |
| 1014 |
1 |
path = ("/" + String.join("/", pathParts)).replace(' ', '+'); |
| 1015 |
|
|
| 1016 |
|
|
| 1017 |
|
|
| 1018 |
1 |
Plausible plausible = Plausible.getInstance(); |
| 1019 |
|
|
| 1020 |
|
|
| 1021 |
|
|
| 1022 |
|
|
| 1023 |
1 |
plausible.sendEvent("application_launch", path, true, true); |
| 1024 |
|
} |
| 1025 |
|
|
| 1026 |
|
private static final String APPLICATION_STARTED = "Application Started"; |
| 1027 |
|
|
| 1028 |
|
|
| 1029 |
|
|
| 1030 |
|
|
| 1031 |
|
@param |
| 1032 |
|
@param |
| 1033 |
|
@return |
| 1034 |
|
|
| |
|
| 76.9% |
Uncovered Elements: 3 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
| 1035 |
86 |
public static Color getDefaultColour(String property, Color defcolour)... |
| 1036 |
|
{ |
| 1037 |
86 |
String colprop = getProperty(property); |
| 1038 |
86 |
if (colprop == null) |
| 1039 |
|
{ |
| 1040 |
12 |
return defcolour; |
| 1041 |
|
} |
| 1042 |
74 |
Color col = ColorUtils.parseColourString(colprop); |
| 1043 |
74 |
if (col == null) |
| 1044 |
|
{ |
| 1045 |
0 |
Console.warn("Couldn't parse '" + colprop + "' as a colour for " |
| 1046 |
|
+ property); |
| 1047 |
|
} |
| 1048 |
74 |
return (col == null) ? defcolour : col; |
| 1049 |
|
} |
| 1050 |
|
|
| 1051 |
|
|
| 1052 |
|
|
| 1053 |
|
|
| 1054 |
|
@param |
| 1055 |
|
@param |
| 1056 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1057 |
4 |
public static void setColourProperty(String property, Color colour)... |
| 1058 |
|
{ |
| 1059 |
4 |
setProperty(property, jalview.util.Format.getHexString(colour)); |
| 1060 |
|
} |
| 1061 |
|
|
| 1062 |
|
|
| 1063 |
|
|
| 1064 |
|
|
| 1065 |
|
@param |
| 1066 |
|
@param |
| 1067 |
|
@return |
| 1068 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
| 1069 |
132 |
public static String setDateProperty(String propertyName, Date date)... |
| 1070 |
|
{ |
| 1071 |
132 |
String formatted = date_format.format(date); |
| 1072 |
132 |
setProperty(propertyName, formatted); |
| 1073 |
132 |
return formatted; |
| 1074 |
|
} |
| 1075 |
|
|
| 1076 |
|
|
| 1077 |
|
|
| 1078 |
|
|
| 1079 |
|
|
| 1080 |
|
@param |
| 1081 |
|
@return |
| 1082 |
|
|
| 1083 |
|
|
| |
|
| 87.5% |
Uncovered Elements: 1 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 1084 |
42 |
public static Date getDateProperty(String propertyName)... |
| 1085 |
|
{ |
| 1086 |
42 |
String val = getProperty(propertyName); |
| 1087 |
42 |
if (val != null) |
| 1088 |
|
{ |
| 1089 |
42 |
try |
| 1090 |
|
{ |
| 1091 |
42 |
return date_format.parse(val); |
| 1092 |
|
} catch (Exception ex) |
| 1093 |
|
{ |
| 1094 |
8 |
jalview.bin.Console |
| 1095 |
|
.errPrintln("Invalid or corrupt date in property '" |
| 1096 |
|
+ propertyName + "' : value was '" + val + "'"); |
| 1097 |
|
} |
| 1098 |
|
} |
| 1099 |
8 |
return null; |
| 1100 |
|
} |
| 1101 |
|
|
| 1102 |
|
|
| 1103 |
|
|
| 1104 |
|
|
| 1105 |
|
|
| 1106 |
|
@param |
| 1107 |
|
@return |
| 1108 |
|
|
| |
|
| 37.5% |
Uncovered Elements: 5 (8) |
Complexity: 4 |
Complexity Density: 0.67 |
|
| 1109 |
90 |
public static Integer getIntegerProperty(String property)... |
| 1110 |
|
{ |
| 1111 |
90 |
String val = getProperty(property); |
| 1112 |
? |
if (val != null && (val = val.trim()).length() > 0) |
| 1113 |
|
{ |
| 1114 |
0 |
try |
| 1115 |
|
{ |
| 1116 |
0 |
return Integer.valueOf(val); |
| 1117 |
|
} catch (NumberFormatException x) |
| 1118 |
|
{ |
| 1119 |
0 |
jalview.bin.Console.errPrintln("Invalid integer in property '" |
| 1120 |
|
+ property + "' (value was '" + val + "')"); |
| 1121 |
|
} |
| 1122 |
|
} |
| 1123 |
90 |
return null; |
| 1124 |
|
} |
| 1125 |
|
|
| 1126 |
|
|
| 1127 |
|
|
| 1128 |
|
|
| 1129 |
|
|
| 1130 |
|
@param |
| 1131 |
|
@param |
| 1132 |
|
|
| |
|
| 0% |
Uncovered Elements: 9 (9) |
Complexity: 4 |
Complexity Density: 0.8 |
|
| 1133 |
0 |
public static void setOrRemove(String propName, String value)... |
| 1134 |
|
{ |
| 1135 |
0 |
if (propName == null) |
| 1136 |
|
{ |
| 1137 |
0 |
return; |
| 1138 |
|
} |
| 1139 |
0 |
if (value == null || value.trim().length() < 1) |
| 1140 |
|
{ |
| 1141 |
0 |
Cache.applicationProperties.remove(propName); |
| 1142 |
|
} |
| 1143 |
|
else |
| 1144 |
|
{ |
| 1145 |
0 |
Cache.applicationProperties.setProperty(propName, value); |
| 1146 |
|
} |
| 1147 |
|
} |
| 1148 |
|
|
| 1149 |
|
|
| 1150 |
|
|
| 1151 |
|
|
| 1152 |
|
@param |
| 1153 |
|
|
| 1154 |
|
|
| |
|
| 9.1% |
Uncovered Elements: 30 (33) |
Complexity: 10 |
Complexity Density: 0.53 |
|
| 1155 |
325 |
public static void initUserColourSchemes(String files)... |
| 1156 |
|
{ |
| 1157 |
325 |
if (files == null || files.length() == 0) |
| 1158 |
|
{ |
| 1159 |
325 |
return; |
| 1160 |
|
} |
| 1161 |
|
|
| 1162 |
|
|
| 1163 |
|
|
| 1164 |
0 |
StringBuffer coloursFound = new StringBuffer(); |
| 1165 |
0 |
StringTokenizer st = new StringTokenizer(files, "|"); |
| 1166 |
0 |
while (st.hasMoreElements()) |
| 1167 |
|
{ |
| 1168 |
0 |
String file = st.nextToken(); |
| 1169 |
0 |
try |
| 1170 |
|
{ |
| 1171 |
0 |
UserColourScheme ucs = ColourSchemeLoader.loadColourScheme(file); |
| 1172 |
0 |
if (ucs != null) |
| 1173 |
|
{ |
| 1174 |
0 |
if (coloursFound.length() > 0) |
| 1175 |
|
{ |
| 1176 |
0 |
coloursFound.append("|"); |
| 1177 |
|
} |
| 1178 |
0 |
coloursFound.append(file); |
| 1179 |
0 |
ColourSchemes.getInstance().registerColourScheme(ucs); |
| 1180 |
|
} |
| 1181 |
|
} catch (Exception ex) |
| 1182 |
|
{ |
| 1183 |
0 |
if (!Jalview.quiet()) |
| 1184 |
0 |
jalview.bin.Console |
| 1185 |
|
.outPrintln("Error loading User ColourFile\n" + ex); |
| 1186 |
|
} |
| 1187 |
|
} |
| 1188 |
0 |
if (!files.equals(coloursFound.toString())) |
| 1189 |
|
{ |
| 1190 |
0 |
if (coloursFound.toString().length() > 1) |
| 1191 |
|
{ |
| 1192 |
0 |
setProperty(UserDefinedColours.USER_DEFINED_COLOURS, |
| 1193 |
|
coloursFound.toString()); |
| 1194 |
|
} |
| 1195 |
|
else |
| 1196 |
|
{ |
| 1197 |
0 |
applicationProperties |
| 1198 |
|
.remove(UserDefinedColours.USER_DEFINED_COLOURS); |
| 1199 |
|
} |
| 1200 |
|
} |
| 1201 |
|
} |
| 1202 |
|
|
| 1203 |
|
|
| 1204 |
|
|
| 1205 |
|
|
| 1206 |
|
@param |
| 1207 |
|
@param |
| 1208 |
|
@param |
| 1209 |
|
|
| |
|
| 86.7% |
Uncovered Elements: 2 (15) |
Complexity: 6 |
Complexity Density: 0.86 |
|
| 1210 |
3388 |
private static void appendIfNotNull(StringBuilder sb, String prefix,... |
| 1211 |
|
String value, String suffix, String defaultValue) |
| 1212 |
|
{ |
| 1213 |
3388 |
if (value == null && defaultValue == null) |
| 1214 |
|
{ |
| 1215 |
2178 |
return; |
| 1216 |
|
} |
| 1217 |
1210 |
if (prefix != null) |
| 1218 |
1210 |
sb.append(prefix); |
| 1219 |
1210 |
sb.append(value == null ? defaultValue : value); |
| 1220 |
1210 |
if (suffix != null) |
| 1221 |
1210 |
sb.append(suffix); |
| 1222 |
|
} |
| 1223 |
|
|
| 1224 |
|
|
| 1225 |
|
|
| 1226 |
|
@return |
| 1227 |
|
|
| |
|
| 82.9% |
Uncovered Elements: 13 (76) |
Complexity: 10 |
Complexity Density: 0.17 |
|
| 1228 |
242 |
public static String getVersionDetailsForConsole()... |
| 1229 |
|
{ |
| 1230 |
242 |
boolean extra = Console.isDebugEnabled() |
| 1231 |
|
|| !"release".equals(ChannelProperties.getProperty("channel")); |
| 1232 |
242 |
StringBuilder sb = new StringBuilder(); |
| 1233 |
242 |
sb.append(ChannelProperties.getProperty("app_name")) |
| 1234 |
|
.append(" Version: "); |
| 1235 |
242 |
sb.append(Cache.getDefault("VERSION", "TEST")); |
| 1236 |
242 |
sb.append("\n"); |
| 1237 |
242 |
sb.append(ChannelProperties.getProperty("app_name")) |
| 1238 |
|
.append(" Installation: "); |
| 1239 |
242 |
sb.append(Cache.getDefault("INSTALLATION", "unknown")); |
| 1240 |
242 |
sb.append("\n"); |
| 1241 |
242 |
appendIfNotNull(sb, "Channel: ", |
| 1242 |
|
ChannelProperties.getProperty("channel"), "\n", null); |
| 1243 |
242 |
sb.append("Build Date: "); |
| 1244 |
242 |
sb.append(Cache.getDefault("BUILD_DATE", "unknown")); |
| 1245 |
242 |
sb.append("\n"); |
| 1246 |
242 |
if (extra) |
| 1247 |
|
{ |
| 1248 |
242 |
appendIfNotNull(sb, "Preferences file: ", propertiesFile, "\n", |
| 1249 |
|
"unknown"); |
| 1250 |
242 |
appendIfNotNull(sb, "Log file: ", |
| 1251 |
|
System.getProperty("installer.logfile"), "\n", "unknown"); |
| 1252 |
|
} |
| 1253 |
242 |
sb.append("Java version: "); |
| 1254 |
242 |
sb.append(System.getProperty("java.version")); |
| 1255 |
242 |
sb.append("\n"); |
| 1256 |
242 |
if (extra) |
| 1257 |
|
{ |
| 1258 |
242 |
appendIfNotNull(sb, "Java home: ", System.getProperty("java.home"), |
| 1259 |
|
"\n", "unknown"); |
| 1260 |
242 |
appendIfNotNull(sb, "Java launch class: ", |
| 1261 |
|
System.getProperty("sun.java.command"), "\n", "unknown"); |
| 1262 |
242 |
sb.append("Java platform: "); |
| 1263 |
242 |
sb.append(System.getProperty("os.name")); |
| 1264 |
242 |
sb.append(" "); |
| 1265 |
242 |
sb.append(System.getProperty("os.version")); |
| 1266 |
242 |
sb.append(" ("); |
| 1267 |
242 |
sb.append(System.getProperty("os.arch")); |
| 1268 |
242 |
sb.append(")"); |
| 1269 |
242 |
sb.append("\n"); |
| 1270 |
242 |
LookAndFeel laf = UIManager.getLookAndFeel(); |
| 1271 |
242 |
String lafName = laf == null ? "Not obtained" : laf.getName(); |
| 1272 |
242 |
String lafClass = laf == null ? "unknown" : laf.getClass().getName(); |
| 1273 |
242 |
sb.append("Java LAF: "); |
| 1274 |
242 |
sb.append(lafName); |
| 1275 |
242 |
sb.append(" ("); |
| 1276 |
242 |
sb.append(lafClass); |
| 1277 |
242 |
sb.append(")\n"); |
| 1278 |
|
|
| 1279 |
242 |
if (LaunchUtils.getJavaVersion() > 8) |
| 1280 |
|
{ |
| 1281 |
242 |
sb.append("Java Virtual Machine PID: "); |
| 1282 |
242 |
sb.append(ProcessHandle.current().pid()); |
| 1283 |
242 |
sb.append("\n"); |
| 1284 |
|
} |
| 1285 |
|
|
| 1286 |
|
} |
| 1287 |
242 |
appendIfNotNull(sb, "Installer version: ", |
| 1288 |
|
System.getProperty("sys.install4jVersion"), "\n", null); |
| 1289 |
242 |
if (extra) |
| 1290 |
|
{ |
| 1291 |
242 |
String installerAppdir = System.getProperty("installer.appdir"); |
| 1292 |
242 |
if (installerAppdir != null) |
| 1293 |
|
{ |
| 1294 |
0 |
try |
| 1295 |
|
{ |
| 1296 |
0 |
String temp = new File(installerAppdir).getCanonicalPath(); |
| 1297 |
0 |
installerAppdir = temp; |
| 1298 |
|
} catch (IOException e) |
| 1299 |
|
{ |
| 1300 |
0 |
installerAppdir = "(non-canonical) " + installerAppdir; |
| 1301 |
0 |
Console.warn( |
| 1302 |
|
"Could not get canonical path for installer appdir, leaving as is."); |
| 1303 |
|
} |
| 1304 |
|
} |
| 1305 |
242 |
appendIfNotNull(sb, "Installer template version: ", |
| 1306 |
|
System.getProperty("installer.template_version"), "\n", null); |
| 1307 |
242 |
appendIfNotNull(sb, "Installer appdir: ", installerAppdir, "\n", |
| 1308 |
|
null); |
| 1309 |
242 |
appendIfNotNull(sb, "Installer extrainfo: ", |
| 1310 |
|
System.getProperty("installer.extrainfo"), "\n", null); |
| 1311 |
|
} |
| 1312 |
242 |
appendIfNotNull(sb, "Launcher version: ", |
| 1313 |
|
System.getProperty("launcher.version"), "\n", null); |
| 1314 |
242 |
if (extra) |
| 1315 |
|
{ |
| 1316 |
242 |
appendIfNotNull(sb, "Launcher appdir: ", |
| 1317 |
|
System.getProperty("launcher.appdir"), "\n", null); |
| 1318 |
242 |
appendIfNotNull(sb, "Launcher distdir: ", |
| 1319 |
|
System.getProperty("launcher.distdir"), "\n", null); |
| 1320 |
242 |
appendIfNotNull(sb, "Launcher appbase: ", |
| 1321 |
|
System.getProperty("launcher.appbase"), "\n", null); |
| 1322 |
242 |
appendIfNotNull(sb, "Launcher script: ", |
| 1323 |
|
System.getProperty("launcher.script"), "\n", null); |
| 1324 |
|
} |
| 1325 |
242 |
return sb.toString(); |
| 1326 |
|
} |
| 1327 |
|
|
| 1328 |
|
|
| 1329 |
|
|
| 1330 |
|
@return |
| 1331 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1332 |
547 |
public static String getBuildDetailsForSplash()... |
| 1333 |
|
{ |
| 1334 |
|
|
| 1335 |
|
|
| 1336 |
547 |
return Cache.getDefault("INSTALLATION", "unknown"); |
| 1337 |
|
} |
| 1338 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 1339 |
0 |
public static String getStackTraceString(Throwable t)... |
| 1340 |
|
{ |
| 1341 |
0 |
StringWriter sw = new StringWriter(); |
| 1342 |
0 |
PrintWriter pw = new PrintWriter(sw); |
| 1343 |
0 |
t.printStackTrace(pw); |
| 1344 |
0 |
return sw.toString(); |
| 1345 |
|
} |
| 1346 |
|
|
| 1347 |
|
|
| |
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1348 |
0 |
public static void clearProxyProperties()... |
| 1349 |
|
{ |
| 1350 |
0 |
setProxyProperties(null, null, null, null, null, null, null, null, |
| 1351 |
|
null); |
| 1352 |
|
} |
| 1353 |
|
|
| |
|
| 66.7% |
Uncovered Elements: 4 (12) |
Complexity: 7 |
Complexity Density: 1.75 |
|
| 1354 |
325 |
public static void resetProxyProperties()... |
| 1355 |
|
{ |
| 1356 |
325 |
setProxyProperties(startupProxyProperties[0], startupProxyProperties[1], |
| 1357 |
|
startupProxyProperties[2], startupProxyProperties[3], |
| 1358 |
|
startupProxyProperties[4], |
| 1359 |
325 |
startupProxyProperties[5] == null ? null |
| 1360 |
|
: startupProxyProperties[5].toCharArray(), |
| 1361 |
|
startupProxyProperties[6], |
| 1362 |
325 |
startupProxyProperties[7] == null ? null |
| 1363 |
|
: startupProxyProperties[7].toCharArray(), |
| 1364 |
|
startupProxyProperties[8]); |
| 1365 |
325 |
StringBuilder sb = new StringBuilder(); |
| 1366 |
325 |
sb.append("Setting proxy properties to: http.proxyHost=") |
| 1367 |
|
.append(startupProxyProperties[0]).append(", http.proxyPort=") |
| 1368 |
|
.append(startupProxyProperties[1]) |
| 1369 |
325 |
.append(startupProxyProperties[4] != null |
| 1370 |
|
&& !startupProxyProperties[4].isEmpty() |
| 1371 |
|
? " [" + startupProxyProperties[4] + "]" |
| 1372 |
|
: "") |
| 1373 |
|
.append(", https.proxyHost=").append(startupProxyProperties[2]) |
| 1374 |
|
.append(", https.proxyPort=").append(startupProxyProperties[3]) |
| 1375 |
325 |
.append(startupProxyProperties[6] != null |
| 1376 |
|
&& !startupProxyProperties[6].isEmpty() |
| 1377 |
|
? " [" + startupProxyProperties[6] + "]" |
| 1378 |
|
: ""); |
| 1379 |
|
|
| 1380 |
325 |
Console.debug(sb.toString()); |
| 1381 |
|
} |
| 1382 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 1383 |
93 |
public static void setProxyPropertiesFromPreferences()... |
| 1384 |
|
{ |
| 1385 |
93 |
setProxyPropertiesFromPreferences(Cache.PROXYTYPE_SYSTEM); |
| 1386 |
|
} |
| 1387 |
|
|
| |
|
| 13.8% |
Uncovered Elements: 25 (29) |
Complexity: 11 |
Complexity Density: 0.65 |
|
| 1388 |
93 |
public static void setProxyPropertiesFromPreferences(... |
| 1389 |
|
String previousProxyType) |
| 1390 |
|
{ |
| 1391 |
93 |
String proxyType = Cache.getDefault("USE_PROXY", |
| 1392 |
|
Cache.PROXYTYPE_SYSTEM); |
| 1393 |
93 |
if (previousProxyType != null |
| 1394 |
|
&& !proxyType.equals(Cache.PROXYTYPE_CUSTOM) |
| 1395 |
|
|
| 1396 |
|
&& proxyType.equals(previousProxyType)) |
| 1397 |
|
{ |
| 1398 |
|
|
| 1399 |
93 |
return; |
| 1400 |
|
} |
| 1401 |
0 |
switch (proxyType) |
| 1402 |
|
{ |
| 1403 |
0 |
case Cache.PROXYTYPE_NONE: |
| 1404 |
0 |
if (!previousProxyType.equals(proxyType)) |
| 1405 |
|
{ |
| 1406 |
0 |
Console.info("Setting no proxy settings"); |
| 1407 |
0 |
Cache.setProxyProperties(null, null, null, null, null, null, null, |
| 1408 |
|
null, null); |
| 1409 |
|
} |
| 1410 |
0 |
break; |
| 1411 |
0 |
case Cache.PROXYTYPE_CUSTOM: |
| 1412 |
|
|
| 1413 |
|
|
| 1414 |
0 |
Console.info("Setting custom proxy settings"); |
| 1415 |
0 |
boolean proxyAuthSet = Cache.getDefault("PROXY_AUTH", false); |
| 1416 |
0 |
Cache.setProxyProperties(Cache.getDefault("PROXY_SERVER", null), |
| 1417 |
|
Cache.getDefault("PROXY_PORT", null), |
| 1418 |
|
Cache.getDefault("PROXY_SERVER_HTTPS", null), |
| 1419 |
|
Cache.getDefault("PROXY_PORT_HTTPS", null), |
| 1420 |
0 |
proxyAuthSet ? Cache.getDefault("PROXY_AUTH_USERNAME", "") |
| 1421 |
|
: null, |
| 1422 |
0 |
proxyAuthSet ? Cache.proxyAuthPassword : null, |
| 1423 |
0 |
proxyAuthSet ? Cache.getDefault("PROXY_AUTH_USERNAME", "") |
| 1424 |
|
: null, |
| 1425 |
0 |
proxyAuthSet ? Cache.proxyAuthPassword : null, "localhost"); |
| 1426 |
0 |
break; |
| 1427 |
0 |
default: |
| 1428 |
0 |
Console.info("Setting system proxy settings"); |
| 1429 |
0 |
Cache.resetProxyProperties(); |
| 1430 |
|
} |
| 1431 |
|
} |
| 1432 |
|
|
| |
|
| 48.4% |
Uncovered Elements: 16 (31) |
Complexity: 7 |
Complexity Density: 0.3 |
|
| 1433 |
325 |
public static void setProxyProperties(String httpHost, String httpPort,... |
| 1434 |
|
String httpsHost, String httpsPort, String httpUser, |
| 1435 |
|
char[] httpPassword, String httpsUser, char[] httpsPassword, |
| 1436 |
|
String nonProxyHosts) |
| 1437 |
|
{ |
| 1438 |
325 |
setOrClearSystemProperty("http.proxyHost", httpHost); |
| 1439 |
325 |
setOrClearSystemProperty("http.proxyPort", httpPort); |
| 1440 |
325 |
setOrClearSystemProperty("https.proxyHost", httpsHost); |
| 1441 |
325 |
setOrClearSystemProperty("https.proxyPort", httpsPort); |
| 1442 |
325 |
setOrClearSystemProperty("http.proxyUser", httpUser); |
| 1443 |
325 |
setOrClearSystemProperty("https.proxyUser", httpsUser); |
| 1444 |
|
|
| 1445 |
|
|
| 1446 |
|
|
| 1447 |
|
|
| 1448 |
325 |
boolean customProxySet = getDefault("USE_PROXY", PROXYTYPE_SYSTEM) |
| 1449 |
|
.equals(PROXYTYPE_CUSTOM); |
| 1450 |
|
|
| 1451 |
|
|
| 1452 |
|
|
| 1453 |
|
|
| 1454 |
|
|
| 1455 |
|
|
| 1456 |
|
|
| 1457 |
|
|
| 1458 |
|
|
| 1459 |
|
|
| 1460 |
|
|
| 1461 |
|
|
| 1462 |
|
|
| 1463 |
|
|
| 1464 |
|
|
| 1465 |
|
|
| 1466 |
|
|
| 1467 |
|
|
| 1468 |
|
|
| 1469 |
|
|
| 1470 |
|
|
| 1471 |
|
|
| 1472 |
|
|
| 1473 |
325 |
if (httpUser != null || httpsUser != null) |
| 1474 |
|
{ |
| 1475 |
0 |
try |
| 1476 |
|
{ |
| 1477 |
0 |
char[] displayHttpPw = new char[httpPassword == null ? 0 |
| 1478 |
|
: httpPassword.length]; |
| 1479 |
0 |
Arrays.fill(displayHttpPw, '*'); |
| 1480 |
0 |
Console.debug( |
| 1481 |
|
"CACHE Proxy: setting new Authenticator with httpUser='" |
| 1482 |
|
+ httpUser + "' httpPassword='" + displayHttpPw |
| 1483 |
|
+ "'"); |
| 1484 |
0 |
if (!Platform.isJS()) |
| 1485 |
|
|
| 1486 |
|
|
| 1487 |
|
|
| 1488 |
|
|
| 1489 |
|
|
| 1490 |
|
|
| 1491 |
|
{ |
| 1492 |
0 |
Authenticator.setDefault(new Authenticator() |
| 1493 |
|
{ |
| |
|
| 0% |
Uncovered Elements: 28 (28) |
Complexity: 20 |
Complexity Density: 1 |
|
| 1494 |
0 |
@Override... |
| 1495 |
|
protected PasswordAuthentication getPasswordAuthentication() |
| 1496 |
|
{ |
| 1497 |
0 |
if (getRequestorType() == RequestorType.PROXY) |
| 1498 |
|
{ |
| 1499 |
0 |
String protocol = getRequestingProtocol(); |
| 1500 |
0 |
boolean needProxyPasswordSet = false; |
| 1501 |
0 |
if (customProxySet && |
| 1502 |
|
|
| 1503 |
|
|
| 1504 |
|
(protocol.equalsIgnoreCase("http") |
| 1505 |
|
&& (httpUser != null |
| 1506 |
|
&& httpUser.length() > 0 |
| 1507 |
|
&& (httpPassword == null |
| 1508 |
|
|| httpPassword.length == 0))) |
| 1509 |
|
|| (protocol.equalsIgnoreCase("https") |
| 1510 |
|
&& (httpsUser != null |
| 1511 |
|
&& httpsUser.length() > 0 |
| 1512 |
|
&& (httpsPassword == null |
| 1513 |
|
|| httpsPassword.length == 0)))) |
| 1514 |
|
{ |
| 1515 |
|
|
| 1516 |
0 |
String message = MessageManager |
| 1517 |
|
.getString("label.proxy_password_required"); |
| 1518 |
0 |
Preferences.openPreferences( |
| 1519 |
|
Preferences.TabRef.CONNECTIONS_TAB, message); |
| 1520 |
0 |
Preferences.getInstance() |
| 1521 |
|
.proxyAuthPasswordCheckHighlight(true, true); |
| 1522 |
|
} |
| 1523 |
|
else |
| 1524 |
|
{ |
| 1525 |
0 |
try |
| 1526 |
|
{ |
| 1527 |
0 |
if (protocol.equalsIgnoreCase("http") |
| 1528 |
|
&& getRequestingHost() |
| 1529 |
|
.equalsIgnoreCase(httpHost) |
| 1530 |
|
&& getRequestingPort() == Integer |
| 1531 |
|
.valueOf(httpPort)) |
| 1532 |
|
{ |
| 1533 |
0 |
Console.debug( |
| 1534 |
|
"AUTHENTICATOR returning PasswordAuthentication(\"" |
| 1535 |
|
+ httpUser + "\", '" |
| 1536 |
|
+ new String(displayHttpPw) + "')"); |
| 1537 |
0 |
return new PasswordAuthentication(httpUser, |
| 1538 |
|
httpPassword); |
| 1539 |
|
} |
| 1540 |
0 |
if (protocol.equalsIgnoreCase("https") |
| 1541 |
|
&& getRequestingHost() |
| 1542 |
|
.equalsIgnoreCase(httpsHost) |
| 1543 |
|
&& getRequestingPort() == Integer |
| 1544 |
|
.valueOf(httpsPort)) |
| 1545 |
|
{ |
| 1546 |
0 |
char[] displayHttpsPw = new char[httpPassword.length]; |
| 1547 |
0 |
Arrays.fill(displayHttpsPw, '*'); |
| 1548 |
0 |
Console.debug( |
| 1549 |
|
"AUTHENTICATOR returning PasswordAuthentication(\"" |
| 1550 |
|
+ httpsUser + "\", '" + displayHttpsPw |
| 1551 |
|
+ "'"); |
| 1552 |
0 |
return new PasswordAuthentication(httpsUser, |
| 1553 |
|
httpsPassword); |
| 1554 |
|
} |
| 1555 |
|
} catch (NumberFormatException e) |
| 1556 |
|
{ |
| 1557 |
0 |
Console.error("Problem with proxy port values [http:" |
| 1558 |
|
+ httpPort + ", https:" + httpsPort + "]"); |
| 1559 |
|
} |
| 1560 |
0 |
Console.debug( |
| 1561 |
|
"AUTHENTICATOR after trying to get PasswordAuthentication"); |
| 1562 |
|
} |
| 1563 |
|
} |
| 1564 |
|
|
| 1565 |
0 |
Console.debug("AUTHENTICATOR returning null"); |
| 1566 |
0 |
return null; |
| 1567 |
|
} |
| 1568 |
|
}); |
| 1569 |
|
} |
| 1570 |
|
|
| 1571 |
|
|
| 1572 |
|
|
| 1573 |
0 |
Console.debug( |
| 1574 |
|
"AUTHENTICATOR setting property 'jdk.http.auth.tunneling.disabledSchemes' to \"\""); |
| 1575 |
0 |
System.setProperty("jdk.http.auth.tunneling.disabledSchemes", ""); |
| 1576 |
|
} catch (SecurityException e) |
| 1577 |
|
{ |
| 1578 |
0 |
Console.error("Could not set default Authenticator"); |
| 1579 |
0 |
Console.debug(getStackTraceString(e)); |
| 1580 |
|
} |
| 1581 |
|
} |
| 1582 |
|
else |
| 1583 |
|
{ |
| 1584 |
|
|
| 1585 |
|
|
| 1586 |
|
|
| 1587 |
|
|
| 1588 |
|
|
| 1589 |
325 |
if (!Platform.isJS()) |
| 1590 |
|
|
| 1591 |
|
|
| 1592 |
|
|
| 1593 |
|
|
| 1594 |
|
|
| 1595 |
|
|
| 1596 |
|
{ |
| 1597 |
325 |
Console.debug( |
| 1598 |
|
"AUTHENTICATOR setting default Authenticator to null"); |
| 1599 |
325 |
Authenticator.setDefault(null); |
| 1600 |
|
} |
| 1601 |
|
} |
| 1602 |
|
|
| 1603 |
|
|
| 1604 |
325 |
Console.debug( |
| 1605 |
|
"AUTHENTICATOR setting property 'http.nonProxyHosts' to \"" |
| 1606 |
|
+ nonProxyHosts + "\""); |
| 1607 |
325 |
setOrClearSystemProperty("http.nonProxyHosts", nonProxyHosts); |
| 1608 |
|
} |
| 1609 |
|
|
| |
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 1610 |
0 |
public static void setOrClearSystemProperty(String key, char[] value)... |
| 1611 |
|
{ |
| 1612 |
0 |
setOrClearSystemProperty(key, |
| 1613 |
0 |
(value == null) ? null : new String(value)); |
| 1614 |
|
} |
| 1615 |
|
|
| |
|
| 55.6% |
Uncovered Elements: 4 (9) |
Complexity: 3 |
Complexity Density: 0.6 |
|
| 1616 |
2275 |
public static void setOrClearSystemProperty(String key, String value)... |
| 1617 |
|
{ |
| 1618 |
2275 |
if (key == null) |
| 1619 |
|
{ |
| 1620 |
0 |
return; |
| 1621 |
|
} |
| 1622 |
2275 |
if (value == null) |
| 1623 |
|
{ |
| 1624 |
2275 |
System.clearProperty(key); |
| 1625 |
|
} |
| 1626 |
|
else |
| 1627 |
|
{ |
| 1628 |
0 |
System.setProperty(key, value); |
| 1629 |
|
} |
| 1630 |
|
} |
| 1631 |
|
|
| 1632 |
|
|
| 1633 |
|
|
| 1634 |
|
|
| 1635 |
|
|
| 1636 |
|
private static final String releaseAppbase; |
| 1637 |
|
|
| 1638 |
|
private static String getdownAppbase; |
| 1639 |
|
|
| 1640 |
|
private static String getdownDistDir; |
| 1641 |
|
|
| |
|
| 50% |
Uncovered Elements: 5 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 1642 |
55 |
static... |
| 1643 |
|
{ |
| 1644 |
55 |
if (!Platform.isJS()) |
| 1645 |
|
{ |
| 1646 |
55 |
Float specversion = Float |
| 1647 |
|
.parseFloat(System.getProperty("java.specification.version")); |
| 1648 |
55 |
releaseAppbase = (specversion < 9) |
| 1649 |
|
? "https://www.jalview.org/getdown/release/1.8" |
| 1650 |
|
: "https://www.jalview.org/getdown/release/11"; |
| 1651 |
|
} |
| 1652 |
|
else |
| 1653 |
|
{ |
| 1654 |
|
|
| 1655 |
|
|
| 1656 |
0 |
releaseAppbase = "https://www.jalview.org/jalview-js"; |
| 1657 |
0 |
getdownAppbase = releaseAppbase; |
| 1658 |
0 |
getdownDistDir = "/swingjs/j2s"; |
| 1659 |
|
} |
| 1660 |
|
} |
| 1661 |
|
|
| 1662 |
|
|
| |
|
| 72.2% |
Uncovered Elements: 10 (36) |
Complexity: 9 |
Complexity Density: 0.45 |
|
| 1663 |
126 |
private static void setGetdownAppbase()... |
| 1664 |
|
{ |
| 1665 |
126 |
if (getdownAppbase != null) |
| 1666 |
|
{ |
| 1667 |
108 |
return; |
| 1668 |
|
} |
| 1669 |
18 |
String appbase = System.getProperty("launcher.appbase"); |
| 1670 |
18 |
if (appbase == null) |
| 1671 |
|
{ |
| 1672 |
18 |
appbase = System.getProperty("getdownappbase"); |
| 1673 |
|
} |
| 1674 |
18 |
String distDir = System.getProperty("launcher.distdir"); |
| 1675 |
18 |
if (distDir == null) |
| 1676 |
|
{ |
| 1677 |
18 |
distDir = System.getProperty("getdowndistdir"); |
| 1678 |
|
} |
| 1679 |
18 |
if (appbase == null) |
| 1680 |
|
{ |
| 1681 |
18 |
appbase = buildProperties.getProperty("GETDOWNAPPBASE"); |
| 1682 |
18 |
distDir = buildProperties.getProperty("GETDOWNAPPDISTDIR"); |
| 1683 |
|
} |
| 1684 |
18 |
if (appbase == null) |
| 1685 |
|
{ |
| 1686 |
18 |
appbase = releaseAppbase; |
| 1687 |
18 |
distDir = "release"; |
| 1688 |
|
} |
| 1689 |
18 |
if (appbase.endsWith("/")) |
| 1690 |
|
{ |
| 1691 |
0 |
appbase = appbase.substring(0, appbase.length() - 1); |
| 1692 |
|
} |
| 1693 |
18 |
if (distDir == null) |
| 1694 |
|
{ |
| 1695 |
0 |
distDir = appbase.equals(releaseAppbase) ? "release" : "alt"; |
| 1696 |
|
} |
| 1697 |
18 |
getdownAppbase = appbase; |
| 1698 |
18 |
getdownDistDir = distDir; |
| 1699 |
|
} |
| 1700 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 1701 |
126 |
public static String getGetdownAppbase()... |
| 1702 |
|
{ |
| 1703 |
126 |
setGetdownAppbase(); |
| 1704 |
126 |
return getdownAppbase; |
| 1705 |
|
} |
| 1706 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 1707 |
126 |
public static String getAppbaseBuildProperties()... |
| 1708 |
|
{ |
| 1709 |
126 |
String appbase = getGetdownAppbase(); |
| 1710 |
126 |
return appbase + "/" + getdownDistDir + "/build_properties"; |
| 1711 |
|
} |
| 1712 |
|
|
| 1713 |
|
private static final Collection<String> bootstrapProperties = new ArrayList<>( |
| 1714 |
|
Arrays.asList(JALVIEWLOGLEVEL, BOOTSTRAP_TEST)); |
| 1715 |
|
|
| |
|
| 70.7% |
Uncovered Elements: 12 (41) |
Complexity: 11 |
Complexity Density: 0.38 |
|
| 1716 |
150 |
public static Properties bootstrapProperties(String filename)... |
| 1717 |
|
{ |
| 1718 |
150 |
Properties bootstrapProps = new Properties(); |
| 1719 |
150 |
File file = null; |
| 1720 |
150 |
if (filename != null) |
| 1721 |
|
{ |
| 1722 |
48 |
file = new File(filename); |
| 1723 |
|
} |
| 1724 |
150 |
if (file == null || !file.exists()) |
| 1725 |
|
{ |
| 1726 |
102 |
if (file != null) |
| 1727 |
|
{ |
| 1728 |
0 |
jalview.bin.Console |
| 1729 |
|
.errPrintln("Could not load bootstrap preferences file '" |
| 1730 |
|
+ file.getPath() + "'"); |
| 1731 |
|
} |
| 1732 |
102 |
String channelPrefsFilename = ChannelProperties |
| 1733 |
|
.getProperty("preferences.filename"); |
| 1734 |
102 |
String propertiesFilename = System.getProperty("user.home") |
| 1735 |
|
+ File.separatorChar + channelPrefsFilename; |
| 1736 |
102 |
jalview.bin.Console.errPrintln( |
| 1737 |
|
"Using default properties file '" + propertiesFilename + "'"); |
| 1738 |
102 |
file = new File(propertiesFilename); |
| 1739 |
|
} |
| 1740 |
150 |
if (file == null || !file.exists()) |
| 1741 |
|
|
| 1742 |
|
{ |
| 1743 |
0 |
String releasePrefsFilename = fallbackPropertiesFile; |
| 1744 |
0 |
String releasePropertiesFilename = System.getProperty("user.home") |
| 1745 |
|
+ File.separatorChar + releasePrefsFilename; |
| 1746 |
0 |
jalview.bin.Console.errPrintln("Falling back to properties file '" |
| 1747 |
|
+ releasePropertiesFilename + "'"); |
| 1748 |
0 |
file = new File(releasePropertiesFilename); |
| 1749 |
|
} |
| 1750 |
|
|
| 1751 |
150 |
if (!file.exists()) |
| 1752 |
|
{ |
| 1753 |
0 |
jalview.bin.Console |
| 1754 |
|
.errPrintln("Could not load bootstrap preferences file '" |
| 1755 |
|
+ file.getPath() + "'"); |
| 1756 |
0 |
return null; |
| 1757 |
|
} |
| 1758 |
|
|
| 1759 |
150 |
try |
| 1760 |
|
{ |
| 1761 |
150 |
FileInputStream in = new FileInputStream(file.getAbsoluteFile()); |
| 1762 |
150 |
Properties props = new Properties(); |
| 1763 |
150 |
props.load(in); |
| 1764 |
150 |
for (String prop : bootstrapProperties) |
| 1765 |
|
{ |
| 1766 |
300 |
if (props.containsKey(prop)) |
| 1767 |
9 |
bootstrapProps.put(prop, props.getProperty(prop)); |
| 1768 |
|
} |
| 1769 |
|
} catch (FileNotFoundException e) |
| 1770 |
|
{ |
| 1771 |
0 |
jalview.bin.Console |
| 1772 |
|
.errPrintln("Could not find bootstrap preferences file '" |
| 1773 |
|
+ file.getAbsolutePath() + "'"); |
| 1774 |
|
} catch (IOException e) |
| 1775 |
|
{ |
| 1776 |
0 |
jalview.bin.Console.errPrintln( |
| 1777 |
|
"IOException when loading bootstrap preferences file '" |
| 1778 |
|
+ file.getAbsolutePath() + "'"); |
| 1779 |
|
} |
| 1780 |
150 |
return bootstrapProps; |
| 1781 |
|
} |
| 1782 |
|
|
| |
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 1783 |
0 |
public static void setSessionProperty(String key, String val)... |
| 1784 |
|
{ |
| 1785 |
0 |
if (key != null) |
| 1786 |
|
{ |
| 1787 |
0 |
sessionProperties.put(key, val); |
| 1788 |
|
} |
| 1789 |
|
} |
| 1790 |
|
|
| |
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 2 |
|
| 1791 |
464461 |
public static String getSessionProperty(String key)... |
| 1792 |
|
{ |
| 1793 |
464462 |
return key == null ? null : sessionProperties.get(key); |
| 1794 |
|
} |
| 1795 |
|
|
| |
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 1796 |
93 |
public static boolean getArgCacheDefault(Arg a, String pref, boolean def)... |
| 1797 |
|
{ |
| 1798 |
93 |
ArgParser ap = Jalview.getInstance().getArgParser(); |
| 1799 |
93 |
return ap.isSet(a) ? ap.getBoolean(a) : getDefault(pref, def); |
| 1800 |
|
} |
| 1801 |
|
} |