use of com.walmartlabs.concord.process.loader.model.Options in project concord by walmartlabs.
the class EffectiveProcessDefinitionProcessor method process.
@Override
public Payload process(Chain chain, Payload payload) {
ProcessDefinition pd = payload.getHeader(Payload.PROJECT_DEFINITION);
if (pd == null) {
return chain.process(payload);
}
Options opts = Options.builder().instanceId(payload.getProcessKey().getInstanceId()).parentInstanceId(payload.getHeader(Payload.PARENT_INSTANCE_ID)).configuration(sanitizeConfiguration(payload.getHeader(Payload.CONFIGURATION, Collections.emptyMap()))).activeProfiles(payload.getHeader(Payload.ACTIVE_PROFILES, Collections.emptyList())).build();
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
pd.serialize(opts, out);
byte[] bytes = out.toByteArray();
if (bytes.length == 0) {
return chain.process(payload);
}
stateManager.tx(tx -> {
stateManager.deleteFile(tx, payload.getProcessKey(), EFFECTIVE_YAML_PATH);
stateManager.insert(tx, payload.getProcessKey(), EFFECTIVE_YAML_PATH, bytes);
});
} catch (Exception e) {
log.warn("process ['{}'] -> error: {}", payload.getProcessKey(), e.getMessage());
throw new ProcessException(payload.getProcessKey(), "Error while processing effective concord.yml: " + e.getMessage(), e);
}
return chain.process(payload);
}
Aggregations