use of javax.ws.rs.core.Variant in project droolsjbpm-integration by kiegroup.
the class FormResource method getProcessForm.
@ApiOperation(value = "Returns the form information for a specified process definition.")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Process definition, form or Container Id not found"), @ApiResponse(code = 200, response = String.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = PROCESS_FORM_DEF_JSON) })) })
@GET
@Path(PROCESS_FORM_GET_URI)
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getProcessForm(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id that process definition belongs to", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "identifier of process definition that form should be fetched for", required = true, example = "evaluation") @PathParam(PROCESS_ID) String processId, @ApiParam(value = "optional language that the form should be found for", required = false) @QueryParam("lang") @DefaultValue("en") String language, @ApiParam(value = "optional filter flag if form should be filtered or returned as is", required = false) @QueryParam("filter") boolean filter, @ApiParam(value = "optional type of the form, defaults to ANY so system will find the most current one", required = false) @QueryParam("type") @DefaultValue("ANY") String formType, @ApiParam(value = "optional marshall content flag if the content should be transformed or not, defaults to true", required = false) @QueryParam("marshallContent") @DefaultValue("true") boolean marshallContent) {
Variant variant = getVariant(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
try {
String response = formServiceBase.getFormDisplayProcess(containerId, processId, language, filter, formType);
if (marshallContent) {
response = marshallFormContent(response, formType, variant);
}
logger.debug("Returning OK response with content '{}'", response);
return createResponse(response, variant, Response.Status.OK, conversationIdHeader);
} catch (DeploymentNotFoundException e) {
return notFound(MessageFormat.format(CONTAINER_NOT_FOUND, containerId), variant, conversationIdHeader);
} catch (ProcessDefinitionNotFoundException e) {
return notFound(MessageFormat.format(PROCESS_DEFINITION_NOT_FOUND, processId, containerId), variant, conversationIdHeader);
} catch (IllegalStateException e) {
return notFound("Form for process id " + processId + " not found", variant, conversationIdHeader);
} catch (Exception e) {
logger.error("Unexpected error during processing {}", e.getMessage(), e);
return internalServerError(errorMessage(e), variant, conversationIdHeader);
}
}
use of javax.ws.rs.core.Variant in project droolsjbpm-integration by kiegroup.
the class FormResource method getProcessRenderedForm.
@ApiOperation(value = "Returns the rendered form for a specified process definition", response = String.class, code = 200)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Process, form or Container Id not found") })
@GET
@Path(PROCESS_FORM_CONTENT_GET_URI)
@Produces({ MediaType.TEXT_HTML })
public Response getProcessRenderedForm(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id that process definition belongs to", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "identifier of process definition that form should be fetched for", required = true, example = "evaluation") @PathParam(PROCESS_ID) String processId, @ApiParam(value = "optional renderer name that the form should be rendered with", required = false) @QueryParam("renderer") @DefaultValue("patternfly") String renderer) {
Variant variant = getVariant(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
try {
String renderedForm = formRendererBase.getProcessRenderedForm(renderer, containerId, processId);
if (renderedForm == null) {
return Response.status(Status.NOT_FOUND).build();
}
return Response.ok().entity(renderedForm).build();
} catch (DeploymentNotFoundException e) {
return notFound(MessageFormat.format(CONTAINER_NOT_FOUND, containerId), variant, conversationIdHeader);
} catch (ProcessDefinitionNotFoundException e) {
return notFound(MessageFormat.format(PROCESS_DEFINITION_NOT_FOUND, processId, containerId), variant, conversationIdHeader);
} catch (IllegalArgumentException e) {
return notFound(e.getMessage(), variant, conversationIdHeader);
} catch (Exception e) {
logger.error("Unexpected error during processing {}", e.getMessage(), e);
return internalServerError(errorMessage(e), variant, conversationIdHeader);
}
}
use of javax.ws.rs.core.Variant in project droolsjbpm-integration by kiegroup.
the class ImageResource method getProcessImage.
@ApiOperation(value = "Returns an SVG image file of a specified process definition diagram.", response = String.class, code = 200)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Process definition, image or Container Id not found") })
@GET
@Path(PROCESS_IMG_GET_URI)
@Produces({ MediaType.APPLICATION_SVG_XML })
public Response getProcessImage(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id that process definition belongs to", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "identifier of the process definition that image should be loaded for", required = true, example = "evaluation") @PathParam(PROCESS_ID) String processId) {
Variant v = getVariant(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
try {
String svgString = imageServiceBase.getProcessImage(containerId, processId);
logger.debug("Returning OK response with content '{}'", svgString);
return createResponse(svgString, v, Response.Status.OK, conversationIdHeader);
} catch (IllegalArgumentException e) {
return notFound("Image for process id " + processId + " not found", v, conversationIdHeader);
} catch (Exception e) {
logger.error("Unexpected error during processing {}", e.getMessage(), e);
return internalServerError(errorMessage(e), v, conversationIdHeader);
}
}
use of javax.ws.rs.core.Variant in project droolsjbpm-integration by kiegroup.
the class DefinitionResource method getAssociatedEntities.
@ApiOperation(value = "Retrieves actors and groups that are involved in given process and container")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Process or Container Id not found"), @ApiResponse(code = 200, response = AssociatedEntitiesDefinition.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_PROCESS_ENTITIES_RESPONSE_JSON) })) })
@GET
@Path(PROCESS_DEF_ASSOCIATED_ENTITIES_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getAssociatedEntities(@Context HttpHeaders headers, @ApiParam(value = "container id where the process definition resides", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "process id that the involved actors and groups should be retrieved from", required = true, example = "evaluation") @PathParam(PROCESS_ID) String processId) {
Variant v = getVariant(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
try {
AssociatedEntitiesDefinition associatedEntitiesDefinition = definitionServiceBase.getAssociatedEntities(containerId, processId);
return createCorrectVariant(associatedEntitiesDefinition, headers, Response.Status.OK, conversationIdHeader);
} catch (IllegalStateException e) {
return notFound(MessageFormat.format(PROCESS_DEFINITION_NOT_FOUND, processId, containerId), v, conversationIdHeader);
} catch (Exception e) {
return internalServerError(errorMessage(e), v, conversationIdHeader);
}
}
use of javax.ws.rs.core.Variant in project droolsjbpm-integration by kiegroup.
the class DefinitionResource method getServiceTasks.
@ApiOperation(value = "Retrieves service tasks definitions that are present in given process and container")
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Process or Container Id not found"), @ApiResponse(code = 200, response = ServiceTasksDefinition.class, message = "Successful response", examples = @Example(value = { @ExampleProperty(mediaType = JSON, value = GET_PROCESS_SERVICE_TASKS_RESPONSE_JSON) })) })
@GET
@Path(PROCESS_DEF_SERVICE_TASKS_GET_URI)
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getServiceTasks(@Context HttpHeaders headers, @ApiParam(value = "container id where the process definition resides", required = true, example = "evaluation_1.0.0-SNAPSHOT") @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "process id that the service task definitions should be retrieved from", required = true, example = "evaluation") @PathParam(PROCESS_ID) String processId) {
Variant v = getVariant(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers);
try {
ServiceTasksDefinition serviceTasksDefinition = definitionServiceBase.getServiceTasks(containerId, processId);
return createCorrectVariant(serviceTasksDefinition, headers, Response.Status.OK, conversationIdHeader);
} catch (IllegalStateException e) {
return notFound(MessageFormat.format(PROCESS_DEFINITION_NOT_FOUND, processId, containerId), v, conversationIdHeader);
} catch (Exception e) {
return internalServerError(errorMessage(e), v, conversationIdHeader);
}
}
Aggregations