public byte[] getProcessImage(String processId) { RepositoryService repositoryService = this.processEngine.getRepositoryService(); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(processId).uniqueResult(); String imgRes = processDefinition.getImageResourceName(); InputStream in = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), imgRes); if (null == in) throw new RuntimeException("Failed to retrieve image resource: " + imgRes); ByteArrayOutputStream out = new ByteArrayOutputStream(); final int BUF_SIZE = 1 << 8; // 1KiB buffer byte[] buffer = new byte[BUF_SIZE]; int bytesRead = -1; try { while ((bytesRead = in.read(buffer)) > -1) { out.write(buffer, 0, bytesRead); } in.close(); } catch (IOException e) { throw new RuntimeException("Failed to read image resource: " + imgRes, e); } byte[] imageBytes = out.toByteArray(); return imageBytes; }
if (processDefinition != null) { String imgRes = processDefinition.getImageResourceName(); inputStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), imgRes);
InputStream template = repoService.getResourceAsStream(procDef.getDeploymentId(), startFormResourceName); InputStream css = loadCSS(procDef.getDeploymentId()); if(css!=null) renderContext.put("CSS", streamToString(css));
public List<ProcessDefinitionRef> removeProcessDefinition(String procDefId) { RepositoryService repositoryService = this.processEngine.getRepositoryService(); ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId).uniqueResult(); if (processDefinition != null) { // Todo: this deletes a complete deployment. Currently, there is no way of deleting a procDef only repositoryService.deleteDeploymentCascade(processDefinition.getDeploymentId()); } return getProcessDefinitions(); }
private InputStream loadCSS(String executionId) { RepositoryService repoService = processEngine.getRepositoryService(); ExecutionService execService = processEngine.getExecutionService(); Execution execution = execService.findExecutionById(executionId); if (execution != null) { ProcessDefinition definition = repoService.createProcessDefinitionQuery() .processDefinitionId(execution.getProcessDefinitionId()).uniqueResult(); InputStream in = repoService.getResourceAsStream(definition.getDeploymentId(), PROCESSFORMS_CSS); return in; } return null; } }
InputStream template = repoService.getResourceAsStream(procDef.getDeploymentId(), name);
public static ProcessDefinitionRef adoptDefinition(ProcessDefinition processDefinition) { ProcessDefinitionRef def = new ProcessDefinitionRef(); def.setId(processDefinition.getId()); def.setName(processDefinition.getName()); def.setVersion(processDefinition.getVersion()); def.setKey(processDefinition.getKey()); def.setSuspended(processDefinition.isSuspended()); def.setDeploymentId(processDefinition.getDeploymentId()); // TODO: Are these needed? // ProcessDefinitionImpl cast = (ProcessDefinitionImpl) processDefinition; // def.setDescription(processDefinition.getDescription()); // def.setPackageName(cast.getPackageName()); return def; }