Introduce FeatureManager to ResourceCommand
[vid.git] / vid-app-common / src / main / java / org / onap / vid / job / command / ResourceCommand.kt
index a266dd0..9b4f8b9 100644 (file)
@@ -23,7 +23,6 @@ package org.onap.vid.job.command
 
 import com.fasterxml.jackson.module.kotlin.convertValue
 import org.apache.commons.lang3.ObjectUtils.defaultIfNull
-import org.onap.logging.ref.slf4j.ONAPLogConstants
 import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate
 import org.onap.vid.changeManagement.RequestDetailsWrapper
 import org.onap.vid.exceptions.AbortingException
@@ -34,12 +33,14 @@ import org.onap.vid.job.impl.JobSharedData
 import org.onap.vid.model.Action
 import org.onap.vid.model.RequestReferencesContainer
 import org.onap.vid.model.serviceInstantiation.BaseResource
+import org.onap.vid.model.serviceInstantiation.BaseResource.PauseInstantiation.afterCompletion
 import org.onap.vid.mso.RestMsoImplementation
 import org.onap.vid.mso.model.ModelInfo
+import org.onap.vid.properties.Features
 import org.onap.vid.utils.JACKSON_OBJECT_MAPPER
 import org.onap.vid.utils.getEnumFromMapOfStrings
-import org.slf4j.MDC
 import org.springframework.http.HttpMethod
+import org.togglz.core.manager.FeatureManager
 import java.util.*
 
 
@@ -78,7 +79,8 @@ abstract class ResourceCommand(
         protected val msoResultHandlerService: MsoResultHandlerService,
         protected val watchChildrenJobsBL: WatchChildrenJobsBL,
         private val jobsBrokerService: JobsBrokerService,
-        private val jobAdapter: JobAdapter
+        private val jobAdapter: JobAdapter,
+        private val featureManager: FeatureManager
         ) : CommandBase(), JobCommand {
 
     companion object {
@@ -114,7 +116,7 @@ abstract class ResourceCommand(
         jobStatus = comulateStatusAndUpdatePropertyIfFinal(jobStatus)
 
         try {
-            Logger.debug("job: ${this.javaClass.simpleName} ${sharedData.jobUuid} $actionPhase ${getActionType()} $internalState $jobStatus $childJobs")
+            Logger.debug(EELFLoggerDelegate.debugLogger, "job: ${this.javaClass.simpleName} ${sharedData.jobUuid} $actionPhase ${getActionType()} $internalState $jobStatus $childJobs")
         } catch (e:Exception) { /* do nothing. Just failed to log...*/}
 
         if (shallStopJob(jobStatus)) {
@@ -123,7 +125,7 @@ abstract class ResourceCommand(
         }
 
         val (nextActionPhase, nextInternalState) = calcNextInternalState(jobStatus, internalState, actionPhase)
-        Logger.debug("next state for job ${sharedData.jobUuid} is $nextInternalState")
+        Logger.debug(EELFLoggerDelegate.debugLogger, "next state for job ${sharedData.jobUuid} is $nextInternalState")
         actionPhase = nextActionPhase
         internalState = nextInternalState
 
@@ -133,7 +135,7 @@ abstract class ResourceCommand(
         }
 
         jobStatus = getExternalInProgressStatus()
-        Logger.debug("next status for job ${sharedData.jobUuid} is $jobStatus")
+        Logger.debug(EELFLoggerDelegate.debugLogger, "next status for job ${sharedData.jobUuid} is $jobStatus")
 //        if (internalState.immediate) return call() //shortcut instead of execute another command
         return NextCommand(jobStatus, this)
     }
@@ -332,13 +334,13 @@ abstract class ResourceCommand(
             handleInProgressStatus(jobStatus)
         } catch (e: javax.ws.rs.ProcessingException) {
             // Retry when we can't connect MSO during getStatus
-            Logger.error(EELFLoggerDelegate.errorLogger, "Cannot get orchestration status for {}, will retry: {}", requestId, e, e)
+            Logger.error("Cannot get orchestration status for {}, will retry: {}", requestId, e, e)
             JobStatus.IN_PROGRESS;
         } catch (e: InProgressStatusService.BadResponseFromMso) {
             inProgressStatusService.handleFailedMsoResponse(sharedData.jobUuid, requestId, e.msoResponse)
             JobStatus.IN_PROGRESS
         } catch (e: RuntimeException) {
-            Logger.error(EELFLoggerDelegate.errorLogger, "Cannot get orchestration status for {}, stopping: {}", requestId, e, e)
+            Logger.error("Cannot get orchestration status for {}, stopping: {}", requestId, e, e)
             JobStatus.STOPPED
         }
     }
@@ -362,8 +364,6 @@ abstract class ResourceCommand(
     }
 
     protected fun executeAndHandleMsoInstanceRequest(restCallPlan: MsoRestCallPlan): JobStatus {
-        //make sure requestIds are unique
-        MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, UUID.randomUUID().toString())
         val msoResponse = restMso.restCall(
                 restCallPlan.httpMethod,
                 RequestReferencesContainer::class.java,