use of com.walmartlabs.concord.server.sdk.PartialProcessKey in project concord by walmartlabs.
the class ProcessResource method get.
/**
* Returns a process instance details.
*
* @deprecated use {@link ProcessResourceV2#get(UUID, Set)}
*/
@GET
@ApiOperation("Get a process' details")
@javax.ws.rs.Path("/{id}")
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
@Deprecated
public ProcessEntry get(@ApiParam @PathParam("id") UUID instanceId) {
PartialProcessKey processKey = PartialProcessKey.from(instanceId);
ProcessEntry e = processQueueManager.get(processKey);
if (e == null) {
log.warn("get ['{}'] -> not found", instanceId);
throw new ConcordApplicationException("Process instance not found", Status.NOT_FOUND);
}
return e;
}
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 provided configuration.
*
* @param entryPoint
* @param req
* @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 provided configuration", hidden = true)
@javax.ws.rs.Path("/{entryPoint}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@WithTimer(suffix = "_json")
@Deprecated
public StartProcessResponse start(@PathParam("entryPoint") String entryPoint, Map<String, Object> req, @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());
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, req, 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 downloadAttachment.
/**
* Returns a process' attachment file.
*/
@GET
@ApiOperation(value = "Download a process' attachment", response = File.class)
@javax.ws.rs.Path("/{id}/attachment/{name:.*}")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response downloadAttachment(@ApiParam @PathParam("id") UUID instanceId, @PathParam("name") @NotNull @Size(min = 1) String attachmentName) {
ProcessEntry processEntry = processManager.assertProcess(instanceId);
assertProcessAccess(processEntry, "attachment");
PartialProcessKey processKey = new ProcessKey(processEntry.instanceId(), processEntry.createdAt());
// TODO replace with javax.validation
if (attachmentName.endsWith("/")) {
throw new ConcordApplicationException("Invalid attachment name: " + attachmentName, Status.BAD_REQUEST);
}
String resource = path(Constants.Files.JOB_ATTACHMENTS_DIR_NAME, attachmentName);
Optional<Path> o = stateManager.get(processKey, resource, src -> {
try {
Path tmp = IOUtils.createTempFile("attachment", ".bin");
try (OutputStream dst = Files.newOutputStream(tmp)) {
IOUtils.copy(src, dst);
}
return Optional.of(tmp);
} catch (IOException e) {
throw new ConcordApplicationException("Error while exporting an attachment: " + attachmentName, e);
}
});
if (!o.isPresent()) {
return Response.status(Status.NOT_FOUND).build();
}
Path tmp = o.get();
return Response.ok((StreamingOutput) out -> {
try (InputStream in = Files.newInputStream(tmp)) {
IOUtils.copy(in, out);
} finally {
Files.delete(tmp);
}
}).build();
}
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 multipart request data.
*
* @param entryPoint
* @param input
* @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 multipart request data", hidden = true)
@javax.ws.rs.Path("/{entryPoint}")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
@WithTimer(suffix = "_with_entrypoint")
@Deprecated
public StartProcessResponse start(@PathParam("entryPoint") String entryPoint, MultipartInput input, @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());
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, input, 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 fork.
/**
* Starts a new child process by forking the start of the specified parent process.
*
* @param parentInstanceId
* @param req
* @param sync
* @return
*/
@POST
@ApiOperation("Fork a process")
@javax.ws.rs.Path("/{id}/fork")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public StartProcessResponse fork(@ApiParam @PathParam("id") UUID parentInstanceId, @ApiParam Map<String, Object> req, @ApiParam @Deprecated @DefaultValue("false") @QueryParam("sync") boolean sync, @ApiParam @QueryParam("out") String[] out) {
if (sync) {
throw syncIsForbidden();
}
ProcessEntry parent = processQueueManager.get(PartialProcessKey.from(parentInstanceId));
if (parent == null) {
throw new ValidationErrorsException("Unknown parent instance ID: " + parentInstanceId);
}
PartialProcessKey processKey = PartialProcessKey.from(UUID.randomUUID());
ProcessKey parentProcessKey = new ProcessKey(parent.instanceId(), parent.createdAt());
UUID projectId = parent.projectId();
UserPrincipal userPrincipal = UserPrincipal.assertCurrent();
Set<String> handlers = parent.handlers();
Imports imports = queueDao.getImports(parentProcessKey);
Payload payload;
try {
payload = payloadManager.createFork(processKey, parentProcessKey, ProcessKind.DEFAULT, userPrincipal.getId(), userPrincipal.getUsername(), projectId, req, out, handlers, imports);
} catch (IOException e) {
log.error("fork ['{}', '{}'] -> error creating a payload: {}", processKey, parentProcessKey, e);
throw new ConcordApplicationException("Error creating a payload", e);
}
return toResponse(processManager.startFork(payload));
}
Aggregations