class StackService extends ExternalTaskUtils {

    public void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) {
        Map<String, Object> variables = new HashMap<>();
        mdcSetup.setupMDC(externalTask);
        String xmlRequest = externalTask.getVariable("openstackAdapterTaskRequest");
        logger.debug("Executing External Task Stack Service. {}", xmlRequest);
        MutableBoolean success = new MutableBoolean();
        MutableBoolean backout = new MutableBoolean();
        String response = "";
        Holder<String> canonicalStackId = new Holder<>();
        String errorMessage = "";
        try {
            if (xmlRequest != null) {
                Holder<Map<String, String>> outputs = new Holder<>();
                Holder<VnfRollback> vnfRollback = new Holder<>();
                Optional<String> requestType = findRequestType(xmlRequest);
                Holder<String> networkId = new Holder<>();
                Holder<String> neutronNetworkId = new Holder<>();
                Holder<String> networkFqdn = new Holder<>();
                Holder<Map<String, String>> subnetIdMap = new Holder<>();
                Holder<NetworkRollback> networkRollback = new Holder<>();
                if ("createVolumeGroupRequest".equals(requestType.get())) {
                    logger.debug("Executing External Task Stack Service For Create Volume Group");
                    response = createVolumeGroup(xmlRequest, outputs, vnfRollback, canonicalStackId, backout, success);
                } else if ("createVfModuleRequest".equals(requestType.get())) {
                    logger.debug("Executing External Task Stack Service For Create Vf Module");
                    response = createVfModule(xmlRequest, outputs, vnfRollback, canonicalStackId, backout, success);
                } else if ("deleteVfModuleRequest".equals(requestType.get())) {
                    logger.debug("Executing External Task Stack Service For Delete Vf Module");
                    response = deleteVfModule(xmlRequest, outputs, vnfRollback, canonicalStackId, backout, success);
                } else if ("deleteVolumeGroupRequest".equals(requestType.get())) {
                    logger.debug("Executing External Task Stack Service For Delete Volume Group");
                    response = deleteVolumeGroup(xmlRequest, outputs, vnfRollback, canonicalStackId, backout, success);
                } else if ("createNetworkRequest".equals(requestType.get())) {
                    response = createNetwork(xmlRequest, networkId, neutronNetworkId, networkFqdn, subnetIdMap,
                            networkRollback, canonicalStackId, backout, success);
                } else if ("deleteNetworkRequest".equals(requestType.get())) {
                    response = deleteNetwork(xmlRequest, canonicalStackId, backout, success);
                } else if ("updateNetworkRequest".equals(requestType.get())) {
                    response =
                            updateNetwork(xmlRequest, subnetIdMap, networkRollback, canonicalStackId, backout, success);
                } else if ("rollbackNetworkRequest".equals(requestType.get())) {
                    response = rollbackNetwork(xmlRequest, canonicalStackId, backout, success);
                }
            }
        } catch (Exception e) {
            logger.error("Error during External Task Stack Service", e);
            errorMessage = e.getMessage();
        }
        variables.put("backout", backout.booleanValue());
        variables.put("WorkflowResponse", response);
        variables.put("OpenstackInvokeSuccess", success.booleanValue());
        variables.put("stackId", canonicalStackId.value);
        variables.put("openstackAdapterErrorMessage", errorMessage);
        variables.put("PollRollbackStatus", false);
        variables.put("rollbackPerformed", false);
        variables.put("OpenstackRollbackSuccess", false);
        variables.put("OpenstackPollSuccess", false);

        if (success.isTrue()) {
            externalTaskService.complete(externalTask, variables);
            logger.debug("The External Task Id: {}  Successful", externalTask.getId());
        } else {
            logger.debug("The External Task Id: {}  Failed. Not Retrying", externalTask.getId());
            externalTaskService.complete(externalTask, variables);
        }
    }

}