We were able to do this by creating a Filter for intercepting selectors
EngineConstants.SLING_FILTER_SCOPE + "=" + EngineConstants.FILTER_SCOPE_REQUEST,
EngineConstants.SLING_FILTER_SELECTORS + "=" + "configPersist",
@9944223
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) {
String configName = request.getParameter("configName");
ConfigurationMetadata configMetadata = configManager.getConfigurationMetadata(configName);
//get config fields of type=token.
Set<String> tokenFields = //using a Util class to get the field(s) to be updated. Field is identified using a type property i.e type=token.
String jsonDataString = IOUtils.toString(request.getInputStream(), StandardCharsets.UTF_8);
JsonNode jsonNode = new ObjectMapper().readTree(jsonDataString);
JsonNode propItems = jsonNode.get("items"); // For multiple items in CA config
if (propItems != null && propItems.isArray()) {
for (JsonNode item : propItems) {
//update the properties of JsonNode, if the a property name is found from "tokenFields".
JsonNode properties = item.get("properties");
((ObjectNode) properties).put(propertyName, "a-dynaically-generated-value-here");
}
}
}
This way, before saving the CA config, we were able to update the 'dynamicValue'.
thanks