use of javax.ws.rs.core.Variant in project droolsjbpm-integration by kiegroup.
the class ProcessAdminResource method migrateProcessInstances.
@ApiOperation(value = "Migrates multiple process instances to process definition in another KIE container.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Process instance or Container Id not found"), @ApiResponse(code = 404, message = "Container Id not found"), @ApiResponse(code = 201, response = MigrationReportInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_MIGRATION_REPORTS_RESPONSE_JSON) })) })
@PUT
@Path(MIGRATE_PROCESS_INSTANCES_PUT_URI)
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response migrateProcessInstances(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id that process instances belongs to", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "list of identifiers of process instance to be migrated", required = true) @QueryParam(PROCESS_INST_ID) List<Long> processInstanceIds, @ApiParam(value = "container id that new process definition belongs to", required = true) @QueryParam("targetContainerId") String targetContainerId, @ApiParam(value = "process definition that process instances should be migrated to", required = true) @QueryParam("targetProcessId") String targetProcessId, @ApiParam(value = "node mapping - unique ids of old definition to new definition given as Map", required = false, examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = SIMPLE_VAR_MAP_JSON), @ExampleProperty(mediaType = XML, value = SIMPLE_VAR_MAP_XML) })) String payload) {
Variant v = getVariant(headers);
String type = getContentType(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
try {
MigrationReportInstanceList reportInstances = processAdminServiceBase.migrateProcessInstances(containerId, processInstanceIds, targetContainerId, targetProcessId, payload, type);
return createCorrectVariant(reportInstances, headers, Response.Status.CREATED, conversationIdHeader);
} catch (ProcessInstanceNotFoundException e) {
return notFound(MessageFormat.format(PROCESS_INSTANCE_NOT_FOUND, processInstanceIds), v, conversationIdHeader);
} catch (DeploymentNotFoundException e) {
return notFound(MessageFormat.format(CONTAINER_NOT_FOUND, containerId), v, conversationIdHeader);
} catch (Exception e) {
logger.error("Unexpected error during processing {}", e.getMessage(), e);
return internalServerError(errorMessage(e), v, conversationIdHeader);
}
}
use of javax.ws.rs.core.Variant in project droolsjbpm-integration by kiegroup.
the class ProcessAdminResource method getExecutionErrors.
@ApiOperation(value = "Returns all process execution errors for a specified KIE container.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Process instance or Container Id not found"), @ApiResponse(code = 200, response = ExecutionErrorInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_EXEC_ERRORS_RESPONSE_JSON) })) })
@GET
@Path(ERRORS_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getExecutionErrors(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id that errors belong to", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "optional flag that indicates if acknowledged errors should also be collected, defaults to false", required = false) @QueryParam("includeAck") @DefaultValue("false") boolean includeAcknowledged, @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, @ApiParam(value = "optional sort column, no default", required = false) @QueryParam("sort") String sort, @ApiParam(value = "optional sort direction (asc, desc) - defaults to asc", required = false) @QueryParam("sortOrder") @DefaultValue("true") boolean sortOrder) {
Variant v = getVariant(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
try {
ExecutionErrorInstanceList executionErrorInstanceList = processAdminServiceBase.getExecutionErrors(containerId, includeAcknowledged, page, pageSize, sort, sortOrder);
return createCorrectVariant(executionErrorInstanceList, headers, Response.Status.OK, conversationIdHeader);
} catch (ExecutionErrorNotFoundException e) {
return notFound(e.getMessage(), v, conversationIdHeader);
} catch (DeploymentNotFoundException e) {
return notFound(MessageFormat.format(CONTAINER_NOT_FOUND, containerId), v, conversationIdHeader);
} catch (Exception e) {
logger.error("Unexpected error during processing {}", e.getMessage(), e);
return internalServerError(errorMessage(e), v, conversationIdHeader);
}
}
use of javax.ws.rs.core.Variant in project droolsjbpm-integration by kiegroup.
the class ExecutorResource method getRequestsByStatus.
// queries
@ApiOperation(value = "Retrieves asynchronous jobs filtered by status")
@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
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getRequestsByStatus(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "optional job status (QUEUED, DONE, CANCELLED, ERROR, RETRYING, RUNNING)", required = true, 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.getRequestsByStatus(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);
}
}
use of javax.ws.rs.core.Variant 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);
}
}
use of javax.ws.rs.core.Variant 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);
}
}
Aggregations