use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.
the class TaskAssigningRuntimeResource method executeTasksQuery.
@ApiOperation(value = "Executes the task assigning integration query for returning the tasks information as a TaskDataList.", notes = "This operation is mainly intended for the tasks assigning integration implementation, third parties are recommended to use the queries described in the task assigning getting started guide.", response = TaskDataList.class)
@POST
@Path(TASK_ASSIGNING_QUERIES_TASK_DATA_URI)
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response executeTasksQuery(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "map with the query parameters", required = true, examples = @Example(value = { @ExampleProperty(mediaType = MediaType.APPLICATION_JSON, value = TASKS_QUERY_PARAMS_MAP_EXAMPLE_JSON), @ExampleProperty(mediaType = MediaType.APPLICATION_XML, value = TASKS_QUERY_PARAMS_MAP_EXAMPLE_XML) })) String payload) {
final Variant v = getVariant(headers);
// no container id available so only used to transfer conversation id if given by client
final Header conversationIdHeader = buildConversationIdHeader("", context, headers);
try {
String contentType = getContentType(headers);
@SuppressWarnings("unchecked") final Map<String, Object> queryParameters = marshallerHelper.unmarshal(payload, contentType, Map.class);
final LocalDateTime queryTime = LocalDateTime.now();
final List<TaskData> taskDataList = runtimeServiceBase.executeFindTasksQuery(queryParameters);
final TaskDataList result = new TaskDataList(taskDataList);
result.setQueryTime(queryTime);
return createCorrectVariant(result, headers, Response.Status.OK, conversationIdHeader);
} catch (Exception e) {
LOGGER.error("Unexpected error finding tasks {}", 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 SolverResource method getSolver.
@ApiOperation(value = "Retrieves solver by its identifier from given container", response = SolverInstance.class, code = 200)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Container does not exist or failure in creating solver") })
@GET
@Path(RestURI.SOLVER_ID_URI)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getSolver(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id where the solver resides", required = true) @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "identifier of the solver", required = true) @PathParam(SOLVER_ID) String solverId) {
Variant v = getVariant(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, solverService.getKieServerRegistry(), headers);
try {
ServiceResponse<SolverInstance> result = solverService.getSolver(containerId, solverId);
if (result.getType() == ServiceResponse.ResponseType.SUCCESS) {
return createCorrectVariant(marshallerHelper, containerId, result.getResult(), headers, Response.Status.OK, conversationIdHeader);
}
return createCorrectVariant(marshallerHelper, containerId, result.getMsg(), headers, Response.Status.NOT_FOUND, conversationIdHeader);
} catch (Exception e) {
logger.error("Unexpected error retrieving solver state {}", e.getMessage(), e);
return internalServerError(MessageFormat.format(Messages.UNEXPECTED_ERROR, e.getMessage()), v, conversationIdHeader);
}
}
use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.
the class SolverResource method getSolverWithBestSolution.
@ApiOperation(value = "Retrieves best solution from solver within container", response = SolverInstance.class, code = 200)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Container does not exist or failure in creating solver") })
@GET
@Path(SOLVER_ID_URI + "/" + SOLVER_BEST_SOLUTION)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getSolverWithBestSolution(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id where the solver resides", required = true) @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "identifier of the solver", required = true) @PathParam(SOLVER_ID) String solverId) {
Variant v = getVariant(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, solverService.getKieServerRegistry(), headers);
try {
ServiceResponse<SolverInstance> result = solverService.getSolverWithBestSolution(containerId, solverId);
if (result.getType() == ServiceResponse.ResponseType.SUCCESS) {
return createCorrectVariant(marshallerHelper, containerId, result.getResult(), headers, Response.Status.OK, conversationIdHeader);
}
return createCorrectVariant(marshallerHelper, containerId, result.getMsg(), headers, Response.Status.NOT_FOUND, conversationIdHeader);
} catch (Exception e) {
logger.error("Unexpected error during processing {}", e.getMessage(), e);
return internalServerError(MessageFormat.format(Messages.UNEXPECTED_ERROR, e.getMessage()), v, conversationIdHeader);
}
}
use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.
the class SolverResource method isEveryProblemFactChangeProcessed.
@ApiOperation(value = "Retrieves status if problem fact changes have been processed in given solver", response = Boolean.class, code = 200)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Container does not exist or failure in creating solver") })
@GET
@Path(RestURI.SOLVER_ID_URI + "/" + SOLVER_PROBLEM_FACTS_CHANGES_PROCESSED)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response isEveryProblemFactChangeProcessed(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id where the solver resides", required = true) @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "identifier of the solver", required = true) @PathParam(SOLVER_ID) String solverId) {
Variant v = getVariant(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, solverService.getKieServerRegistry(), headers);
try {
ServiceResponse<Boolean> result = solverService.isEveryProblemFactChangeProcessed(containerId, solverId);
if (result.getType() == ServiceResponse.ResponseType.SUCCESS) {
return createCorrectVariant(marshallerHelper, containerId, result.getResult(), headers, Response.Status.OK, conversationIdHeader);
}
return createCorrectVariant(marshallerHelper, containerId, result.getMsg(), headers, Response.Status.NOT_FOUND, conversationIdHeader);
} catch (Exception e) {
logger.error("Unexpected error querying problem facts processing state {}", e.getMessage(), e);
return internalServerError(MessageFormat.format(Messages.UNEXPECTED_ERROR, e.getMessage()), v, conversationIdHeader);
}
}
use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.
the class SolverResource method disposeSolver.
@ApiOperation(value = "Disposes given solver", response = Void.class, code = 200)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Container does not exist or failure in creating solver") })
@DELETE
@Path(RestURI.SOLVER_ID_URI)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response disposeSolver(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id where the solver resides", required = true) @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "identifier of the solver", required = true) @PathParam(SOLVER_ID) String solverId) {
Variant v = getVariant(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, solverService.getKieServerRegistry(), headers);
try {
ServiceResponse<Void> result = solverService.disposeSolver(containerId, solverId);
if (result.getType() == ServiceResponse.ResponseType.SUCCESS) {
return createResponse("", v, Response.Status.OK, conversationIdHeader);
}
return createCorrectVariant(marshallerHelper, containerId, result.getMsg(), headers, Response.Status.BAD_REQUEST, conversationIdHeader);
} catch (Exception e) {
logger.error("Unexpected error disposing solver {} on container {}. Message: '{}'", solverId, containerId, e.getMessage(), e);
return internalServerError(MessageFormat.format(Messages.UNEXPECTED_ERROR, e.getMessage()), v, conversationIdHeader);
}
}
Aggregations