use of com.walmartlabs.concord.server.sdk.PartialProcessKey in project concord by walmartlabs.
the class ProcessResource method killCascade.
/**
* Forcefully stops a process and all its children.
*
* @param instanceId
*/
@DELETE
@ApiOperation("Forcefully stops a process and its all children")
@javax.ws.rs.Path("/{id}/cascade")
@WithTimer
public void killCascade(@ApiParam @PathParam("id") UUID instanceId) {
PartialProcessKey processKey = PartialProcessKey.from(instanceId);
processManager.killCascade(processKey);
}
use of com.walmartlabs.concord.server.sdk.PartialProcessKey in project concord by walmartlabs.
the class ProcessResource method start.
/**
* Starts a new process instance using the specified entry point and payload archive.
*
* @param entryPoint
* @param in
* @param parentInstanceId
* @param sync
* @return
* @deprecated use {@link #start(MultipartInput, UUID, boolean, String[], HttpServletRequest)}
*/
@POST
@ApiOperation(value = "Start a new process using the specified entry point and payload archive", hidden = true)
@javax.ws.rs.Path("/{entryPoint}")
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
@Produces(MediaType.APPLICATION_JSON)
@WithTimer(suffix = "_octetstream_and_entrypoint")
@Deprecated
public StartProcessResponse start(@PathParam("entryPoint") String entryPoint, InputStream in, @QueryParam("parentId") UUID parentInstanceId, @Deprecated @DefaultValue("false") @QueryParam("sync") boolean sync, @QueryParam("out") String[] out) {
if (sync) {
throw syncIsForbidden();
}
// allow empty POST requests
if (isEmpty(in)) {
return start(entryPoint, parentInstanceId, sync, out);
}
assertPartialKey(parentInstanceId);
PartialProcessKey processKey = PartialProcessKey.from(UUID.randomUUID());
UUID orgId = OrganizationManager.DEFAULT_ORG_ID;
EntryPoint ep = payloadManager.parseEntryPoint(processKey, orgId, entryPoint);
UserPrincipal userPrincipal = UserPrincipal.assertCurrent();
Payload payload;
try {
payload = payloadManager.createPayload(processKey, parentInstanceId, userPrincipal.getId(), userPrincipal.getUsername(), ep, in, out);
} catch (IOException e) {
log.error("start ['{}'] -> error creating a payload: {}", entryPoint, e);
throw new ConcordApplicationException("Error creating a payload", e);
}
return toResponse(processManager.start(payload));
}
use of com.walmartlabs.concord.server.sdk.PartialProcessKey in project concord by walmartlabs.
the class ProcessResource method resume.
/**
* Resumes an existing process.
*/
@POST
@ApiOperation("Resume a process")
@javax.ws.rs.Path("/{id}/resume/{eventName}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public ResumeProcessResponse resume(@ApiParam @PathParam("id") UUID instanceId, @ApiParam @PathParam("eventName") @NotNull String eventName, @ApiParam @QueryParam("saveAs") String saveAs, @ApiParam Map<String, Object> req) {
PartialProcessKey processKey = PartialProcessKey.from(instanceId);
if (saveAs != null && !saveAs.isEmpty() && req != null) {
req = ConfigurationUtils.toNested(saveAs, req);
}
req = ExpressionUtils.escapeMap(req);
Payload payload;
try {
payload = payloadManager.createResumePayload(processKey, eventName, req);
} catch (IOException e) {
log.error("resume ['{}', '{}'] -> error creating a payload: {}", instanceId, eventName, e);
throw new ConcordApplicationException("Error creating a payload", e);
}
processManager.resume(payload);
return new ResumeProcessResponse();
}
use of com.walmartlabs.concord.server.sdk.PartialProcessKey in project concord by walmartlabs.
the class ProcessResource method start.
/**
* Starts a new process instance.
*
* @param in
* @param parentInstanceId
* @param sync
* @return
* @deprecated use {@link #start(MultipartInput, UUID, boolean, String[], HttpServletRequest)}
*/
@POST
@ApiOperation(value = "Start a new process instance using the supplied payload archive", hidden = true)
@Consumes(MediaType.APPLICATION_OCTET_STREAM)
@Produces(MediaType.APPLICATION_JSON)
@WithTimer(suffix = "_octetstream")
@Deprecated
public StartProcessResponse start(InputStream in, @QueryParam("parentId") UUID parentInstanceId, @Deprecated @DefaultValue("false") @QueryParam("sync") boolean sync, @QueryParam("out") String[] out) {
if (sync) {
throw syncIsForbidden();
}
assertPartialKey(parentInstanceId);
PartialProcessKey processKey = PartialProcessKey.from(UUID.randomUUID());
UserPrincipal userPrincipal = UserPrincipal.assertCurrent();
Payload payload;
try {
payload = payloadManager.createPayload(processKey, parentInstanceId, userPrincipal.getId(), userPrincipal.getUsername(), in, out);
} catch (IOException e) {
log.error("start -> error creating a payload: {}", e.getMessage());
throw new ConcordApplicationException("Error creating a payload", e);
}
return toResponse(processManager.start(payload));
}
use of com.walmartlabs.concord.server.sdk.PartialProcessKey in project concord by walmartlabs.
the class ProcessResource method listAttachments.
/**
* Lists process attachments.
*
* @param instanceId
* @return
*/
@GET
@ApiOperation(value = "List attachments", responseContainer = "list", response = String.class)
@javax.ws.rs.Path("/{id}/attachment")
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public List<String> listAttachments(@ApiParam @PathParam("id") UUID instanceId) {
ProcessEntry processEntry = processManager.assertProcess(instanceId);
assertProcessAccess(processEntry, "attachments");
PartialProcessKey processKey = new ProcessKey(processEntry.instanceId(), processEntry.createdAt());
String resource = Constants.Files.JOB_ATTACHMENTS_DIR_NAME + "/";
List<String> l = stateManager.list(processKey, resource);
return l.stream().map(s -> s.substring(resource.length())).collect(Collectors.toList());
}
Aggregations