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:
Frederik Heremans
2012-05-02 10:16:39 +00:00
parent 8ca1f704f3
commit de57698423
2 changed files with 15 additions and 0 deletions

View File

@@ -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")

View File

@@ -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