import com.fasterxml.jackson.module.kotlin.convertValue
+import org.apache.commons.lang3.ObjectUtils.defaultIfNull
import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate
import org.onap.vid.changeManagement.RequestDetailsWrapper
import org.onap.vid.exceptions.AbortingException
import org.onap.vid.model.RequestReferencesContainer
import org.onap.vid.model.serviceInstantiation.BaseResource
import org.onap.vid.mso.RestMsoImplementation
+import org.onap.vid.mso.model.ModelInfo
import org.onap.vid.utils.JACKSON_OBJECT_MAPPER
import org.onap.vid.utils.getEnumFromMapOfStrings
import org.springframework.http.HttpMethod
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)) {
}
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
}
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)
}
else -> InternalState.IN_PROGRESS
}
- InternalState.REPLACE_MYSELF -> when (jobStatus) {
- JobStatus.IN_PROGRESS -> InternalState.REPLACE_MYSELF
- else -> InternalState.IN_PROGRESS
- }
-
InternalState.IN_PROGRESS -> {
when {
jobStatus != JobStatus.COMPLETED -> InternalState.IN_PROGRESS
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
}
}
return commandParentData.parentData
}
+ protected fun serviceModelInfoFromRequest(): ModelInfo = commandParentData.getModelInfo(CommandParentData.CommandDataKey.SERVICE_MODEL_INFO)
+ protected fun serviceInstanceIdFromRequest(): String = commandParentData.getInstanceId(CommandParentData.CommandDataKey.SERVICE_INSTANCE_ID)
+
protected open fun addMyselfToChildrenData(commandParentData: CommandParentData, request: BaseResource) {
// Nothing by default
}
protected fun pushChildrenJobsToBroker(children:Collection<BaseResource>,
dataForChild: Map<String, Any>,
jobType: JobType?=null): List<String> {
- var counter = 0;
- return children
- .map {Pair(it, counter++)}
+ return setPositionWhereIsMissing(children)
.map { jobAdapter.createChildJob(jobType ?: it.first.jobType, it.first, sharedData, dataForChild, it.second) }
.map { jobsBrokerService.add(it) }
.map { it.toString() }
}
+ protected fun setPositionWhereIsMissing(children: Collection<BaseResource>): List<Pair<BaseResource, Int>> {
+ var orderingPosition = children.map{ defaultIfNull(it.position, 0) }.max() ?: 0
+ return children
+ .map {Pair(it, it.position ?: ++orderingPosition)}
+ }
}