class ManualHandlingTasks {

    public void setFalloutTaskVariables(DelegateTask task) {

        DelegateExecution execution = task.getExecution();
        try {
            logger.debug("Setting fallout task variables:");
            String taskId = task.getId();
            logger.debug("taskId is: " + taskId);
            String type = TASK_TYPE_FALLOUT;
            BuildingBlockExecution gBuildingBlockExecution =
                    (BuildingBlockExecution) execution.getVariable(G_BUILDING_BLOCK_EXECUTION);
            WorkflowException workflowException = (WorkflowException) execution.getVariable(WORKFLOW_EXCEPTION);
            String nfRole = (String) execution.getVariable(RAINY_DAY_VNF_TYPE);
            logger.debug(TASK_VARIABLE_NFROLE + ": " + nfRole);
            String subscriptionServiceType = (String) execution.getVariable(RAINY_DAY_SERVICE_TYPE);
            logger.debug(TASK_VARIABLE_SUBSCRIPTION_SERVICE_TYPE + ": " + subscriptionServiceType);
            String originalRequestId = (String) execution.getVariable(MSO_REQUEST_ID);
            logger.debug(TASK_VARIABLE_ORIGINAL_REQUEST_ID + ": " + originalRequestId);
            String originalRequestorId =
                    gBuildingBlockExecution.getGeneralBuildingBlock().getRequestContext().getRequestorId();
            logger.debug(TASK_VARIABLE_ORIGINAL_REQUESTOR_ID + ": " + originalRequestorId);
            String description = "Manual user task to handle a failure of a BB execution";
            logger.debug(TASK_VARIABLE_DESCRIPTION + ": " + description);
            String taskTimeout = (String) gBuildingBlockExecution.getVariable(TASK_TIMEOUT);
            String timeout = Date.from((new Date()).toInstant().plus(Duration.parse(taskTimeout))).toGMTString();
            logger.debug(TASK_VARIABLE_TIMEOUT + ": " + timeout);
            String errorSource = ASTERISK;
            if (workflowException != null && workflowException.getExtSystemErrorSource() != null) {
                errorSource = workflowException.getExtSystemErrorSource().toString();
            }
            logger.debug(TASK_VARIABLE_ERROR_SOURCE + ": " + errorSource);
            String errorCode = ASTERISK;
            if (workflowException != null) {
                errorCode = workflowException.getErrorCode() + "";
            }
            logger.debug(TASK_VARIABLE_ERROR_CODE + ": " + errorCode);
            String errorMessage = ASTERISK;
            if (workflowException != null) {
                errorMessage = workflowException.getErrorMessage();
            }
            logger.debug(TASK_VARIABLE_ERROR_MESSAGE + ": " + errorMessage);
            String buildingBlockName = gBuildingBlockExecution.getFlowToBeCalled();
            logger.debug(TASK_VARIABLE_BUILDING_BLOCK_NAME + ": " + buildingBlockName);
            String buildingBlockStep = ASTERISK;
            if (workflowException != null) {
                buildingBlockStep = workflowException.getWorkStep();
            }
            execution.setVariable(WORKSTEP, buildingBlockStep);
            logger.debug(TASK_VARIABLE_BUILDING_BLOCK_STEP + ": " + buildingBlockStep);
            String validResponses = this.environment.getProperty(validResponsesPath);
            logger.debug(TASK_VARIABLE_VALID_RESPONSES + ": " + validResponses);

            Map<String, String> taskVariables = new HashMap<>();
            taskVariables.put(TASK_VARIABLE_TYPE, type);
            taskVariables.put(TASK_VARIABLE_NFROLE, nfRole);
            taskVariables.put(TASK_VARIABLE_SUBSCRIPTION_SERVICE_TYPE, subscriptionServiceType);
            taskVariables.put(TASK_VARIABLE_ORIGINAL_REQUEST_ID, originalRequestId);
            taskVariables.put(TASK_VARIABLE_ORIGINAL_REQUESTOR_ID, originalRequestorId);
            taskVariables.put(TASK_VARIABLE_ERROR_SOURCE, errorSource);
            taskVariables.put(TASK_VARIABLE_ERROR_CODE, errorCode);
            taskVariables.put(TASK_VARIABLE_ERROR_MESSAGE, errorMessage);
            taskVariables.put(TASK_VARIABLE_BUILDING_BLOCK_NAME, buildingBlockName);
            taskVariables.put(TASK_VARIABLE_BUILDING_BLOCK_STEP, buildingBlockStep);
            taskVariables.put(TASK_VARIABLE_VALID_RESPONSES, validResponses);
            taskVariables.put(TASK_VARIABLE_TIMEOUT, timeout);
            taskVariables.put(TASK_VARIABLE_DESCRIPTION, description);
            TaskService taskService = execution.getProcessEngineServices().getTaskService();

            taskService.setVariablesLocal(taskId, taskVariables);
            logger.debug("successfully created fallout task: " + taskId);
        } catch (BpmnError e) {
            logger.debug(BPMN_EXCEPTION + e.getMessage());
            throw e;
        } catch (Exception ex) {
            String msg = "Exception in setFalloutTaskVariables " + ex.getMessage();
            logger.debug(msg);
            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg);
        }
    }

}