Java Code Examples for org.activiti.engine.repository.DeploymentBuilder#addZipInputStream()

The following examples show how to use org.activiti.engine.repository.DeploymentBuilder#addZipInputStream() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AddZipInputStreamTest.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
public static void main(String[] args) throws Exception {
	// 新建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
	// 存储服务
	RepositoryService repositoryService = engine.getRepositoryService();
	// 新建部署构造器
	DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
	// 新建文件输入流
	FileInputStream fileInputStream = new FileInputStream(new File("resources/datas.zip"));
	// 新建Zip输入流
	ZipInputStream zipInputStream = new ZipInputStream(fileInputStream);
	// 将Zip输入流添加到部署构造器中
	deploymentBuilder.addZipInputStream(zipInputStream);
	// 发布部署构造器
	deploymentBuilder.deploy();
	// 关闭流程引擎
	engine.close();
}
 
Example 2
Source File: SingleResourceAutoDeploymentStrategy.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
public void deployResources(final String deploymentNameHint, final Resource[] resources, final RepositoryService repositoryService) {

  // Create a separate deployment for each resource using the resource
  // name

  for (final Resource resource : resources) {

    final String resourceName = determineResourceName(resource);
    final DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering().name(resourceName);

    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();
  }
}
 
Example 3
Source File: DefaultAutoDeploymentStrategy.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Override
public void deployResources(final String deploymentNameHint, final Resource[] resources, final RepositoryService repositoryService) {

  // Create a single deployment for all resources using the name hint as
  // the
  // literal name
  final DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering().name(deploymentNameHint);

  for (final Resource resource : resources) {
    final String resourceName = determineResourceName(resource);

    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();

}
 
Example 4
Source File: AddZipInputStreamTest.java    From CrazyWorkflowHandoutsActiviti6 with MIT License 6 votes vote down vote up
public static void main(String[] args) throws Exception {
	// 新建流程引擎
	ProcessEngine engine = ProcessEngines.getDefaultProcessEngine();
	// 存储服务
	RepositoryService repositoryService = engine.getRepositoryService();
	// 新建部署构造器
	DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
	// 新建文件输入流
	FileInputStream fileInputStream = new FileInputStream(new File("resources/datas.zip"));
	// 新建Zip输入流
	ZipInputStream zipInputStream = new ZipInputStream(fileInputStream);
	// 将Zip输入流添加到部署构造器中
	deploymentBuilder.addZipInputStream(zipInputStream);
	// 发布部署构造器
	deploymentBuilder.deploy();
	// 关闭流程引擎
	engine.close();
}
 
Example 5
Source File: SingleResourceAutoDeploymentStrategy.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@Override
public void deployResources(final String deploymentNameHint, final Resource[] resources, final RepositoryService repositoryService) {

    // Create a separate deployment for each resource using the resource
    // name

    for (final Resource resource : resources) {

        final String resourceName = determineResourceName(resource);
        final DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering().name(resourceName);

        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();
    }
}
 
Example 6
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 部署流程资源
 */
@RequestMapping(value = "/deploy")
public String deploy(@RequestParam(value = "file", required = true) MultipartFile file) {

    // 获取上传的文件名
    String fileName = file.getOriginalFilename();

    try {
        // 得到输入流(字节流)对象
        InputStream fileInputStream = file.getInputStream();

        // 文件的扩展名
        String extension = FilenameUtils.getExtension(fileName);

        // zip或者bar类型的文件用ZipInputStream方式部署
        DeploymentBuilder deployment = repositoryService.createDeployment();
        if (extension.equals("zip") || extension.equals("bar")) {
            ZipInputStream zip = new ZipInputStream(fileInputStream);
            deployment.addZipInputStream(zip);
        } else {
            // 其他类型的文件直接部署
            deployment.addInputStream(fileName, fileInputStream);
        }
        deployment.deploy();
    } catch (Exception e) {
        logger.error("error on deploy process, because of file input stream");
    }

    return "redirect:process-list";
}
 
Example 7
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 部署流程资源
 */
@RequestMapping(value = "/deploy")
public String deploy(@RequestParam(value = "file", required = true) MultipartFile file) {

    // 获取上传的文件名
    String fileName = file.getOriginalFilename();

    try {
        // 得到输入流(字节流)对象
        InputStream fileInputStream = file.getInputStream();

        // 文件的扩展名
        String extension = FilenameUtils.getExtension(fileName);

        // zip或者bar类型的文件用ZipInputStream方式部署
        DeploymentBuilder deployment = repositoryService.createDeployment();
        if (extension.equals("zip") || extension.equals("bar")) {
            ZipInputStream zip = new ZipInputStream(fileInputStream);
            deployment.addZipInputStream(zip);
        } else {
            // 其他类型的文件直接部署
            deployment.addInputStream(fileName, fileInputStream);
        }
        deployment.deploy();
    } catch (Exception e) {
        logger.error("error on deploy process, because of file input stream");
    }

    return "redirect:process-list";
}
 
Example 8
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 部署流程资源
 */
@RequestMapping(value = "/deploy")
public String deploy(@RequestParam(value = "file", required = true) MultipartFile file) {

    // 获取上传的文件名
    String fileName = file.getOriginalFilename();

    try {
        // 得到输入流(字节流)对象
        InputStream fileInputStream = file.getInputStream();

        // 文件的扩展名
        String extension = FilenameUtils.getExtension(fileName);

        // zip或者bar类型的文件用ZipInputStream方式部署
        DeploymentBuilder deployment = repositoryService.createDeployment();
        if (extension.equals("zip") || extension.equals("bar")) {
            ZipInputStream zip = new ZipInputStream(fileInputStream);
            deployment.addZipInputStream(zip);
        } else {
            // 其他类型的文件直接部署
            deployment.addInputStream(fileName, fileInputStream);
        }
        deployment.deploy();
    } catch (Exception e) {
        logger.error("error on deploy process, because of file input stream");
    }

    return "redirect:process-list";
}
 
Example 9
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 部署流程资源
 */
@RequestMapping(value = "/deploy")
public String deploy(@RequestParam(value = "file", required = true) MultipartFile file) {

    // 获取上传的文件名
    String fileName = file.getOriginalFilename();

    try {
        // 得到输入流(字节流)对象
        InputStream fileInputStream = file.getInputStream();

        // 文件的扩展名
        String extension = FilenameUtils.getExtension(fileName);

        // zip或者bar类型的文件用ZipInputStream方式部署
        DeploymentBuilder deployment = repositoryService.createDeployment();
        if (extension.equals("zip") || extension.equals("bar")) {
            ZipInputStream zip = new ZipInputStream(fileInputStream);
            deployment.addZipInputStream(zip);
        } else {
            // 其他类型的文件直接部署
            deployment.addInputStream(fileName, fileInputStream);
        }
        deployment.deploy();
    } catch (Exception e) {
        logger.error("error on deploy process, because of file input stream");
    }

    return "redirect:process-list";
}
 
Example 10
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 部署流程资源
 */
@RequestMapping(value = "/deploy")
public String deploy(@RequestParam(value = "file", required = true) MultipartFile file) {

    // 获取上传的文件名
    String fileName = file.getOriginalFilename();

    try {
        // 得到输入流(字节流)对象
        InputStream fileInputStream = file.getInputStream();

        // 文件的扩展名
        String extension = FilenameUtils.getExtension(fileName);

        // zip或者bar类型的文件用ZipInputStream方式部署
        DeploymentBuilder deployment = repositoryService.createDeployment();
        if (extension.equals("zip") || extension.equals("bar")) {
            ZipInputStream zip = new ZipInputStream(fileInputStream);
            deployment.addZipInputStream(zip);
        } else {
            // 其他类型的文件直接部署
            deployment.addInputStream(fileName, fileInputStream);
        }
        deployment.deploy();
    } catch (Exception e) {
        logger.error("error on deploy process, because of file input stream");
    }

    return "redirect:process-list";
}
 
Example 11
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 部署流程资源
 */
@RequestMapping(value = "/deploy")
public String deploy(@RequestParam(value = "file", required = true) MultipartFile file) {

    // 获取上传的文件名
    String fileName = file.getOriginalFilename();

    try {
        // 得到输入流(字节流)对象
        InputStream fileInputStream = file.getInputStream();

        // 文件的扩展名
        String extension = FilenameUtils.getExtension(fileName);

        // zip或者bar类型的文件用ZipInputStream方式部署
        DeploymentBuilder deployment = repositoryService.createDeployment();
        if (extension.equals("zip") || extension.equals("bar")) {
            ZipInputStream zip = new ZipInputStream(fileInputStream);
            deployment.addZipInputStream(zip);
        } else {
            // 其他类型的文件直接部署
            deployment.addInputStream(fileName, fileInputStream);
        }
        deployment.deploy();
    } catch (Exception e) {
        logger.error("error on deploy process, because of file input stream");
    }

    return "redirect:processes";
}
 
Example 12
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 部署流程资源
 */
@RequestMapping(value = "/deploy")
public String deploy(@RequestParam(value = "file", required = true) MultipartFile file) {

    // 获取上传的文件名
    String fileName = file.getOriginalFilename();

    try {
        // 得到输入流(字节流)对象
        InputStream fileInputStream = file.getInputStream();

        // 文件的扩展名
        String extension = FilenameUtils.getExtension(fileName);

        // zip或者bar类型的文件用ZipInputStream方式部署
        DeploymentBuilder deployment = repositoryService.createDeployment();
        if (extension.equals("zip") || extension.equals("bar")) {
            ZipInputStream zip = new ZipInputStream(fileInputStream);
            deployment.addZipInputStream(zip);
        } else {
            // 其他类型的文件直接部署
            deployment.addInputStream(fileName, fileInputStream);
        }
        deployment.deploy();
    } catch (Exception e) {
        logger.error("error on deploy process, because of file input stream");
    }

    return "redirect:process-list";
}
 
Example 13
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 部署流程资源
 */
@RequestMapping(value = "/deploy")
public String deploy(@RequestParam(value = "file", required = true) MultipartFile file) {

    // 获取上传的文件名
    String fileName = file.getOriginalFilename();

    try {
        // 得到输入流(字节流)对象
        InputStream fileInputStream = file.getInputStream();

        // 文件的扩展名
        String extension = FilenameUtils.getExtension(fileName);

        // zip或者bar类型的文件用ZipInputStream方式部署
        DeploymentBuilder deployment = repositoryService.createDeployment();
        if (extension.equals("zip") || extension.equals("bar")) {
            ZipInputStream zip = new ZipInputStream(fileInputStream);
            deployment.addZipInputStream(zip);
        } else {
            // 其他类型的文件直接部署
            deployment.addInputStream(fileName, fileInputStream);
        }
        deployment.deploy();
    } catch (Exception e) {
        logger.error("error on deploy process, because of file input stream");
    }

    return "redirect:process-list";
}
 
Example 14
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 部署流程资源
 */
@RequestMapping(value = "/deploy")
public String deploy(@RequestParam(value = "file", required = true) MultipartFile file) {

    // 获取上传的文件名
    String fileName = file.getOriginalFilename();

    try {
        // 得到输入流(字节流)对象
        InputStream fileInputStream = file.getInputStream();

        // 文件的扩展名
        String extension = FilenameUtils.getExtension(fileName);

        // zip或者bar类型的文件用ZipInputStream方式部署
        DeploymentBuilder deployment = repositoryService.createDeployment();
        if (extension.equals("zip") || extension.equals("bar")) {
            ZipInputStream zip = new ZipInputStream(fileInputStream);
            deployment.addZipInputStream(zip);
        } else {
            // 其他类型的文件直接部署
            deployment.addInputStream(fileName, fileInputStream);
        }
        deployment.deploy();
    } catch (Exception e) {
        logger.error("error on deploy process, because of file input stream");
    }

    return "redirect:process-list";
}
 
Example 15
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 部署流程资源
 */
@RequestMapping(value = "/deploy")
public String deploy(@RequestParam(value = "file", required = true) MultipartFile file) {

    // 获取上传的文件名
    String fileName = file.getOriginalFilename();

    try {
        // 得到输入流(字节流)对象
        InputStream fileInputStream = file.getInputStream();

        // 文件的扩展名
        String extension = FilenameUtils.getExtension(fileName);

        // zip或者bar类型的文件用ZipInputStream方式部署
        DeploymentBuilder deployment = repositoryService.createDeployment();
        if (extension.equals("zip") || extension.equals("bar")) {
            ZipInputStream zip = new ZipInputStream(fileInputStream);
            deployment.addZipInputStream(zip);
        } else {
            // 其他类型的文件直接部署
            deployment.addInputStream(fileName, fileInputStream);
        }
        deployment.deploy();
    } catch (Exception e) {
        logger.error("error on deploy process, because of file input stream");
    }

    return "redirect:process-list";
}
 
Example 16
Source File: ResourceParentFolderAutoDeploymentStrategy.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void deployResources(final String deploymentNameHint, final Resource[] resources, final RepositoryService repositoryService) {

    // Create a deployment for each distinct parent folder using the name
    // hint
    // as a prefix
    final Map<String, Set<Resource>> resourcesMap = createMap(resources);

    for (final Entry<String, Set<Resource>> group : resourcesMap.entrySet()) {

        final String deploymentName = determineDeploymentName(deploymentNameHint, group.getKey());

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

        for (final Resource resource : group.getValue()) {
            final String resourceName = determineResourceName(resource);

            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();
    }

}
 
Example 17
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 部署流程资源
 */
@RequestMapping(value = "/deploy")
public String deploy(@RequestParam(value = "file", required = true) MultipartFile file) {

    // 获取上传的文件名
    String fileName = file.getOriginalFilename();

    try {
        // 得到输入流(字节流)对象
        InputStream fileInputStream = file.getInputStream();

        // 文件的扩展名
        String extension = FilenameUtils.getExtension(fileName);

        // zip或者bar类型的文件用ZipInputStream方式部署
        DeploymentBuilder deployment = repositoryService.createDeployment();
        if (extension.equals("zip") || extension.equals("bar")) {
            ZipInputStream zip = new ZipInputStream(fileInputStream);
            deployment.addZipInputStream(zip);
        } else {
            // 其他类型的文件直接部署
            deployment.addInputStream(fileName, fileInputStream);
        }
        deployment.deploy();
    } catch (Exception e) {
        logger.error("error on deploy process, because of file input stream");
    }

    return "redirect:process-list";
}
 
Example 18
Source File: FlowableDeploymentController.java    From hsweb-framework with Apache License 2.0 5 votes vote down vote up
/**
 * 部署流程资源
 * 加载ZIP文件中的流程
 */
@PostMapping(value = "/deploy")
@ApiOperation("上传流程定义文件并部署流程")
@Authorize(action = "deploy")
public ResponseMessage<Deployment> deploy(@RequestPart(value = "file") MultipartFile file) throws IOException {
    // 获取上传的文件名
    String fileName = file.getOriginalFilename();

    // 得到输入流(字节流)对象
    InputStream fileInputStream = file.getInputStream();

    // 文件的扩展名
    String extension = FilenameUtils.getExtension(fileName);

    // zip或者bar类型的文件用ZipInputStream方式部署
    DeploymentBuilder deployment = repositoryService.createDeployment();
    if ("zip".equals(extension) || "bar".equals(extension)) {
        ZipInputStream zip = new ZipInputStream(fileInputStream);
        deployment.addZipInputStream(zip);
    } else {
        // 其他类型的文件直接部署
        deployment.addInputStream(fileName, fileInputStream);
    }
    Deployment result = deployment.deploy();

    return ResponseMessage.ok(result);
}
 
Example 19
Source File: DeploymentController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 部署流程资源
 */
@RequestMapping(value = "/deploy")
public String deploy(@RequestParam(value = "file", required = true) MultipartFile file) {

    // 获取上传的文件名
    String fileName = file.getOriginalFilename();

    try {
        // 得到输入流(字节流)对象
        InputStream fileInputStream = file.getInputStream();

        // 文件的扩展名
        String extension = FilenameUtils.getExtension(fileName);

        // zip或者bar类型的文件用ZipInputStream方式部署
        DeploymentBuilder deployment = repositoryService.createDeployment();
        if (extension.equals("zip") || extension.equals("bar")) {
            ZipInputStream zip = new ZipInputStream(fileInputStream);
            deployment.addZipInputStream(zip);
        } else {
            // 其他类型的文件直接部署
            deployment.addInputStream(fileName, fileInputStream);
        }
        deployment.deploy();
    } catch (Exception e) {
        logger.error("error on deploy process, because of file input stream");
    }

    return "redirect:process-list";
}
 
Example 20
Source File: ResourceParentFolderAutoDeploymentStrategy.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public void deployResources(final String deploymentNameHint, final Resource[] resources, final RepositoryService repositoryService) {

  // Create a deployment for each distinct parent folder using the name
  // hint
  // as a prefix
  final Map<String, Set<Resource>> resourcesMap = createMap(resources);

  for (final Entry<String, Set<Resource>> group : resourcesMap.entrySet()) {

    final String deploymentName = determineDeploymentName(deploymentNameHint, group.getKey());

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

    for (final Resource resource : group.getValue()) {
      final String resourceName = determineResourceName(resource);

      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();
  }

}