Search in sources :

Example 61 with Header

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

the class UserTaskResource method exit.

@ApiOperation(value = "Exits a specified task instance.", response = Void.class, code = 201)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Task with given id not found") })
@PUT
@Path(TASK_INSTANCE_EXIT_PUT_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response exit(@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 the task instance that should be exited", required = true, example = "123") @PathParam(TASK_INSTANCE_ID) Long taskId, @ApiParam(value = "optional user id to be used instead of authenticated user - only when bypass authenticated user is enabled", required = false) @QueryParam("user") String userId) {
    Variant v = getVariant(headers);
    Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
    try {
        userTaskServiceBase.exit(containerId, taskId, userId);
        return createResponse("", v, Response.Status.CREATED, conversationIdHeader);
    } catch (TaskNotFoundException e) {
        return notFound(errorMessage(e, MessageFormat.format(TASK_INSTANCE_NOT_FOUND, taskId)), v, conversationIdHeader);
    } catch (Exception e) {
        logger.error("Unexpected error during processing {}", 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) 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) PermissionDeniedException(org.jbpm.services.task.exception.PermissionDeniedException) 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 62 with Header

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

the class UserTaskResource method start.

@ApiOperation(value = "Starts a specified task instance.", response = Void.class, code = 201)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Task with given id not found") })
@PUT
@Path(TASK_INSTANCE_START_PUT_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response start(@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 the task instance that should be started", required = true, example = "123") @PathParam(TASK_INSTANCE_ID) Long taskId, @ApiParam(value = "optional user id to be used instead of authenticated user - only when bypass authenticated user is enabled", required = false) @QueryParam("user") String userId) {
    Variant v = getVariant(headers);
    Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
    try {
        userTaskServiceBase.start(containerId, taskId, userId);
        return createResponse("", v, Response.Status.CREATED, conversationIdHeader);
    } catch (TaskNotFoundException e) {
        return notFound(errorMessage(e, MessageFormat.format(TASK_INSTANCE_NOT_FOUND, taskId)), v, conversationIdHeader);
    } catch (Exception e) {
        logger.error("Unexpected error during processing {}", 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) 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) PermissionDeniedException(org.jbpm.services.task.exception.PermissionDeniedException) 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 63 with Header

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

the class UserTaskResource method delegate.

@ApiOperation(value = "Delegates a specified task instance to a specified target user as the new task owner.", response = Void.class, code = 201)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Task with given id not found"), @ApiResponse(code = 403, message = "User was unable to execute current operation on task with given id due to a no 'current status' match or insufficient permissions") })
@PUT
@Path(TASK_INSTANCE_DELEGATE_PUT_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response delegate(@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 the task instance that should be delegated", required = true, example = "123") @PathParam(TASK_INSTANCE_ID) Long taskId, @ApiParam(value = "optional user id to be used instead of authenticated user - only when bypass authenticated user is enabled", required = false) @QueryParam("user") String userId, @ApiParam(value = "user that task should be dalegated to", required = true) @QueryParam("targetUser") String targetUserId) {
    Variant v = getVariant(headers);
    Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
    try {
        userTaskServiceBase.delegate(containerId, taskId, userId, targetUserId);
        return createResponse("", v, Response.Status.CREATED, conversationIdHeader);
    } catch (TaskNotFoundException e) {
        return notFound(errorMessage(e, MessageFormat.format(TASK_INSTANCE_NOT_FOUND, taskId)), v, conversationIdHeader);
    } catch (PermissionDeniedException e) {
        return forbidden(errorMessage(e, e.getMessage()), v, conversationIdHeader);
    } catch (Exception e) {
        logger.error("Unexpected error during processing {}", 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) 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) PermissionDeniedException(org.jbpm.services.task.exception.PermissionDeniedException) PermissionDeniedException(org.jbpm.services.task.exception.PermissionDeniedException) 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 64 with Header

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

the class ProcessResource method getVariableHistory.

@ApiOperation(value = "Returns the history of a specified variable in a specified process instance.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Process Instance or Container Id not found"), @ApiResponse(code = 200, response = VariableInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_PROCESS_INSTANCE_VARS_LOG_RESPONSE_JSON) })) })
@GET
@Path(PROCESS_INSTANCE_VAR_INSTANCE_BY_VAR_NAME_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getVariableHistory(@Context HttpHeaders headers, @ApiParam(value = "container id that process instance belongs to", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "identifier of the process instance that variable history should be collected for", required = true, example = "123") @PathParam(PROCESS_INST_ID) long processInstanceId, @ApiParam(value = "name of the variables that history should be collected for", required = true, example = "person") @PathParam("varName") String variableName, @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) {
    Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
    Variant v = getVariant(headers);
    try {
        VariableInstanceList variableInstanceList = runtimeDataServiceBase.getVariableHistory(processInstanceId, variableName, page, pageSize);
        logger.debug("Returning result of variable '{}; history search: {}", variableName, variableInstanceList);
        return createCorrectVariant(variableInstanceList, headers, Response.Status.OK, conversationIdHeader);
    } catch (ProcessInstanceNotFoundException e) {
        return notFound(MessageFormat.format(PROCESS_INSTANCE_NOT_FOUND, processInstanceId), 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.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) 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) VariableInstanceList(org.kie.server.api.model.instance.VariableInstanceList) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) WorkItemNotFoundException(org.jbpm.services.api.WorkItemNotFoundException) DeploymentNotActiveException(org.jbpm.services.api.DeploymentNotActiveException) ProcessDefinitionNotFoundException(org.jbpm.services.api.ProcessDefinitionNotFoundException) 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 65 with Header

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

the class ProcessResource method getVariablesCurrentState.

@ApiOperation(value = "Returns the current variable values of a specified process instance in 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 = VariableInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_PROCESS_INSTANCE_VARS_LOG_RESPONSE_JSON) })) })
@GET
@Path(PROCESS_INSTANCE_VAR_INSTANCES_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getVariablesCurrentState(@Context HttpHeaders headers, @ApiParam(value = "container id that process instance belongs to", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "identifier of the process instance that variables state should be collected for", required = true, example = "123") @PathParam(PROCESS_INST_ID) long processInstanceId) {
    Variant v = getVariant(headers);
    Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
    try {
        VariableInstanceList variableInstanceList = runtimeDataServiceBase.getVariablesCurrentState(processInstanceId);
        logger.debug("Returning result of variables search: {}", variableInstanceList);
        return createCorrectVariant(variableInstanceList, headers, Response.Status.OK, conversationIdHeader);
    } catch (ProcessInstanceNotFoundException e) {
        return notFound(MessageFormat.format(PROCESS_INSTANCE_NOT_FOUND, processInstanceId), 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.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) 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) VariableInstanceList(org.kie.server.api.model.instance.VariableInstanceList) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) WorkItemNotFoundException(org.jbpm.services.api.WorkItemNotFoundException) DeploymentNotActiveException(org.jbpm.services.api.DeploymentNotActiveException) ProcessDefinitionNotFoundException(org.jbpm.services.api.ProcessDefinitionNotFoundException) 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)

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