Search in sources :

Example 6 with IdentityLink

use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.

the class GetIdentityLinksForProcessDefinitionCmd method execute.

@SuppressWarnings({ "unchecked", "rawtypes" })
public List<IdentityLink> execute(CommandContext commandContext) {
    ProcessDefinitionEntity processDefinition = Context.getCommandContext().getProcessDefinitionManager().findLatestProcessDefinitionById(processDefinitionId);
    ensureNotNull("Cannot find process definition with id " + processDefinitionId, "processDefinition", processDefinition);
    List<IdentityLink> identityLinks = (List) processDefinition.getIdentityLinks();
    return identityLinks;
}
Also used : List(java.util.List) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity) IdentityLink(org.camunda.bpm.engine.task.IdentityLink)

Example 7 with IdentityLink

use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.

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.camunda.bpm.engine.repository.ProcessDefinition) IdentityLink(org.camunda.bpm.engine.task.IdentityLink) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 8 with IdentityLink

use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.

the class TaskAuthorizationTest method testProcessTaskAddCandidateUserWithUpdatePersmissionOnTask.

public void testProcessTaskAddCandidateUserWithUpdatePersmissionOnTask() {
    // given
    startProcessInstanceByKey(PROCESS_KEY);
    String taskId = selectSingleTask().getId();
    createGrantAuthorization(TASK, taskId, userId, UPDATE);
    // when
    taskService.addCandidateUser(taskId, "demo");
    // then
    disableAuthorization();
    List<IdentityLink> linksForTask = taskService.getIdentityLinksForTask(taskId);
    enableAuthorization();
    assertNotNull(linksForTask);
    assertEquals(1, linksForTask.size());
    IdentityLink identityLink = linksForTask.get(0);
    assertNotNull(identityLink);
    assertEquals("demo", identityLink.getUserId());
    assertEquals(IdentityLinkType.CANDIDATE, identityLink.getType());
}
Also used : IdentityLink(org.camunda.bpm.engine.task.IdentityLink)

Example 9 with IdentityLink

use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.

the class TaskAuthorizationTest method testProcessTaskAddCandidateGroup.

public void testProcessTaskAddCandidateGroup() {
    // given
    startProcessInstanceByKey(PROCESS_KEY);
    String taskId = selectSingleTask().getId();
    createGrantAuthorization(TASK, taskId, userId, UPDATE);
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, UPDATE_TASK);
    // when
    taskService.addCandidateGroup(taskId, "accounting");
    // then
    disableAuthorization();
    List<IdentityLink> linksForTask = taskService.getIdentityLinksForTask(taskId);
    enableAuthorization();
    assertNotNull(linksForTask);
    assertEquals(1, linksForTask.size());
    IdentityLink identityLink = linksForTask.get(0);
    assertNotNull(identityLink);
    assertEquals("accounting", identityLink.getGroupId());
    assertEquals(IdentityLinkType.CANDIDATE, identityLink.getType());
}
Also used : IdentityLink(org.camunda.bpm.engine.task.IdentityLink)

Example 10 with IdentityLink

use of org.camunda.bpm.engine.task.IdentityLink in project camunda-bpm-platform by camunda.

the class TaskAuthorizationTest method testProcessTaskAddCandidateUserWithUpdateTasksPersmissionOnProcessDefinition.

public void testProcessTaskAddCandidateUserWithUpdateTasksPersmissionOnProcessDefinition() {
    // given
    startProcessInstanceByKey(PROCESS_KEY);
    String taskId = selectSingleTask().getId();
    createGrantAuthorization(PROCESS_DEFINITION, PROCESS_KEY, userId, UPDATE_TASK);
    // when
    taskService.addCandidateUser(taskId, "demo");
    // then
    disableAuthorization();
    List<IdentityLink> linksForTask = taskService.getIdentityLinksForTask(taskId);
    enableAuthorization();
    assertNotNull(linksForTask);
    assertEquals(1, linksForTask.size());
    IdentityLink identityLink = linksForTask.get(0);
    assertNotNull(identityLink);
    assertEquals("demo", identityLink.getUserId());
    assertEquals(IdentityLinkType.CANDIDATE, identityLink.getType());
}
Also used : IdentityLink(org.camunda.bpm.engine.task.IdentityLink)

Aggregations

IdentityLink (org.camunda.bpm.engine.task.IdentityLink)81 Task (org.camunda.bpm.engine.task.Task)13 Deployment (org.camunda.bpm.engine.test.Deployment)13 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)12 Test (org.junit.Test)12 ArrayList (java.util.ArrayList)7 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)5 InputStream (java.io.InputStream)4 HashSet (java.util.HashSet)4 Expression (org.camunda.bpm.engine.delegate.Expression)4 HistoricIdentityLinkLog (org.camunda.bpm.engine.history.HistoricIdentityLinkLog)4 DeploymentBuilder (org.camunda.bpm.engine.repository.DeploymentBuilder)4 VariableMap (org.camunda.bpm.engine.variable.VariableMap)4 TaskService (org.camunda.bpm.engine.TaskService)3 HistoricIdentityLinkLogQuery (org.camunda.bpm.engine.history.HistoricIdentityLinkLogQuery)3 List (java.util.List)2 HalResource (org.camunda.bpm.engine.rest.hal.HalResource)2 Job (org.camunda.bpm.engine.runtime.Job)2 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)2 Matchers.anyString (org.mockito.Matchers.anyString)2