Search in sources :

Example 66 with ProcessDefinition

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

the class StartAuthorizationTest method testAddAndRemoveIdentityLinks.

@Deployment
public void testAddAndRemoveIdentityLinks() throws Exception {
    setUpUsersAndGroups();
    try {
        ProcessDefinition latestProcessDef = repositoryService.createProcessDefinitionQuery().processDefinitionKey("potentialStarterNoDefinition").singleResult();
        assertNotNull(latestProcessDef);
        List<IdentityLink> links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
        assertEquals(0, links.size());
        repositoryService.addCandidateStarterGroup(latestProcessDef.getId(), "group1");
        links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
        assertEquals(1, links.size());
        assertEquals("group1", links.get(0).getGroupId());
        repositoryService.addCandidateStarterUser(latestProcessDef.getId(), "user1");
        links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
        assertEquals(2, links.size());
        assertEquals(true, containsUserOrGroup(null, "group1", links));
        assertEquals(true, containsUserOrGroup("user1", null, links));
        repositoryService.deleteCandidateStarterGroup(latestProcessDef.getId(), "nonexisting");
        links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
        assertEquals(2, links.size());
        repositoryService.deleteCandidateStarterGroup(latestProcessDef.getId(), "group1");
        links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
        assertEquals(1, links.size());
        assertEquals("user1", links.get(0).getUserId());
        repositoryService.deleteCandidateStarterUser(latestProcessDef.getId(), "user1");
        links = repositoryService.getIdentityLinksForProcessDefinition(latestProcessDef.getId());
        assertEquals(0, links.size());
    } finally {
        tearDownUsersAndGroups();
    }
}
Also used : ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) IdentityLink(org.activiti.engine.task.IdentityLink) Deployment(org.activiti.engine.test.Deployment)

Example 67 with ProcessDefinition

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

the class ProcessValidationExecutedAfterDeployTest method testGetStartFormData.

public void testGetStartFormData() {
    disableValidation();
    repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/regression/ProcessValidationExecutedAfterDeployTest.bpmn20.xml").deploy();
    enableValidation();
    clearDeploymentCache();
    ProcessDefinition definition = getLatestProcessDefinitionVersionByKey("testProcess1");
    if (definition == null) {
        fail("Error occurred in fetching process model.");
    }
    try {
        formService.getStartFormData(definition.getId());
        assertTrue(true);
    } catch (ActivitiException e) {
        fail("Error occurred in fetching start form data:");
    }
    for (org.activiti.engine.repository.Deployment deployment : repositoryService.createDeploymentQuery().list()) {
        repositoryService.deleteDeployment(deployment.getId());
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition)

Example 68 with ProcessDefinition

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

the class StartAuthorizationTest method testPotentialStarter.

@Deployment
public void testPotentialStarter() throws Exception {
    // first check an unauthorized user. An exception is expected
    setUpUsersAndGroups();
    try {
        // Authentication should not be done. So an unidentified user should also be able to start the process
        identityService.setAuthenticatedUserId("unauthorizedUser");
        try {
            runtimeService.startProcessInstanceByKey("potentialStarter");
        } catch (Exception e) {
            fail("No StartAuthorizationException expected, " + e.getClass().getName() + " caught.");
        }
        // check with an authorized user obviously it should be no problem starting the process
        identityService.setAuthenticatedUserId("user1");
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("potentialStarter");
        assertProcessEnded(processInstance.getId());
        assertTrue(processInstance.isEnded());
        //check extensionElements with : <formalExpression>group2, group(group3), user(user3)</formalExpression>
        ProcessDefinition potentialStarter = repositoryService.createProcessDefinitionQuery().processDefinitionKey("potentialStarter").startableByUser("user1").latestVersion().singleResult();
        assertNotNull(potentialStarter);
        potentialStarter = repositoryService.createProcessDefinitionQuery().processDefinitionKey("potentialStarter").startableByUser("user3").latestVersion().singleResult();
        assertNotNull(potentialStarter);
        potentialStarter = repositoryService.createProcessDefinitionQuery().processDefinitionKey("potentialStarter").startableByUser("userInGroup2").latestVersion().singleResult();
        assertNotNull(potentialStarter);
        potentialStarter = repositoryService.createProcessDefinitionQuery().processDefinitionKey("potentialStarter").startableByUser("userInGroup3").latestVersion().singleResult();
        assertNotNull(potentialStarter);
    } finally {
        tearDownUsersAndGroups();
    }
}
Also used : ProcessInstance(org.activiti.engine.runtime.ProcessInstance) ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) Deployment(org.activiti.engine.test.Deployment)

Example 69 with ProcessDefinition

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

the class ProcessDefinitionIdentityLinkResource method deleteIdentityLink.

@RequestMapping(value = "/repository/process-definitions/{processDefinitionId}/identitylinks/{family}/{identityId}", method = RequestMethod.DELETE)
public void deleteIdentityLink(@PathVariable("processDefinitionId") String processDefinitionId, @PathVariable("family") String family, @PathVariable("identityId") String identityId, HttpServletResponse response) {
    ProcessDefinition processDefinition = getProcessDefinitionFromRequest(processDefinitionId);
    validateIdentityLinkArguments(family, identityId);
    // Check if identitylink to delete exists
    IdentityLink link = getIdentityLink(family, identityId, processDefinition.getId());
    if (link.getUserId() != null) {
        repositoryService.deleteCandidateStarterUser(processDefinition.getId(), link.getUserId());
    } else {
        repositoryService.deleteCandidateStarterGroup(processDefinition.getId(), link.getGroupId());
    }
    response.setStatus(HttpStatus.NO_CONTENT.value());
}
Also used : ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) IdentityLink(org.activiti.engine.task.IdentityLink) RestIdentityLink(org.activiti.rest.service.api.engine.RestIdentityLink) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 70 with ProcessDefinition

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

the class ProcessDefinitionIdentityLinkResource method getIdentityLink.

@RequestMapping(value = "/repository/process-definitions/{processDefinitionId}/identitylinks/{family}/{identityId}", method = RequestMethod.GET, produces = "application/json")
public RestIdentityLink getIdentityLink(@PathVariable("processDefinitionId") String processDefinitionId, @PathVariable("family") String family, @PathVariable("identityId") String identityId, HttpServletRequest request) {
    ProcessDefinition processDefinition = getProcessDefinitionFromRequest(processDefinitionId);
    validateIdentityLinkArguments(family, identityId);
    // Check if identitylink to get exists
    IdentityLink link = getIdentityLink(family, identityId, processDefinition.getId());
    return restResponseFactory.createRestIdentityLink(link);
}
Also used : ProcessDefinition(org.activiti.engine.repository.ProcessDefinition) IdentityLink(org.activiti.engine.task.IdentityLink) RestIdentityLink(org.activiti.rest.service.api.engine.RestIdentityLink) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)211 Deployment (org.activiti.engine.test.Deployment)82 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)42 ArrayList (java.util.ArrayList)29 ActivitiException (org.activiti.engine.ActivitiException)25 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)23 RepositoryService (org.activiti.engine.RepositoryService)20 ProcessDefinitionQuery (org.activiti.engine.repository.ProcessDefinitionQuery)19 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)19 Task (org.activiti.engine.task.Task)16 Date (java.util.Date)14 Test (org.junit.Test)14 JsonNode (com.fasterxml.jackson.databind.JsonNode)12 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)12 HashMap (java.util.HashMap)12 ProcessDefinitionEntity (org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity)11 JobDefinitionEntity (org.finra.herd.model.jpa.JobDefinitionEntity)11 InputStream (java.io.InputStream)10 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)10 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)9