@ApiOperation(value="Retrieves process instance image", response=String.class, code=200) @ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Process instance, image or Container Id not found") }) @GET @Path(PROCESS_INST_IMG_GET_URI) @Produces({MediaType.APPLICATION_SVG_XML}) public Response getProcessInstanceImage(@javax.ws.rs.core.Context HttpHeaders headers, @ApiParam(value = "container id that process instance belongs to", required = true) @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "identifier of the process instance that image should be loaded for", required = true) @PathParam(PROCESS_INST_ID) Long procInstId) { Variant v = getVariant(headers); Header conversationIdHeader = buildConversationIdHeader(containerId, context, headers); try { String svgString = imageServiceBase.getActiveProcessImage(containerId, procInstId); logger.debug("Returning OK response with content '{}'", svgString); return createResponse(svgString, v, Response.Status.OK, conversationIdHeader); } catch (ProcessInstanceNotFoundException e) { return notFound(MessageFormat.format("Not found", e.getMessage()), v, conversationIdHeader); } catch (IllegalArgumentException e) { return notFound("Image for process instance id " + procInstId + " not found", v, conversationIdHeader); } catch (Exception e) { logger.error("Unexpected error during processing {}", e.getMessage(), e); return internalServerError(MessageFormat.format("Unexpected error encountered", e.getMessage()), v, conversationIdHeader); } } }
@ApiOperation(value="Retrieves process definition image", 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) @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "identifier of the process definition that image should be loaded for", required = true) @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(MessageFormat.format("Unexpected error encountered", e.getMessage()), v, conversationIdHeader); } }
public String getProcessImage(String containerId, String processId) { containerId = registry.getContainerId(containerId, ContainerLocatorProvider.get().getLocator()); String imageSVGString = null; byte[] imageSVG = getProcessImageAsBytes(containerId, processId); if (imageSVG != null) { try { imageSVGString = new String(imageSVG, "UTF-8"); } catch (UnsupportedEncodingException e) { logger.debug("UnsupportedEncodingException while building process image due to {}", e.getMessage()); } } return imageSVGString; }
public String getActiveProcessImage(String containerId, long procInstId) { ProcessInstanceDesc instance = dataService.getProcessInstanceById(procInstId); if (instance == null) { throw new ProcessInstanceNotFoundException("No instance found for process instance id " + procInstId); } String imageSVGString = null; // get SVG String byte[] imageSVG = getProcessImageAsBytes(instance.getDeploymentId(), instance.getProcessId()); if (imageSVG != null) { // find active nodes and modify image Map<String, String> subProcessLinks = new HashMap<>(); Collection<NodeInstanceDesc> activeLogs = dataService.getProcessInstanceHistoryActive(procInstId, new QueryContext(0, 1000)); Collection<NodeInstanceDesc> completedLogs = dataService.getProcessInstanceHistoryCompleted(procInstId, new QueryContext(0, 1000)); Map<Long, String> active = new HashMap<Long, String>(); List<String> completed = new ArrayList<String>(); for (NodeInstanceDesc activeNode : activeLogs) { active.put(activeNode.getId(), activeNode.getNodeId()); populateSubProcessLink(containerId, activeNode, subProcessLinks); } for (NodeInstanceDesc completeNode : completedLogs) { completed.add(completeNode.getNodeId()); active.remove(completeNode.getId()); populateSubProcessLink(containerId, completeNode, subProcessLinks); } ByteArrayInputStream svgStream = new ByteArrayInputStream(imageSVG); imageSVGString = SVGImageProcessor.transform(svgStream, completed, new ArrayList<String>(active.values()), subProcessLinks); return imageSVGString; } throw new IllegalArgumentException("No process found for " + instance.getProcessId() + " within container " + containerId); }
imageServiceBase = new ImageServiceBase(runtimeDataService, imageReferences, registry); formRendererBase = new FormRendererBase(definitionService, userTaskService, formManagerService, caseRuntimeDataService, registry);