/**
   * * 文件上传功能,该功能需要在bean配置中添加multipartResolver,并引入commons-fileupload包 否则会出现下面的错误
   * org.springframework.web.util.NestedServletException: Request processing failed; nested
   * exception is java.lang.IllegalArgumentException: Expected MultipartHttpServletRequest: is a
   * MultipartResolver configured?
   *
   * @param file
   * @return
   */
  @RequestMapping(value = "/deploy")
  public String deploy(@RequestParam(value = "file") MultipartFile file) {
    String filenName = file.getOriginalFilename();
    try {
      InputStream fileInputStream = file.getInputStream();

      String extension = FilenameUtils.getExtension(filenName);
      DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
      if (extension.equals("zip") || extension.equals("bar")) {
        ZipInputStream zip = new ZipInputStream(fileInputStream);
        deploymentBuilder.addZipInputStream(zip);
      } else {
        deploymentBuilder.addInputStream(filenName, fileInputStream);
      }
      deploymentBuilder.deploy();
    } catch (Exception ex) {
      log.error("error on deploy process,because of file input stream");
    }
    return "redirect:/workflow/process-list";
  }
  protected void autoDeployResources(ProcessEngine processEngine) {
    if (deploymentResources != null && deploymentResources.length > 0) {
      RepositoryService repositoryService = processEngine.getRepositoryService();

      DeploymentBuilder deploymentBuilder =
          repositoryService.createDeployment().enableDuplicateFiltering().name(deploymentName);

      for (Resource resource : deploymentResources) {
        String resourceName = null;

        if (resource instanceof ContextResource) {
          resourceName = ((ContextResource) resource).getPathWithinContext();

        } else if (resource instanceof ByteArrayResource) {
          resourceName = resource.getDescription();

        } else {
          try {
            resourceName = resource.getFile().getAbsolutePath();
          } catch (IOException e) {
            resourceName = resource.getFilename();
          }
        }

        try {
          if (resourceName.endsWith(".bar")
              || resourceName.endsWith(".zip")
              || resourceName.endsWith(".jar")) {
            deploymentBuilder.addZipInputStream(new ZipInputStream(resource.getInputStream()));
          } else {
            deploymentBuilder.addInputStream(resourceName, resource.getInputStream());
          }
        } catch (IOException e) {
          throw new ActivitiException(
              "couldn't auto deploy resource '" + resource + "': " + e.getMessage(), e);
        }
      }

      deploymentBuilder.deploy();
    }
  }