@RequestMapping(value = "/rest/stencil-sets/cmmneditor", method = RequestMethod.GET, produces = "application/json") public JsonNode getCmmnStencilSetForEditor() { try { JsonNode stencilNode = objectMapper.readTree(this.getClass().getClassLoader().getResourceAsStream("stencilset_cmmn.json")); return stencilNode; } catch (Exception e) { LOGGER.error("Error reading bpmn stencil set json", e); throw new InternalServerErrorException("Error reading bpmn stencil set json"); } } }
@RequestMapping(value = "/rest/stencil-sets/editor", method = RequestMethod.GET, produces = "application/json") public JsonNode getStencilSetForEditor() { try { JsonNode stencilNode = objectMapper.readTree(this.getClass().getClassLoader().getResourceAsStream("stencilset_bpmn.json")); return stencilNode; } catch (Exception e) { LOGGER.error("Error reading bpmn stencil set json", e); throw new InternalServerErrorException("Error reading bpmn stencil set json"); } }
@RequestMapping(value = "/rest/tasks/{taskId}/raw-content/text", method = RequestMethod.POST) public String createContentItemOnTaskText(@PathVariable("taskId") String taskId, @RequestParam("file") MultipartFile file) { ContentItemRepresentation contentItem = super.createContentItemOnTask(taskId, file); String contentItemJson = null; try { contentItemJson = objectMapper.writeValueAsString(contentItem); } catch (Exception e) { LOGGER.error("Error while processing ContentItem representation json", e); throw new InternalServerErrorException("ContentItem on task could not be saved"); } return contentItemJson; }
@RequestMapping(value = "/rest/import-case-model/text", method = RequestMethod.POST) public String importCaseModelText(HttpServletRequest request, @RequestParam("file") MultipartFile file) { ModelRepresentation modelRepresentation = modelQueryService.importCaseModel(request, file); String modelRepresentationJson = null; try { modelRepresentationJson = objectMapper.writeValueAsString(modelRepresentation); } catch (Exception e) { LOGGER.error("Error while processing Model representation json", e); throw new InternalServerErrorException("Model Representation could not be saved"); } return modelRepresentationJson; }
@RequestMapping(value = "/import-decision-table-text", method = RequestMethod.POST, produces = "application/json") public String importDecisionTableText(HttpServletRequest request, @RequestParam("file") MultipartFile file) { ModelRepresentation decisionTableRepresentation = decisionTableService.importDecisionTable(request, file); String json = null; try { json = objectMapper.writeValueAsString(decisionTableRepresentation); } catch (Exception e) { LOGGER.error("Error writing imported decision table json", e); throw new InternalServerErrorException("Error writing imported decision table representation json"); } return json; }
@RequestMapping(value = "/rest/process-instances/{processInstanceId}/raw-content/text", method = RequestMethod.POST) public String createContentItemOnProcessInstanceText(@PathVariable("processInstanceId") String processInstanceId, @RequestParam("file") MultipartFile file) { ContentItemRepresentation contentItem = super.createContentItemOnProcessInstance(processInstanceId, file); String contentItemJson = null; try { contentItemJson = objectMapper.writeValueAsString(contentItem); } catch (Exception e) { LOGGER.error("Error while processing ContentItem representation json", e); throw new InternalServerErrorException("ContentItem on process instance could not be saved"); } return contentItemJson; }
@RequestMapping(value = "/rest/import-process-model/text", method = RequestMethod.POST) public String importProcessModelText(HttpServletRequest request, @RequestParam("file") MultipartFile file) { ModelRepresentation modelRepresentation = modelQueryService.importProcessModel(request, file); String modelRepresentationJson = null; try { modelRepresentationJson = objectMapper.writeValueAsString(modelRepresentation); } catch (Exception e) { LOGGER.error("Error while processing Model representation json", e); throw new InternalServerErrorException("Model Representation could not be saved"); } return modelRepresentationJson; }
@RequestMapping(value = "/rest/content/raw/text", method = RequestMethod.POST) public String createTemporaryRawContentItemText(@RequestParam("file") MultipartFile file) { ContentItemRepresentation contentItem = super.createTemporaryRawContentItem(file); String contentItemJson = null; try { contentItemJson = objectMapper.writeValueAsString(contentItem); } catch (Exception e) { LOGGER.error("Error while processing ContentItem representation json", e); throw new InternalServerErrorException("ContentItem could not be saved"); } return contentItemJson; }
@RequestMapping(value = "/rest/case-instances/{caseId}/raw-content/text", method = RequestMethod.POST) public String createContentItemOnCaseText(@PathVariable("caseId") String caseId, @RequestParam("file") MultipartFile file) { ContentItemRepresentation contentItem = super.createContentItemOnCase(caseId, file); String contentItemJson = null; try { contentItemJson = objectMapper.writeValueAsString(contentItem); } catch (Exception e) { LOGGER.error("Error while processing ContentItem representation json", e); throw new InternalServerErrorException("ContentItem on process instance could not be saved"); } return contentItemJson; }
@Transactional @RequestMapping(value = "/rest/app-definitions/{modelId}/text/import", method = RequestMethod.POST) public String importAppDefinitionText(HttpServletRequest request, @PathVariable String modelId, @RequestParam("file") MultipartFile file) { AppDefinitionRepresentation appDefinitionRepresentation = appDefinitionImportService.importAppDefinitionNewVersion(request, file, modelId); String appDefinitionRepresentationJson = null; try { appDefinitionRepresentationJson = objectMapper.writeValueAsString(appDefinitionRepresentation); } catch (Exception e) { LOGGER.error("Error while App Definition representation json", e); throw new InternalServerErrorException("App definition could not be saved"); } return appDefinitionRepresentationJson; }
@Transactional @RequestMapping(value = "/rest/app-definitions/text/import", method = RequestMethod.POST) public String importAppDefinitionText(HttpServletRequest request, @RequestParam("file") MultipartFile file) { AppDefinitionRepresentation appDefinitionRepresentation = appDefinitionImportService.importAppDefinition(request, file); String appDefinitionRepresentationJson = null; try { appDefinitionRepresentationJson = objectMapper.writeValueAsString(appDefinitionRepresentation); } catch (Exception e) { LOGGER.error("Error while App Definition representation json", e); throw new InternalServerErrorException("App definition could not be saved"); } return appDefinitionRepresentationJson; } }
@ResponseStatus(value = HttpStatus.OK) @RequestMapping(value = "/profile-picture", method = RequestMethod.POST, produces = "application/json") public void uploadProfilePicture(@RequestParam("file") MultipartFile file) { try { profileService.uploadProfilePicture(file.getContentType(), file.getBytes()); } catch (IOException e) { throw new InternalServerErrorException(e.getMessage(), e); } }
@RequestMapping(value = "/rest/case-definitions/{caseDefinitionId}/model-json", method = RequestMethod.GET, produces = "application/json") public JsonNode getModelJSONForCaseDefinition(@PathVariable String caseDefinitionId) { CmmnModel pojoModel = cmmnRepositoryService.getCmmnModel(caseDefinitionId); if (pojoModel == null || pojoModel.getLocationMap().isEmpty()) { throw new InternalServerErrorException("Case definition could not be found with id " + caseDefinitionId); } return processCaseElements(pojoModel, null, null, null); }
@RequestMapping(value = "/rest/process-definitions/{processDefinitionId}/model-json", method = RequestMethod.GET, produces = "application/json") public JsonNode getModelJSONForProcessDefinition(@PathVariable String processDefinitionId) { BpmnModel pojoModel = repositoryService.getBpmnModel(processDefinitionId); if (pojoModel == null || pojoModel.getLocationMap().isEmpty()) { throw new InternalServerErrorException("Process definition could not be found with id " + processDefinitionId); } return processProcessElements(pojoModel, null, null, Collections.EMPTY_LIST, ""); }
protected ObjectNode deleteEmbededReferencesFromStepModel(ObjectNode editorJsonNode) { try { JsonNode startFormNode = editorJsonNode.get("startForm"); if (startFormNode != null) { editorJsonNode.remove("startForm"); } internalDeleteNodeByNameFromStepModel(editorJsonNode.get("steps"), "formDefinition"); internalDeleteNodeByNameFromStepModel(editorJsonNode.get("steps"), "subProcessDefinition"); return editorJsonNode; } catch (Exception e) { throw new InternalServerErrorException("Cannot delete the external references"); } }
protected ObjectNode deleteEmbededReferencesFromBPMNModel(ObjectNode editorJsonNode) { try { internalDeleteNodeByNameFromBPMNModel(editorJsonNode, "formreference"); internalDeleteNodeByNameFromBPMNModel(editorJsonNode, "subprocessreference"); return editorJsonNode; } catch (Exception e) { throw new InternalServerErrorException("Cannot delete the external references"); } }
@RequestMapping(value = "/profile-picture", method = RequestMethod.GET) public void getProfilePicture(HttpServletResponse response) { try { Pair<String, InputStream> picture = profileService.getProfilePicture(); if (picture == null) { throw new NotFoundException(); } response.setContentType(picture.getLeft()); ServletOutputStream servletOutputStream = response.getOutputStream(); byte[] buffer = new byte[32384]; while (true) { int count = picture.getRight().read(buffer); if (count == -1) break; servletOutputStream.write(buffer, 0, count); } // Flush and close stream servletOutputStream.flush(); servletOutputStream.close(); } catch (Exception e) { throw new InternalServerErrorException("Could not get profile picture", e); } }
throw new InternalServerErrorException("Could not generate CMMN xml");
/** * POST /rest/admin/cmmn-deployments: upload a form deployment */ @RequestMapping(method = RequestMethod.POST, produces = "application/json") public JsonNode handleCmmnFileUpload(HttpServletRequest request, @RequestParam("file") MultipartFile file) { if (!file.isEmpty()) { try { ServerConfig serverConfig = retrieveServerConfig(EndpointType.CMMN); String fileName = file.getOriginalFilename(); if (fileName != null && (fileName.endsWith(".cmmn") || fileName.endsWith(".xml"))) { return clientService.uploadDeployment(serverConfig, fileName, file.getInputStream()); } else { LOGGER.error("Invalid cmmn deployment file name {}", fileName); throw new BadRequestException("Invalid file name"); } } catch (IOException e) { LOGGER.error("Error deploying form upload", e); throw new InternalServerErrorException("Could not deploy file: " + e.getMessage()); } } else { LOGGER.error("No cmmn deployment file found in request"); throw new BadRequestException("No file found in POST body"); } }
/** * POST /rest/admin/app-deployments: upload a form deployment */ @RequestMapping(method = RequestMethod.POST, produces = "application/json") public JsonNode handleAppFileUpload(HttpServletRequest request, @RequestParam("file") MultipartFile file) { if (!file.isEmpty()) { try { ServerConfig serverConfig = retrieveServerConfig(EndpointType.APP); String fileName = file.getOriginalFilename(); if (fileName != null && (fileName.endsWith(".app") ||fileName.endsWith(".zip") || fileName.endsWith(".bar"))) { return clientService.uploadDeployment(serverConfig, fileName, file.getInputStream()); } else { LOGGER.error("Invalid app deployment file name {}", fileName); throw new BadRequestException("Invalid file name"); } } catch (IOException e) { LOGGER.error("Error deploying app upload", e); throw new InternalServerErrorException("Could not deploy file: " + e.getMessage()); } } else { LOGGER.error("No app deployment file found in request"); throw new BadRequestException("No file found in POST body"); } }