use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.
the class RuntimeDataResource method getNodeInstanceForWorkItem.
@ApiOperation(value = "Returns node instances for a specified work item in a specified process instance.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Node instance id not found"), @ApiResponse(code = 200, response = NodeInstance.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_PROCESS_INSTANCE_NODE_RESPONSE_JSON) })) })
@GET
@Path(NODE_INSTANCES_BY_WORK_ITEM_ID_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getNodeInstanceForWorkItem(@Context HttpHeaders headers, @ApiParam(value = "process instance id that work item belongs to", required = true) @PathParam(PROCESS_INST_ID) long processInstanceId, @ApiParam(value = "work item id to retrieve node instance for", required = true) @PathParam("workItemId") long workItemId) {
Variant v = getVariant(headers);
// no container id available so only used to transfer conversation id if given by client
Header conversationIdHeader = buildConversationIdHeader("", context, headers);
NodeInstance nodeInstanceDesc = null;
try {
nodeInstanceDesc = runtimeDataServiceBase.getNodeInstanceForWorkItem(processInstanceId, workItemId);
} catch (IllegalArgumentException e) {
return notFound(MessageFormat.format(NODE_INSTANCE_NOT_FOUND, workItemId, processInstanceId), v, conversationIdHeader);
}
return createCorrectVariant(nodeInstanceDesc, headers, Response.Status.OK, conversationIdHeader);
}
use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.
the class RuntimeDataResource method getProcessInstanceById.
@ApiOperation(value = "Returns information about a specified process instance.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Process instance id not found"), @ApiResponse(code = 200, response = ProcessInstance.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_PROCESS_INSTANCE_RESPONSE_JSON) })) })
@GET
@Path(PROCESS_INSTANCE_BY_INSTANCE_ID_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getProcessInstanceById(@Context HttpHeaders headers, @ApiParam(value = "process instance id to retrieve process instance", required = true) @PathParam(PROCESS_INST_ID) long processInstanceId, @ApiParam(value = "load process instance variables or not, defaults to false", required = false) @QueryParam("withVars") boolean withVars) {
Variant v = getVariant(headers);
// no container id available so only used to transfer conversation id if given by client
Header conversationIdHeader = buildConversationIdHeader("", context, headers);
org.kie.server.api.model.instance.ProcessInstance processInstanceDesc = null;
try {
processInstanceDesc = runtimeDataServiceBase.getProcessInstanceById(processInstanceId, withVars);
} catch (ProcessInstanceNotFoundException e) {
return notFound(MessageFormat.format(PROCESS_INSTANCE_NOT_FOUND, processInstanceId), v, conversationIdHeader);
}
return createCorrectVariant(processInstanceDesc, headers, Response.Status.OK, conversationIdHeader);
}
use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.
the class RestUtilsTest method buildConversationIdHeaderCreatingContainer.
@Test
public void buildConversationIdHeaderCreatingContainer() {
String kieServerId = "KieServerId";
KieServerEnvironment.setServerId(kieServerId);
KieContainerInstanceImpl containerInstanceImpl = new KieContainerInstanceImpl(CONTAINER_ID, KieContainerStatus.CREATING);
when(registry.getContainer(CONTAINER_ID)).thenReturn(containerInstanceImpl);
Header conversationIdHeader = RestUtils.buildConversationIdHeader(CONTAINER_ID, registry, headers);
assertNull(conversationIdHeader);
}
use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.
the class RestUtilsTest method buildConversationIdHeaderRunningContainer.
@Test
public void buildConversationIdHeaderRunningContainer() {
String kieServerId = "KieServerId";
KieServerEnvironment.setServerId(kieServerId);
String groupId = "org.kie";
String artifactId = "testArtifact";
String version = "1.0";
ReleaseId releaseId = new ReleaseId(groupId, artifactId, version);
KieContainerInstanceImpl containerInstanceImpl = new KieContainerInstanceImpl(CONTAINER_ID, KieContainerStatus.STARTED);
containerInstanceImpl.getResource().setReleaseId(releaseId);
when(registry.getContainer(CONTAINER_ID)).thenReturn(containerInstanceImpl);
Header conversationIdHeader = RestUtils.buildConversationIdHeader(CONTAINER_ID, registry, headers);
assertEquals(KieServerConstants.KIE_CONVERSATION_ID_TYPE_HEADER, conversationIdHeader.getName());
assertNotNull(conversationIdHeader.getValue());
assertTrue(conversationIdHeader.getValue().contains(groupId));
assertTrue(conversationIdHeader.getValue().contains(artifactId));
assertTrue(conversationIdHeader.getValue().contains(version));
assertTrue(conversationIdHeader.getValue().contains(CONTAINER_ID));
assertTrue(conversationIdHeader.getValue().contains(kieServerId));
}
use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.
the class ModelEvaluatorResource method getModels.
@ApiOperation(value = "Retrieves DMN model for given container", response = ServiceResponse.class, code = 200, notes = REF_KIESERVER_DMN_API_DOC)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Models or container not found"), @ApiResponse(code = 200, response = String.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = MediaType.APPLICATION_JSON, value = EXAMPLE_KIESERVER_GET_RESPONSE_JSON), @ExampleProperty(mediaType = MediaType.APPLICATION_XML, value = EXAMPLE_KIESERVER_GET_RESPONSE_XML) })) })
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getModels(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "Container id that models should be loaded from", required = true, example = EXAMPLE_CONTAINER_ID) @PathParam(CONTAINER_ID) String containerId) {
Variant v = getVariant(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, modelEvaluatorService.getKieServerRegistry(), headers);
try {
ServiceResponse<DMNModelInfoList> result = modelEvaluatorService.getModels(containerId);
if (result.getType() == ServiceResponse.ResponseType.SUCCESS) {
return createCorrectVariant(marshallerHelper, containerId, result, headers, Response.Status.OK, conversationIdHeader);
}
return createCorrectVariant(marshallerHelper, containerId, result, headers, Response.Status.NOT_FOUND, conversationIdHeader);
} catch (Exception e) {
LOG.error("Unexpected error retrieving models. Message: '{}'", e.getMessage(), e);
return internalServerError(MessageFormat.format("ERROR", e.getMessage()), v, conversationIdHeader);
}
}
Aggregations