Skip to content

Commit

Permalink
OWS-637: Allow paths relative to USER HOME dir in deployment.properti…
Browse files Browse the repository at this point in the history
…es file
  • Loading branch information
janakmulani committed Oct 25, 2024
1 parent fcd4a55 commit f742b34
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package net.sourceforge.jnlp.config;

import net.adoptopenjdk.icedteaweb.JavaSystemProperties;
import net.adoptopenjdk.icedteaweb.config.validators.ValueValidator;
import net.adoptopenjdk.icedteaweb.http.CloseableConnection;
import net.adoptopenjdk.icedteaweb.http.ConnectionFactory;
Expand Down Expand Up @@ -65,6 +66,7 @@ public final class DeploymentConfiguration {
public static final String LOCKED_POSTFIX = ".locked";
public static final String LOCAL_DEPLOYMENT_PROPERTIES_FILE_PATH = "localDeploymentPropertiesFilePath";

public static final String USER_HOME_DIR_TOKEN = "#USER_HOME_DIR#";
private String userComments;

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

processPropertiesWithHomeDirToken(properties);

if (fixIssues) {
checkAndFixConfiguration(properties);
}
Expand Down Expand Up @@ -367,14 +371,27 @@ private void checkAndFixConfiguration(final Map<String, Setting> initial) {
try {
checker.validate(setting.getValue());
} catch (final IllegalArgumentException e) {
LOG.error("Property '{}' has incorrect value \"{}\". Possible values {}.", key, setting.getValue(), checker.getPossibleValues(), e);
LOG.error("Property '{}' has incorrect value \"{}\". Possible values {}. Setting default {}", key, setting.getValue(), checker.getPossibleValues(), setting.getDefaultValue(), e);
setting.setValue(setting.getDefaultValue());
}
}
}
}
}

private void processPropertiesWithHomeDirToken(final Map<String, Setting> properties) {
for (final Map.Entry<String, Setting> entry : properties.entrySet()) {
final String key = entry.getKey();
final Setting setting = entry.getValue();
final String propertyValue = setting.getValue();
if (propertyValue != null && propertyValue.contains(USER_HOME_DIR_TOKEN)) {
final String newValue = propertyValue.replace(USER_HOME_DIR_TOKEN, JavaSystemProperties.getUserHome());
setting.setValue(newValue);
LOG.debug("Replaced USER_HOME_DIR_TOKEN in key {} value {} default {}", key, setting.getValue(), setting.getDefaultValue());
}
}
}

/**
* Looks in the following locations:
* <pre>
Expand Down

0 comments on commit f742b34

Please sign in to comment.