use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.
the class CaseResource method getCaseInstanceRoleAssignments.
@ApiOperation(value = "Returns role assignments for a specified case instance.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Case instance not found"), @ApiResponse(code = 200, response = CaseRoleAssignmentList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = CASE_ROLES_ASSIGNMENTS_JSON) })) })
@GET
@Path(CASE_ROLES_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getCaseInstanceRoleAssignments(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id that case instance belongs to", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "identifier of the case instance", required = true, example = "CASE-00000000001") @PathParam(CASE_ID) String caseId) {
return invokeCaseOperation(headers, containerId, caseId, (Variant v, String type, Header... customHeaders) -> {
logger.debug("About to look for role assignments in case {}", caseId);
CaseRoleAssignmentList responseObject = this.caseManagementServiceBase.getRoleAssignment(containerId, caseId);
logger.debug("Returning OK response with content '{}'", responseObject);
return createCorrectVariant(responseObject, headers, Response.Status.OK, customHeaders);
});
}
use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.
the class CaseResource method getCaseInstancesByContainer.
/*
* basic queries through container
*/
@ApiOperation(value = "Returns case instances in a specified KIE container.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 200, response = CaseInstanceList.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = CASE_INSTANCES_JSON) })) })
@GET
@Path(CASE_INSTANCES_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getCaseInstancesByContainer(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id that should be used to filter case instances", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "optional case instance status (open, closed, canceled) - defaults ot open (1) only", required = false, allowableValues = "open,closed,cancelled") @QueryParam("status") List<String> status, @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, @ApiParam(value = "optional flag to load data when loading case instance", required = false) @QueryParam("withData") @DefaultValue("false") boolean withData) {
return invokeCaseOperation(headers, containerId, null, (Variant v, String type, Header... customHeaders) -> {
List<String> actualStatus = status;
if (status == null || status.isEmpty()) {
actualStatus = new ArrayList<String>();
actualStatus.add(CaseStatus.OPEN.getName());
}
logger.debug("About to look for case instances in container {} with status {}", containerId, actualStatus);
CaseInstanceList responseObject = this.caseManagementRuntimeDataServiceBase.getCaseInstancesByContainer(containerId, actualStatus, page, pageSize, sort, sortOrder, withData);
logger.debug("Returning OK response with content '{}'", responseObject);
return createCorrectVariant(responseObject, headers, Response.Status.OK, customHeaders);
});
}
use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.
the class AbstractCaseResource method invokeCaseOperation.
protected Response invokeCaseOperation(HttpHeaders headers, String containerId, String caseId, String processId, CaseOperation operation) {
Variant v = getVariant(headers);
String type = getContentType(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
try {
return operation.invoke(v, type, conversationIdHeader);
} catch (SecurityException e) {
return forbidden(e.getMessage(), v, conversationIdHeader);
} catch (CaseActiveException e) {
return alreadyExists(MessageFormat.format(CASE_INSTANCE_ACTIVE, caseId), v, conversationIdHeader);
} catch (CaseNotFoundException e) {
return notFound(MessageFormat.format(CASE_INSTANCE_NOT_FOUND, caseId), v, conversationIdHeader);
} catch (AdHocFragmentNotFoundException e) {
return notFound(e.getMessage(), v, conversationIdHeader);
} catch (StageNotFoundException e) {
return notFound(e.getMessage(), v, conversationIdHeader);
} catch (DeploymentNotFoundException e) {
return notFound(MessageFormat.format(CONTAINER_NOT_FOUND, containerId), v, conversationIdHeader);
} catch (IllegalArgumentException e) {
return badRequest(e.getMessage(), v, conversationIdHeader);
} catch (ProcessDefinitionNotFoundException e) {
return notFound(MessageFormat.format(PROCESS_DEFINITION_NOT_FOUND, processId, 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 UserTaskResource method getTaskOutputContentByTaskId.
@ApiOperation(value = "Returns output data for a specified task instance.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Task with given id not found"), @ApiResponse(code = 200, response = Map.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_PROCESS_INSTANCE_VARS_RESPONSE_JSON) })) })
@GET
@Path(TASK_INSTANCE_OUTPUT_DATA_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getTaskOutputContentByTaskId(@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 output data should be loaded from", required = true, example = "123") @PathParam(TASK_INSTANCE_ID) Long taskId) {
Variant v = getVariant(headers);
String type = getContentType(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
try {
String response = userTaskServiceBase.getTaskOutputContentByTaskId(containerId, taskId, type);
logger.debug("Returning OK response with content '{}'", response);
return createResponse(response, v, Response.Status.OK, 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);
}
}
use of org.kie.server.remote.rest.common.Header in project droolsjbpm-integration by kiegroup.
the class UserTaskResource method deleteAttachment.
@ApiOperation(value = "Deletes a specified attachment from a specified task instance.", response = Void.class, code = 204)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Task with given id not found") })
@DELETE
@Path(TASK_INSTANCE_ATTACHMENT_DELETE_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response deleteAttachment(@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 attachment belongs to", required = true, example = "123") @PathParam(TASK_INSTANCE_ID) Long taskId, @ApiParam(value = "identifier of the attachment to be deleted", required = true, example = "567") @PathParam("attachmentId") Long attachmentId) {
Variant v = getVariant(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
try {
userTaskServiceBase.deleteAttachment(containerId, taskId, attachmentId);
// produce 204 NO_CONTENT response code
return noContent(v, 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);
}
}
Aggregations