class AAIUpdateTasks {

    public void updateNetworkCreated(BuildingBlockExecution execution) throws Exception {
        execution.setVariable("aaiNetworkActivateRollback", false);
        L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
        L3Network copiedl3network = l3network.shallowCopyId();
        CreateNetworkResponse response = execution.getVariable("createNetworkResponse");
        try {
            if (response.getNetworkFqdn() != null) {
                l3network.setContrailNetworkFqdn(response.getNetworkFqdn());
            }
            l3network.setOrchestrationStatus(OrchestrationStatus.CREATED);
            l3network.setHeatStackId(response.getNetworkStackId());
            l3network.setNeutronNetworkId(response.getNeutronNetworkId());

            copiedl3network.setContrailNetworkFqdn(response.getNetworkFqdn());
            copiedl3network.setOrchestrationStatus(OrchestrationStatus.CREATED);
            copiedl3network.setHeatStackId(response.getNetworkStackId());
            copiedl3network.setNeutronNetworkId(response.getNeutronNetworkId());

            aaiNetworkResources.updateNetwork(copiedl3network);

            Map<String, String> subnetMap = response.getSubnetMap();
            List<Subnet> subnets = l3network.getSubnets();
            if (subnets != null && subnetMap != null) {
                for (Subnet subnet : subnets) {
                    Subnet copiedSubnet = subnet.shallowCopyId();
                    copiedSubnet.setNeutronSubnetId(subnetMap.get(copiedSubnet.getSubnetId()));
                    copiedSubnet.setOrchestrationStatus(OrchestrationStatus.CREATED);
                    aaiNetworkResources.updateSubnet(copiedl3network, copiedSubnet);
                }
            }

            execution.setVariable("aaiNetworkActivateRollback", true);
        } catch (Exception ex) {
            logger.error("Exception occurred in AAIUpdateTasks updateNetworkCreated", ex);
            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
        }
    }

}