use of com.walmartlabs.concord.server.events.EventInitiatorSupplier in project concord by walmartlabs.
the class OneOpsEventResource method event.
@POST
@Path("/oneops")
@Consumes(MediaType.APPLICATION_JSON)
@WithTimer
public Response event(Map<String, Object> event) {
if (executor.isDisabled(EVENT_SOURCE)) {
log.warn("event ['{}'] disabled", EVENT_SOURCE);
return Response.ok().build();
}
if (event == null || event.isEmpty()) {
return Response.status(Status.BAD_REQUEST).build();
}
if (cfg.isLogEvents()) {
auditLog.add(AuditObject.EXTERNAL_EVENT, AuditAction.ACCESS).field("source", EVENT_SOURCE).field("eventId", String.valueOf(event.get("cmsId"))).field("payload", event).log();
}
List<OneOpsTriggerProcessor.Result> results = new ArrayList<>();
processors.forEach(p -> p.process(event, results));
for (OneOpsTriggerProcessor.Result result : results) {
Event e = Event.builder().id(String.valueOf(event.get("cmsId"))).name(EVENT_SOURCE).attributes(result.event()).initiator(memo(new EventInitiatorSupplier("author", userManager, result.event()))).build();
List<PartialProcessKey> processKeys = executor.execute(e, initiatorResolver, result.triggers());
log.info("event ['{}'] -> done, {} processes started", e.id(), processKeys.size());
}
return Response.ok().build();
}
Aggregations