2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  # Copyright (c) 2020, Wipro Limited.
 
   7  # Licensed under the Apache License, Version 2.0 (the "License")
 
   8  # you may not use this file except in compliance with the License.
 
   9  # You may obtain a copy of the License at
 
  11  #       http://www.apache.org/licenses/LICENSE-2.0
 
  13  # Unless required by applicable law or agreed to in writing, software
 
  14  # distributed under the License is distributed on an "AS IS" BASIS,
 
  15  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  16  # See the License for the specific language governing permissions and
 
  17  # limitations under the License.
 
  18  * ============LICENSE_END=========================================================
 
  21 package org.onap.so.bpmn.infrastructure.scripts
 
  24 import com.google.gson.JsonArray
 
  25 import org.camunda.bpm.engine.delegate.BpmnError
 
  26 import org.camunda.bpm.engine.delegate.DelegateExecution
 
  27 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
 
  28 import org.onap.so.bpmn.common.scripts.ExceptionUtil
 
  29 import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils
 
  30 import org.onap.so.bpmn.common.scripts.OofUtils
 
  31 import org.onap.so.bpmn.common.scripts.RequestDBUtil
 
  32 import org.onap.so.bpmn.core.json.JsonUtils
 
  33 import org.onap.so.db.request.beans.ResourceOperationStatus
 
  34 import org.slf4j.Logger
 
  35 import org.slf4j.LoggerFactory
 
  36 import java.sql.Timestamp
 
  38 import static org.apache.commons.lang3.StringUtils.isBlank
 
  39 import com.google.gson.JsonObject
 
  40 import com.google.gson.JsonParser
 
  41 import com.fasterxml.jackson.databind.ObjectMapper
 
  42 import org.onap.aaiclient.client.aai.AAIObjectType
 
  43 import org.onap.aaiclient.client.aai.AAIResourcesClient
 
  44 import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
 
  45 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
 
  46 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
 
  47 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
 
  48 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
 
  49 import javax.ws.rs.NotFoundException
 
  50 import org.onap.so.beans.nsmf.AllocateTnNssi
 
  51 import org.onap.so.beans.nsmf.DeAllocateNssi
 
  52 import org.onap.so.beans.nsmf.ServiceInfo
 
  53 import org.onap.so.bpmn.core.UrnPropertiesReader
 
  54 import org.onap.aai.domain.yang.ServiceInstance
 
  55 import org.onap.aai.domain.yang.SliceProfile
 
  56 import org.onap.aai.domain.yang.SliceProfiles
 
  57 import org.onap.aai.domain.yang.Relationship
 
  62         private static final Logger logger = LoggerFactory.getLogger(AnNssmfUtils.class)
 
  63         ObjectMapper objectMapper = new ObjectMapper();
 
  64         ExceptionUtil exceptionUtil = new ExceptionUtil()
 
  65         JsonUtils jsonUtil = new JsonUtils()
 
  66         public String buildSelectRANNSSIRequest(String requestId, String messageType, String UUID,String invariantUUID,
 
  67                 String name, Map<String, Object> profileInfo, List<String> nsstInfoList, JsonArray capabilitiesList, Boolean preferReuse){
 
  68         JsonParser parser = new JsonParser()
 
  69         def transactionId = requestId
 
  70         logger.debug( "transactionId is: " + transactionId)
 
  71         String correlator = requestId
 
  72         String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator
 
  73         String profileJson = objectMapper.writeValueAsString(profileInfo);
 
  74         String nsstInfoListString = objectMapper.writeValueAsString(nsstInfoList);
 
  75         //Prepare requestInfo object
 
  76         JsonObject requestInfo = new JsonObject()
 
  77         requestInfo.addProperty("transactionId", transactionId)
 
  78         requestInfo.addProperty("requestId", requestId)
 
  79         requestInfo.addProperty("callbackUrl", callbackUrl)
 
  80         requestInfo.addProperty("sourceId","SO" )
 
  81         requestInfo.addProperty("timeout", 600)
 
  82         requestInfo.addProperty("numSolutions", 1)
 
  84         //Prepare serviceInfo object
 
  85         JsonObject ranNsstInfo = new JsonObject()
 
  86         ranNsstInfo.addProperty("UUID", UUID)
 
  87         ranNsstInfo.addProperty("invariantUUID", invariantUUID)
 
  88         ranNsstInfo.addProperty("name", name)
 
  90         JsonObject json = new JsonObject()
 
  91         json.add("requestInfo", requestInfo)
 
  92         json.add("NSTInfo", ranNsstInfo)
 
  93         json.add("serviceProfile", (JsonObject) parser.parse(profileJson))
 
  94         //json.add("NSSTInfo", (JsonArray) parser.parse(nsstInfoListString))
 
  95         json.add("subnetCapabilities", capabilitiesList)
 
  96         json.addProperty("preferReuse", preferReuse)
 
  98         return json.toString()
 
 101 public String buildCreateTNNSSMFSubnetCapabilityRequest() {
 
 102         JsonObject esrInfo = new JsonObject()
 
 103         esrInfo.addProperty("networkType", "tn")
 
 104         esrInfo.addProperty("vendor", "ONAP_internal")
 
 106         JsonArray subnetTypes = new JsonArray()
 
 107         subnetTypes.add("TN_FH")
 
 108         subnetTypes.add("TN_MH")
 
 109         JsonObject response = new JsonObject()
 
 110         JsonObject subnetTypesObj = new JsonObject()
 
 111         subnetTypesObj.add("subnetTypes", subnetTypes)
 
 112         response.add("subnetCapabilityQuery", subnetTypesObj)
 
 113         response.add("esrInfo", esrInfo)
 
 114         return response.toString()
 
 117 public String buildCreateANNFNSSMFSubnetCapabilityRequest() {
 
 118         JsonObject esrInfo = new JsonObject()
 
 119         esrInfo.addProperty("networkType", "an")
 
 120         esrInfo.addProperty("vendor", "ONAP_internal")
 
 122         JsonArray subnetTypes = new JsonArray()
 
 123         subnetTypes.add("AN_NF")
 
 124         JsonObject response = new JsonObject()
 
 125         JsonObject subnetTypesObj = new JsonObject()
 
 126         subnetTypesObj.add("subnetTypes", subnetTypes)
 
 127         response.add("subnetCapabilityQuery", subnetTypesObj)
 
 128         response.add("esrInfo", esrInfo)
 
 129         return response.toString()
 
 131 public void createDomainWiseSliceProfiles(List<String> ranConstituentSliceProfiles, DelegateExecution execution) {
 
 133         for(String profile : ranConstituentSliceProfiles) {
 
 134                 String domainType = jsonUtil.getJsonValue(profile, "domainType")
 
 137                                 execution.setVariable("ranNfSliceProfile", profile)
 
 140                                 execution.setVariable("tnFhSliceProfile", profile)
 
 143                                 execution.setVariable("tnMhSliceProfile", profile)
 
 146                                 logger.debug("No expected match found for current domainType")
 
 147                                 logger.error("No expected match found for current domainType "+ domainType)
 
 148                                 exceptionUtil.buildAndThrowWorkflowException(execution, 1000,"No expected match found for current domainType "+ domainType)
 
 154 public void createSliceProfilesInAai(DelegateExecution execution) {
 
 156         org.onap.aai.domain.yang.ServiceInstance ANNF_sliceProfileInstance = new ServiceInstance();
 
 157         org.onap.aai.domain.yang.ServiceInstance TNFH_sliceProfileInstance = new ServiceInstance();
 
 158         org.onap.aai.domain.yang.ServiceInstance TNMH_sliceProfileInstance = new ServiceInstance();
 
 159         //generate slice profile ids and slice profile instance ids
 
 160         String ANNF_sliceProfileInstanceId = UUID.randomUUID().toString()
 
 161         String ANNF_sliceProfileId = UUID.randomUUID().toString()
 
 162         String TNFH_sliceProfileInstanceId = UUID.randomUUID().toString()
 
 163         String TNFH_sliceProfileId = UUID.randomUUID().toString()
 
 164         String TNMH_sliceProfileInstanceId = UUID.randomUUID().toString()
 
 165         String TNMH_sliceProfileId = UUID.randomUUID().toString()
 
 166         execution.setVariable("ANNF_sliceProfileInstanceId",ANNF_sliceProfileInstanceId)
 
 167         execution.setVariable("ANNF_sliceProfileId",ANNF_sliceProfileId)
 
 168         execution.setVariable("TNFH_sliceProfileInstanceId",TNFH_sliceProfileInstanceId)
 
 169         execution.setVariable("TNFH_sliceProfileId",TNFH_sliceProfileId)
 
 170         execution.setVariable("TNMH_sliceProfileInstanceId",TNMH_sliceProfileInstanceId)
 
 171         execution.setVariable("TNMH_sliceProfileId",TNMH_sliceProfileId)
 
 172         //slice profiles assignment
 
 173         org.onap.aai.domain.yang.SliceProfiles ANNF_SliceProfiles = new SliceProfiles()
 
 174         org.onap.aai.domain.yang.SliceProfiles TNFH_SliceProfiles = new SliceProfiles()
 
 175         org.onap.aai.domain.yang.SliceProfiles TNMH_SliceProfiles = new SliceProfiles()
 
 176         org.onap.aai.domain.yang.SliceProfile ANNF_SliceProfile = new SliceProfile()
 
 177         org.onap.aai.domain.yang.SliceProfile TNFH_SliceProfile = new SliceProfile()
 
 178         org.onap.aai.domain.yang.SliceProfile TNMH_SliceProfile = new SliceProfile()
 
 179         ANNF_SliceProfile = createSliceProfile("AN-NF", execution)
 
 180         TNFH_SliceProfile = createSliceProfile("TN-FH",execution)
 
 181         TNMH_SliceProfile = createSliceProfile("TN-MH",execution)
 
 183         ANNF_SliceProfiles.getSliceProfile().add(ANNF_SliceProfile)
 
 184         TNFH_SliceProfiles.getSliceProfile().add(TNFH_SliceProfile)
 
 185         TNMH_SliceProfiles.getSliceProfile().add(TNMH_SliceProfile)
 
 187         logger.debug("sliceProfiles : 1. "+ANNF_SliceProfiles.toString()+"\n 2. "+TNFH_SliceProfiles.toString()+"\n 3. "+TNMH_SliceProfiles.toString())
 
 188         //ANNF slice profile instance creation
 
 189         ANNF_sliceProfileInstance.setServiceInstanceId(ANNF_sliceProfileInstanceId)
 
 190         String sliceInstanceName = "sliceprofile_"+ANNF_sliceProfileId
 
 191         ANNF_sliceProfileInstance.setServiceInstanceName(sliceInstanceName)
 
 192         String serviceType = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "sST")
 
 193         ANNF_sliceProfileInstance.setServiceType(serviceType)
 
 194         String serviceStatus = "deactivated"
 
 195         ANNF_sliceProfileInstance.setOrchestrationStatus(serviceStatus)
 
 196         String serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "pLMNIdList")
 
 197         ANNF_sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
 
 198         String serviceRole = "slice-profile-instance"
 
 199         ANNF_sliceProfileInstance.setServiceRole(serviceRole)
 
 200         ArrayList<String> snssaiList = execution.getVariable("snssaiList")
 
 201         String snssai = snssaiList.get(0)
 
 202         ANNF_sliceProfileInstance.setEnvironmentContext(snssai)
 
 203         ANNF_sliceProfileInstance.setWorkloadContext("AN-NF")    
 
 204         ANNF_sliceProfileInstance.setSliceProfiles(ANNF_SliceProfiles)
 
 205         String serviceFunctionAnnf = jsonUtil.getJsonValue(execution.getVariable("ranNfSliceProfile"), "resourceSharingLevel")
 
 206         ANNF_sliceProfileInstance.setServiceFunction(serviceFunctionAnnf)
 
 207         logger.debug("completed ANNF sliceprofileinstance build : "+ ANNF_sliceProfileInstance.toString())
 
 209         //TNFH slice profile instance creation
 
 210         TNFH_sliceProfileInstance.setServiceInstanceId(TNFH_sliceProfileInstanceId)
 
 211         sliceInstanceName = "sliceprofile_"+TNFH_sliceProfileId
 
 212         TNFH_sliceProfileInstance.setServiceInstanceName(sliceInstanceName)
 
 213         serviceType = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "sST")
 
 214         TNFH_sliceProfileInstance.setServiceType(serviceType)
 
 215         TNFH_sliceProfileInstance.setOrchestrationStatus(serviceStatus)
 
 216         serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "pLMNIdList")
 
 217         TNFH_sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
 
 218         TNFH_sliceProfileInstance.setServiceRole(serviceRole)
 
 219         TNFH_sliceProfileInstance.setEnvironmentContext(snssai)
 
 220         TNFH_sliceProfileInstance.setWorkloadContext("TN-FH")
 
 221         TNFH_sliceProfileInstance.setSliceProfiles(TNFH_SliceProfiles)
 
 222         String serviceFunctionTnFH = jsonUtil.getJsonValue(execution.getVariable("tnFhSliceProfile"), "resourceSharingLevel")
 
 223         TNFH_sliceProfileInstance.setServiceFunction(serviceFunctionTnFH)
 
 224         logger.debug("completed TNFH sliceprofileinstance build : "+TNFH_sliceProfileInstance)
 
 226         //TNMH slice profile instance creation
 
 227         TNMH_sliceProfileInstance.setServiceInstanceId(TNMH_sliceProfileInstanceId)
 
 228         sliceInstanceName = "sliceprofile_"+TNMH_sliceProfileId
 
 229         TNMH_sliceProfileInstance.setServiceInstanceName(sliceInstanceName)
 
 230         serviceType = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "sST")
 
 231         TNMH_sliceProfileInstance.setServiceType(serviceType)
 
 232         TNMH_sliceProfileInstance.setOrchestrationStatus(serviceStatus)
 
 233         serviceInstanceLocationid = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "pLMNIdList")
 
 234         TNMH_sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
 
 235         TNMH_sliceProfileInstance.setServiceRole(serviceRole)
 
 236         TNMH_sliceProfileInstance.setEnvironmentContext(snssai)
 
 237         TNMH_sliceProfileInstance.setWorkloadContext("TN-MH")
 
 238         TNMH_sliceProfileInstance.setSliceProfiles(TNMH_SliceProfiles)
 
 239         String serviceFunctionTnMH = jsonUtil.getJsonValue(execution.getVariable("tnMhSliceProfile"), "resourceSharingLevel")
 
 240         TNMH_sliceProfileInstance.setServiceFunction(serviceFunctionTnMH)
 
 241         logger.debug("completed TNMH sliceprofileinstance build : "+TNMH_sliceProfileInstance)
 
 246                 AAIResourcesClient client = new AAIResourcesClient()
 
 247                 AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(ANNF_sliceProfileInstanceId))
 
 248                 client.create(sliceProfileUri, ANNF_sliceProfileInstance)
 
 250                 AAIResourceUri sliceProfileUri1 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(TNFH_sliceProfileInstanceId))
 
 251                 client.create(sliceProfileUri1, TNFH_sliceProfileInstance)
 
 253                 AAIResourceUri sliceProfileUri2 = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(TNMH_sliceProfileInstanceId))
 
 254                 client.create(sliceProfileUri2, TNMH_sliceProfileInstance)
 
 256         } catch (BpmnError e) {
 
 258         } catch (Exception ex) {
 
 259                 msg = "Exception in AnNssmfUtils.createSliceProfilesInAai " + ex.getMessage()
 
 261                 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
 
 265 private SliceProfile createSliceProfile(String domainType, DelegateExecution execution) {
 
 267         SliceProfile result = new SliceProfile()
 
 268         Map<String,Object> profile
 
 271                         profile = objectMapper.readValue(execution.getVariable("ranNfSliceProfile"), Map.class)//pending fields - maxBandwidth, sST, pLMNIdList, cSReliabilityMeanTime, 
 
 272                                                                                                                                                                                                         //msgSizeByte, maxNumberofPDUSessions,overallUserDensity,transferIntervalTarget
 
 273                         result.setJitter(profile.get("jitter"))
 
 274                         result.setLatency(profile.get("latency"))
 
 275                         result.setResourceSharingLevel(profile.get("resourceSharingLevel"))
 
 276                         result.setUeMobilityLevel(profile.get("uEMobilityLevel"))
 
 277                         result.setMaxNumberOfUEs(profile.get("maxNumberofUEs"))
 
 278                         result.setActivityFactor(profile.get("activityFactor"))
 
 279                         result.setCoverageAreaTAList(profile.get("coverageAreaTAList"))
 
 280                         result.setExpDataRateDL(profile.get("expDataRateDL"))
 
 281                         result.setExpDataRateUL(profile.get("expDataRateUL"))
 
 282                         result.setSurvivalTime(profile.get("survivalTime"))
 
 283                         result.setAreaTrafficCapDL(profile.get("areaTrafficCapDL"))
 
 284                         result.setAreaTrafficCapUL(profile.get("areaTrafficCapUL"))
 
 285                         result.setExpDataRate(profile.get("expDataRate"))
 
 286                         result.setProfileId(execution.getVariable("ANNF_sliceProfileId"))
 
 289                         profile = objectMapper.readValue(execution.getVariable("tnFhSliceProfile"), Map.class) //pending fields - maxBandwidth, sST, pLMNIdList
 
 290                         result.setJitter(profile.get("jitter"))
 
 291                         result.setLatency(profile.get("latency"))
 
 292                         result.setResourceSharingLevel(profile.get("resourceSharingLevel"))
 
 293                         result.setProfileId(execution.getVariable("TNFH_sliceProfileId"))
 
 296                         profile = objectMapper.readValue(execution.getVariable("tnMhSliceProfile"), Map.class)//pending fields - maxBandwidth, sST, pLMNIdList
 
 297                         result.setJitter(profile.get("jitter"))
 
 298                         result.setLatency(profile.get("latency"))
 
 299                         result.setResourceSharingLevel(profile.get("resourceSharingLevel"))
 
 300                         result.setProfileId(execution.getVariable("TNMH_sliceProfileId"))
 
 303                         logger.debug("No expected match found for current domainType")
 
 304                         logger.error("No expected match found for current domainType "+ domainType)
 
 305                         exceptionUtil.buildAndThrowWorkflowException(execution, 1000,"No expected match found for current domainType "+ domainType)
 
 311      * create relationship in AAI
 
 313     public createRelationShipInAAI = { DelegateExecution execution, final Relationship relationship, String instanceId ->
 
 314         logger.debug("createRelationShipInAAI Start")
 
 316                 AAIResourcesClient client = new AAIResourcesClient()
 
 318             AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(instanceId)).relationshipAPI()
 
 319             client.create(uri, relationship)
 
 321         } catch (BpmnError e) {
 
 323         } catch (Exception ex) {
 
 324             msg = "Exception in AN NSSMF Utils : CreateRelationShipInAAI. " + ex.getMessage()
 
 326             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
 
 328         logger.debug("createRelationShipInAAI Exit")
 
 332         public void processRanNfModifyRsp(DelegateExecution execution) {
 
 333                 String status = execution.getVariable("ranNfStatus")
 
 334                 if(status.equals("success")) {
 
 335                         logger.debug("completed Ran NF NSSI modification ... proceeding with the flow")
 
 338                         logger.error("failed to modify ran Nf nssi")
 
 339                         exceptionUtil.buildAndThrowWorkflowException(execution, 1000, "modify ran nf nssi not successfull")
 
 343         public String buildCreateNSSMFRequest(DelegateExecution execution, String domainType, String action) {
 
 344                 JsonObject esrInfo = new JsonObject()
 
 345             esrInfo.addProperty("networkType", "tn")
 
 346             esrInfo.addProperty("vendor", "ONAP_internal")
 
 347                 JsonObject response = new JsonObject()
 
 348                 JsonObject allocateTnNssi = new JsonObject()
 
 349                 JsonObject serviceInfo = new JsonObject()
 
 350                 JsonArray transportSliceNetworksList  = new JsonArray()
 
 351                 JsonArray connectionLinksList = new JsonArray()
 
 352                 JsonObject connectionLinks = new JsonObject()
 
 353                 if(action.equals("allocate")){
 
 354                         Map<String, String> endpoints
 
 355                         if(domainType.equals("TN_FH")) {
 
 356                                 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNFH_modelInvariantUuid"))
 
 357                                 serviceInfo.addProperty("serviceUuid", execution.getVariable("TNFH_modelUuid"))
 
 358                                 allocateTnNssi.addProperty("nsstId", execution.getVariable("TNFH_modelUuid"))
 
 359                                 allocateTnNssi.addProperty("nssiName", execution.getVariable("TNFH_modelName"))
 
 360                                 Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("tnFhSliceProfile"), Map.class)
 
 361                                 sliceProfile.put("sliceProfileId", execution.getVariable("TNFH_sliceProfileInstanceId"))
 
 362                                 String sliceProfileString = objectMapper.writeValueAsString(sliceProfile)
 
 363                                 allocateTnNssi.addProperty("sliceProfile", sliceProfileString)
 
 364                                 endpoints.put("transportEndpointA", execution.getVariable("tranportEp_ID_RU"))
 
 365                                 endpoints.put("transportEndpointB", execution.getVariable("tranportEp_ID_DUIN"))
 
 366                                 String endpointsString = objectMapper.writeValueAsString(endpoints)
 
 367                                 connectionLinksList.add(endpointsString)
 
 368                         }else if(domainType.equals("TN_MH")) {
 
 369                                 serviceInfo.addProperty("serviceInvariantUuid", execution.getVariable("TNMH_modelInvariantUuid"))
 
 370                                 serviceInfo.addProperty("serviceUuid", execution.getVariable("TNMH_modelUuid"))
 
 371                                 allocateTnNssi.addProperty("nsstId", execution.getVariable("TNMH_modelUuid"))
 
 372                                 allocateTnNssi.addProperty("nssiName", execution.getVariable("TNMH_modelName"))
 
 373                                 Map<String,Object> sliceProfile = objectMapper.readValue(execution.getVariable("tnMhSliceProfile"), Map.class)
 
 374                                 sliceProfile.put("sliceProfileId", execution.getVariable("TNMH_sliceProfileInstanceId"))
 
 375                                 String sliceProfileString = objectMapper.writeValueAsString(sliceProfile)
 
 376                                 allocateTnNssi.addProperty("sliceProfile", sliceProfileString)
 
 377                                 endpoints.put("transportEndpointA", execution.getVariable("tranportEp_ID_DUEG"))
 
 378                                 endpoints.put("transportEndpointB", execution.getVariable("tranportEp_ID_CUIN"))
 
 379                                 String endpointsString = objectMapper.writeValueAsString(endpoints)
 
 380                                 connectionLinksList.add(endpointsString)
 
 384                         connectionLinks.add("connectionLinks", connectionLinksList)
 
 385                         transportSliceNetworksList.add(connectionLinks)
 
 386                         allocateTnNssi.add("transportSliceNetworks", transportSliceNetworksList)
 
 387                         allocateTnNssi.addProperty("nssiId", null)
 
 388                         serviceInfo.addProperty("nssiId", null)
 
 389                 }else if(action.equals("modify-allocate")) {
 
 390                         if(domainType.equals("TN_FH")) {
 
 391                                 serviceInfo.addProperty("serviceInvariantUuid", null)
 
 392                                 serviceInfo.addProperty("serviceUuid", null)
 
 393                                 allocateTnNssi.addProperty("nsstId", null)
 
 394                                 allocateTnNssi.addProperty("nssiName", execution.getVariable("TNFH_nssiName"))
 
 395                                 allocateTnNssi.addProperty("sliceProfileId", execution.getVariable("TNFH_sliceProfileInstanceId"))
 
 396                                 allocateTnNssi.addProperty("nssiId", execution.getVariable("TNFH_NSSI"))
 
 397                                 serviceInfo.addProperty("nssiId", execution.getVariable("TNFH_NSSI"))
 
 398                         }else if(domainType.equals("TN_MH")) {
 
 399                                 serviceInfo.addProperty("serviceInvariantUuid", null)
 
 400                                 serviceInfo.addProperty("serviceUuid", null)
 
 401                                 allocateTnNssi.addProperty("nsstId", null)
 
 402                                 allocateTnNssi.addProperty("nssiName", execution.getVariable("TNMH_nssiName"))
 
 403                                 allocateTnNssi.addProperty("sliceProfileId", execution.getVariable("TNMH_sliceProfileInstanceId"))
 
 404                                 allocateTnNssi.addProperty("nssiId", execution.getVariable("TNMH_NSSI"))
 
 405                                 serviceInfo.addProperty("nssiId", execution.getVariable("TNMH_NSSI"))
 
 408                 String nsiInfo = jsonUtil.getJsonValue(execution.getVariable("sliceParams"), "nsiInfo")
 
 409                 allocateTnNssi.addProperty("nsiInfo", nsiInfo)
 
 410                 allocateTnNssi.addProperty("scriptName", "TN1")
 
 411                 serviceInfo.addProperty("nsiId", execution.getVariable("nsiId"))
 
 412                 serviceInfo.addProperty("globalSubscriberId", execution.getVariable("globalSubscriberId"))
 
 413                 serviceInfo.addProperty("subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
 
 414                 response.add("esrInfo", esrInfo)
 
 415                 response.add("serviceInfo", serviceInfo)
 
 416                 response.add("allocateTnNssi", allocateTnNssi)
 
 417                 return response.toString()
 
 420         public String buildDeallocateNssiRequest(DelegateExecution execution,String domainType) {
 
 421                 String globalSubscriberId = execution.getVariable("globalSubscriberId")
 
 422                 String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
 
 424                 JsonObject deAllocateNssi = new JsonObject()
 
 425                 deAllocateNssi.addProperty("snssaiList", execution.getVariable("snssaiList"))
 
 426                 deAllocateNssi.addProperty("nsiId", execution.getVariable("nsiId"))
 
 427                 deAllocateNssi.addProperty("modifyAction", true)
 
 428                 deAllocateNssi.addProperty("terminateNssiOption", 0)
 
 429                 deAllocateNssi.addProperty("scriptName", "TN1")
 
 431                 if(domainType.equals("TN_FH")) {
 
 432                         deAllocateNssi.addProperty("nssiId", execution.getVariable("TNFH_NSSI"))
 
 433                         deAllocateNssi.addProperty("sliceProfileId", execution.getVariable("TNFH_sliceProfileInstanceId"))
 
 434                 }else if(domainType.equals("TN_MH")) {
 
 435                         deAllocateNssi.addProperty("nssiId", execution.getVariable("TNMH_NSSI"))
 
 436                         deAllocateNssi.addProperty("sliceProfileId", execution.getVariable("TNMH_sliceProfileInstanceId"))
 
 439                 JsonObject esrInfo = new JsonObject()
 
 440             esrInfo.addProperty("networkType", "tn")
 
 441             esrInfo.addProperty("vendor", "ONAP_internal")
 
 443                 JsonObject serviceInfo = new JsonObject()
 
 444                 serviceInfo.addProperty("serviceInvariantUuid", null)
 
 445                 serviceInfo.addProperty("serviceUuid", null)
 
 446                 serviceInfo.addProperty("globalSubscriberId", globalSubscriberId)
 
 447                 serviceInfo.addProperty("subscriptionServiceType", subscriptionServiceType)
 
 449                 JsonObject json = new JsonObject()
 
 450                 json.add("deAllocateNssi", deAllocateNssi)
 
 451                 json.add("esrInfo", esrInfo)
 
 452                 json.add("serviceInfo", serviceInfo)
 
 453                 return json.toString()