kimi42345
2020-03-17 6c6fdb4db59a2a2343e43ffd73a07f17b057c4fa
src/main/java/com/highdatas/mdm/service/act/impl/RepositoryServiceImpl.java
@@ -30,6 +30,7 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.ClassUtils;
@@ -52,7 +53,8 @@
   RepositoryService service;
   @Autowired
   ObjectMapper objectMapper;
   @Value("${img.url}")
   String basePath;
   //download
    public void getModelXml(HttpServletResponse response, String modelId) throws IOException {
      Model model = service.getModel(modelId);
@@ -443,12 +445,15 @@
         //1.3
        ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(hashMap.get("json_xml").getBytes("utf-8"));
          BpmnModel bpmnModel = new BpmnJsonConverter().convertToBpmnModel(modelNode);
        if (bpmnModel.getProcesses().size() == 0) {
           return false;
        }
          byte[] bpmnBytes = new BpmnXMLConverter().convertToXML(bpmnModel);
        String processName = newModel.getName()+ ".bpmn20.xml";
          Deployment deployment = service.createDeployment().name(newModel.getName()).addString(processName,new String(bpmnBytes,"UTF-8")).deploy();
          newModel.setDeploymentId(deployment.getId());
          newModel.setCategory(deployment.getId());
         service.saveModel(newModel);
         
         //1.4
@@ -464,8 +469,7 @@
        service.addModelEditorSourceExtra(newModel.getId(), result);
        String newModelId = newModel.getId();
        //TODO dir 2.
          String basePath = ClassUtils.getDefaultClassLoader().getResource("").getPath();
          String path =  basePath + "static/processes/" + newModelId;
          String path =  basePath  + newModelId;
        File dir = new File(path);
        if (!dir.exists()) {
           dir.mkdirs();
@@ -476,6 +480,7 @@
          if (file.exists()) {
         file.delete();
          }
          log.info(file.getAbsolutePath());
          file.createNewFile();
          fileOutputStream2 = new FileOutputStream(file);
          fileOutputStream2.write(bpmnBytes);