Merge "Fix Critical & Major issues in adapters"
[so.git] / bpmn / so-bpmn-infrastructure-common / src / main / groovy / org / onap / so / bpmn / infrastructure / scripts / DoCreateSliceServiceOption.groovy
1 package org.onap.so.bpmn.infrastructure.scripts
2
3 import com.fasterxml.jackson.core.type.TypeReference
4 import groovy.json.JsonBuilder
5 import groovy.json.JsonSlurper
6 import org.camunda.bpm.engine.delegate.BpmnError
7 import org.camunda.bpm.engine.delegate.DelegateExecution
8 import org.onap.aai.domain.yang.Relationship
9 import org.onap.aai.domain.yang.RelationshipList
10 import org.onap.aai.domain.yang.ServiceInstance
11 import org.onap.logging.filter.base.ONAPComponents
12 import org.onap.so.beans.nsmf.SliceTaskParams
13 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
14 import org.onap.so.bpmn.common.scripts.ExceptionUtil
15 import org.onap.so.bpmn.common.scripts.OofUtils
16 import org.onap.so.bpmn.core.UrnPropertiesReader
17 import org.onap.so.bpmn.core.domain.ServiceDecomposition
18 import org.onap.so.bpmn.core.domain.ServiceProxy
19 import org.onap.so.bpmn.core.json.JsonUtils
20 import org.onap.so.client.HttpClient
21 import org.onap.so.client.HttpClientFactory
22 import org.onap.so.client.aai.AAIObjectType
23 import org.onap.so.client.aai.AAIResourcesClient
24 import org.onap.so.client.aai.entities.AAIResultWrapper
25 import org.onap.so.client.aai.entities.uri.AAIResourceUri
26 import org.onap.so.client.aai.entities.uri.AAIUriFactory
27 import org.onap.so.db.request.client.RequestsDbClient
28 import org.onap.so.db.request.beans.OrchestrationTask
29 import org.slf4j.Logger
30 import org.slf4j.LoggerFactory
31 import javax.ws.rs.NotFoundException
32 import javax.ws.rs.core.Response
33
34 import static org.apache.commons.lang3.StringUtils.isBlank
35
36 public class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
37
38     private static final Logger logger = LoggerFactory.getLogger( DoCreateSliceServiceOption.class)
39
40
41     ExceptionUtil exceptionUtil = new ExceptionUtil()
42
43     JsonUtils jsonUtil = new JsonUtils()
44
45     RequestsDbClient requestsDbClient = new RequestsDbClient()
46
47     OofUtils oofUtils = new OofUtils()
48
49     /**
50      * Pre Process the BPMN Flow Request
51      * Inclouds:
52      * generate the nsOperationKey
53      * generate the nsParameters
54      */
55     void preProcessRequest (DelegateExecution execution) {
56         String msg = ""
57         logger.trace("Enter preProcessRequest()")
58         String taskID = execution.getVariable("taskID")
59         Boolean isSharable = true
60         String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
61         if (resourceSharingLevel.equals("shared"))
62             isSharable = true
63         execution.setVariable("isSharable",isSharable)
64         logger.trace("Exit preProcessRequest")
65
66     }
67
68
69     void getNSIOptionfromOOF(DelegateExecution execution) {
70
71         String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
72         logger.debug( "get NSI option OOF Url: " + urlString)
73         boolean isNSISuggested = true
74         execution.setVariable("isNSISuggested",isNSISuggested)
75         String nsiInstanceId = ""
76         String nsiName = ""
77         SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
78         //Prepare auth for OOF - Begin
79         def authHeader = ""
80         String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution)
81         String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution)
82
83         String basicAuthValue = utils.encrypt(basicAuth, msokey)
84         if (basicAuthValue != null) {
85             logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue)
86             try {
87                 authHeader = utils.getBasicAuth(basicAuthValue, msokey)
88                 execution.setVariable("BasicAuthHeaderValue", authHeader)
89             } catch (Exception ex) {
90                 logger.debug( "Unable to encode username and password string: " + ex)
91                 exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " +
92                         "encode username and password string")
93             }
94         } else {
95             logger.debug( "Unable to obtain BasicAuth - BasicAuth value null")
96             exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " +
97                     "value null")
98         }
99         //Prepare auth for OOF - End
100
101         String requestId = execution.getVariable("msoRequestId")
102         Map<String, Object> profileInfo = execution.getVariable("serviceProfile")
103         String nstModelUuid = execution.getVariable("nstModelUuid")
104         String nstModelInvariantUuid = execution.getVariable("nstModelInvariantUuid")
105         String nstInfo = """"NSTInfo" : {
106         "invariantUUID":"${nstModelInvariantUuid}",
107         "UUID":"${nstModelUuid}"
108          }"""
109
110         String oofRequest = oofUtils.buildSelectNSIRequest(execution, requestId, nstInfo, profileInfo)
111
112         //send request to get NSI option - Begin
113         URL url = new URL(urlString+"/api/oof/v1/selectnsi")
114         HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.OOF)
115         httpClient.addAdditionalHeader("Authorization", authHeader)
116         Response httpResponse = httpClient.post(oofRequest)
117
118         int responseCode = httpResponse.getStatus()
119         logger.debug("OOF sync response code is: " + responseCode)
120
121         if(responseCode != 200){
122             exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.")
123             logger.debug("Info: No NSI suggested by OOF" )
124         }
125
126         if(httpResponse.hasEntity()){
127             String OOFResponse = httpResponse.readEntity(String.class)
128             execution.setVariable("OOFResponse", OOFResponse)
129             int index = 0   //This needs to be changed to derive a value when we add policy to decide the solution options.
130             Map OOFResponseObject = new JsonSlurper().parseText(OOFResponse)
131             if(execution.getVariable("isSharable" )  == true && OOFResponseObject.get("solutions").containsKey("sharedNSIsolutions")) {
132                 nsiInstanceId = OOFResponseObject.get("solutions").get("sharedNSIsolutions").get(0).get("NSISolution").NSIId
133                 nsiName = OOFResponseObject.get("solutions").get("sharedNSIsolutions").get(0).get("NSISolution").NSIName
134                 sliceTaskParams.setNstId(nsiInstanceId)
135                 sliceTaskParams.setSuggestNsiName(nsiName)
136                 execution.setVariable("nsiInstanceId",nsiInstanceId)
137                 execution.setVariable("nsiName",nsiName)
138             }else {
139                 if(OOFResponseObject.get("solutions").containsKey("newNSISolutions")) {
140                     List NSSImap = OOFResponseObject.get("solutions").get("newNSISolutions").get(index).get("NSSISolutions")
141                     for(Map nssi :  NSSImap) {
142                         String nssiName = nssi.get("NSSISolution").NSSIName
143                         String nssiId = nssi.get("NSSISolution").NSSIId
144                         String domain = nssi.get("NSSISolution").domain.toUpperCase()
145                         switch (domain) {
146                             case "AN":
147                                 sliceTaskParams.setAnSuggestNssiId(nssiId)
148                                 sliceTaskParams.setAnSuggestNssiName(nssiName)
149                                 break;
150                             case "CN":
151                                 sliceTaskParams.setCnSuggestNssiId(nssiId)
152                                 sliceTaskParams.setCnSuggestNssiName(nssiName)
153                                 break;
154                             case "TN":
155                                 sliceTaskParams.setTnSuggestNssiId(nssiId)
156                                 sliceTaskParams.setTnSuggestNssiName(nssiName)
157                                 break;
158                             default:
159                                 break;
160                         }
161                     }
162                 }
163
164             }
165             execution.setVariable("sliceTaskParams", sliceTaskParams)
166             logger.debug("Info: No NSI suggested by OOF" )
167         }
168         //send request to get NSI option - Begin
169
170
171         //send request to get NSI service Info - Begin
172
173         /***
174          * Need to check whether its needed.
175          */
176 //            logger.debug("Begin to query OOF suggetsed NSI from AAI ")
177 //            if(isBlank(nsiInstanceId)){
178 //                isNSISuggested = false
179 //                execution.setVariable("isNSISuggested",isNSISuggested)
180 //            }else
181 //            {
182 //                try {
183 //                    String globalSubscriberId = execution.getVariable('globalSubscriberId')
184 //                    String serviceType = execution.getVariable('subscriptionServiceType')
185 //                    AAIResourcesClient resourceClient = new AAIResourcesClient()
186 //                    AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nsiInstanceId)
187 //                    AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class)
188 //                    Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class)
189 //                    org.onap.aai.domain.yang.ServiceInstance nsiServiceInstance = si.get()
190 //                    execution.setVariable("nsiServiceInstance",nsiServiceInstance)
191 //                    isNSISuggested = true
192 //                    execution.setVariable("isNSISuggested",isNSISuggested)
193 //                    SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
194 //                    sliceTaskParams.setSuggestNsiId(nsiInstanceId)
195 //                    sliceTaskParams.setSuggestNsiName(si.get().getServiceInstanceName())
196 //                    execution.setVariable("sliceTaskParams", sliceTaskParams)
197 //                    logger.debug("Info: NSI suggested by OOF exist in AAI ")
198 //                }catch(BpmnError e) {
199 //                    throw e
200 //                }catch(Exception ex) {
201 //                    String msg = "Internal Error in getServiceInstance: " + ex.getMessage()
202 //                    //exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
203 //                    logger.debug("Info: NSI suggested by OOF doesnt exist in AAI " + nsiInstanceId)
204 //                }
205 //            }
206         //send request to get NSI service Info - End
207         //${OrchestrationTaskHandler.createOrchestrationTask(execution.getVariable("OrchestrationTask"))}
208         logger.debug( "*** Completed options Call to OOF ***")
209
210     }
211
212
213     public void parseServiceProfile(DelegateExecution execution) {
214         logger.debug("Start parseServiceProfile")
215         String serviceType = execution.getVariable("serviceType")
216         Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
217
218         // set sliceProfile for three domains
219         Map<String, Object> sliceProfileTn = getSliceProfile(serviceType, "TN", serviceProfile)
220         Map<String, Object> sliceProfileCn = getSliceProfile(serviceType, "CN", serviceProfile)
221         Map<String, Object> sliceProfileAn = getSliceProfile(serviceType, "AN", serviceProfile)
222
223         execution.setVariable("sliceProfileTn", sliceProfileTn)
224         execution.setVariable("sliceProfileCn", sliceProfileCn)
225         execution.setVariable("sliceProfileAn", sliceProfileAn)
226         logger.debug("sliceProfileTn: " + sliceProfileTn)
227         logger.debug("sliceProfileCn: " + sliceProfileCn)
228         logger.debug("sliceProfileAn: " + sliceProfileAn)
229
230         logger.debug("Finish parseServiceProfile")
231     }
232
233     public Map getSliceProfile(String serviceType, String domain, Map<String, Object> serviceProfile) {
234         String variablePath = "nsmf." + serviceType + ".profileMap" + domain
235         String profileMapStr = UrnPropertiesReader.getVariable(variablePath)
236         logger.debug("Profile map for " + domain + " : " + profileMapStr)
237         Map<String, String> profileMaps = objectMapper.readValue(profileMapStr, new TypeReference<Map<String, String>>(){})
238         Map<String, Object> sliceProfileTn = [:]
239         for (Map.Entry<String, String> profileMap : profileMaps) {
240             sliceProfileTn.put(profileMap.key, serviceProfile.get(profileMap.value))
241         }
242
243         return sliceProfileTn
244     }
245
246
247     void prepareNSSIList(DelegateExecution execution)
248     {
249         ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
250         List<String> nssiAssociated = new ArrayList<>()
251         Map<String, String> nssimap = new HashMap<>()
252         String nsiInstanceId=execution.getVariable("nsiInstanceId")
253         String globalSubscriberId = execution.getVariable("globalSubscriberId")
254         String serviceType = execution.getVariable("subscriptionServiceType")
255
256         try {
257
258             ServiceInstance si = execution.getVariable("nsiServiceInstance")
259             //List<Relationship> relationships = si.getRelationshipList().getRelationship().stream().filter(relation ->
260             //        relation.getRelatedTo().equalsIgnoreCase("service-instance"))
261             RelationshipList relationshipList = si.getRelationshipList()
262             List<Relationship> relationships = relationshipList.getRelationship()
263             for(Relationship relationship in relationships)
264             {
265                 if(relationship.getRelatedTo().equalsIgnoreCase("service-instance"))
266                 {
267                     String NSSIassociated = relationship.getRelatedLink().substring(relationship.getRelatedLink().lastIndexOf("/") + 1);
268                     if(!NSSIassociated.equals(nsiInstanceId))
269                         nssiAssociated.add(NSSIassociated)
270                 }
271             }
272         }catch(BpmnError e) {
273             throw e
274         }catch(Exception ex) {
275             String msg = "Internal Error in getServiceInstance: " + ex.getMessage()
276             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
277         }
278         Map<String, Object> params = execution.getVariable("params")
279         SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
280         for(String nssiID in nssiAssociated)
281         {
282             try {
283                 AAIResourcesClient resourceClient = new AAIResourcesClient()
284                 AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nssiID)
285                 AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class)
286                 Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class)
287                 org.onap.aai.domain.yang.ServiceInstance nssi = si.get()
288
289                 String domain = nssi.getEnvironmentContext().toString().toUpperCase()
290                 switch (domain) {
291                     case "AN":
292                         sliceTaskParams.setAnSuggestNssiId(nssi.getServiceInstanceId())
293                         sliceTaskParams.setAnSuggestNssiName(nssi.getServiceInstanceName())
294                         break;
295                     case "CN":
296                         sliceTaskParams.setCnSuggestNssiId(nssi.getServiceInstanceId())
297                         sliceTaskParams.setCnSuggestNssiName(nssi.getServiceInstanceName())
298                         break;
299                     case "TN":
300                         sliceTaskParams.setTnSuggestNssiId(nssi.getServiceInstanceId())
301                         sliceTaskParams.setTnSuggestNssiName(nssi.getServiceInstanceName())
302                         break;
303                     default:
304                         break;
305                 }
306             }catch(NotFoundException e)
307             {
308                 logger.debug("NSSI Service Instance not found in AAI: " + nssiID)
309             }catch(Exception e)
310             {
311                 logger.debug("NSSI Service Instance not found in AAI: " + nssiID)
312             }
313
314         }
315         String nstName = serviceDecomposition.getModelInfo().getModelName()
316         sliceTaskParams.setNstName(nstName)
317         String nstId = serviceDecomposition.getModelInfo().getModelUuid()
318         sliceTaskParams.setNstId(nstId)
319         execution.setVariable("sliceTaskParams",sliceTaskParams)
320
321     }
322
323
324     void updateOptionsInDB(DelegateExecution execution) {
325         logger.debug("Updating options with default value since not sharable : Begin ")
326         String taskID = execution.getVariable("taskID")
327         String params = execution.getVariable("params")
328         logger.debug("Updating options with default value since not sharable : End ")
329
330     }
331
332     void prepareNSTDecompose(DelegateExecution execution) {
333
334         String modelUuid = execution.getVariable("nstModelUuid")
335         String modelInvariantUuid = execution.getVariable("nstModelInvariantUuid")
336
337         String serviceModelInfo = """{
338             "modelInvariantUuid":"${modelInvariantUuid}",
339             "modelUuid":"${modelUuid}",
340             "modelVersion":""
341              }"""
342         execution.setVariable("serviceModelInfo", serviceModelInfo)
343     }
344
345     void prepareNSSTDecompose(DelegateExecution execution) {
346         Boolean isMoreNSSTtoProcess = false
347         Integer maxNSST = execution.getVariable("maxNSST")
348         Integer currentNSST=execution.getVariable("currentNSST")
349         List<String> nsstModelUUIDList = new ArrayList<>()
350         nsstModelUUIDList = execution.getVariable("nsstModelUUIDList")
351         String modelUuid = nsstModelUUIDList.get(currentNSST)
352         String serviceModelInfo = """{
353             "modelInvariantUuid":"",
354             "modelUuid":"${modelUuid}",
355             "modelVersion":""
356              }"""
357         execution.setVariable("serviceModelInfo", serviceModelInfo)
358         currentNSST=currentNSST+1
359         if(currentNSST<maxNSST)
360             isMoreNSSTtoProcess=true
361         execution.setVariable("isMoreNSSTtoProcess",isMoreNSSTtoProcess)
362         execution.setVariable("maxNSST",maxNSST)
363         execution.setVariable("currentNSST",currentNSST)
364     }
365
366
367     void updateStatusInDB(DelegateExecution execution) {
368
369         String taskID = execution.getVariable("taskID")
370         //OrchestrationTask orchestrationTask = requestsDbClient.getNetworkSliceOption(taskID);
371         //orchestrationTask.setTaskStage("wait to confirm")
372         //requestsDbClient.updateNetworkSliceOption(orchestrationTask)
373     }
374
375     void prepareNSSTlistfromNST(DelegateExecution execution) {
376         //Need to update this part from decomposition.
377         logger.trace("Enter prepareNSSTlistfromNST()")
378         Boolean isMoreNSSTtoProcess = false
379         ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
380         SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
381         String nstName = serviceDecomposition.getModelInfo().getModelName()
382         sliceTaskParams.setNstName(nstName)
383         String nstId = serviceDecomposition.getModelInfo().getModelUuid()
384         sliceTaskParams.setNstId(nstId)
385         execution.setVariable("sliceTaskParams",sliceTaskParams)
386
387         List<ServiceProxy> proxyList = serviceDecomposition.getServiceProxy()
388         List<String> nsstModelUUIDList = new ArrayList<>()
389         for(ServiceProxy serviceProxy:proxyList)
390             nsstModelUUIDList.add(serviceProxy.getSourceModelUuid())
391         execution.setVariable("nsstModelUUIDList",nsstModelUUIDList)
392         Integer maxNSST = nsstModelUUIDList.size()
393         Integer currentNSST=0
394         execution.setVariable("maxNSST",maxNSST)
395         execution.setVariable("currentNSST",currentNSST)
396         if(currentNSST<maxNSST)
397             isMoreNSSTtoProcess=true
398         execution.setVariable("isMoreNSSTtoProcess",isMoreNSSTtoProcess)
399         logger.trace("Exit prepareNSSTlistfromNST()")
400
401     }
402
403
404     void getNSSTOption(DelegateExecution execution) {
405         ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
406         String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
407         String globalSubscriberId = execution.getVariable("globalSubscriberId")
408         String serviceType = execution.getVariable("subscriptionServiceType")
409         String nssiInstanceId =""
410         String nssiName =""
411         SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
412         logger.debug( "get NSI option OOF Url: " + urlString)
413         boolean isNSISuggested = false
414         execution.setVariable("isNSISuggested",isNSISuggested)
415
416         //Prepare auth for OOF - Begin
417         def authHeader = ""
418         String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution)
419         String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution)
420
421         String basicAuthValue = utils.encrypt(basicAuth, msokey)
422         if (basicAuthValue != null) {
423             logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue)
424             try {
425                 authHeader = utils.getBasicAuth(basicAuthValue, msokey)
426                 execution.setVariable("BasicAuthHeaderValue", authHeader)
427             } catch (Exception ex) {
428                 logger.debug( "Unable to encode username and password string: " + ex)
429                 exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " +
430                         "encode username and password string")
431             }
432         } else {
433             logger.debug( "Unable to obtain BasicAuth - BasicAuth value null")
434             exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " +
435                     "value null")
436         }
437         //Prepare auth for OOF - End
438         //Prepare send request to OOF - Begin
439         String requestId = execution.getVariable("msoRequestId")
440         Map<String, Object> profileInfo = execution.getVariable("serviceProfile")
441         String nsstModelInvariantUuid = serviceDecomposition.getModelInfo().getModelInvariantUuid()
442         String nsstModelUuid = serviceDecomposition.getModelInfo().getModelUuid()
443         String nsstInfo = """"NSSTInfo": {
444         "invariantUUID":"${nsstModelInvariantUuid}",
445         "UUID":"${nsstModelUuid}"
446          }"""
447         String oofRequest = oofUtils.buildSelectNSSIRequest(execution, requestId, nsstInfo ,profileInfo)
448
449
450         URL url = new URL(urlString+"/api/oof/v1/selectnssi")
451         HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.OOF)
452         httpClient.addAdditionalHeader("Authorization", authHeader)
453         Response httpResponse = httpClient.post(oofRequest)
454
455         int responseCode = httpResponse.getStatus()
456         logger.debug("OOF sync response code is: " + responseCode)
457
458         if(responseCode != 200){
459             exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.")
460         }
461
462         if(httpResponse.hasEntity()){
463             String OOFResponse = httpResponse.readEntity(String.class)
464             execution.setVariable("OOFResponse", OOFResponse)
465             nssiInstanceId = jsonUtil.getJsonValue(OOFResponse, "NSSIIInfo.NSSIID")
466             nssiName = jsonUtil.getJsonValue(OOFResponse, "NSSIInfo.NSSIName")
467             execution.setVariable("nssiInstanceId",nssiInstanceId)
468             execution.setVariable("nssiName",nssiName)
469         }
470         if(isBlank(nssiInstanceId)){
471             logger.debug( "There is no valid NSST suggested by OOF.")
472         }else
473         {
474             try {
475                 AAIResourcesClient resourceClient = new AAIResourcesClient()
476                 AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nssiInstanceId)
477                 AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class)
478                 Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class)
479                 org.onap.aai.domain.yang.ServiceInstance nssi = si.get()
480
481                 String domain = nssi.getEnvironmentContext().toString().toUpperCase()
482                 switch (domain) {
483                     case "AN":
484                         sliceTaskParams.setAnSuggestNssiId(nssi.getServiceInstanceId())
485                         sliceTaskParams.setAnSuggestNssiName(nssi.getServiceInstanceName())
486                         break;
487                     case "CN":
488                         sliceTaskParams.setCnSuggestNssiId(nssi.getServiceInstanceId())
489                         sliceTaskParams.setCnSuggestNssiName(nssi.getServiceInstanceName())
490                         break;
491                     case "TN":
492                         sliceTaskParams.setTnSuggestNssiId(nssi.getServiceInstanceId())
493                         sliceTaskParams.setTnSuggestNssiName(nssi.getServiceInstanceName())
494                         break;
495                     default:
496                         break;
497                 }
498             }catch(NotFoundException e)
499             {
500                 logger.debug("NSSI Service Instance not found in AAI: " + nssiInstanceId)
501             }catch(Exception e)
502             {
503                 logger.debug("NSSI Service Instance not found in AAI: " + nssiInstanceId)
504             }
505         }
506
507
508         //Prepare send request to OOF - End
509
510 //        String content = serviceDecomposition.getServiceInfo().getServiceArtifact().get(0).getContent()
511 //        String nsstID = jsonUtil.getJsonValue(content, "metadata.id")
512 //        String vendor = jsonUtil.getJsonValue(content, "metadata.vendor")
513 //        String domain = jsonUtil.getJsonValue(content, "metadata.domainType")
514 //        String type = jsonUtil.getJsonValue(content, "metadata.type")
515 //        String nsstContentInfo = """{
516 //        "NsstID":"${nsstID}",
517 //        "Vendor":"${vendor}",
518 //        "type":"${type}"
519 //         }"""
520
521         logger.debug("Prepare NSSI option completed ")
522     }
523 }
524