private void removeTaskIndex(WorkflowModel workflow, TaskModel task, boolean archiveTask)
            throws JsonProcessingException {
        if (archiveTask) {
            if (task.getStatus().isTerminal()) {
                // Only allow archival if task is in terminal state
                // DO NOT archive async, since if archival errors out, task data will be lost
                indexDAO.updateTask(
                        workflow.getWorkflowId(),
                        task.getTaskId(),
                        new String[] {ARCHIVED_FIELD},
                        new Object[] {true});
            } else {
                throw new IllegalArgumentException(
                        String.format(
                                "Cannot archive task: %s of workflow: %s with status: %s",
                                task.getTaskId(), workflow.getWorkflowId(), task.getStatus()));
            }
        } else {
            // Not archiving, remove task from index
            indexDAO.asyncRemoveTask(workflow.getWorkflowId(), task.getTaskId());
        }
    }
Sets the update time for the task. Sets the end time for the task (if task is in terminal
state and end time is not set). Updates the task in the {@link ExecutionDAO} first, then
stores it in the {@link IndexDAO}.

@param taskModel the task to be updated in the data store
@throws TransientException if the {@link IndexDAO} or {@link ExecutionDAO} operations fail.
@throws com.netflix.conductor.core.exception.NonTransientException if the externalization of
    payload fails.
core/src/main/java/com/netflix/conductor/core/dal/ExecutionDAOFacade.java