Don't use EELFLoggerDelegate.errorLogger in Async jobs
[vid.git] / vid-app-common / src / main / java / org / onap / vid / job / command / VnfCommand.kt
index b008c13..9023682 100644 (file)
@@ -12,7 +12,6 @@ import org.onap.vid.model.serviceInstantiation.Vnf
 import org.onap.vid.mso.RestMsoImplementation
 import org.onap.vid.properties.Features
 import org.onap.vid.services.AsyncInstantiationBusinessLogic
-import org.onap.vid.utils.isNotActive
 import org.springframework.beans.factory.annotation.Autowired
 import org.springframework.beans.factory.config.ConfigurableBeanFactory
 import org.springframework.context.annotation.Scope
@@ -62,8 +61,7 @@ class VnfCommand @Autowired constructor(
             try {
                 childJobs = pushChildrenJobsToBroker(vfModulesForChildrenJobs(vfModules), dataForChild, JobType.VolumeGroupInstantiation)
             } catch (e: AsdcCatalogException) {
-                LOGGER.error(EELFLoggerDelegate.errorLogger, "Failed to retrieve service definitions from SDC, for VfModule is BaseModule.. Error: " + e.message, e)
-                //return Job.JobStatus.FAILED
+                LOGGER.error("Failed to retrieve service definitions from SDC, for VfModule is BaseModule.. Error: " + e.message, e)
                 throw e;
             }
         }
@@ -77,7 +75,7 @@ class VnfCommand @Autowired constructor(
                     .map { childVfModuleWithVnfRegionAndTenant(it) }
 
     internal fun childVfModuleWithVnfRegionAndTenant(vfModule: VfModule): VfModule {
-        if (featureManager.isNotActive(Features.FLAG_2006_VFMODULE_TAKES_TENANT_AND_REGION_FROM_VNF)) {
+        if (!shouldEntailRegionAndTenantToVfModule(vfModule)) {
             return vfModule
         }
 
@@ -86,11 +84,14 @@ class VnfCommand @Autowired constructor(
         return vfModule.cloneWith(vnfLcpCloudRegionId, vnfTenantId)
     }
 
+    private fun shouldEntailRegionAndTenantToVfModule(vfModule: VfModule) =
+            vfModule.action == Action.Create
+                    && featureManager.isActive(Features.FLAG_2006_VFMODULE_TAKES_TENANT_AND_REGION_FROM_VNF)
+
     private fun filterModuleByNeedToCreateBase(vfModule: VfModule): Boolean {
         return needToCreateBaseModule ==
                 commandUtils.isVfModuleBaseModule(
-                        serviceModelInfoFromRequest().modelVersionId,
-                        vfModule.modelInfo.modelVersionId)
+                        serviceModelInfoFromRequest().modelVersionId, vfModule.modelInfo)
     }
 
     override fun planCreateMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String, testApi: String?): MsoRestCallPlan {