use of org.camunda.bpm.engine.repository.Resource in project camunda-bpm-platform by camunda.
the class DeploymentResourcesResourceImpl method getDeploymentResources.
public List<DeploymentResourceDto> getDeploymentResources() {
List<Resource> resources = engine.getRepositoryService().getDeploymentResources(deploymentId);
List<DeploymentResourceDto> deploymentResources = new ArrayList<DeploymentResourceDto>();
for (Resource resource : resources) {
deploymentResources.add(DeploymentResourceDto.fromResources(resource));
}
if (!deploymentResources.isEmpty()) {
return deploymentResources;
} else {
throw new InvalidRequestException(Status.NOT_FOUND, "Deployment resources for deployment id '" + deploymentId + "' do not exist.");
}
}
use of org.camunda.bpm.engine.repository.Resource in project camunda-bpm-platform by camunda.
the class DeploymentAuthorizationTest method testGetResourceAsStreamByIdWithReadPermissionOnAnyDeployment.
public void testGetResourceAsStreamByIdWithReadPermissionOnAnyDeployment() {
// given
String deploymentId = createDeployment(null);
createGrantAuthorization(DEPLOYMENT, ANY, userId, READ);
disableAuthorization();
List<Resource> resources = repositoryService.getDeploymentResources(deploymentId);
enableAuthorization();
String resourceId = resources.get(0).getId();
// when
InputStream stream = repositoryService.getResourceAsStreamById(deploymentId, resourceId);
// then
assertNotNull(stream);
deleteDeployment(deploymentId);
}
use of org.camunda.bpm.engine.repository.Resource in project camunda-bpm-platform by camunda.
the class EmbeddedProcessApplicationTest method testDeployAppWithResources.
public void testDeployAppWithResources() {
registerProcessEngine();
TestApplicationWithResources processApplication = new TestApplicationWithResources();
processApplication.deploy();
Deployment deployment = repositoryService.createDeploymentQuery().singleResult();
assertNotNull(deployment);
List<Resource> deploymentResources = repositoryService.getDeploymentResources(deployment.getId());
assertEquals(4, deploymentResources.size());
processApplication.undeploy();
assertEquals(0, repositoryService.createDeploymentQuery().count());
}
use of org.camunda.bpm.engine.repository.Resource in project camunda-bpm-platform by camunda.
the class DeploymentAuthorizationTest method testGetResourceAsStreamByIdWithReadPermissionOnDeployment.
public void testGetResourceAsStreamByIdWithReadPermissionOnDeployment() {
// given
String deploymentId = createDeployment(null);
createGrantAuthorization(DEPLOYMENT, deploymentId, userId, READ);
disableAuthorization();
List<Resource> resources = repositoryService.getDeploymentResources(deploymentId);
enableAuthorization();
String resourceId = resources.get(0).getId();
// when
InputStream stream = repositoryService.getResourceAsStreamById(deploymentId, resourceId);
// then
assertNotNull(stream);
deleteDeployment(deploymentId);
}
use of org.camunda.bpm.engine.repository.Resource in project camunda-bpm-platform by camunda.
the class RedeploymentTest method testRedeployFormDifferentDeploymentsById.
public void testRedeployFormDifferentDeploymentsById() {
// given
ProcessDefinitionQuery query = repositoryService.createProcessDefinitionQuery();
BpmnModelInstance model1 = createProcessWithServiceTask(PROCESS_1_KEY);
// first deployment
Deployment deployment1 = repositoryService.createDeployment().name(DEPLOYMENT_NAME + "-1").addModelInstance(RESOURCE_1_NAME, model1).deploy();
assertEquals(1, repositoryService.getDeploymentResources(deployment1.getId()).size());
Resource resource1 = getResourceByName(deployment1.getId(), RESOURCE_1_NAME);
verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 1);
// second deployment
BpmnModelInstance model2 = createProcessWithReceiveTask(PROCESS_2_KEY);
Deployment deployment2 = repositoryService.createDeployment().name(DEPLOYMENT_NAME + "-2").addModelInstance(RESOURCE_2_NAME, model2).deploy();
assertEquals(1, repositoryService.getDeploymentResources(deployment2.getId()).size());
Resource resource2 = getResourceByName(deployment2.getId(), RESOURCE_2_NAME);
verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 1);
verifyQueryResults(query.processDefinitionKey(PROCESS_2_KEY), 1);
// when
Deployment deployment3 = repositoryService.createDeployment().name(DEPLOYMENT_NAME + "-3").addDeploymentResourceById(deployment1.getId(), resource1.getId()).addDeploymentResourceById(deployment2.getId(), resource2.getId()).deploy();
assertEquals(2, repositoryService.getDeploymentResources(deployment3.getId()).size());
verifyQueryResults(query.processDefinitionKey(PROCESS_1_KEY), 2);
verifyQueryResults(query.processDefinitionKey(PROCESS_2_KEY), 2);
deleteDeployments(deployment1, deployment2, deployment3);
}
Aggregations