Java Code Examples for org.activiti.engine.history.HistoricTaskInstanceQuery#list()

The following examples show how to use org.activiti.engine.history.HistoricTaskInstanceQuery#list() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HistoryServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" })
public void testHistoricTaskInstanceQueryByDeploymentId() {
  org.activiti.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult();
  HashSet<String> processInstanceIds = new HashSet<String>();
  for (int i = 0; i < 4; i++) {
    processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess", i + "").getId());
  }
  processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1").getId());

  HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().deploymentId(deployment.getId());
  assertEquals(5, taskInstanceQuery.count());

  List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list();
  assertNotNull(taskInstances);
  assertEquals(5, taskInstances.size());

  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().deploymentId("invalid");
  assertEquals(0, taskInstanceQuery.count());
}
 
Example 2
Source File: HistoryServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = { "org/activiti5/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti5/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" })
public void testHistoricTaskInstanceQueryByDeploymentId() {
  org.activiti.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult();
  HashSet<String> processInstanceIds = new HashSet<String>();
  for (int i = 0; i < 4; i++) {
    processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess", i + "").getId());
  }
  processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1").getId());

  HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().deploymentId(deployment.getId());
  assertEquals(5, taskInstanceQuery.count());

  List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list();
  assertNotNull(taskInstances);
  assertEquals(5, taskInstances.size());
  
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().deploymentId("invalid");
  assertEquals(0, taskInstanceQuery.count());
}
 
Example 3
Source File: ActivitiWorkflowEngine.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private List<WorkflowTask> queryHistoricTasks(WorkflowTaskQuery query)
{
    HistoricTaskInstanceQuery historicQuery = createHistoricTaskQuery(query);

   List<HistoricTaskInstance> results;
   int limit = query.getLimit();
   if (limit > 0)
   {
       results = historicQuery.listPage(0, limit);
   }
   else
   {
       results = historicQuery.list();
   }
   return getValidHistoricTasks(results);
}
 
Example 4
Source File: PermissionService.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
/**
 * Check if the given user is allowed to read the task.
 */
public HistoricTaskInstance validateReadPermissionOnTask(User user, String taskId) {

  List<HistoricTaskInstance> tasks = historyService.createHistoricTaskInstanceQuery().taskId(taskId).taskInvolvedUser(String.valueOf(user.getId())).list();

  if (CollectionUtils.isNotEmpty(tasks)) {
    return tasks.get(0);
  }

  // Task is maybe accessible through groups of user
  HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery();
  historicTaskInstanceQuery.taskId(taskId);

  List<String> groupIds = getGroupIdsForUser(user);
  if (!groupIds.isEmpty()) {
    historicTaskInstanceQuery.taskCandidateGroupIn(getGroupIdsForUser(user));
  }

  tasks = historicTaskInstanceQuery.list();
  if (CollectionUtils.isNotEmpty(tasks)) {
    return tasks.get(0);
  }

  // Last resort: user has access to proc inst -> can see task
  tasks = historyService.createHistoricTaskInstanceQuery().taskId(taskId).list();
  if (CollectionUtils.isNotEmpty(tasks)) {
    HistoricTaskInstance task = tasks.get(0);
    if (task != null && task.getProcessInstanceId() != null) {
      boolean hasReadPermissionOnProcessInstance = hasReadPermissionOnProcessInstance(user, task.getProcessInstanceId());
      if (hasReadPermissionOnProcessInstance) {
        return task;
      }
    }
  }
  throw new NotPermittedException("User is not allowed to work with task " + taskId);
}
 
Example 5
Source File: HistoricTaskQueryResource.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@RequestMapping(value = "/rest/query/history/tasks", method = RequestMethod.POST, produces = "application/json")
public ResultListDataRepresentation listTasks(@RequestBody ObjectNode requestNode) {
  if (requestNode == null) {
    throw new BadRequestException("No request found");
  }

  HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery();

  User currentUser = SecurityUtils.getCurrentUserObject();

  JsonNode processInstanceIdNode = requestNode.get("processInstanceId");
  if (processInstanceIdNode != null && processInstanceIdNode.isNull() == false) {
    String processInstanceId = processInstanceIdNode.asText();
    if (permissionService.hasReadPermissionOnProcessInstance(currentUser, processInstanceId)) {
      taskQuery.processInstanceId(processInstanceId);
    } else {
      throw new NotPermittedException();
    }
  }

  JsonNode finishedNode = requestNode.get("finished");
  if (finishedNode != null && finishedNode.isNull() == false) {
    boolean isFinished = finishedNode.asBoolean();
    if (isFinished) {
      taskQuery.finished();
    } else {
      taskQuery.unfinished();
    }
  }

  List<HistoricTaskInstance> tasks = taskQuery.list();

  // get all users to have the user object available in the task on the client side
  ResultListDataRepresentation result = new ResultListDataRepresentation(convertTaskInfoList(tasks));
  return result;
}
 
Example 6
Source File: HistoryServiceTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" })
public void testHistoricTaskInstanceQueryByDeploymentIdIn() {
  org.activiti.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult();
  HashSet<String> processInstanceIds = new HashSet<String>();
  for (int i = 0; i < 4; i++) {
    processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess", i + "").getId());
  }
  processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1").getId());

  List<String> deploymentIds = new ArrayList<String>();
  deploymentIds.add(deployment.getId());
  HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().deploymentIdIn(deploymentIds);
  assertEquals(5, taskInstanceQuery.count());

  List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list();
  assertNotNull(taskInstances);
  assertEquals(5, taskInstances.size());

  deploymentIds.add("invalid");
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().deploymentIdIn(deploymentIds);
  assertEquals(5, taskInstanceQuery.count());

  deploymentIds = new ArrayList<String>();
  deploymentIds.add("invalid");
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().deploymentIdIn(deploymentIds);
  assertEquals(0, taskInstanceQuery.count());
}
 
Example 7
Source File: HistoryServiceTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" })
public void testHistoricTaskInstanceOrQueryByDeploymentIdIn() {
  org.activiti.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult();
  HashSet<String> processInstanceIds = new HashSet<String>();
  for (int i = 0; i < 4; i++) {
    processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess", i + "").getId());
  }
  processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1").getId());

  List<String> deploymentIds = new ArrayList<String>();
  deploymentIds.add(deployment.getId());
  HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().deploymentIdIn(deploymentIds).processDefinitionId("invalid").endOr();
  assertEquals(5, taskInstanceQuery.count());

  List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list();
  assertNotNull(taskInstances);
  assertEquals(5, taskInstances.size());

  deploymentIds.add("invalid");
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().deploymentIdIn(deploymentIds).processDefinitionId("invalid").endOr();
  assertEquals(5, taskInstanceQuery.count());

  deploymentIds = new ArrayList<String>();
  deploymentIds.add("invalid");
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().deploymentIdIn(deploymentIds).processDefinitionId("invalid").endOr();
  assertEquals(0, taskInstanceQuery.count());

  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().taskDefinitionKey("theTask").deploymentIdIn(deploymentIds).endOr();
  assertEquals(5, taskInstanceQuery.count());

  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().taskDefinitionKey("theTask").or().deploymentIdIn(deploymentIds).endOr();
  assertEquals(0, taskInstanceQuery.count());
}
 
Example 8
Source File: HistoryServiceTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = { "org/activiti5/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti5/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" })
public void testHistoricTaskInstanceQueryByDeploymentIdIn() {
  org.activiti.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult();
  HashSet<String> processInstanceIds = new HashSet<String>();
  for (int i = 0; i < 4; i++) {
    processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess", i + "").getId());
  }
  processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1").getId());

  List<String> deploymentIds = new ArrayList<String>();
  deploymentIds.add(deployment.getId());
  HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().deploymentIdIn(deploymentIds);
  assertEquals(5, taskInstanceQuery.count());

  List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list();
  assertNotNull(taskInstances);
  assertEquals(5, taskInstances.size());
  
  deploymentIds.add("invalid");
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().deploymentIdIn(deploymentIds);
  assertEquals(5, taskInstanceQuery.count());
  
  deploymentIds = new ArrayList<String>();
  deploymentIds.add("invalid");
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().deploymentIdIn(deploymentIds);
  assertEquals(0, taskInstanceQuery.count());
}
 
Example 9
Source File: HistoryServiceTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Deployment(resources = { "org/activiti5/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti5/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" })
public void testHistoricTaskInstanceOrQueryByDeploymentIdIn() {
  org.activiti.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult();
  HashSet<String> processInstanceIds = new HashSet<String>();
  for (int i = 0; i < 4; i++) {
    processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess", i + "").getId());
  }
  processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1").getId());

  List<String> deploymentIds = new ArrayList<String>();
  deploymentIds.add(deployment.getId());
  HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().deploymentIdIn(deploymentIds).processDefinitionId("invalid").endOr();
  assertEquals(5, taskInstanceQuery.count());

  List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list();
  assertNotNull(taskInstances);
  assertEquals(5, taskInstances.size());
  
  deploymentIds.add("invalid");
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().deploymentIdIn(deploymentIds).processDefinitionId("invalid").endOr();
  assertEquals(5, taskInstanceQuery.count());
  
  deploymentIds = new ArrayList<String>();
  deploymentIds.add("invalid");
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().deploymentIdIn(deploymentIds).processDefinitionId("invalid").endOr();
  assertEquals(0, taskInstanceQuery.count());
  
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().taskDefinitionKey("theTask").deploymentIdIn(deploymentIds).endOr();
  assertEquals(5, taskInstanceQuery.count());
  
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().taskDefinitionKey("theTask").or().deploymentIdIn(deploymentIds).endOr();
  assertEquals(0, taskInstanceQuery.count());
}
 
Example 10
Source File: HistoryServiceTest.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" })
public void testHistoricTaskInstanceOrQueryByDeploymentId() {
  org.activiti.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult();
  HashSet<String> processInstanceIds = new HashSet<String>();
  for (int i = 0; i < 4; i++) {
    processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess", i + "").getId());
  }
  processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1").getId());

  HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().deploymentId(deployment.getId()).endOr();
  assertEquals(5, taskInstanceQuery.count());

  List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list();
  assertNotNull(taskInstances);
  assertEquals(5, taskInstances.size());

  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().deploymentId("invalid").endOr();
  assertEquals(0, taskInstanceQuery.count());

  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().taskDefinitionKey("theTask").deploymentId("invalid").endOr();
  assertEquals(5, taskInstanceQuery.count());

  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().taskDefinitionKey("theTask").or().deploymentId("invalid").endOr();
  assertEquals(0, taskInstanceQuery.count());
  
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
      .or()
        .taskDefinitionKey("theTask")
        .deploymentId("invalid")
      .endOr()
      .or()
        .processDefinitionKey("oneTaskProcess")
        .processDefinitionId("invalid")
      .endOr();
  assertEquals(4, taskInstanceQuery.count());
  
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
      .or()
        .taskDefinitionKey("theTask")
        .deploymentId("invalid")
      .endOr()
      .or()
        .processDefinitionKey("oneTaskProcess2")
        .processDefinitionId("invalid")
      .endOr();
  assertEquals(1, taskInstanceQuery.count());
  
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
      .or()
        .taskDefinitionKey("theTask")
        .deploymentId("invalid")
      .endOr()
      .or()
        .processDefinitionKey("oneTaskProcess")
        .processDefinitionId("invalid")
      .endOr()
      .processInstanceBusinessKey("1");
  assertEquals(1, taskInstanceQuery.count());
  
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
      .or()
        .taskDefinitionKey("theTask")
        .deploymentId("invalid")
      .endOr()
      .or()
        .processDefinitionKey("oneTaskProcess2")
        .processDefinitionId("invalid")
      .endOr()
      .processInstanceBusinessKey("1");
  assertEquals(1, taskInstanceQuery.count());
  
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
      .or()
        .taskDefinitionKey("theTask")
        .deploymentId("invalid")
      .endOr()
      .or()
        .processDefinitionKey("oneTaskProcess2")
        .processDefinitionId("invalid")
      .endOr()
      .processInstanceBusinessKey("2");
  assertEquals(0, taskInstanceQuery.count());
}
 
Example 11
Source File: HistoryServiceTest.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
@Deployment(resources = { "org/activiti5/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti5/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" })
public void testHistoricTaskInstanceOrQueryByDeploymentId() {
  org.activiti.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult();
  HashSet<String> processInstanceIds = new HashSet<String>();
  for (int i = 0; i < 4; i++) {
    processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess", i + "").getId());
  }
  processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1").getId());

  HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().deploymentId(deployment.getId()).endOr();
  assertEquals(5, taskInstanceQuery.count());

  List<HistoricTaskInstance> taskInstances = taskInstanceQuery.list();
  assertNotNull(taskInstances);
  assertEquals(5, taskInstances.size());
  
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().deploymentId("invalid").endOr();
  assertEquals(0, taskInstanceQuery.count());
  
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().or().taskDefinitionKey("theTask").deploymentId("invalid").endOr();
  assertEquals(5, taskInstanceQuery.count());
  
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().taskDefinitionKey("theTask").or().deploymentId("invalid").endOr();
  assertEquals(0, taskInstanceQuery.count());
  
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
      .or()
        .taskDefinitionKey("theTask")
        .deploymentId("invalid")
      .endOr()
      .or()
        .processDefinitionKey("oneTaskProcess")
        .processDefinitionId("invalid")
      .endOr();
  assertEquals(4, taskInstanceQuery.count());
  
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
      .or()
        .taskDefinitionKey("theTask")
        .deploymentId("invalid")
      .endOr()
      .or()
        .processDefinitionKey("oneTaskProcess2")
        .processDefinitionId("invalid")
      .endOr();
  assertEquals(1, taskInstanceQuery.count());
  
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
      .or()
        .taskDefinitionKey("theTask")
        .deploymentId("invalid")
      .endOr()
      .or()
        .processDefinitionKey("oneTaskProcess")
        .processDefinitionId("invalid")
      .endOr()
      .processInstanceBusinessKey("1");
  assertEquals(1, taskInstanceQuery.count());
  
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
      .or()
        .taskDefinitionKey("theTask")
        .deploymentId("invalid")
      .endOr()
      .or()
        .processDefinitionKey("oneTaskProcess2")
        .processDefinitionId("invalid")
      .endOr()
      .processInstanceBusinessKey("1");
  assertEquals(1, taskInstanceQuery.count());
  
  taskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
      .or()
        .taskDefinitionKey("theTask")
        .deploymentId("invalid")
      .endOr()
      .or()
        .processDefinitionKey("oneTaskProcess2")
        .processDefinitionId("invalid")
      .endOr()
      .processInstanceBusinessKey("2");
  assertEquals(0, taskInstanceQuery.count());
}
 
Example 12
Source File: WorkflowRestImpl.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Validates if the logged in user is allowed to get information about a specific process instance.
 * If the user is not allowed an exception is thrown.
 * 
 * @param processId identifier of the process instance
 */
protected List<HistoricVariableInstance> validateIfUserAllowedToWorkWithProcess(String processId)
{
    List<HistoricVariableInstance> variableInstances = activitiProcessEngine.getHistoryService()
            .createHistoricVariableInstanceQuery()
            .processInstanceId(processId)
            .list();
    
    Map<String, Object> variableMap = new HashMap<String, Object>();
    if (variableInstances != null && variableInstances.size() > 0) 
    {
        for (HistoricVariableInstance variableInstance : variableInstances)
        {
            variableMap.put(variableInstance.getVariableName(), variableInstance.getValue());
        }
    }
    else
    {
        throw new EntityNotFoundException(processId);
    }
    
    if (tenantService.isEnabled())
    {
        String tenantDomain = (String) variableMap.get(ActivitiConstants.VAR_TENANT_DOMAIN);
        if (TenantUtil.getCurrentDomain().equals(tenantDomain) == false)
        {
            throw new PermissionDeniedException("Process is running in another tenant");
        }
    }

    //MNT-17918 - required for initiator variable already updated as NodeRef type
    Object initiator = variableMap.get(WorkflowConstants.PROP_INITIATOR);
    String nodeId = ((initiator instanceof ActivitiScriptNode) ? ((ActivitiScriptNode) initiator).getNodeRef().getId() : ((NodeRef) initiator).getId());

    if (initiator != null && AuthenticationUtil.getRunAsUser().equals(nodeId))
    {
        // user is allowed
        return variableInstances;
    }

    String username = AuthenticationUtil.getRunAsUser();
    if (authorityService.isAdminAuthority(username)) 
    {
        // Admin is allowed to read all processes in the current tenant
        return variableInstances;
    }
    else
    {
        // MNT-12382 check for membership in the assigned group
        ActivitiScriptNode group = (ActivitiScriptNode) variableMap.get("bpm_groupAssignee");
        if (group != null)
        {
            // check that the process is unclaimed
            Task task = activitiProcessEngine.getTaskService().createTaskQuery().processInstanceId(processId).singleResult();
            if ((task != null) && (task.getAssignee() == null) && isUserInGroup(username, group.getNodeRef()))
            {
                return variableInstances;
            }
        }

        // If non-admin user, involvement in the task is required (either owner, assignee or externally involved).
        HistoricTaskInstanceQuery query = activitiProcessEngine.getHistoryService()
                .createHistoricTaskInstanceQuery()
                .processInstanceId(processId)
                .taskInvolvedUser(AuthenticationUtil.getRunAsUser());
        
        List<HistoricTaskInstance> taskList = query.list();
        
        if (org.apache.commons.collections.CollectionUtils.isEmpty(taskList)) 
        {
            throw new PermissionDeniedException("user is not allowed to access information about process " + processId);
        }
    }
    
    return variableInstances;
}