1 package org.onap.so.bpmn.infrastructure.scripts
 
   3 import org.camunda.bpm.engine.delegate.BpmnError
 
   4 import org.camunda.bpm.engine.delegate.DelegateExecution
 
   5 import org.onap.aai.domain.yang.ServiceInstance
 
   6 import org.onap.aai.domain.yang.SliceProfile
 
   7 import org.onap.logging.filter.base.ONAPComponents
 
   8 import org.onap.so.beans.nsmf.AllocateAnNssi
 
   9 import org.onap.so.beans.nsmf.AllocateCnNssi
 
  10 import org.onap.so.beans.nsmf.AllocateTnNssi
 
  11 import org.onap.so.beans.nsmf.AnSliceProfile
 
  12 import org.onap.so.beans.nsmf.CnSliceProfile
 
  13 import org.onap.so.beans.nsmf.EsrInfo
 
  14 import org.onap.so.beans.nsmf.JobStatusRequest
 
  15 import org.onap.so.beans.nsmf.NetworkType
 
  16 import org.onap.so.beans.nsmf.NsiInfo
 
  17 import org.onap.so.beans.nsmf.NssiAllocateRequest
 
  18 import org.onap.so.beans.nsmf.PerfReq
 
  19 import org.onap.so.beans.nsmf.PerfReqEmbbList
 
  20 import org.onap.so.beans.nsmf.PerfReqUrllcList
 
  21 import org.onap.so.beans.nsmf.ResourceSharingLevel
 
  22 import org.onap.so.beans.nsmf.ServiceProfile
 
  23 import org.onap.so.beans.nsmf.SliceTaskParams
 
  24 import org.onap.so.beans.nsmf.TnSliceProfile
 
  25 import org.onap.so.beans.nsmf.UeMobilityLevel
 
  26 import org.onap.so.bpmn.common.scripts.ExceptionUtil
 
  27 import org.onap.so.bpmn.core.RollbackData
 
  28 import org.onap.so.bpmn.core.UrnPropertiesReader
 
  29 import org.onap.so.bpmn.core.domain.ModelInfo
 
  30 import org.onap.so.bpmn.core.domain.ServiceDecomposition
 
  31 import org.onap.so.bpmn.core.json.JsonUtils
 
  32 import org.onap.so.client.HttpClient
 
  33 import org.onap.so.client.HttpClientFactory
 
  34 import org.onap.so.client.aai.AAIObjectType
 
  35 import org.onap.so.client.aai.AAIResourcesClient
 
  36 import org.onap.so.client.aai.entities.AAIEdgeLabel
 
  37 import org.onap.so.client.aai.entities.uri.AAIResourceUri
 
  38 import org.onap.so.client.aai.entities.uri.AAIUriFactory
 
  39 import org.slf4j.Logger
 
  40 import org.slf4j.LoggerFactory
 
  41 import com.fasterxml.jackson.databind.ObjectMapper;
 
  42 import javax.ws.rs.core.Response
 
  44 import static org.apache.commons.lang3.StringUtils.isBlank
 
  47 class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor{
 
  49     private static final Logger logger = LoggerFactory.getLogger( DoAllocateNSSI.class);
 
  50     private static final ObjectMapper MAPPER = new ObjectMapper();
 
  52     ExceptionUtil exceptionUtil = new ExceptionUtil()
 
  54     JsonUtils jsonUtil = new JsonUtils()
 
  57      * Pre Process the BPMN Flow Request
 
  59      * generate the nsOperationKey
 
  60      * generate the nsParameters
 
  62     void preProcessRequest (DelegateExecution execution) {
 
  63         logger.trace("Enter preProcessRequest()")
 
  65         String nssmfOperation = ""
 
  66         String msoRequestId = execution.getVariable("msoRequestId")
 
  67         String nsstInput = execution.getVariable("nsstInput")
 
  68         String modelUuid = jsonUtil.getJsonValue(nsstInput, "modelUuid")
 
  69         //modelUuid="2763777c-27bd-4df7-93b8-c690e23f4d3f"
 
  70         String nssiInstanceId = jsonUtil.getJsonValue(nsstInput, "serviceInstanceId")
 
  71         String serviceModelInfo = """{
 
  72             "modelInvariantUuid":"",
 
  73             "modelUuid":"${modelUuid}",
 
  76         execution.setVariable("serviceModelInfo",serviceModelInfo)
 
  77         execution.setVariable("nssiInstanceId",nssiInstanceId)
 
  78         String nssiProfileID = UUID.randomUUID().toString()
 
  79         execution.setVariable("nssiProfileID",nssiProfileID)
 
  80         if(isBlank(nssiInstanceId))
 
  82             nssmfOperation="create"
 
  83             nssiInstanceId = UUID.randomUUID().toString()
 
  85             nssmfOperation = "update"
 
  87         execution.setVariable("nssmfOperation",nssmfOperation)
 
  88         execution.setVariable("nssiInstanceId",nssiInstanceId)
 
  90         def isDebugLogEnabled ="false"
 
  91         def isNSSICreated = false
 
  92         execution.setVariable("isNSSICreated",isNSSICreated)
 
  95         execution.setVariable("currentCycle", currentCycle)
 
  97         logger.trace("Exit preProcessRequest")
 
 101     void getNSSTInfo(DelegateExecution execution){
 
 102         logger.trace("Enter getNSSTInfo in DoAllocateNSSI()")
 
 103         ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
 
 104         ModelInfo modelInfo = serviceDecomposition.getModelInfo()
 
 105         String serviceRole = "nssi"
 
 106         String nssiServiceInvariantUuid = serviceDecomposition.modelInfo.getModelInvariantUuid()
 
 107         String nssiServiceUuid = serviceDecomposition.modelInfo.getModelUuid()
 
 108         String nssiServiceType = serviceDecomposition.getServiceType()
 
 109         String uuiRequest = execution.getVariable("uuiRequest")
 
 110         String nssiServiceName = "nssi_"+jsonUtil.getJsonValue(uuiRequest, "service.name")
 
 111         execution.setVariable("nssiServiceName",nssiServiceName)
 
 112         execution.setVariable("nssiServiceType",nssiServiceType)
 
 113         execution.setVariable("nssiServiceInvariantUuid",nssiServiceInvariantUuid)
 
 114         execution.setVariable("nssiServiceUuid",nssiServiceUuid)
 
 115         execution.setVariable("serviceRole",serviceRole)
 
 117         String content = serviceDecomposition.getServiceInfo().getServiceArtifact().get(0).getContent()
 
 118         String nsstID = jsonUtil.getJsonValue(content, "metadata.id")
 
 119         String nsstVendor = jsonUtil.getJsonValue(content, "metadata.vendor")
 
 120         String nsstDomain = jsonUtil.getJsonValue(content, "metadata.domainType")
 
 121         String nsstType = jsonUtil.getJsonValue(content, "metadata.type")
 
 123         execution.setVariable("nsstID",nsstID)
 
 124         execution.setVariable("nsstVendor",nsstVendor)
 
 125         execution.setVariable("nsstDomain",nsstDomain)
 
 126         execution.setVariable("nssiServiceUuid",nssiServiceUuid)
 
 127         execution.setVariable("nsstType",nsstType)
 
 129         String nsstContentInfo = """{
 
 130         "NsstID":"${nsstID}",
 
 131         "Vendor":"${nsstVendor}",
 
 135         logger.trace("Exit getNSSTInfo in DoAllocateNSSI()")
 
 138     void timeDelay(DelegateExecution execution) {
 
 139         logger.trace("Enter timeDelay in DoAllocateNSSI()")
 
 142             int currentCycle = execution.getVariable("currentCycle")
 
 143             currentCycle=currentCycle+1
 
 146                 logger.trace("Completed all the retry times... but still nssmf havent completed the creation process...")
 
 147                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "NSSMF creation didnt complete by time...")
 
 149             execution.setVariable("currentCycle",currentCycle)
 
 150         } catch(InterruptedException e) {
 
 151             logger.info("Time Delay exception" + e)
 
 153         logger.trace("Exit timeDelay in DoAllocateNSSI()")
 
 157     void sendUpdateRequestNSSMF(DelegateExecution execution) {
 
 158         logger.trace("Enter sendUpdateRequestNSSMF in DoAllocateNSSI()")
 
 159         String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
 
 160         logger.debug( "get NSSMF: " + urlString)
 
 162        //Prepare auth for NSSMF - Begin
 
 164         String basicAuth = UrnPropertiesReader.getVariable("mso.nssmf.auth", execution)
 
 165         String domain = execution.getVariable("nsstDomain")
 
 166         String nssmfRequest = buildUpdateNSSMFRequest(execution, domain.toUpperCase())
 
 168         //send request to update NSSI option - Begin
 
 169         URL url = new URL(urlString+"/api/rest/provMns/v1/NSS/SliceProfiles")
 
 170         HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
 
 171         Response httpResponse = httpClient.post(nssmfRequest)
 
 173         int responseCode = httpResponse.getStatus()
 
 174         logger.debug("NSSMF sync response code is: " + responseCode)
 
 176         if(responseCode < 199 && responseCode > 299){
 
 177             String nssmfResponse ="NSSMF response have nobody"
 
 178             if(httpResponse.hasEntity())
 
 179                 nssmfResponse = httpResponse.readEntity(String.class)
 
 180             logger.trace("received error message from NSSMF : "+nssmfResponse)
 
 181             logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
 
 182             exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
 
 185         if(httpResponse.hasEntity()){
 
 186             String nssmfResponse = httpResponse.readEntity(String.class)
 
 187             execution.setVariable("nssmfResponse", nssmfResponse)
 
 188             String nssiId = jsonUtil.getJsonValue(nssmfResponse, "nssiId")
 
 189             String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
 
 190             execution.setVariable("nssiId",nssiId)
 
 191             execution.setVariable("jobId",jobId)
 
 193             exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
 
 195         logger.trace("Exit sendUpdateRequestNSSMF in DoAllocateNSSI()")
 
 198     void sendCreateRequestNSSMF(DelegateExecution execution) {
 
 199         logger.trace("Enter sendCreateRequestNSSMF in DoAllocateNSSI()")
 
 200         String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
 
 201         logger.debug( "get NSSMF: " + urlString)
 
 203         //Prepare auth for NSSMF - Begin
 
 204         String domain = execution.getVariable("nsstDomain")
 
 205         String nssmfRequest = buildCreateNSSMFRequest(execution, domain.toUpperCase())
 
 207         //send request to get NSI option - Begin
 
 208         URL url = new URL(urlString+"/api/rest/provMns/v1/NSS/SliceProfiles")
 
 209         HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
 
 210         Response httpResponse = httpClient.post(nssmfRequest)
 
 212         int responseCode = httpResponse.getStatus()
 
 213         logger.debug("NSSMF sync response code is: " + responseCode)
 
 215         if(responseCode < 199 || responseCode > 299 ){
 
 216             String nssmfResponse ="NSSMF response have nobody"
 
 217             if(httpResponse.hasEntity())
 
 218                 nssmfResponse = httpResponse.readEntity(String.class)
 
 219             logger.trace("received error message from NSSMF : "+nssmfResponse)
 
 220             logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
 
 221             exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
 
 224         if(httpResponse.hasEntity()){
 
 225             String nssmfResponse = httpResponse.readEntity(String.class)
 
 226             execution.setVariable("nssmfResponse", nssmfResponse)
 
 227             String nssiId = jsonUtil.getJsonValue(nssmfResponse, "nssiId")
 
 228             String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
 
 229             execution.setVariable("nssiId",nssiId)
 
 230             execution.setVariable("jobId",jobId)
 
 232             exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
 
 234         logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
 
 238     void getNSSMFProgresss(DelegateExecution execution) {
 
 239         logger.trace("Enter getNSSMFProgresss in DoAllocateNSSI()")
 
 241         String endpoint = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
 
 242         logger.debug( "get NSSMF: " + endpoint)
 
 244         //Prepare auth for NSSMF - Begin
 
 246         String basicAuth = UrnPropertiesReader.getVariable("mso.nssmf.auth", execution)
 
 248         String nssmfRequest = buildNSSMFProgressRequest(execution)
 
 249         String strUrl="/api/rest/provMns/v1/NSS/jobs/"+execution.getVariable("jobId")
 
 250         //send request to update NSSI option - Begin
 
 251         URL url = new URL(endpoint+strUrl)
 
 252         HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
 
 253         Response httpResponse = httpClient.post(nssmfRequest)
 
 255         int responseCode = httpResponse.getStatus()
 
 256         logger.debug("NSSMF sync response code is: " + responseCode)
 
 258         if(responseCode < 199 || responseCode > 299){
 
 259             String nssmfResponse ="NSSMF response have nobody"
 
 260             if(httpResponse.hasEntity())
 
 261                 nssmfResponse = httpResponse.readEntity(String.class)
 
 262             logger.trace("received error message from NSSMF : "+nssmfResponse)
 
 263             logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
 
 264             exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
 
 267         if(httpResponse.hasEntity()){
 
 268             String nssmfResponse = httpResponse.readEntity(String.class)
 
 269             Boolean isNSSICreated = false
 
 270             execution.setVariable("nssmfResponse", nssmfResponse)
 
 271             Integer progress = java.lang.Integer.parseInt(jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.progress"))
 
 272             String status = jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.status")
 
 273             String statusDescription = jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.statusDescription")
 
 274             execution.setVariable("nssmfProgress",progress)
 
 275             execution.setVariable("nssmfStatus",status)
 
 276             execution.setVariable("nddmfStatusDescription",statusDescription)
 
 279             execution.setVariable("isNSSICreated",isNSSICreated)
 
 282             exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
 
 284         logger.trace("Exit getNSSMFProgresss in DoAllocateNSSI()")
 
 288     void updateRelationship(DelegateExecution execution) {
 
 289         logger.trace("Enter updateRelationship in DoAllocateNSSI()")
 
 290         String nssiInstanceId = execution.getVariable("nssiInstanceId")
 
 291         String nsiInstanceId = execution.getVariable("nsiServiceInstanceId")
 
 293             AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nsiInstanceId);
 
 294             AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiInstanceId)
 
 295             getAAIClient().connect(nsiServiceuri, nssiServiceUri, AAIEdgeLabel.COMPOSED_OF);
 
 296         }catch(Exception ex) {
 
 297             String msg = "Exception in DoAllocateNSSI InstantiateNSSI service while creating relationship " + ex.getMessage()
 
 299             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
 
 301         logger.trace("Exit updateRelationship in DoAllocateNSSI()")
 
 305     void instantiateNSSIService(DelegateExecution execution) {
 
 306         logger.trace("Enter instantiateNSSIService in DoAllocateNSSI()")
 
 307         //String nssiInstanceId = execution.getVariable("nssiInstanceId")
 
 308         String nssiInstanceId = execution.getVariable("nssiId")
 
 309         execution.setVariable("nssiInstanceId",nssiInstanceId)
 
 310         String sliceInstanceId = execution.getVariable("nsiServiceInstanceId")
 
 312             org.onap.aai.domain.yang.ServiceInstance nssi = new ServiceInstance();
 
 313             Map<String, Object> serviceProfileMap = execution.getVariable("serviceProfile")
 
 315             nssi.setServiceInstanceId(nssiInstanceId)
 
 316             nssi.setServiceInstanceName(execution.getVariable("nssiServiceName"))
 
 317             //nssi.setServiceType(execution.getVariable("nssiServiceType"))
 
 318             nssi.setServiceType(serviceProfileMap.get("sST").toString())
 
 319             String serviceStatus = "deactivated"
 
 320             nssi.setOrchestrationStatus(serviceStatus)
 
 321             String modelInvariantUuid = execution.getVariable("nssiServiceInvariantUuid")
 
 322             String modelUuid = execution.getVariable("nssiServiceUuid")
 
 323             nssi.setModelInvariantId(modelInvariantUuid)
 
 324             nssi.setModelVersionId(modelUuid)
 
 325             String uuiRequest = execution.getVariable("uuiRequest")
 
 326             String serviceInstanceLocationid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.plmnIdList")
 
 327             nssi.setServiceInstanceLocationId(serviceInstanceLocationid)
 
 328             //String snssai = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.sNSSAI")
 
 329             String envContext=execution.getVariable("nsstDomain")
 
 330             nssi.setEnvironmentContext(envContext)
 
 331             nssi.setServiceRole(execution.getVariable("serviceRole"))
 
 332             AAIResourcesClient client = new AAIResourcesClient()
 
 333             AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), nssiInstanceId)
 
 334             client.create(uri, nssi)
 
 335         } catch (BpmnError e) {
 
 337         } catch (Exception ex) {
 
 338             String msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage()
 
 340             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
 
 343             AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, sliceInstanceId);
 
 344             AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiInstanceId)
 
 345             getAAIClient().connect(nsiServiceuri, nssiServiceUri, AAIEdgeLabel.COMPOSED_OF);
 
 346         }catch(Exception ex) {
 
 347             String msg = "Exception in DoAllocateNSSI InstantiateNSSI service while creating relationship " + ex.getMessage()
 
 349             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
 
 354         def rollbackData = execution.getVariable("RollbackData")
 
 355         if (rollbackData == null) {
 
 356             rollbackData = new RollbackData();
 
 358         //rollbackData.put("SERVICEINSTANCE", "disableRollback", idisableRollback.toStrng())
 
 359         rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true")
 
 360         rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", nssiInstanceId)
 
 361         rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
 
 362         rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId"))
 
 363         execution.setVariable("rollbackData", rollbackData)
 
 364         execution.setVariable("RollbackData", rollbackData)
 
 365         logger.debug("RollbackData:" + rollbackData)
 
 366         logger.trace("Exit instantiateNSSIService in DoAllocateNSSI()")
 
 370     void createSliceProfile(DelegateExecution execution) {
 
 371         logger.trace("Enter createSliceProfile in DoAllocateNSSI()")
 
 372         String sliceserviceInstanceId = execution.getVariable("nssiInstanceId")
 
 373         String nssiProfileID = execution.getVariable("nssiProfileID")
 
 374         Map<String, Object> sliceProfileMap = execution.getVariable("sliceProfileCn")
 
 375         Map<String, Object> serviceProfileMap = execution.getVariable("serviceProfile")
 
 376         SliceProfile sliceProfile = new SliceProfile()
 
 377         sliceProfile.setServiceAreaDimension("")
 
 378         sliceProfile.setPayloadSize(0)
 
 379         sliceProfile.setJitter(0)
 
 380         sliceProfile.setSurvivalTime(0)
 
 381         //sliceProfile.setCsAvailability()
 
 382         //sliceProfile.setReliability()
 
 383         sliceProfile.setExpDataRate(0)
 
 384         sliceProfile.setTrafficDensity(0)
 
 385         sliceProfile.setConnDensity(0)
 
 386         sliceProfile.setExpDataRateUL(Integer.parseInt(sliceProfileMap.get("expDataRateUL").toString()))
 
 387         sliceProfile.setExpDataRateDL(Integer.parseInt(sliceProfileMap.get("expDataRateDL").toString()))
 
 388         sliceProfile.setActivityFactor(Integer.parseInt(sliceProfileMap.get("activityFactor").toString()))
 
 389         sliceProfile.setResourceSharingLevel(sliceProfileMap.get("activityFactor").toString())
 
 390         sliceProfile.setUeMobilityLevel(serviceProfileMap.get("uEMobilityLevel").toString())
 
 391         sliceProfile.setCoverageAreaTAList(serviceProfileMap.get("coverageAreaTAList").toString())
 
 392         sliceProfile.setMaxNumberOfUEs(Integer.parseInt(sliceProfileMap.get("activityFactor").toString()))
 
 393         sliceProfile.setLatency(Integer.parseInt(sliceProfileMap.get("latency").toString()))
 
 394         sliceProfile.setProfileId(nssiProfileID)
 
 395         sliceProfile.setE2ELatency(0)
 
 398             AAIResourcesClient client = new AAIResourcesClient()
 
 399             AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE,
 
 400                     execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), sliceserviceInstanceId, nssiProfileID)
 
 401             client.create(uri, sliceProfile)
 
 402         } catch (BpmnError e) {
 
 404         } catch (Exception ex) {
 
 405             String msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage()
 
 407             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
 
 410         def rollbackData = execution.getVariable("RollbackData")
 
 411         if (rollbackData == null) {
 
 412             rollbackData = new RollbackData();
 
 414         //rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString())
 
 415         rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true")
 
 416         rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", sliceserviceInstanceId)
 
 417         rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("serviceType"))
 
 418         rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId"))
 
 419         execution.setVariable("rollbackData", rollbackData)
 
 420         execution.setVariable("RollbackData", rollbackData)
 
 421         logger.debug("RollbackData:" + rollbackData)
 
 422         logger.trace("Exit createSliceProfile in DoAllocateNSSI()")
 
 426     String buildCreateNSSMFRequest(DelegateExecution execution, String domain) {
 
 428         NssiAllocateRequest request = new NssiAllocateRequest()
 
 429         String strRequest = ""
 
 430         //String uuiRequest = execution.getVariable("uuiRequest")
 
 431         SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
 
 435                 EsrInfo esrInfo = new EsrInfo()
 
 436                 esrInfo.setNetworkType(execution.getVariable("networkType"))
 
 437                 esrInfo.setVendor(execution.getVariable("nsstVendor"))
 
 439                 NsiInfo nsiInfo = new NsiInfo()
 
 440                 nsiInfo.setNsiId(execution.getVariable("nsiInstanceID"))
 
 441                 nsiInfo.setNsiName(execution.getVariable("nsiInstanceName"))
 
 443                 AnSliceProfile anSliceProfile = new AnSliceProfile()
 
 444                 anSliceProfile.setLatency(execution.getVariable("latency"))
 
 445                 anSliceProfile.setCoverageAreaTAList(execution.getVariable("coverageAreaList"))
 
 446                 anSliceProfile.setQi(execution.getVariable("qi"))
 
 448                 AllocateAnNssi allocateAnNssi = new AllocateAnNssi()
 
 449                 allocateAnNssi.setNsstId(execution.getVariable("nsstId"))
 
 450                 allocateAnNssi.setNssiName(execution.getVariable("nssiName"))
 
 451                 allocateAnNssi.setNsiInfo(nsiInfo)
 
 452                 allocateAnNssi.setSliceProfile(anSliceProfile)
 
 453                 String anScriptName = sliceTaskParams.getAnScriptName()
 
 454                 allocateAnNssi.setScriptName(anScriptName)
 
 456                 request.setAllocateAnNssi(allocateAnNssi)
 
 457                 request.setEsrInfo(esrInfo)
 
 460                 Map<String, Object> sliceProfileCn =execution.getVariable("sliceProfileCn")
 
 461                 Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
 
 462                 NsiInfo nsiInfo = new NsiInfo()
 
 463                 nsiInfo.setNsiId(execution.getVariable("nsiServiceInstanceId"))
 
 464                 nsiInfo.setNsiName(execution.getVariable("nsiServiceInstanceName"))
 
 466                 EsrInfo esrInfo = new EsrInfo()
 
 467                 esrInfo.setNetworkType(NetworkType.fromString(domain))
 
 468                 esrInfo.setVendor(execution.getVariable("nsstVendor"))
 
 469                 execution.setVariable("esrInfo",esrInfo)
 
 472                 PerfReqEmbbList perfReqEmbb = new PerfReqEmbbList()
 
 473                 perfReqEmbb.setActivityFactor(sliceProfileCn.get("activityFactor"))
 
 474                 perfReqEmbb.setAreaTrafficCapDL(sliceProfileCn.get("areaTrafficCapDL"))
 
 475                 perfReqEmbb.setAreaTrafficCapUL(sliceProfileCn.get("areaTrafficCapUL"))
 
 476                 perfReqEmbb.setExpDataRateDL(sliceProfileCn.get("expDataRateDL"))
 
 477                 perfReqEmbb.setExpDataRateUL(sliceProfileCn.get("expDataRateUL"))
 
 479                 List<PerfReqEmbbList> listPerfReqEmbbList = new ArrayList<>()
 
 480                 listPerfReqEmbbList.add(perfReqEmbb)
 
 482                 PerfReq perfReq = new PerfReq()
 
 483                 perfReq.setPerfReqEmbbList(listPerfReqEmbbList)
 
 485                 PerfReqUrllcList perfReqUrllc = new PerfReqUrllcList()
 
 486                 perfReqUrllc.setConnDensity(0)
 
 487                 perfReqUrllc.setTrafficDensity(0)
 
 488                 perfReqUrllc.setExpDataRate(0)
 
 489                 perfReqUrllc.setReliability(0)
 
 490                 perfReqUrllc.setCsAvailability(0)
 
 491                 perfReqUrllc.setSurvivalTime(0)
 
 492                 perfReqUrllc.setJitter(0)
 
 493                 perfReqUrllc.setE2eLatency(0)
 
 494                 perfReqUrllc.setPayloadSize("0")
 
 495                 perfReqUrllc.setServiceAreaDimension("")
 
 497                 List<PerfReqUrllcList> perfReqUrllcList = new ArrayList<>()
 
 498                 perfReqUrllcList.add(perfReqUrllc)
 
 499                 perfReq.setPerfReqUrllcList(perfReqUrllcList)
 
 501                 CnSliceProfile cnSliceProfile = new CnSliceProfile()
 
 502                 cnSliceProfile.setSliceProfileId(execution.getVariable("nssiProfileID"))
 
 503                 String plmnStr = serviceProfile.get("plmnIdList")
 
 504                 List<String> plmnIdList=Arrays.asList(plmnStr.split("\\|"))
 
 505                 cnSliceProfile.setPlmnIdList(plmnIdList)
 
 507                 String resourceSharingLevel = serviceProfile.get("resourceSharingLevel").toString()
 
 508                 cnSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(resourceSharingLevel))
 
 510                 String coverageArea = serviceProfile.get("coverageAreaTAList")
 
 511                 List<String> coverageAreaList=Arrays.asList(coverageArea.split("\\|"))
 
 512                 cnSliceProfile.setCoverageAreaTAList(coverageAreaList)
 
 514                 String ueMobilityLevel = serviceProfile.get("uEMobilityLevel").toString()
 
 515                 cnSliceProfile.setUeMobilityLevel(UeMobilityLevel.fromString(ueMobilityLevel))
 
 517                 int latency = serviceProfile.get("latency")
 
 518                 cnSliceProfile.setLatency(latency)
 
 520                 int maxUE = serviceProfile.get("maxNumberofUEs")
 
 521                 cnSliceProfile.setMaxNumberofUEs(maxUE)
 
 523                 String snssai = serviceProfile.get("sNSSAI")
 
 524                 List<String> snssaiList = Arrays.asList(snssai.split("\\|"))
 
 525                 cnSliceProfile.setSnssaiList(snssaiList)
 
 527                 cnSliceProfile.setPerfReq(perfReq)
 
 529                 AllocateCnNssi allocateCnNssi = new AllocateCnNssi()
 
 530                 allocateCnNssi.setNsstId(execution.getVariable("nsstid"))
 
 531                 allocateCnNssi.setNssiName(execution.getVariable("nssiName"))
 
 532                 allocateCnNssi.setSliceProfile(cnSliceProfile)
 
 533                 allocateCnNssi.setNsiInfo(nsiInfo)
 
 534                 String cnScriptName = sliceTaskParams.getCnScriptName()
 
 535                 allocateCnNssi.setScriptName(cnScriptName)
 
 536                 request.setAllocateCnNssi(allocateCnNssi)
 
 537                 request.setEsrInfo(esrInfo)
 
 540                 EsrInfo esrInfo = new EsrInfo()
 
 541                 esrInfo.setNetworkType(execution.getVariable("networkType"))
 
 542                 esrInfo.setVendor(execution.getVariable("vendor"))
 
 544                 TnSliceProfile tnSliceProfile = new TnSliceProfile()
 
 545                 tnSliceProfile.setLatency(execution.getVariable("latency"))
 
 546                 tnSliceProfile.setBandwidth(execution.getVariable("bandWidth"))
 
 548                 NsiInfo nsiInfo = new NsiInfo()
 
 549                 nsiInfo.setNsiId(execution.getVariable("nsiInstanceID"))
 
 550                 nsiInfo.setNsiName(execution.getVariable("nsiInstanceName"))
 
 552                 AllocateTnNssi allocateTnNssi = new AllocateTnNssi()
 
 553                 allocateTnNssi.setSliceProfile(tnSliceProfile)
 
 554                 allocateTnNssi.setNsiInfo(nsiInfo)
 
 555                 allocateTnNssi.setNsstId(execution.getVariable("nsstid"))
 
 556                 String tnScriptName = sliceTaskParams.getTnScriptName()
 
 557                 allocateTnNssi.setScriptName(tnScriptName)
 
 559                 request.setAllocateTnNssi(allocateTnNssi)
 
 560                 request.setEsrInfo(esrInfo)
 
 566             strRequest = MAPPER.writeValueAsString(request);
 
 567         } catch (IOException e) {
 
 568             logger.error("Invalid get progress request bean to convert as string");
 
 569             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Invalid get progress request bean to convert as string")
 
 575     String buildUpdateNSSMFRequest(DelegateExecution execution, String domain) {
 
 576         NssiAllocateRequest request = new NssiAllocateRequest()
 
 577         String nsstInput = execution.getVariable("nsstInput")
 
 578         String nssiId = jsonUtil.getJsonValue(nsstInput, "serviceInstanceId")
 
 579         String strRequest = ""
 
 580         SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
 
 583                 EsrInfo esrInfo = new EsrInfo()
 
 584                 esrInfo.setNetworkType(execution.getVariable("nsstType"))
 
 585                 esrInfo.setVendor(execution.getVariable("vendor"))
 
 587                 NsiInfo nsiInfo = new NsiInfo()
 
 588                 nsiInfo.setNsiId(execution.getVariable("nsiInstanceID"))
 
 589                 nsiInfo.setNsiName(execution.getVariable("nsiInstanceName"))
 
 591                 AnSliceProfile anSliceProfile = new AnSliceProfile()
 
 592                 anSliceProfile.setLatency(execution.getVariable("latency"))
 
 593                 anSliceProfile.setCoverageAreaTAList(execution.getVariable("coverageAreaList"))
 
 594                 anSliceProfile.setQi(execution.getVariable("qi"))
 
 596                 AllocateAnNssi allocateAnNssi = new AllocateAnNssi()
 
 597                 allocateAnNssi.setNsstId(execution.getVariable("nsstId"))
 
 598                 allocateAnNssi.setNssiName(execution.getVariable("nssiName"))
 
 599                 allocateAnNssi.setNsiInfo(nsiInfo)
 
 600                 allocateAnNssi.setSliceProfile(anSliceProfile)
 
 601                 String anScriptName = sliceTaskParams.getAnScriptName()
 
 602                 allocateAnNssi.setScriptName(anScriptName)
 
 603                 request.setAllocateAnNssi(allocateAnNssi)
 
 604                 request.setEsrInfo(esrInfo)
 
 607                 Map<String, Object> sliceProfileCn =execution.getVariable("sliceProfileCn")
 
 608                 Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
 
 609                 NsiInfo nsiInfo = new NsiInfo()
 
 610                 nsiInfo.setNsiId(execution.getVariable("nsiServiceInstanceId"))
 
 611                 nsiInfo.setNsiName(execution.getVariable("nsiServiceInstanceName"))
 
 613                 EsrInfo esrInfo = new EsrInfo()
 
 614                 esrInfo.setNetworkType(NetworkType.fromString(domain))
 
 615                 esrInfo.setVendor(execution.getVariable("nsstVendor"))
 
 616                 execution.setVariable("esrInfo",esrInfo)
 
 619                 PerfReqEmbbList perfReqEmbb = new PerfReqEmbbList()
 
 620                 perfReqEmbb.setActivityFactor(sliceProfileCn.get("activityFactor"))
 
 621                 perfReqEmbb.setAreaTrafficCapDL(sliceProfileCn.get("areaTrafficCapDL"))
 
 622                 perfReqEmbb.setAreaTrafficCapUL(sliceProfileCn.get("areaTrafficCapUL"))
 
 623                 perfReqEmbb.setExpDataRateDL(sliceProfileCn.get("expDataRateDL"))
 
 624                 perfReqEmbb.setExpDataRateUL(sliceProfileCn.get("expDataRateUL"))
 
 626                 List<PerfReqEmbbList> listPerfReqEmbbList = new ArrayList<>()
 
 627                 listPerfReqEmbbList.add(perfReqEmbb)
 
 629                 PerfReq perfReq = new PerfReq()
 
 630                 perfReq.setPerfReqEmbbList(listPerfReqEmbbList)
 
 632                 PerfReqUrllcList perfReqUrllc = new PerfReqUrllcList()
 
 633                 perfReqUrllc.setConnDensity(0)
 
 634                 perfReqUrllc.setTrafficDensity(0)
 
 635                 perfReqUrllc.setExpDataRate(0)
 
 636                 perfReqUrllc.setReliability(0)
 
 637                 perfReqUrllc.setCsAvailability(0)
 
 638                 perfReqUrllc.setSurvivalTime(0)
 
 639                 perfReqUrllc.setJitter(0)
 
 640                 perfReqUrllc.setE2eLatency(0)
 
 641                 perfReqUrllc.setPayloadSize("0")
 
 642                 perfReqUrllc.setServiceAreaDimension("")
 
 644                 List<PerfReqUrllcList> perfReqUrllcList = new ArrayList<>()
 
 645                 perfReqUrllcList.add(perfReqUrllc)
 
 646                 perfReq.setPerfReqUrllcList(perfReqUrllcList)
 
 648                 CnSliceProfile cnSliceProfile = new CnSliceProfile()
 
 649                 cnSliceProfile.setSliceProfileId(execution.getVariable("nssiProfileID"))
 
 650                 String plmnStr = serviceProfile.get("plmnIdList")
 
 651                 List<String> plmnIdList=Arrays.asList(plmnStr.split("\\|"))
 
 652                 cnSliceProfile.setPlmnIdList(plmnIdList)
 
 654                 String resourceSharingLevel = serviceProfile.get("resourceSharingLevel").toString()
 
 655                 cnSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(resourceSharingLevel))
 
 657                 String coverageArea = serviceProfile.get("coverageAreaTAList")
 
 658                 List<String> coverageAreaList=Arrays.asList(coverageArea.split("\\|"))
 
 659                 cnSliceProfile.setCoverageAreaTAList(coverageAreaList)
 
 661                 String ueMobilityLevel = serviceProfile.get("uEMobilityLevel").toString()
 
 662                 cnSliceProfile.setUeMobilityLevel(UeMobilityLevel.fromString(ueMobilityLevel))
 
 664                 int latency = serviceProfile.get("latency")
 
 665                 cnSliceProfile.setLatency(latency)
 
 667                 int maxUE = serviceProfile.get("maxNumberofUEs")
 
 668                 cnSliceProfile.setMaxNumberofUEs(maxUE)
 
 670                 String snssai = serviceProfile.get("sNSSAI")
 
 671                 List<String> snssaiList = Arrays.asList(snssai.split("\\|"))
 
 672                 cnSliceProfile.setSnssaiList(snssaiList)
 
 674                 cnSliceProfile.setPerfReq(perfReq)
 
 676                 AllocateCnNssi allocateCnNssi = new AllocateCnNssi()
 
 677                 allocateCnNssi.setNsstId(execution.getVariable("nsstid"))
 
 678                 allocateCnNssi.setNssiName(execution.getVariable("nssiName"))
 
 679                 allocateCnNssi.setSliceProfile(cnSliceProfile)
 
 680                 allocateCnNssi.setNsiInfo(nsiInfo)
 
 681                 allocateCnNssi.setNssiId(nssiId)              // need to check this
 
 682                 String cnScriptName = sliceTaskParams.getCnScriptName()
 
 683                 allocateCnNssi.setScriptName(cnScriptName)
 
 684                 request.setAllocateCnNssi(allocateCnNssi)
 
 685                 request.setEsrInfo(esrInfo)
 
 688                 EsrInfo esrInfo = new EsrInfo()
 
 689                 esrInfo.setNetworkType(execution.getVariable("networkType"))
 
 690                 esrInfo.setVendor(execution.getVariable("vendor"))
 
 692                 TnSliceProfile tnSliceProfile = new TnSliceProfile()
 
 693                 tnSliceProfile.setLatency(execution.getVariable("latency"))
 
 694                 tnSliceProfile.setBandwidth(execution.getVariable("bandWidth"))
 
 696                 NsiInfo nsiInfo = new NsiInfo()
 
 697                 nsiInfo.setNsiId(execution.getVariable("nsiInstanceID"))
 
 698                 nsiInfo.setNsiName(execution.getVariable("nsiInstanceName"))
 
 700                 AllocateTnNssi allocateTnNssi = new AllocateTnNssi()
 
 701                 allocateTnNssi.setSliceProfile(tnSliceProfile)
 
 702                 allocateTnNssi.setNsiInfo(nsiInfo)
 
 703                 allocateTnNssi.setNsstId(execution.getVariable("nsstid"))
 
 704                 String tnScriptName = sliceTaskParams.getTnScriptName()
 
 705                 allocateTnNssi.setScriptName(tnScriptName)
 
 706                 request.setAllocateTnNssi(allocateTnNssi)
 
 707                 request.setEsrInfo(esrInfo)
 
 713             strRequest = MAPPER.writeValueAsString(request);
 
 714         } catch (IOException e) {
 
 715             logger.error("Invalid get progress request bean to convert as string");
 
 716             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Invalid get progress request bean to convert as string")
 
 721     String buildNSSMFProgressRequest(DelegateExecution execution){
 
 722         JobStatusRequest request = new JobStatusRequest()
 
 723         String strRequest = ""
 
 724         EsrInfo esrInfo = execution.getVariable("esrInfo")
 
 725         request.setNsiId(execution.getVariable("nsiServiceInstanceId"))
 
 726         request.setNssiId(execution.getVariable("nssiId"))
 
 727         request.setEsrInfo(esrInfo)
 
 730             strRequest = MAPPER.writeValueAsString(request);
 
 731         } catch (IOException e) {
 
 732             logger.error("Invalid get progress request bean to convert as string");
 
 733             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Invalid get progress request bean to convert as string")
 
 738     public void prepareUpdateOrchestrationTask(DelegateExecution execution) {
 
 739         logger.debug("Start prepareUpdateOrchestrationTask progress")
 
 740         String requestMethod = "PUT"
 
 741         String progress = execution.getVariable("nssmfProgress")
 
 742         String status = execution.getVariable("nssmfStatus")
 
 743         String statusDescription=execution.getVariable("nddmfStatusDescription")
 
 744         SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
 
 745         String domain = execution.getVariable("nsstDomain")
 
 746         switch (domain.toUpperCase()) {
 
 748                 sliceTaskParams.setAnProgress(progress)
 
 749                 sliceTaskParams.setAnStatus(status)
 
 750                 sliceTaskParams.setAnStatusDescription(statusDescription)
 
 753                 sliceTaskParams.setCnProgress(progress)
 
 754                 sliceTaskParams.setCnStatus(status)
 
 755                 sliceTaskParams.setCnStatusDescription(statusDescription)
 
 758                 sliceTaskParams.setTnProgress(progress)
 
 759                 sliceTaskParams.setTnStatus(status)
 
 760                 sliceTaskParams.setTnStatusDescription(statusDescription)
 
 765         String paramJson = sliceTaskParams.convertToJson()
 
 766         execution.setVariable("CSSOT_paramJson", paramJson)
 
 767         execution.setVariable("CSSOT_requestMethod", requestMethod)
 
 768         logger.debug("Finish prepareUpdateOrchestrationTask progress")