Get subfile of deployment

Hi there,

in the new modeler (4.11.1) i have seen that you can upload your bpmn with additional files:

And now i try to get the content of the subfile of my deployment:

What i currently have is:

// get the name of current process definition
String processName = execution.getProcessEngineServices()
                .getRepositoryService()
                .getProcessDefinition(execution.getProcessDefinitionId())
                .getKey();

// get the last deployment with the name of the process definition
List<Deployment> lastdeployment = execution.getProcessEngineServices()
                .getRepositoryService().createDeploymentQuery().deploymentName(processName)
                .orderByDeploymentTime().desc().listPage(0,1);

Anyone who knows how to get the content of the subfile?

Did you solve this problem?

No, not yet!

Still hope someone could help me :grin:

Hi @Jako and @richard_flip,

a deployment contains resources. Here you can access the file content.

String deploymentId = repositoryService().createDeploymentQuery().singleResult().getId();
List<Resource> deploymentResources = repositoryService().getDeploymentResources(deploymentId);
deploymentResources.get(0).getBytes();

It’s very generic approach, you have to handle the content as bytes in your application.

Hope this helps, Ingo

1 Like

Thx @Ingo_Richtsmeier, i’ll try that and give feedback…

Thanks a lot @Ingo_Richtsmeier for your hint, here my solution:

        // get the name of current process
        String processName = execution.getProcessEngineServices()
                .getRepositoryService()
                .getProcessDefinition(execution.getProcessDefinitionId())
                .getKey();

        // search for the last deployment
        List<Deployment> lastDeployment = execution.getProcessEngineServices()
                .getRepositoryService().createDeploymentQuery().deploymentName(processName)
                .orderByDeploymentTime()
                .desc()
                .listPage(0,1);

        // get the Id
        String lastDeploymentId = lastDeployment.get(0).getId();

        // get all resources of the deployment
        List<Resource> deploymentResources = execution.getProcessEngineServices()
                .getRepositoryService()
                .getDeploymentResources(lastDeploymentId);

        // convert the test_config.json resource into a SpinJsonNode object
        for (Resource file: deploymentResources) {
            if(file.getName().equals("test_config.json")){
                byte[] configFile = file.getBytes();
                String decodedJsonString = new String(configFile, "UTF-8");
                SpinJsonNode resultJson = JSON(decodedJsonString);
                System.out.println(resultJson);
            }
        }

It is important to select a software development service that understands the data input and output of their projects https://mlsdev.com/services/dedicated-development-team. In addition, a software development service should be able to meet the needs of its clients. A well-developed product will meet the needs of its customers. A good software development service will understand the data input and output of the project and fit them within the company’s objectives. Moreover, a custom-built application will solve a problem and be compatible with other tasks in the company.