Search in sources :

Example 46 with Deployment

use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.

the class CallActivityTest method testInstantiateSuspendedChildProcess.

public void testInstantiateSuspendedChildProcess() throws Exception {
    BpmnModel childBpmnModel = loadBPMNModel(CHILD_PROCESS_RESOURCE);
    Deployment childDeployment = processEngine.getRepositoryService().createDeployment().name("childProcessDeployment").addBpmnModel("childProcess.bpmn20.xml", childBpmnModel).deploy();
    suspendProcessDefinitions(childDeployment);
    try {
        ProcessInstance childProcessInstance = runtimeService.startProcessInstanceByKey("childProcess");
        fail("Exception expected");
    } catch (ActivitiException ae) {
        assertTextPresent("Cannot start process instance. Process definition Child Process", ae.getMessage());
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) Deployment(org.activiti.engine.repository.Deployment) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 47 with Deployment

use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.

the class CallActivityTest method testInstantiateProcessByMessage.

public void testInstantiateProcessByMessage() throws Exception {
    BpmnModel messageTriggeredBpmnModel = loadBPMNModel(MESSAGE_TRIGGERED_PROCESS_RESOURCE);
    Deployment messageTriggeredBpmnDeployment = processEngine.getRepositoryService().createDeployment().name("messageTriggeredProcessDeployment").addBpmnModel("messageTriggered.bpmn20.xml", messageTriggeredBpmnModel).deploy();
    ProcessInstance childProcessInstance = runtimeService.startProcessInstanceByMessage("TRIGGER_PROCESS_MESSAGE");
    assertNotNull(childProcessInstance);
}
Also used : Deployment(org.activiti.engine.repository.Deployment) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 48 with Deployment

use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.

the class CallActivityTest method testInstantiateSuspendedProcessByMessage.

public void testInstantiateSuspendedProcessByMessage() throws Exception {
    BpmnModel messageTriggeredBpmnModel = loadBPMNModel(MESSAGE_TRIGGERED_PROCESS_RESOURCE);
    Deployment messageTriggeredBpmnDeployment = processEngine.getRepositoryService().createDeployment().name("messageTriggeredProcessDeployment").addBpmnModel("messageTriggered.bpmn20.xml", messageTriggeredBpmnModel).deploy();
    suspendProcessDefinitions(messageTriggeredBpmnDeployment);
    try {
        ProcessInstance childProcessInstance = runtimeService.startProcessInstanceByMessage("TRIGGER_PROCESS_MESSAGE");
        fail("Exception expected");
    } catch (ActivitiException ae) {
        assertTextPresent("Cannot start process instance. Process definition Message Triggered Process", ae.getMessage());
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) Deployment(org.activiti.engine.repository.Deployment) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) BpmnModel(org.activiti.bpmn.model.BpmnModel)

Example 49 with Deployment

use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.

the class DeploymentResourceCollectionResource method getDeploymentResources.

@RequestMapping(value = "/repository/deployments/{deploymentId}/resources", method = RequestMethod.GET, produces = "application/json")
public List<DeploymentResourceResponse> getDeploymentResources(@PathVariable String deploymentId, HttpServletRequest request) {
    // Check if deployment exists
    Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
    if (deployment == null) {
        throw new ActivitiObjectNotFoundException("Could not find a deployment with id '" + deploymentId + "'.", Deployment.class);
    }
    List<String> resourceList = repositoryService.getDeploymentResourceNames(deploymentId);
    return restResponseFactory.createDeploymentResourceResponseList(deploymentId, resourceList, contentTypeResolver);
}
Also used : Deployment(org.activiti.engine.repository.Deployment) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 50 with Deployment

use of org.activiti.engine.repository.Deployment in project Activiti by Activiti.

the class DeploymentResourceResource method getDeploymentResource.

@RequestMapping(value = "/repository/deployments/{deploymentId}/resources/**", method = RequestMethod.GET, produces = "application/json")
public DeploymentResourceResponse getDeploymentResource(@PathVariable("deploymentId") String deploymentId, HttpServletRequest request) {
    // Check if deployment exists
    Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
    if (deployment == null) {
        throw new ActivitiObjectNotFoundException("Could not find a deployment with id '" + deploymentId + "'.");
    }
    String pathInfo = request.getPathInfo();
    String resourceName = pathInfo.replace("/repository/deployments/" + deploymentId + "/resources/", "");
    List<String> resourceList = repositoryService.getDeploymentResourceNames(deploymentId);
    if (resourceList.contains(resourceName)) {
        // Build resource representation
        DeploymentResourceResponse response = restResponseFactory.createDeploymentResourceResponse(deploymentId, resourceName, contentTypeResolver.resolveContentType(resourceName));
        return response;
    } else {
        // Resource not found in deployment
        throw new ActivitiObjectNotFoundException("Could not find a resource with id '" + resourceName + "' in deployment '" + deploymentId + "'.");
    }
}
Also used : Deployment(org.activiti.engine.repository.Deployment) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Deployment (org.activiti.engine.repository.Deployment)66 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)12 BpmnModel (org.activiti.bpmn.model.BpmnModel)10 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 ByteArrayInputStream (java.io.ByteArrayInputStream)8 ActivitiException (org.activiti.engine.ActivitiException)7 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)6 HttpGet (org.apache.http.client.methods.HttpGet)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 InputStream (java.io.InputStream)3 HashSet (java.util.HashSet)3 BpmnXMLConverter (org.activiti.bpmn.converter.BpmnXMLConverter)3 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)3 ProcessEngine (org.activiti.engine.ProcessEngine)3 RuntimeService (org.activiti.engine.RuntimeService)3 DeploymentBuilder (org.activiti.engine.repository.DeploymentBuilder)3 Task (org.activiti.engine.task.Task)3