mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merged BRANCHES/DEV/V4.0-BUG-FIX to HEAD:
35979: ALF-10278, ALF-13902: Ending task now done with the right assignee when unassigned (eg. not claimed from pool) or when workflow-owner completes the task assigned to someone else, without claiming first git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@35980 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -33,6 +33,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.activiti.engine.history.HistoricDetail;
|
||||
import org.activiti.engine.history.HistoricTaskInstance;
|
||||
import org.activiti.engine.history.HistoricVariableUpdate;
|
||||
import org.activiti.engine.task.Task;
|
||||
import org.alfresco.repo.workflow.BPMEngineRegistry;
|
||||
@@ -308,6 +309,11 @@ public class ActivitiTaskComponentTest extends AbstractActivitiComponentTest
|
||||
}
|
||||
|
||||
Assert.assertTrue("Task variables are not flushed to process-instance", found);
|
||||
|
||||
// Check task assignee, should be currently logged in user
|
||||
HistoricTaskInstance hti = historyService.createHistoricTaskInstanceQuery().taskId(task.getId()).singleResult();
|
||||
assertNotNull(hti);
|
||||
assertEquals("admin", hti.getAssignee());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@@ -1347,6 +1347,15 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
String msg = messageService.getMessage(ERR_END_UNEXISTING_TASK, taskId);
|
||||
throw new WorkflowException(msg);
|
||||
}
|
||||
|
||||
// Check if the assignee is equal to the current logged-in user. If not, assign task before ending
|
||||
String currentUserName = AuthenticationUtil.getFullyAuthenticatedUser();
|
||||
if(task.getAssignee() == null || !task.getAssignee().equals(currentUserName)) {
|
||||
taskService.setAssignee(localTaskId, currentUserName);
|
||||
// Also update pojo used to set the outcome, this will read assignee as wel
|
||||
task.setAssignee(currentUserName);
|
||||
}
|
||||
|
||||
setOutcome(task, transition);
|
||||
taskService.complete(localTaskId);
|
||||
// The task should have a historicTaskInstance
|
||||
|
Reference in New Issue
Block a user