use of com.walmartlabs.concord.process.loader.model.ProcessDefinition in project concord by walmartlabs.
the class ProjectLoader method toResult.
private static Result toResult(com.walmartlabs.concord.project.ProjectLoader.Result r) {
List<Snapshot> snapshots = r.getSnapshots();
ProcessDefinition pd = new ProcessDefinitionV1(r.getProjectDefinition());
return new Result() {
@Override
public List<Snapshot> snapshots() {
return snapshots;
}
@Override
public ProcessDefinition projectDefinition() {
return pd;
}
};
}
use of com.walmartlabs.concord.process.loader.model.ProcessDefinition in project concord by walmartlabs.
the class ProcessHandlersProcessor method process.
@Override
public Payload process(Chain chain, Payload payload) {
Set<String> handlers = new HashSet<>();
ProcessDefinition pd = payload.getHeader(Payload.PROJECT_DEFINITION);
if (pd == null) {
return chain.process(payload);
}
Collection<String> profiles = payload.getHeader(Payload.ACTIVE_PROFILES);
update(payload, pd, profiles, handlers, Constants.Flows.ON_FAILURE_FLOW, Constants.Request.DISABLE_ON_FAILURE_KEY);
update(payload, pd, profiles, handlers, Constants.Flows.ON_CANCEL_FLOW, Constants.Request.DISABLE_ON_CANCEL_KEY);
update(payload, pd, profiles, handlers, Constants.Flows.ON_TIMEOUT_FLOW, Constants.Request.DISABLE_ON_TIMEOUT_KEY);
payload = payload.putHeader(Payload.PROCESS_HANDLERS, handlers);
return chain.process(payload);
}
use of com.walmartlabs.concord.process.loader.model.ProcessDefinition 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);
}
use of com.walmartlabs.concord.process.loader.model.ProcessDefinition in project concord by walmartlabs.
the class ConfigurationProcessor method getProfileCfg.
private static Map<String, Object> getProfileCfg(Payload payload, List<String> activeProfiles) {
if (activeProfiles == null) {
activeProfiles = Collections.emptyList();
}
ProcessDefinition pd = payload.getHeader(Payload.PROJECT_DEFINITION);
if (pd == null) {
return Collections.emptyMap();
}
Map<String, Object> m = ProcessDefinitionUtils.getVariables(pd, activeProfiles);
return m != null ? m : Collections.emptyMap();
}
use of com.walmartlabs.concord.process.loader.model.ProcessDefinition in project concord by walmartlabs.
the class TriggerResource method refresh.
private void refresh(RepositoryEntry repo) {
ProcessDefinition pd;
try {
pd = repositoryManager.withLock(repo.getUrl(), () -> {
Repository repository = repositoryManager.fetch(repo.getProjectId(), repo);
ProjectLoader.Result result = projectLoader.loadProject(repository.path(), importsNormalizerFactory.forProject(repo.getProjectId()), ImportsListener.NOP_LISTENER);
return result.projectDefinition();
});
ProjectValidator.Result result = ProjectValidator.validate(pd);
if (!result.isValid()) {
throw new ValidationErrorsException(String.join("\n", result.getErrors()));
}
} catch (Exception e) {
log.error("refresh ['{}'] -> project load error", repo.getId(), e);
throw new ConcordApplicationException("Refresh failed (repository ID: " + repo.getId() + "): " + e.getMessage(), e);
}
triggerManager.refresh(repo.getProjectId(), repo.getId(), pd);
}
Aggregations