class AAICreateTasks {

    public void createNetworkPolicies(BuildingBlockExecution execution) {
        try {
            String fqdns = execution.getVariable(CONTRAIL_NETWORK_POLICY_FQDN_LIST);
            if (fqdns != null && !fqdns.isEmpty()) {
                String fqdnList[] = fqdns.split(",");
                int fqdnCount = fqdnList.length;
                if (fqdnCount > 0) {
                    for (int i = 0; i < fqdnCount; i++) {
                        String fqdn = fqdnList[i];
                        AAIPluralResourceUri uri =
                                AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkPolicies());
                        uri.queryParam(NETWORK_POLICY_FQDN_PARAM, fqdn);
                        Optional<org.onap.aai.domain.yang.NetworkPolicy> oNetPolicy =
                                aaiNetworkResources.getNetworkPolicy(uri);
                        if (!oNetPolicy.isPresent()) {
                            logger.debug("This network policy FQDN is not in AAI yet: {}", fqdn);
                            String networkPolicyId = UUID.randomUUID().toString();
                            logger.debug("Adding network-policy with network-policy-id {}", networkPolicyId);
                            NetworkPolicy networkPolicy = new NetworkPolicy();
                            networkPolicy.setNetworkPolicyId(networkPolicyId);
                            networkPolicy.setNetworkPolicyFqdn(fqdn);
                            networkPolicy.setHeatStackId(execution.getVariable(HEAT_STACK_ID));

                            aaiNetworkResources.createNetworkPolicy(networkPolicy);
                        }
                    }
                }
            }
        } catch (Exception ex) {
            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
        }
    }

}