class ServiceLevelUpgrade extends ServiceLevel implements JavaDelegate {

    @Override
    public void execute(DelegateExecution execution) throws Exception {
        LOG.debug("Running execute block for activity id: {}, name: {}", execution.getCurrentActivityId(),
                execution.getCurrentActivityName());

        if (execution.hasVariable(ServiceLevelConstants.RESOURCE_TYPE)
                && execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE) != null) {
            final String controllerScope = (String) execution.getVariable(ServiceLevelConstants.RESOURCE_TYPE);
            LOG.debug("Scope retrieved from delegate execution: " + controllerScope);
            if (ServiceLevelConstants.VALID_CONTROLLER_SCOPE.contains(controllerScope)) {
                final String wflName = fetchWorkflowUsingScope(controllerScope, ServiceLevelConstants.SW_UP_OPERATION);
                LOG.debug("Software Upgrade workflow fetched for the scope: {} is: {}", controllerScope, wflName);
                validateParamsWithScope(execution, controllerScope, SOFTWARE_UP_PARAMS_MAP.get(controllerScope));
                LOG.info("Parameters validated successfully for {}", wflName);
                execution.setVariable(ServiceLevelConstants.SOFTWARE_WORKFLOW_TO_INVOKE, wflName);
                execution.setVariable(ServiceLevelConstants.CONTROLLER_STATUS, ServiceLevelConstants.EMPTY_STRING);
                execution.setVariable(ServiceLevelConstants.PNF_COUNTER, ServiceLevelConstants.COUNT_ZERO);
            } else {
                exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE,
                        "Invalid Controller scope for resource level software upgrade");
            }
        } else {
            exceptionBuilder.buildAndThrowWorkflowException(execution, ServiceLevelConstants.ERROR_CODE,
                    "Resource type not found in the execution to invoke resource level software upgrade");
        }
    }

}