use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.
the class DefinitionResource method getAssociatedEntities.
@ApiOperation(value = "Retrieves actors and groups that are involved in given process and container")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Process or Container Id not found"), @ApiResponse(code = 200, response = AssociatedEntitiesDefinition.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_PROCESS_ENTITIES_RESPONSE_JSON) })) })
@GET
@Path(PROCESS_DEF_ASSOCIATED_ENTITIES_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getAssociatedEntities(@Context HttpHeaders headers, @ApiParam(value = "container id where the process definition resides", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "process id that the involved actors and groups should be retrieved from", required = true, example = "evaluation") @PathParam(PROCESS_ID) String processId) {
Variant v = getVariant(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
try {
AssociatedEntitiesDefinition associatedEntitiesDefinition = definitionServiceBase.getAssociatedEntities(containerId, processId);
return createCorrectVariant(associatedEntitiesDefinition, headers, Response.Status.OK, conversationIdHeader);
} catch (IllegalStateException e) {
return notFound(MessageFormat.format(PROCESS_DEFINITION_NOT_FOUND, processId, containerId), v, conversationIdHeader);
} catch (Exception e) {
return internalServerError(errorMessage(e), v, conversationIdHeader);
}
}
use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.
the class DefinitionResource method getServiceTasks.
@ApiOperation(value = "Retrieves service tasks definitions that are present in given process and container")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Process or Container Id not found"), @ApiResponse(code = 200, response = ServiceTasksDefinition.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_PROCESS_SERVICE_TASKS_RESPONSE_JSON) })) })
@GET
@Path(PROCESS_DEF_SERVICE_TASKS_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getServiceTasks(@Context HttpHeaders headers, @ApiParam(value = "container id where the process definition resides", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "process id that the service task definitions should be retrieved from", required = true, example = "evaluation") @PathParam(PROCESS_ID) String processId) {
Variant v = getVariant(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
try {
ServiceTasksDefinition serviceTasksDefinition = definitionServiceBase.getServiceTasks(containerId, processId);
return createCorrectVariant(serviceTasksDefinition, headers, Response.Status.OK, conversationIdHeader);
} catch (IllegalStateException e) {
return notFound(MessageFormat.format(PROCESS_DEFINITION_NOT_FOUND, processId, containerId), v, conversationIdHeader);
} catch (Exception e) {
return internalServerError(errorMessage(e), v, conversationIdHeader);
}
}
use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.
the class DocumentResource method getDocumentContent.
@ApiOperation(value = "Retrieves document's content identified by given documentId", response = byte[].class, code = 200, responseHeaders = { @ResponseHeader(name = "Content-Disposition", description = "provides file name of the document") })
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Document with given id not found") })
@GET
@Path(DOCUMENT_INSTANCE_CONTENT_GET_URI)
@Produces({ MediaType.APPLICATION_OCTET_STREAM })
public Response getDocumentContent(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "document id of a document that content should be retruned from", required = true, example = "xxx-yyy-zzz") @PathParam("documentId") String documentId) {
Variant v = getVariant(headers);
// no container id available so only used to transfer conversation id if given by client
Header conversationIdHeader = buildConversationIdHeader("", context, headers);
try {
final DocumentInstance document = documentServiceBase.getDocument(documentId);
if (document == null) {
return notFound("Document with id " + documentId + " not found", v, conversationIdHeader);
}
String fileName = MimeUtility.encodeWord(document.getName(), "utf-8", "Q");
StreamingOutput entity = new StreamingOutput() {
@Override
public void write(OutputStream output) throws IOException, WebApplicationException {
output.write(document.getContent());
}
};
if (conversationIdHeader != null) {
return Response.ok().entity(entity).header(conversationIdHeader.getName(), conversationIdHeader.getValue()).header("Content-Disposition", "attachment; filename=\"" + fileName + "\"").build();
}
return Response.ok().entity(entity).header("Content-Disposition", "attachment; filename=\"" + fileName + "\"").build();
} catch (Exception e) {
logger.error("Unexpected error during processing {}", e.getMessage(), e);
return internalServerError(errorMessage(e), v, conversationIdHeader);
}
}
use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.
the class DocumentResource method listDocuments.
@ApiOperation(value = "Returns all documents from KIE Server.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = DocumentInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_DOCUMENTS_RESPONSE_JSON) })) })
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response listDocuments(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "optional pagination - at which page to start, defaults to 0 (meaning first)", required = false) @QueryParam("page") @DefaultValue("0") Integer page, @ApiParam(value = "optional pagination - size of the result, defaults to 10", required = false) @QueryParam("pageSize") @DefaultValue("10") Integer pageSize) {
Variant v = getVariant(headers);
// no container id available so only used to transfer conversation id if given by client
Header conversationIdHeader = buildConversationIdHeader("", context, headers);
try {
DocumentInstanceList documents = documentServiceBase.listDocuments(page, pageSize);
return createCorrectVariant(documents, headers, Response.Status.OK, conversationIdHeader);
} catch (Exception e) {
logger.error("Unexpected error during processing {}", e.getMessage(), e);
return internalServerError(errorMessage(e), v, conversationIdHeader);
}
}
use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.
the class RuntimeDataResource method getVariablesCurrentState.
@ApiOperation(value = "Returns current variable values of a specified process instance.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = VariableInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_PROCESS_INSTANCE_VARS_LOG_RESPONSE_JSON) })) })
@GET
@Path(VAR_INSTANCES_BY_INSTANCE_ID_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getVariablesCurrentState(@Context HttpHeaders headers, @ApiParam(value = "process instance id to load variables current state (latest value) for", required = true) @PathParam(PROCESS_INST_ID) long processInstanceId) {
// no container id available so only used to transfer conversation id if given by client
Header conversationIdHeader = buildConversationIdHeader("", context, headers);
VariableInstanceList variableInstanceList = runtimeDataServiceBase.getVariablesCurrentState(processInstanceId);
logger.debug("Returning result of variables search: {}", variableInstanceList);
return createCorrectVariant(variableInstanceList, headers, Response.Status.OK, conversationIdHeader);
}
Aggregations