Search in sources :

Example 26 with PartialProcessKey

use of com.walmartlabs.concord.server.sdk.PartialProcessKey in project concord by walmartlabs.

the class ProcessLocksResource method assertProcess.

private ProcessEntry assertProcess(UUID instanceId) {
    PartialProcessKey processKey = PartialProcessKey.from(instanceId);
    ProcessEntry p = processQueueManager.get(processKey);
    if (p == null) {
        throw new ConcordApplicationException("Process not found: " + instanceId, Response.Status.NOT_FOUND);
    }
    if (p.orgId() == null) {
        throw new ConcordApplicationException("Organization is required", Response.Status.BAD_REQUEST);
    }
    if (p.projectId() == null) {
        throw new ConcordApplicationException("Project is required", Response.Status.BAD_REQUEST);
    }
    return p;
}
Also used : PartialProcessKey(com.walmartlabs.concord.server.sdk.PartialProcessKey) ConcordApplicationException(com.walmartlabs.concord.server.sdk.ConcordApplicationException) ProcessEntry(com.walmartlabs.concord.server.process.ProcessEntry)

Example 27 with PartialProcessKey

use of com.walmartlabs.concord.server.sdk.PartialProcessKey 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();
}
Also used : PartialProcessKey(com.walmartlabs.concord.server.sdk.PartialProcessKey) ArrayList(java.util.ArrayList) Event(com.walmartlabs.concord.server.events.Event) EventInitiatorSupplier(com.walmartlabs.concord.server.events.EventInitiatorSupplier) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer)

Aggregations

PartialProcessKey (com.walmartlabs.concord.server.sdk.PartialProcessKey)27 ConcordApplicationException (com.walmartlabs.concord.server.sdk.ConcordApplicationException)18 WithTimer (com.walmartlabs.concord.server.sdk.metrics.WithTimer)14 ApiOperation (io.swagger.annotations.ApiOperation)14 UserPrincipal (com.walmartlabs.concord.server.security.UserPrincipal)8 EntryPoint (com.walmartlabs.concord.server.process.PayloadManager.EntryPoint)4 ProcessKey (com.walmartlabs.concord.server.sdk.ProcessKey)4 UUID (java.util.UUID)3 ValidationErrorsException (org.sonatype.siesta.ValidationErrorsException)3 Imports (com.walmartlabs.concord.imports.Imports)2 ProcessStatus (com.walmartlabs.concord.server.sdk.ProcessStatus)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 SettableFuture (com.google.common.util.concurrent.SettableFuture)1 ConfigurationUtils (com.walmartlabs.concord.common.ConfigurationUtils)1 IOUtils (com.walmartlabs.concord.common.IOUtils)1 Form (com.walmartlabs.concord.forms.Form)1 FormField (com.walmartlabs.concord.forms.FormField)1 FormUtils (com.walmartlabs.concord.forms.FormUtils)1 AttachmentsRule (com.walmartlabs.concord.policyengine.AttachmentsRule)1 CheckResult (com.walmartlabs.concord.policyengine.CheckResult)1