private Execution parseOrchestration(String configJson) throws IOException {
@SuppressWarnings("unchecked")
Map<String, Serializable> config = objectMapper.readValue(configJson, Map.class);
Execution orchestration = Execution.newOrchestration(getString(config, "application"));
if (config.containsKey("name")) {
orchestration.setDescription(getString(config, "name"));
}
if (config.containsKey("description")) {
orchestration.setDescription(getString(config, "description"));
}
for (Map<String, Object> context : getList(config, "stages")) {
String type = context.remove("type").toString();
String providerType = getString(context, "providerType");
if (providerType != null && !providerType.equals("aws") && !providerType.equals("titus")) {
type += format("_%s", providerType);
}
Stage stage = new Stage(orchestration, type, context);
orchestration.getStages().add(stage);
}
if (config.get("trigger") != null) {
orchestration.setTrigger(objectMapper.convertValue(config.get("trigger"), Trigger.class));
}
orchestration.setBuildTime(clock.millis());
orchestration.setAuthentication(AuthenticationDetails.build().orElse(new AuthenticationDetails()));
orchestration.setOrigin((String) config.getOrDefault("origin", "unknown"));
orchestration.setStartTimeExpiry((Long) config.get("startTimeExpiry"));
return orchestration;
}