diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/HumanTaskActivityBehavior.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/HumanTaskActivityBehavior.java index 3c94e952f93..219a587cceb 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/HumanTaskActivityBehavior.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/behavior/impl/HumanTaskActivityBehavior.java @@ -403,7 +403,7 @@ public void trigger(CommandContext commandContext, PlanItemInstanceEntity planIt // Should be only one for (TaskEntity taskEntity : taskEntities) { if (!taskEntity.isDeleted()) { - TaskHelper.completeTask(taskEntity, Authentication.getAuthenticatedUserId(), cmmnEngineConfiguration); + TaskHelper.completeTask(taskEntity, taskEntity.getTempCompletedBy(), cmmnEngineConfiguration); } } diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/CompleteTaskCmd.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/CompleteTaskCmd.java index 689be50ec7a..5c802972fce 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/CompleteTaskCmd.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/CompleteTaskCmd.java @@ -27,7 +27,6 @@ import org.flowable.common.engine.api.FlowableIllegalArgumentException; import org.flowable.common.engine.api.FlowableObjectNotFoundException; import org.flowable.common.engine.api.delegate.event.FlowableEventDispatcher; -import org.flowable.common.engine.impl.identity.Authentication; import org.flowable.common.engine.impl.interceptor.Command; import org.flowable.common.engine.impl.interceptor.CommandContext; import org.flowable.common.engine.impl.logging.CmmnLoggingSessionConstants; @@ -137,9 +136,10 @@ public Void execute(CommandContext commandContext) { "Human task '" + taskLabel + "' completed", taskEntity, planItemInstanceEntity, cmmnEngineConfiguration.getObjectMapper()); } - if (StringUtils.isNotEmpty(userId)) { - Authentication.setAuthenticatedUserId(userId); + if (userId != null) { + taskEntity.setTempCompletedBy(userId); } + CommandContextUtil.getAgenda(commandContext).planTriggerPlanItemInstanceOperation(planItemInstanceEntity); } else { diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/CompleteTaskWithFormCmd.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/CompleteTaskWithFormCmd.java index 80ff19eb192..56555955179 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/CompleteTaskWithFormCmd.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/CompleteTaskWithFormCmd.java @@ -26,7 +26,6 @@ import org.flowable.common.engine.api.FlowableException; import org.flowable.common.engine.api.FlowableIllegalArgumentException; import org.flowable.common.engine.api.scope.ScopeTypes; -import org.flowable.common.engine.impl.identity.Authentication; import org.flowable.common.engine.impl.interceptor.CommandContext; import org.flowable.form.api.FormFieldHandler; import org.flowable.form.api.FormInfo; @@ -206,6 +205,10 @@ protected void completeTask(CommandContext commandContext, TaskEntity task, Map< if (transientVariablesLocal != null) { task.setTransientVariablesLocal(transientVariablesLocal); } + + if (userId != null) { + task.setTempCompletedBy(userId); + } logUserTaskCompleted(task, cmmnEngineConfiguration); @@ -215,9 +218,6 @@ protected void completeTask(CommandContext commandContext, TaskEntity task, Map< cmmnEngineConfiguration.getListenerNotificationHelper().executeTaskListeners(task, TaskListener.EVENTNAME_COMPLETE); - if (StringUtils.isNotEmpty(userId)) { - Authentication.setAuthenticatedUserId(userId); - } CommandContextUtil.getAgenda(commandContext).planTriggerPlanItemInstanceOperation(planItemInstanceEntity); } diff --git a/modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/persistence/entity/TaskEntity.java b/modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/persistence/entity/TaskEntity.java index 34fb3acba51..1c65256c63e 100755 --- a/modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/persistence/entity/TaskEntity.java +++ b/modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/persistence/entity/TaskEntity.java @@ -90,6 +90,10 @@ public interface TaskEntity extends VariableScope, Task, DelegateTask, Entity, H void setAssigneeValue(String assignee); void setOwnerValue(String owner); + + String getTempCompletedBy(); + + void setTempCompletedBy(String completedBy); List getQueryVariables(); } diff --git a/modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/persistence/entity/TaskEntityImpl.java b/modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/persistence/entity/TaskEntityImpl.java index e924fc7ed91..1b66458905d 100644 --- a/modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/persistence/entity/TaskEntityImpl.java +++ b/modules/flowable-task-service/src/main/java/org/flowable/task/service/impl/persistence/entity/TaskEntityImpl.java @@ -119,6 +119,7 @@ public class TaskEntityImpl extends AbstractTaskServiceVariableScopeEntity imple // Non-persisted protected String eventName; protected String eventHandlerId; + protected String tempCompletedBy; protected List queryVariables; protected List queryIdentityLinks; protected boolean forcedUpdate; @@ -709,6 +710,16 @@ public String getEventHandlerId() { public void setEventHandlerId(String eventHandlerId) { this.eventHandlerId = eventHandlerId; } + + @Override + public String getTempCompletedBy() { + return tempCompletedBy; + } + + @Override + public void setTempCompletedBy(String tempCompletedBy) { + this.tempCompletedBy = tempCompletedBy; + } @Override public void setExecutionId(String executionId) {