Search in sources :

Example 1 with TaskReassignmentList

use of org.kie.server.api.model.admin.TaskReassignmentList in project droolsjbpm-integration by kiegroup.

the class UserTaskAdminResource method getTaskReassignments.

@ApiOperation(value = "Returns task reassignments for a specified task instance.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Task instance or Container Id not found"), @ApiResponse(code = 200, response = TaskReassignmentList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_TASK_REASSIGNMENTS_RESPONSE_JSON) })) })
@GET
@Path(TASK_INSTANCE_REASSIGNMENTS_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getTaskReassignments(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id that task instance belongs to", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "identifier of task instance to be updated", required = true, example = "123") @PathParam(TASK_INSTANCE_ID) Long tInstanceId, @ApiParam(value = "optional flag that indicates if active only reassignmnets should be collected, defaults to true", required = false) @QueryParam("activeOnly") @DefaultValue("true") boolean activeOnly) {
    Variant v = getVariant(headers);
    Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
    try {
        TaskReassignmentList taskReassignmentList = userTaskAdminServiceBase.getTaskReassignments(containerId, tInstanceId, activeOnly);
        return createCorrectVariant(taskReassignmentList, headers, Response.Status.OK, conversationIdHeader);
    } catch (ProcessInstanceNotFoundException e) {
        return notFound(MessageFormat.format(TASK_INSTANCE_NOT_FOUND, tInstanceId), 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);
    }
}
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) DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) TaskReassignmentList(org.kie.server.api.model.admin.TaskReassignmentList) 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) ExecutionErrorNotFoundException(org.jbpm.services.api.admin.ExecutionErrorNotFoundException) TaskNotFoundException(org.jbpm.services.api.TaskNotFoundException) 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 2 with TaskReassignmentList

use of org.kie.server.api.model.admin.TaskReassignmentList in project droolsjbpm-integration by kiegroup.

the class UserTaskAdminServicesClientImpl method getTaskReassignments.

@Override
public List<TaskReassignment> getTaskReassignments(String containerId, Long taskId, boolean activeOnly) {
    TaskReassignmentList result = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        valuesMap.put(TASK_INSTANCE_ID, taskId);
        String queryString = "?activeOnly=" + activeOnly;
        result = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), ADMIN_TASK_URI + "/" + TASK_INSTANCE_REASSIGNMENTS_URI, valuesMap) + queryString, TaskReassignmentList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskAdminService", "getTaskReassignments", new Object[] { containerId, taskId, activeOnly })));
        ServiceResponse<TaskReassignmentList> response = (ServiceResponse<TaskReassignmentList>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM").getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        result = response.getResult();
    }
    if (result != null && result.getItems() != null) {
        return result.getItems();
    }
    return Collections.emptyList();
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) TaskReassignmentList(org.kie.server.api.model.admin.TaskReassignmentList) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript)

Aggregations

TaskReassignmentList (org.kie.server.api.model.admin.TaskReassignmentList)2 ApiOperation (io.swagger.annotations.ApiOperation)1 ApiResponses (io.swagger.annotations.ApiResponses)1 HashMap (java.util.HashMap)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 Variant (javax.ws.rs.core.Variant)1 DeploymentNotFoundException (org.jbpm.services.api.DeploymentNotFoundException)1 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)1 TaskNotFoundException (org.jbpm.services.api.TaskNotFoundException)1 ExecutionErrorNotFoundException (org.jbpm.services.api.admin.ExecutionErrorNotFoundException)1 CommandScript (org.kie.server.api.commands.CommandScript)1 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)1 KieServerCommand (org.kie.server.api.model.KieServerCommand)1 ServiceResponse (org.kie.server.api.model.ServiceResponse)1 Header (org.kie.server.remote.rest.common.Header)1 RestUtils.buildConversationIdHeader (org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader)1 RestUtils.createCorrectVariant (org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant)1 RestUtils.getVariant (org.kie.server.remote.rest.common.util.RestUtils.getVariant)1