protected void exportXmlFromModelId(HttpServletResponse response, String modelId) throws Exception{
Model modelData = repositoryService.getModel(modelId);
BpmnJsonConverter jsonConverter = new BpmnJsonConverter();
ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
BpmnModel bpmnModel = jsonConverter.convertToBpmnModel(modelNode);
BpmnXMLConverter xmlConverter = new BpmnXMLConverter();
byte[] bpmnBytes = xmlConverter.convertToXML(bpmnModel);
ByteArrayInputStream in = new ByteArrayInputStream(bpmnBytes);
String filename = bpmnModel.getMainProcess().getId() + ".bpmn20.xml";
FileUpload.copyFile(in,PathUtil.getProjectpath()+Const.FILEACTIVITI,filename);
FileDownload.fileDownload(response, PathUtil.getProjectpath()+Const.FILEACTIVITI+filename, filename);
in.close();
}
protected String viewXmlFromModelId(String modelId) throws Exception{
Model modelData = repositoryService.getModel(modelId);
BpmnJsonConverter jsonConverter = new BpmnJsonConverter();
ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
BpmnModel bpmnModel = jsonConverter.convertToBpmnModel(modelNode);
BpmnXMLConverter xmlConverter = new BpmnXMLConverter();
byte[] bpmnBytes = xmlConverter.convertToXML(bpmnModel);
ByteArrayInputStream in = new ByteArrayInputStream(bpmnBytes);
InputStreamReader isr = new InputStreamReader(in,"utf-8");
BufferedReader bufferedReader = new BufferedReader(isr);
StringBuffer xmlContent = new StringBuffer();
String lineTxt = null;
while ((lineTxt = bufferedReader.readLine()) != null) {
xmlContent.append(lineTxt);
xmlContent.append("\n");
}
isr.close();
return xmlContent.toString();
}
本作品採用《CC 協議》,轉載必須註明作者和本文連結