Search in sources :

Example 31 with Header

use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.

the class ExecutorResource method getRequestsByProcessInstance.

@ApiOperation(value = "Returns jobs for specified process instance.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = RequestInfoInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_REQUESTS_RESPONSE_JSON) })) })
@GET
@Path(JOB_INSTANCES_BY_PROCESS_INSTANCE_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getRequestsByProcessInstance(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "identifier of the process instance that asynchornous jobs should be found for", required = true, example = "123") @PathParam(PROCESS_INST_ID) Long processInstanceId, @ApiParam(value = "optional job status (QUEUED, DONE, CANCELLED, ERROR, RETRYING, RUNNING)", required = false, allowableValues = "QUEUED,DONE,CANCELLED,ERROR,RETRYING,RUNNING") @QueryParam("status") List<String> statuses, @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 {
        RequestInfoInstanceList result = executorServiceBase.getRequestsByProcessInstance(processInstanceId, statuses, page, pageSize);
        return createCorrectVariant(result, headers, Response.Status.OK, conversationIdHeader);
    } catch (Exception e) {
        logger.error("Unexpected error during processing {}", e.getMessage(), e);
        return internalServerError(errorMessage(e), 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) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) RequestInfoInstanceList(org.kie.server.api.model.instance.RequestInfoInstanceList) 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 32 with Header

use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.

the class ExecutorResource method updateRequestData.

@ApiOperation(value = "Updates parameters for job commands, if used.", response = Void.class, code = 204)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error") })
@POST
@Path(UPDATE_JOB_DATA_POST_URI)
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response updateRequestData(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "identifier of the asynchronous job to be updated", required = true, example = "123") @PathParam("jobId") long requestId, @ApiParam(value = "optional container id that the job should be associated with", required = false) @QueryParam("containerId") String containerId, @ApiParam(value = "data to be updated on the asynchronous job represented as Map", required = true, examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = VAR_MAP_JSON), @ExampleProperty(mediaType = XML, value = VAR_MAP_XML) })) String payload) {
    Variant v = getVariant(headers);
    String type = getContentType(headers);
    // no container id available so only used to transfer conversation id if given by client
    Header conversationIdHeader = buildConversationIdHeader("", context, headers);
    try {
        executorServiceBase.updateRequestData(requestId, containerId, payload, type);
        return createResponse("", v, Response.Status.CREATED, conversationIdHeader);
    } catch (IllegalStateException e) {
        return badRequest(e.getMessage(), v, conversationIdHeader);
    } catch (Exception e) {
        logger.error("Unexpected error during processing {}", e.getMessage(), e);
        return internalServerError(errorMessage(e), 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) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 33 with Header

use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.

the class ExecutorResource method getRequestById.

// instance details
@ApiOperation(value = "Returns information about a specified job.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = RequestInfoInstance.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_REQUEST_RESPONSE_JSON) })) })
@GET
@Path(JOB_INSTANCE_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getRequestById(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "identifier of the asynchronous job to be retrieved", required = true, example = "123") @PathParam("jobId") Long requestId, @ApiParam(value = "optional flag that indicats if errors should be loaded as well", required = false) @QueryParam("withErrors") boolean withErrors, @ApiParam(value = "optional flag that indicats if input/output data should be loaded as well", required = false) @QueryParam("withData") boolean withData) {
    Variant v = getVariant(headers);
    String type = getContentType(headers);
    // no container id available so only used to transfer conversation id if given by client
    Header conversationIdHeader = buildConversationIdHeader("", context, headers);
    try {
        String response = executorServiceBase.getRequestById(requestId, withErrors, withData, type);
        return createResponse(response, v, Response.Status.OK, conversationIdHeader);
    } catch (IllegalArgumentException e) {
        return notFound(e.getMessage(), v, conversationIdHeader);
    } catch (Exception e) {
        logger.error("Unexpected error during processing {}", e.getMessage(), e);
        return internalServerError(errorMessage(e), 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) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) 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 34 with Header

use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.

the class ExecutorResource method getRequestsByBusinessKey.

@ApiOperation(value = "Returns information about a job with a specified business key.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = RequestInfoInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_REQUESTS_RESPONSE_JSON) })) })
@GET
@Path(JOB_INSTANCES_BY_KEY_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getRequestsByBusinessKey(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "identifier of the business key that asynchornous jobs should be found for", required = true, example = "custom-job") @PathParam("key") String businessKey, @ApiParam(value = "optional job status (QUEUED, DONE, CANCELLED, ERROR, RETRYING, RUNNING)", required = false, allowableValues = "QUEUED,DONE,CANCELLED,ERROR,RETRYING,RUNNING") @QueryParam("status") List<String> statuses, @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 {
        RequestInfoInstanceList result = null;
        if (statuses == null || statuses.isEmpty()) {
            result = executorServiceBase.getRequestsByBusinessKey(businessKey, page, pageSize);
        } else {
            result = executorServiceBase.getRequestsByBusinessKey(businessKey, statuses, page, pageSize);
        }
        return createCorrectVariant(result, headers, Response.Status.OK, conversationIdHeader);
    } catch (Exception e) {
        logger.error("Unexpected error during processing {}", e.getMessage(), e);
        return internalServerError(errorMessage(e), 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) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) RequestInfoInstanceList(org.kie.server.api.model.instance.RequestInfoInstanceList) 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 35 with Header

use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.

the class ProcessResource method signalProcessInstance.

@ApiOperation(value = "Signals a specified process instance with a specified signal name and optional signal data.", response = Void.class, code = 200)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Process instance or Container Id not found"), @ApiResponse(code = 403, message = "User does not have permission to access this asset") })
@POST
@Path(SIGNAL_PROCESS_INST_POST_URI)
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response signalProcessInstance(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id that process instance belongs to", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "identifier of the process instance to be signaled", required = true, example = "123") @PathParam(PROCESS_INST_ID) Long processInstanceId, @ApiParam(value = "signal name to be send to process instance", required = true, example = "EventReceived") @PathParam(SIGNAL_NAME) String signalName, @ApiParam(value = "optional event data - any type can be provided", required = false, examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = VAR_JSON), @ExampleProperty(mediaType = XML, value = VAR_XML) })) String eventPayload) {
    Variant v = getVariant(headers);
    String type = getContentType(headers);
    Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
    try {
        processServiceBase.signalProcessInstance(containerId, processInstanceId, signalName, eventPayload, type);
        return createResponse(null, v, Response.Status.OK, conversationIdHeader);
    } catch (ProcessInstanceNotFoundException e) {
        return notFound(MessageFormat.format(PROCESS_INSTANCE_NOT_FOUND, processInstanceId), v, conversationIdHeader);
    } catch (DeploymentNotFoundException e) {
        return notFound(MessageFormat.format(CONTAINER_NOT_FOUND, containerId), v, conversationIdHeader);
    } catch (SecurityException e) {
        return forbidden(errorMessage(e, e.getMessage()), v, conversationIdHeader);
    } catch (Exception e) {
        logger.error("Unexpected error during processing {}", e.getMessage(), e);
        return internalServerError(errorMessage(e), v, 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) DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) WorkItemNotFoundException(org.jbpm.services.api.WorkItemNotFoundException) DeploymentNotActiveException(org.jbpm.services.api.DeploymentNotActiveException) ProcessDefinitionNotFoundException(org.jbpm.services.api.ProcessDefinitionNotFoundException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) 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