|
16 | 16 |
|
17 | 17 | package net.sourceforge.jnlp.config; |
18 | 18 |
|
| 19 | +import net.adoptopenjdk.icedteaweb.JavaSystemProperties; |
19 | 20 | import net.adoptopenjdk.icedteaweb.config.validators.ValueValidator; |
20 | 21 | import net.adoptopenjdk.icedteaweb.http.CloseableConnection; |
21 | 22 | import net.adoptopenjdk.icedteaweb.http.ConnectionFactory; |
@@ -65,6 +66,7 @@ public final class DeploymentConfiguration { |
65 | 66 | public static final String LOCKED_POSTFIX = ".locked"; |
66 | 67 | public static final String LOCAL_DEPLOYMENT_PROPERTIES_FILE_PATH = "localDeploymentPropertiesFilePath"; |
67 | 68 |
|
| 69 | + public static final String USER_HOME_DIR_TOKEN = "#USER_HOME_DIR#"; |
68 | 70 | private String userComments; |
69 | 71 |
|
70 | 72 | private ConfigurationException loadingException = null; |
@@ -214,6 +216,8 @@ public void load(final boolean fixIssues) throws ConfigurationException, Malform |
214 | 216 | userComments = loadComments(userPropertiesUrl); |
215 | 217 | mergeMaps(properties, userProperties); |
216 | 218 |
|
| 219 | + processPropertiesWithHomeDirToken(properties); |
| 220 | + |
217 | 221 | if (fixIssues) { |
218 | 222 | checkAndFixConfiguration(properties); |
219 | 223 | } |
@@ -367,14 +371,27 @@ private void checkAndFixConfiguration(final Map<String, Setting> initial) { |
367 | 371 | try { |
368 | 372 | checker.validate(setting.getValue()); |
369 | 373 | } catch (final IllegalArgumentException e) { |
370 | | - LOG.error("Property '{}' has incorrect value \"{}\". Possible values {}.", key, setting.getValue(), checker.getPossibleValues(), e); |
| 374 | + LOG.error("Property '{}' has incorrect value \"{}\". Possible values {}. Setting default {}", key, setting.getValue(), checker.getPossibleValues(), setting.getDefaultValue(), e); |
371 | 375 | setting.setValue(setting.getDefaultValue()); |
372 | 376 | } |
373 | 377 | } |
374 | 378 | } |
375 | 379 | } |
376 | 380 | } |
377 | 381 |
|
| 382 | + private void processPropertiesWithHomeDirToken(final Map<String, Setting> properties) { |
| 383 | + for (final Map.Entry<String, Setting> entry : properties.entrySet()) { |
| 384 | + final String key = entry.getKey(); |
| 385 | + final Setting setting = entry.getValue(); |
| 386 | + final String propertyValue = setting.getValue(); |
| 387 | + if (propertyValue != null && propertyValue.contains(USER_HOME_DIR_TOKEN)) { |
| 388 | + final String newValue = propertyValue.replace(USER_HOME_DIR_TOKEN, JavaSystemProperties.getUserHome()); |
| 389 | + setting.setValue(newValue); |
| 390 | + LOG.debug("Replaced USER_HOME_DIR_TOKEN in key {} value {} default {}", key, setting.getValue(), setting.getDefaultValue()); |
| 391 | + } |
| 392 | + } |
| 393 | + } |
| 394 | + |
378 | 395 | /** |
379 | 396 | * Looks in the following locations: |
380 | 397 | * <pre> |
|
0 commit comments