Search in sources :

Example 1 with Resource

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.");
    }
}
Also used : Resource(org.camunda.bpm.engine.repository.Resource) DeploymentResourcesResource(org.camunda.bpm.engine.rest.sub.repository.DeploymentResourcesResource) ArrayList(java.util.ArrayList) InvalidRequestException(org.camunda.bpm.engine.rest.exception.InvalidRequestException) DeploymentResourceDto(org.camunda.bpm.engine.rest.dto.repository.DeploymentResourceDto)

Example 2 with Resource

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);
}
Also used : InputStream(java.io.InputStream) Resource(org.camunda.bpm.engine.repository.Resource)

Example 3 with Resource

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());
}
Also used : Resource(org.camunda.bpm.engine.repository.Resource) Deployment(org.camunda.bpm.engine.repository.Deployment) ProcessApplicationDeployment(org.camunda.bpm.engine.repository.ProcessApplicationDeployment)

Example 4 with Resource

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);
}
Also used : InputStream(java.io.InputStream) Resource(org.camunda.bpm.engine.repository.Resource)

Example 5 with Resource

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);
}
Also used : Resource(org.camunda.bpm.engine.repository.Resource) ProcessApplicationDeployment(org.camunda.bpm.engine.repository.ProcessApplicationDeployment) Deployment(org.camunda.bpm.engine.repository.Deployment) ProcessDefinitionQuery(org.camunda.bpm.engine.repository.ProcessDefinitionQuery) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance)

Aggregations

Resource (org.camunda.bpm.engine.repository.Resource)27 Deployment (org.camunda.bpm.engine.repository.Deployment)19 ProcessApplicationDeployment (org.camunda.bpm.engine.repository.ProcessApplicationDeployment)14 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)12 ProcessDefinitionQuery (org.camunda.bpm.engine.repository.ProcessDefinitionQuery)9 Test (org.junit.Test)9 InputStream (java.io.InputStream)6 ProcessApplicationRegistration (org.camunda.bpm.application.ProcessApplicationRegistration)3 EmbeddedProcessApplication (org.camunda.bpm.application.impl.EmbeddedProcessApplication)3 ArrayList (java.util.ArrayList)1 RepositoryService (org.camunda.bpm.engine.RepositoryService)1 ResourceEntity (org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity)1 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)1 DeploymentResourceDto (org.camunda.bpm.engine.rest.dto.repository.DeploymentResourceDto)1 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)1 DeploymentResourcesResource (org.camunda.bpm.engine.rest.sub.repository.DeploymentResourcesResource)1 Deployment (org.camunda.bpm.engine.test.Deployment)1 AbstractFoxPlatformIntegrationTest (org.camunda.bpm.integrationtest.util.AbstractFoxPlatformIntegrationTest)1