class CreateInventoryTask extends ExternalTaskUtils {

    public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
        mdcSetup.setupMDC(externalTask);
        boolean inventoryException = false;
        String externalTaskId = externalTask.getId();
        CloudInformation cloudInformation = externalTask.getVariable("cloudInformation");
        boolean success = true;
        if (cloudInformation != null) {
            Integer retryCount = externalTask.getRetries();
            try {
                logger.info("Executing External Task Create Inventory, Retry Number: {} \n {}", retryCount,
                        cloudInformation.toString());
                createInventory.heatbridge(cloudInformation);
            } catch (Exception e) {
                logger.error("Error during inventory of stack", e);
                success = false;
            }
            mdcSetup.setElapsedTime();
            if (success) {
                externalTaskService.complete(externalTask);
                mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.COMPLETE.toString());
                logger.debug("The External Task Id: {}  Successful", externalTaskId);
                logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
                mdcSetup.clearClientMDCs();
            } else {
                if (retryCount == null) {
                    logger.error("The External Task Id: {}  Failed, Setting Retries to Default Start Value: {}",
                            externalTaskId, getRetrySequence().length);
                    externalTaskService.handleFailure(externalTask, UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI,
                            UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI, getRetrySequence().length, 10000);
                } else if (retryCount != null && retryCount - 1 == 0) {
                    externalTaskService.handleBpmnError(externalTask, AAI_INVENTORY_FAILURE);
                    mdcSetup.setResponseCode(ONAPLogConstants.ResponseStatus.ERROR.toString());
                    logger.error("The External Task Id: {}  Failed, All Retries Exhausted", externalTaskId);
                    logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
                } else {
                    logger.error("The External Task Id: {}  Failed, Decrementing Retries: {} , Retry Delay: ",
                            externalTaskId, retryCount - 1, calculateRetryDelay(retryCount));
                    externalTaskService.handleFailure(externalTask, UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI,
                            UNABLE_TO_WRITE_ALL_INVENTORY_TO_A_AI, retryCount - 1, calculateRetryDelay(retryCount));
                }
                logger.error("The External Task Id: {} Failed", externalTaskId);
            }
        } else {
            logger.error("The External Task Id: {}  Failed, No Cloud Information Provided", externalTaskId);
            externalTaskService.handleBpmnError(externalTask, AAI_INVENTORY_FAILURE);
        }
    }

    public  CreateInventoryTask();

}