use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.
the class UserTaskAdminResource method getExecutionErrorsByTask.
@ApiOperation(value = "Returns task execution errors for a specified task instance.")
@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_BY_TASK_ID_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getExecutionErrorsByTask(@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 the task instance that errors should be collected for", required = true, example = "123") @PathParam(TASK_INSTANCE_ID) Long taskId, @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 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.getExecutionErrorsByTaskId(containerId, taskId, 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);
}
}
use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.
the class UserTaskAdminResource method removeTaskOutputs.
@ApiOperation(value = "Deletes output data by parameter name from 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_OUTPUTS_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response removeTaskOutputs(@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 = "one or more names of task outputs to be removed", required = true) @QueryParam("name") List<String> outputNames) {
Variant v = getVariant(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
try {
userTaskAdminServiceBase.removeTaskOutputs(containerId, tInstanceId, outputNames);
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);
}
}
use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.
the class UserTaskAdminResource method notify.
@ApiOperation(value = "Creates an email notification for the specified task instance and returns the ID of the new notification.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Task instance or Container Id not found"), @ApiResponse(code = 201, response = Long.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = INTEGER_JSON) })) })
@POST
@Path(TASK_INSTANCE_NOTIFICATIONS_URI)
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response notify(@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 = "time expression for notification", required = true) @QueryParam("expiresAt") String expiresAt, @ApiParam(value = "optional flag that indicates the type of notification, either whenNotStarted or whenNotCompleted must be set", required = false) @QueryParam("whenNotStarted") @DefaultValue("false") boolean whenNotStarted, @ApiParam(value = "optional flag that indicates the type of notification, either whenNotStarted or whenNotCompleted must be set", required = false) @QueryParam("whenNotCompleted") @DefaultValue("false") boolean whenNotCompleted, @ApiParam(value = "email notification details, as EmailNotification type", required = true, examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = EMAIL_NOTIFICATION_JSON), @ExampleProperty(mediaType = XML, value = EMAIL_NOTIFICATION_XML) })) String payload) {
Variant v = getVariant(headers);
String type = getContentType(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
try {
if (expiresAt == null) {
return badRequest("'expiresAt' query parameter is mandatory", v, conversationIdHeader);
}
if (!whenNotCompleted && !whenNotStarted) {
return badRequest("At least one query parameters must be set to true - 'whenNotStarted' or 'whenNotCompleted'", v, conversationIdHeader);
}
String id = null;
if (whenNotStarted) {
id = userTaskAdminServiceBase.notifyWhenNotStarted(containerId, tInstanceId, expiresAt, payload, type);
}
if (whenNotCompleted) {
id = userTaskAdminServiceBase.notifyWhenNotCompleted(containerId, tInstanceId, expiresAt, payload, type);
}
return createResponse(id, v, Response.Status.CREATED, 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);
}
}
use of org.kie.server.remote.rest.common.Header 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);
}
}
use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.
the class UserTaskAdminResource method acknowledgeError.
@ApiOperation(value = "Acknowledges a specified task execution error.", 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_ERROR_PUT_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response acknowledgeError(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id that error belongs to", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "identifier of the execution error to be acknowledged", required = true, example = "xxx-yyy-zzz") @PathParam("errorId") String errorId) {
Variant v = getVariant(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
try {
userTaskAdminServiceBase.acknowledgeError(Arrays.asList(errorId));
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);
}
}
Aggregations