in seatunnel-server/seatunnel-app/src/main/java/org/apache/seatunnel/app/utils/JobUtils.java [73:103]
public static String replaceJobConfigPlaceholders(
String jobConfigString, JobExecParam jobExecParam) {
Map<String, String> placeholderValues =
(jobExecParam != null && jobExecParam.getPlaceholderValues() != null)
? jobExecParam.getPlaceholderValues()
: Collections.emptyMap();
Matcher matcher = placeholderPattern.matcher(jobConfigString);
StringBuffer result = new StringBuffer();
while (matcher.find()) {
String escapeCharacter = matcher.group(1);
String placeholderName = matcher.group(2);
if (escapeCharacter != null && !escapeCharacter.isEmpty()) {
String withoutEscape =
matcher.group().replace("\\\\${", "${").replace("\\${", "${");
matcher.appendReplacement(result, Matcher.quoteReplacement(withoutEscape));
// remove the escape character and continue
continue;
}
String replacement = placeholderValues.getOrDefault(placeholderName, matcher.group(3));
if (replacement == null) {
throw new SeatunnelException(
SeatunnelErrorEnum.JOB_NO_VALUE_FOUND_FOR_PLACEHOLDER, placeholderName);
}
matcher.appendReplacement(result, Matcher.quoteReplacement(replacement));
}
matcher.appendTail(result);
return result.toString();
}