@Override
public String replaceProperties(File configFile) throws ConfigException {
try {
LOGGER.info("Processing configFile {}", configFile);
Map<String, String> replacements = buildReplacements();
String configFileContent = new String(Files.readAllBytes(Paths.get(configFile.getPath())), StandardCharsets.UTF_8);
String replacedContent = configFileContent;
if (replacements != null) {
replacedContent = replaceTokens(configFileContent, replacements, PROPERTIES_FILE_REPLACEMENT_REGEX, false);
} else {
LOGGER.warn("No config properties found, using file as is {}", configFile.getAbsolutePath());
}
return replaceTokens(replacedContent, System.getenv(), ENV_VAR_REPLACEMENT_REGEX, true);
} catch (IOException e) {
throw new ConfigException(String.format("Unable to read config file %s", configFile), e);
}
}