Search in sources :

Example 96 with Header

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);
    }
}
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) LocalDateTime(java.time.LocalDateTime) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) TaskDataList(org.kie.server.api.model.taskassigning.TaskDataList) TaskData(org.kie.server.api.model.taskassigning.TaskData) 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)

Example 97 with Header

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);
    }
}
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) SolverInstance(org.kie.server.api.model.instance.SolverInstance) 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 98 with Header

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);
    }
}
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) SolverInstance(org.kie.server.api.model.instance.SolverInstance) 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 99 with Header

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);
    }
}
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) 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 100 with Header

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);
    }
}
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) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) 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