Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ private byte[] toByteArray(Object obj) throws IOException {
private Object toObject(byte[] bytes) throws IOException, ClassNotFoundException {
Object obj;
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
ObjectInputStream ois = new ObjectInputStream(bis);
ValidatingObjectInputStream ois = new ValidatingObjectInputStream(bis); {
ois.accept(LinkedList.class, LogMutation.class, HashMap.class, String.class);
obj = ois.readObject();
ois.close();
bis.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,22 @@ public Y9Result<String> deployModel(@RequestParam @NotBlank String modelId) {
public void exportModel(@RequestParam @NotBlank String modelId, HttpServletResponse response) {
try {
Model model = modelService.getModel(modelId);
if (model == null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND, "Model not found");
return;
}

byte[] bpmnBytes = modelService.getBpmnXML(model);

ByteArrayInputStream in = new ByteArrayInputStream(bpmnBytes);
String filename = model.getKey() + ".bpmn20.xml";
response.setHeader("Content-Disposition", "attachment; filename=" + filename);
IOUtils.copy(in, response.getOutputStream());
response.flushBuffer();
response.setCharacterEncoding("UTF-8");
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(filename, "UTF-8"));

try (ByteArrayInputStream in = new ByteArrayInputStream(bpmnBytes)) {
IOUtils.copy(in, response.getOutputStream());
response.flushBuffer();
}
} catch (Exception e) {
LOGGER.error("导出模型失败,modelId:{} 异常:{}", modelId, e.getMessage());
}
Expand Down