1 package org.onap.vid.job.command
3 import org.onap.vid.job.Job
4 import org.onap.vid.job.JobAdapter
5 import org.onap.vid.job.JobCommand
6 import org.onap.vid.job.JobsBrokerService
7 import org.onap.vid.model.Action
8 import org.onap.vid.model.serviceInstantiation.Network
9 import org.onap.vid.mso.RestMsoImplementation
10 import org.onap.vid.services.AsyncInstantiationBusinessLogic
11 import org.springframework.beans.factory.annotation.Autowired
12 import org.springframework.beans.factory.config.ConfigurableBeanFactory
13 import org.springframework.context.annotation.Scope
14 import org.springframework.http.HttpMethod
15 import org.springframework.stereotype.Component
16 import org.togglz.core.manager.FeatureManager
21 @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
22 class NetworkCommand @Autowired constructor(
23 private val asyncInstantiationBL: AsyncInstantiationBusinessLogic,
24 restMso: RestMsoImplementation,
25 private val msoRequestBuilder: MsoRequestBuilder,
26 msoResultHandlerService: MsoResultHandlerService,
27 inProgressStatusService:InProgressStatusService,
28 watchChildrenJobsBL: WatchChildrenJobsBL,
29 jobsBrokerService: JobsBrokerService,
30 jobAdapter: JobAdapter,
31 featureManager: FeatureManager
32 ) : ResourceCommand(restMso, inProgressStatusService, msoResultHandlerService,
33 watchChildrenJobsBL, jobsBrokerService, jobAdapter, featureManager), JobCommand {
34 override fun createChildren(): Job.JobStatus {
35 return Job.JobStatus.COMPLETED_WITH_NO_ACTION
38 override fun planCreateMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String, testApi: String?): MsoRestCallPlan {
39 val serviceInstanceId = serviceInstanceIdFromRequest()
40 val instantiatePath = asyncInstantiationBL.getNetworkInstantiationPath(serviceInstanceId)
41 val requestDetailsWrapper = msoRequestBuilder.generateNetworkInstantiationRequest(
43 serviceModelInfoFromRequest(),
49 val actionDescription = "create network in $serviceInstanceId"
51 return MsoRestCallPlan(HttpMethod.POST, instantiatePath, Optional.of(requestDetailsWrapper), Optional.empty(), actionDescription)
54 override fun planDeleteMyselfRestCall(commandParentData: CommandParentData, request: JobAdapter.AsyncJobRequest, userId: String): MsoRestCallPlan {
55 val serviceInstanceId = serviceInstanceIdFromRequest()
56 val path = asyncInstantiationBL.getNetworkDeletePath(serviceInstanceId, getRequest().instanceId)
57 val requestDetailsWrapper = msoRequestBuilder.generateDeleteNetworkRequest(getRequest() as Network, userId)
58 return MsoRestCallPlan(HttpMethod.DELETE, path, Optional.of(requestDetailsWrapper), Optional.of(userId),
59 "delete network ${getRequest().instanceId} from service instance $serviceInstanceId")
62 override fun isDescendantHasAction(phase: Action): Boolean {