com.contentgrid.spring.boot.actuator.webhooks.WebhookVariables Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of contentgrid-spring-boot-actuators Show documentation
Show all versions of contentgrid-spring-boot-actuators Show documentation
Custom actuators for ContentGrid applications
The newest version!
package com.contentgrid.spring.boot.actuator.webhooks;
import com.contentgrid.spring.common.ContentGridApplicationProperties.SystemProperties;
import java.util.Map;
import lombok.Builder;
import lombok.Value;
import org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver;
@Value
@Builder
public class WebhookVariables implements PlaceholderResolver {
SystemProperties systemProperties;
Map userVariables;
@Override
public String resolvePlaceholder(String placeholderName) {
if(placeholderName.startsWith("vars.")) {
return userVariables.get(placeholderName.substring("vars.".length()));
}
switch(placeholderName) {
case "system.application.id":
return systemProperties.getApplicationId();
case "system.deployment.id":
return systemProperties.getDeploymentId();
default:
throw new IllegalArgumentException(String.format("Can not find a replacement for placeholder '%s'", placeholderName));
}
}
}