Skip to content

Commit f742b34

Browse files
committed
OWS-637: Allow paths relative to USER HOME dir in deployment.properties file
1 parent fcd4a55 commit f742b34

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

core/src/main/java/net/sourceforge/jnlp/config/DeploymentConfiguration.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package net.sourceforge.jnlp.config;
1818

19+
import net.adoptopenjdk.icedteaweb.JavaSystemProperties;
1920
import net.adoptopenjdk.icedteaweb.config.validators.ValueValidator;
2021
import net.adoptopenjdk.icedteaweb.http.CloseableConnection;
2122
import net.adoptopenjdk.icedteaweb.http.ConnectionFactory;
@@ -65,6 +66,7 @@ public final class DeploymentConfiguration {
6566
public static final String LOCKED_POSTFIX = ".locked";
6667
public static final String LOCAL_DEPLOYMENT_PROPERTIES_FILE_PATH = "localDeploymentPropertiesFilePath";
6768

69+
public static final String USER_HOME_DIR_TOKEN = "#USER_HOME_DIR#";
6870
private String userComments;
6971

7072
private ConfigurationException loadingException = null;
@@ -214,6 +216,8 @@ public void load(final boolean fixIssues) throws ConfigurationException, Malform
214216
userComments = loadComments(userPropertiesUrl);
215217
mergeMaps(properties, userProperties);
216218

219+
processPropertiesWithHomeDirToken(properties);
220+
217221
if (fixIssues) {
218222
checkAndFixConfiguration(properties);
219223
}
@@ -367,14 +371,27 @@ private void checkAndFixConfiguration(final Map<String, Setting> initial) {
367371
try {
368372
checker.validate(setting.getValue());
369373
} 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);
371375
setting.setValue(setting.getDefaultValue());
372376
}
373377
}
374378
}
375379
}
376380
}
377381

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+
378395
/**
379396
* Looks in the following locations:
380397
* <pre>

0 commit comments

Comments
 (0)