Search in sources :

Example 76 with Header

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);
}
Also used : RestUtils.createCorrectVariant(org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant) RestUtils.getVariant(org.kie.server.remote.rest.common.util.RestUtils.getVariant) Variant(javax.ws.rs.core.Variant) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) NodeInstance(org.kie.server.api.model.instance.NodeInstance) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 77 with Header

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);
}
Also used : RestUtils.createCorrectVariant(org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant) RestUtils.getVariant(org.kie.server.remote.rest.common.util.RestUtils.getVariant) Variant(javax.ws.rs.core.Variant) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) ProcessInstance(org.kie.server.api.model.instance.ProcessInstance) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 78 with Header

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);
}
Also used : Header(org.kie.server.remote.rest.common.Header) KieContainerInstanceImpl(org.kie.server.services.impl.KieContainerInstanceImpl) Test(org.junit.Test)

Example 79 with Header

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));
}
Also used : Header(org.kie.server.remote.rest.common.Header) ReleaseId(org.kie.server.api.model.ReleaseId) KieContainerInstanceImpl(org.kie.server.services.impl.KieContainerInstanceImpl) Test(org.junit.Test)

Example 80 with Header

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);
    }
}
Also used : RestUtils.getVariant(org.kie.server.remote.rest.common.util.RestUtils.getVariant) RestUtils.createCorrectVariant(org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant) Variant(javax.ws.rs.core.Variant) DMNModelInfoList(org.kie.server.api.model.dmn.DMNModelInfoList) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

Header (org.kie.server.remote.rest.common.Header)212 ApiOperation (io.swagger.annotations.ApiOperation)203 Produces (javax.ws.rs.Produces)203 ApiResponses (io.swagger.annotations.ApiResponses)197 Path (javax.ws.rs.Path)191 RestUtils.buildConversationIdHeader (org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader)190 Variant (javax.ws.rs.core.Variant)184 RestUtils.createCorrectVariant (org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant)175 RestUtils.getVariant (org.kie.server.remote.rest.common.util.RestUtils.getVariant)168 GET (javax.ws.rs.GET)110 DeploymentNotFoundException (org.jbpm.services.api.DeploymentNotFoundException)75 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)72 TaskNotFoundException (org.jbpm.services.api.TaskNotFoundException)70 Consumes (javax.ws.rs.Consumes)54 PUT (javax.ws.rs.PUT)42 PermissionDeniedException (org.jbpm.services.task.exception.PermissionDeniedException)41 POST (javax.ws.rs.POST)35 ProcessDefinitionNotFoundException (org.jbpm.services.api.ProcessDefinitionNotFoundException)31 ExecutionErrorNotFoundException (org.jbpm.services.api.admin.ExecutionErrorNotFoundException)31 DeploymentNotActiveException (org.jbpm.services.api.DeploymentNotActiveException)25