Search in sources :

Example 86 with Header

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

the class RestUtils method buildConversationIdHeader.

public static Header buildConversationIdHeader(String containerId, KieServerRegistry registry, HttpHeaders headers) {
    List<String> conversationIdHeader = headers.getRequestHeader(KieServerConstants.KIE_CONVERSATION_ID_TYPE_HEADER);
    if (conversationIdHeader != null && !conversationIdHeader.isEmpty()) {
        return new Header(KieServerConstants.KIE_CONVERSATION_ID_TYPE_HEADER, conversationIdHeader.get(0));
    }
    KieContainerInstanceImpl container = registry.getContainer(containerId);
    if (container != null && KieContainerStatus.STARTED.equals(container.getStatus())) {
        ReleaseId releaseId = container.getResource().getResolvedReleaseId();
        if (releaseId == null) {
            releaseId = container.getResource().getReleaseId();
        }
        String conversationId = ConversationId.from(KieServerEnvironment.getServerId(), containerId, releaseId).toString();
        return new Header(KieServerConstants.KIE_CONVERSATION_ID_TYPE_HEADER, conversationId);
    }
    return null;
}
Also used : Header(org.kie.server.remote.rest.common.Header) KieContainerInstanceImpl(org.kie.server.services.impl.KieContainerInstanceImpl) ReleaseId(org.kie.server.api.model.ReleaseId)

Example 87 with Header

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

the class UserTaskAdminResource method getExecutionErrors.

@ApiOperation(value = "Returns all task execution errors for a specified KIE container.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "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 task instance belongs 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 name of the task to filter by", required = false) @QueryParam("name") String taskName, @ApiParam(value = "optional process id that the task belongs to to filter by", required = false) @QueryParam("process") String processId, @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 = userTaskAdminServiceBase.getExecutionErrorsByTaskName(containerId, processId, taskName, 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);
    }
}
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) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) ExecutionErrorInstanceList(org.kie.server.api.model.admin.ExecutionErrorInstanceList) ExecutionErrorNotFoundException(org.jbpm.services.api.admin.ExecutionErrorNotFoundException) 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 88 with Header

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

the class UserTaskAdminResource method acknowledgeErrors.

@ApiOperation(value = "Acknowledges one or more task execution errors in a specified KIE container.", response = Void.class, code = 201)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Task instance or Container Id not found") })
@PUT
@Path(ACK_ERRORS_PUT_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response acknowledgeErrors(@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 = "list of identifiers of execution errors to be acknowledged", required = true) @QueryParam("errorId") List<String> errorIds) {
    Variant v = getVariant(headers);
    Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
    try {
        userTaskAdminServiceBase.acknowledgeError(errorIds);
        return createCorrectVariant("", headers, Response.Status.CREATED, 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);
    }
}
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) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) ExecutionErrorNotFoundException(org.jbpm.services.api.admin.ExecutionErrorNotFoundException) 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) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses) PUT(javax.ws.rs.PUT)

Example 89 with Header

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

the class UserTaskAdminResource method cancelReassignment.

@ApiOperation(value = "Deletes a specified reassignment for a specified task instance.", response = Void.class, code = 204)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Task instance or Container Id not found") })
@DELETE
@Path(TASK_INSTANCE_REASSIGNMENT_DELETE_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response cancelReassignment(@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 = "identifier of reassignment to be canceled", required = true, example = "567") @PathParam("reassignmentId") Long reassignmentId) {
    Variant v = getVariant(headers);
    Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
    try {
        userTaskAdminServiceBase.cancelReassignment(containerId, tInstanceId, reassignmentId);
        return noContent(v, conversationIdHeader);
    } catch (TaskNotFoundException 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) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) TaskNotFoundException(org.jbpm.services.api.TaskNotFoundException) 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) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 90 with Header

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

the class UserTaskAdminResource method removeFromTask.

protected Response removeFromTask(HttpHeaders headers, String userId, String containerId, Long tInstanceId, boolean isUser, String entities, int operation) {
    Variant v = getVariant(headers);
    Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
    try {
        String[] multipleEntities = entities.split(",");
        List<String> listOfEntities = Arrays.asList(multipleEntities);
        switch(operation) {
            case POT_OWNER:
                userTaskAdminServiceBase.removePotentialOwners(userId, containerId, tInstanceId, listOfEntities, isUser);
                break;
            case EXL_OWNER:
                userTaskAdminServiceBase.removeExcludedOwners(userId, containerId, tInstanceId, listOfEntities, isUser);
                break;
            case ADMIN:
                userTaskAdminServiceBase.removeBusinessAdmins(userId, containerId, tInstanceId, listOfEntities, isUser);
                break;
        }
        return noContent(v, conversationIdHeader);
    } catch (TaskNotFoundException 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) Header(org.kie.server.remote.rest.common.Header) RestUtils.buildConversationIdHeader(org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader) TaskNotFoundException(org.jbpm.services.api.TaskNotFoundException) 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)

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