Implement so-oof-adapter to handle OOF Callback
[so.git] / bpmn / so-bpmn-infrastructure-common / src / main / groovy / org / onap / so / bpmn / infrastructure / scripts / DoCreateSliceServiceOption.groovy
index 8ab7c7a..9b78afb 100644 (file)
@@ -1,13 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ # Copyright (c) 2019, CMCC Technologies Co., Ltd.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License")
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ #       http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
 package org.onap.so.bpmn.infrastructure.scripts
 
 import com.fasterxml.jackson.core.type.TypeReference
-import groovy.json.JsonBuilder
+import com.fasterxml.jackson.databind.ObjectMapper
 import groovy.json.JsonSlurper
-import org.camunda.bpm.engine.delegate.BpmnError
 import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.aai.domain.yang.Relationship
-import org.onap.aai.domain.yang.RelationshipList
-import org.onap.aai.domain.yang.ServiceInstance
 import org.onap.logging.filter.base.ONAPComponents
 import org.onap.so.beans.nsmf.SliceTaskParams
 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
@@ -24,311 +40,279 @@ import org.onap.aaiclient.client.aai.AAIResourcesClient
 import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
-import org.onap.so.db.request.client.RequestsDbClient
-import org.onap.so.db.request.beans.OrchestrationTask
 import org.slf4j.Logger
 import org.slf4j.LoggerFactory
+
 import javax.ws.rs.NotFoundException
 import javax.ws.rs.core.Response
 
 import static org.apache.commons.lang3.StringUtils.isBlank
 
-public class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
+class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
 
     private static final Logger logger = LoggerFactory.getLogger( DoCreateSliceServiceOption.class)
 
-
     ExceptionUtil exceptionUtil = new ExceptionUtil()
 
     JsonUtils jsonUtil = new JsonUtils()
 
-    RequestsDbClient requestsDbClient = new RequestsDbClient()
-
     OofUtils oofUtils = new OofUtils()
 
-    /**
-     * Pre Process the BPMN Flow Request
-     * Inclouds:
-     * generate the nsOperationKey
-     * generate the nsParameters
-     */
-    void preProcessRequest (DelegateExecution execution) {
-        String msg = ""
-        logger.trace("Enter preProcessRequest()")
-        String taskID = execution.getVariable("taskID")
-        Boolean isSharable = true
-        String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
-        if (resourceSharingLevel.equals("shared"))
-            isSharable = true
-        execution.setVariable("isSharable",isSharable)
-        logger.trace("Exit preProcessRequest")
+    ObjectMapper objectMapper = new ObjectMapper()
 
+    void preProcessRequest (DelegateExecution execution) {
     }
 
 
-    void getNSIOptionfromOOF(DelegateExecution execution) {
+    void prepareSelectNSIRequest(DelegateExecution execution) {
 
         String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
         logger.debug( "get NSI option OOF Url: " + urlString)
+
         boolean isNSISuggested = true
         execution.setVariable("isNSISuggested",isNSISuggested)
-        String nsiInstanceId = ""
-        String nsiName = ""
-        SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
-        //Prepare auth for OOF - Begin
-        def authHeader = ""
-        String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution)
-        String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution)
-
-        String basicAuthValue = utils.encrypt(basicAuth, msokey)
-        if (basicAuthValue != null) {
-            logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue)
-            try {
-                authHeader = utils.getBasicAuth(basicAuthValue, msokey)
-                execution.setVariable("BasicAuthHeaderValue", authHeader)
-            } catch (Exception ex) {
-                logger.debug( "Unable to encode username and password string: " + ex)
-                exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " +
-                        "encode username and password string")
-            }
-        } else {
-            logger.debug( "Unable to obtain BasicAuth - BasicAuth value null")
-            exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " +
-                    "value null")
-        }
-        //Prepare auth for OOF - End
-
         String requestId = execution.getVariable("msoRequestId")
+               String messageType = "NSISelectionResponse"
+               
         Map<String, Object> profileInfo = execution.getVariable("serviceProfile")
-        String nstModelUuid = execution.getVariable("nstModelUuid")
-        String nstModelInvariantUuid = execution.getVariable("nstModelInvariantUuid")
-        String nstInfo = """"NSTInfo" : {
-        "invariantUUID":"${nstModelInvariantUuid}",
-        "UUID":"${nstModelUuid}"
+        Map<String, Object> nstSolution = execution.getVariable("nstSolution")
+        logger.debug("Get NST selection from OOF: " + nstSolution.toString())
+        String nstInfo = """{
+            "modelInvariantId":"${nstSolution.invariantUUID}",
+            "modelVersionId":"${nstSolution.UUID}",
+            "modelName":"${nstSolution.NSTName}"
          }"""
+               
+                execution.setVariable("nsiSelectionUrl", "/api/oof/selection/nsi/v1")
+                execution.setVariable("nsiSelection_messageType",messageType)
+                execution.setVariable("nsiSelection_correlator",requestId)
+                String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution);
+                execution.setVariable("nsiSelection_timeout",timeout)
+                String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo,messageType, profileInfo)
+                execution.setVariable("nsiSelection_oofRequest",oofRequest)
+                logger.debug("Sending request to OOF: " + oofRequest)
+    }
 
-        String oofRequest = oofUtils.buildSelectNSIRequest(execution, requestId, nstInfo, profileInfo)
-
-        //send request to get NSI option - Begin
-        URL url = new URL(urlString+"/api/oof/v1/selectnsi")
-        HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.OOF)
-        httpClient.addAdditionalHeader("Authorization", authHeader)
-        Response httpResponse = httpClient.post(oofRequest)
-
+    void processOOFResponse(Response httpResponse, DelegateExecution execution) {
         int responseCode = httpResponse.getStatus()
-        logger.debug("OOF sync response code is: " + responseCode)
-
-        if(responseCode != 200){
-            exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.")
-            logger.debug("Info: No NSI suggested by OOF" )
-        }
-
-        if(httpResponse.hasEntity()){
-            String OOFResponse = httpResponse.readEntity(String.class)
+        SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
+            String OOFResponse = execution.getVariable("nsiSelection_oofResponse")
+            logger.debug("NSI OOFResponse is: " + OOFResponse)
             execution.setVariable("OOFResponse", OOFResponse)
-            int index = 0   //This needs to be changed to derive a value when we add policy to decide the solution options.
+            //This needs to be changed to derive a value when we add policy to decide the solution options.
             Map OOFResponseObject = new JsonSlurper().parseText(OOFResponse)
-            if(execution.getVariable("isSharable" )  == true && OOFResponseObject.get("solutions").containsKey("sharedNSIsolutions")) {
-                nsiInstanceId = OOFResponseObject.get("solutions").get("sharedNSIsolutions").get(0).get("NSISolution").NSIId
-                nsiName = OOFResponseObject.get("solutions").get("sharedNSIsolutions").get(0).get("NSISolution").NSIName
-                sliceTaskParams.setNstId(nsiInstanceId)
-                sliceTaskParams.setSuggestNsiName(nsiName)
-                execution.setVariable("nsiInstanceId",nsiInstanceId)
-                execution.setVariable("nsiName",nsiName)
-            }else {
-                if(OOFResponseObject.get("solutions").containsKey("newNSISolutions")) {
-                    List NSSImap = OOFResponseObject.get("solutions").get("newNSISolutions").get(index).get("NSSISolutions")
-                    for(Map nssi :  NSSImap) {
-                        String nssiName = nssi.get("NSSISolution").NSSIName
-                        String nssiId = nssi.get("NSSISolution").NSSIId
-                        String domain = nssi.get("NSSISolution").domain.toUpperCase()
-                        switch (domain) {
-                            case "AN":
-                                sliceTaskParams.setAnSuggestNssiId(nssiId)
-                                sliceTaskParams.setAnSuggestNssiName(nssiName)
-                                break;
-                            case "CN":
-                                sliceTaskParams.setCnSuggestNssiId(nssiId)
-                                sliceTaskParams.setCnSuggestNssiName(nssiName)
-                                break;
-                            case "TN":
-                                sliceTaskParams.setTnSuggestNssiId(nssiId)
-                                sliceTaskParams.setTnSuggestNssiName(nssiName)
-                                break;
-                            default:
-                                break;
-                        }
-                    }
-                }
+            Map solutions = OOFResponseObject.get("solutions")
 
+            String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
+            Boolean isSharable = resourceSharingLevel.equals("shared")
+
+            if (solutions != null) {
+                if (isSharable && hasSharedNSIsolutions(solutions)) {
+                    //sharedNSISolution
+                    processSharedNSISolutions(solutions, execution)
+                }
+                else if(solutions.containsKey("newNSISolutions")) {
+                    processNewNSISolutions(solutions, execution)
+                }
             }
             execution.setVariable("sliceTaskParams", sliceTaskParams)
-            logger.debug("Info: No NSI suggested by OOF" )
+            logger.debug("sliceTaskParams: "+sliceTaskParams.convertToJson())
+        logger.debug("*** Completed options Call to OOF ***")
+               //解析sliceProfile
+               logger.debug("start parseServiceProfile")
+               parseServiceProfile(execution)
+               logger.debug("end parseServiceProfile")
+    }
+
+    private boolean hasSharedNSIsolutions( Map solutions){
+        if(solutions.containsKey("sharedNSISolutions")){
+            List sharedNSIsolutions = solutions.get("sharedNSISolutions")
+            if (sharedNSIsolutions != null && !sharedNSIsolutions.isEmpty()) {
+                return  true
+            }
         }
-        //send request to get NSI option - Begin
-
-
-        //send request to get NSI service Info - Begin
-
-        /***
-         * Need to check whether its needed.
-         */
-//            logger.debug("Begin to query OOF suggetsed NSI from AAI ")
-//            if(isBlank(nsiInstanceId)){
-//                isNSISuggested = false
-//                execution.setVariable("isNSISuggested",isNSISuggested)
-//            }else
-//            {
-//                try {
-//                    String globalSubscriberId = execution.getVariable('globalSubscriberId')
-//                    String serviceType = execution.getVariable('subscriptionServiceType')
-//                    AAIResourcesClient resourceClient = new AAIResourcesClient()
-//                    AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nsiInstanceId)
-//                    AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class)
-//                    Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class)
-//                    org.onap.aai.domain.yang.ServiceInstance nsiServiceInstance = si.get()
-//                    execution.setVariable("nsiServiceInstance",nsiServiceInstance)
-//                    isNSISuggested = true
-//                    execution.setVariable("isNSISuggested",isNSISuggested)
-//                    SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
-//                    sliceTaskParams.setSuggestNsiId(nsiInstanceId)
-//                    sliceTaskParams.setSuggestNsiName(si.get().getServiceInstanceName())
-//                    execution.setVariable("sliceTaskParams", sliceTaskParams)
-//                    logger.debug("Info: NSI suggested by OOF exist in AAI ")
-//                }catch(BpmnError e) {
-//                    throw e
-//                }catch(Exception ex) {
-//                    String msg = "Internal Error in getServiceInstance: " + ex.getMessage()
-//                    //exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
-//                    logger.debug("Info: NSI suggested by OOF doesnt exist in AAI " + nsiInstanceId)
-//                }
-//            }
-        //send request to get NSI service Info - End
-        //${OrchestrationTaskHandler.createOrchestrationTask(execution.getVariable("OrchestrationTask"))}
-        logger.debug( "*** Completed options Call to OOF ***")
+        return false
+    }
 
+    private void processNewNSISolutions(Map solutions, DelegateExecution execution) {
+        int index = 0
+        List<Map> newNSISolutions = solutions.get("newNSISolutions")
+        List<Map> NSSImap = new ArrayList<>()
+        if (newNSISolutions != null && newNSISolutions.size() > 0) {
+            NSSImap = newNSISolutions.get(index).get("NSSISolutions") as List<Map>
+            for (Map nssi : NSSImap) {
+                Map oofSliceProfile = nssi.get("sliceProfile")
+                String domain = oofSliceProfile.getOrDefault("domainType","")
+                logger.debug("OOF newNSISolutions SliceProfile: " +oofSliceProfile.toString()+",domain:${domain}")
+                if(null != domain){
+                    //TODO
+//                    def nssiSolution = nssi.get("NSSISolution") as Map<String, ?>
+//                    String nssiName = nssiSolution.getOrDefault("NSSIName", "")
+//                    String nssiId = nssiSolution.getOrDefault("NSSIId", "")
+//                    saveNSSIId(nssi, sliceTaskParams)
+                    Map<String, Object> sliceProfile = getSliceProfile(domain, execution, oofSliceProfile)
+                    saveSliceProfile(execution, domain, sliceProfile)
+
+                }
+            }
+        }
     }
 
+    private void processSharedNSISolutions(Map solutions, DelegateExecution execution) {
+        String nsiName, nsiInstanceId, nssiId, nssiName
+        SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
 
-    public void parseServiceProfile(DelegateExecution execution) {
+        Map sharedNSIsolution = ((List) solutions.get("sharedNSISolutions"))?.get(0)
+        nsiInstanceId = sharedNSIsolution.getOrDefault("NSIId", "")
+        nsiName = sharedNSIsolution.getOrDefault("NSIName", "")
+        sliceTaskParams.setSuggestNsiId(nsiInstanceId)
+        sliceTaskParams.setSuggestNsiName(nsiName)
+
+        //Temporary modification
+        List NSSIs = sharedNSIsolution.get("NSSIs")
+        for(Map nssi : NSSIs){
+            Map oofSliceProfile = ((List)nssi.get("sliceProfile"))?.get(0)
+            String domain = oofSliceProfile.getOrDefault("domainType","")
+            nssiId = nssi.getOrDefault("NSSIId","")
+            nssiName = nssi.getOrDefault("NSSIName","")
+            saveNSSIId(domain, nssiId, nssiName,execution)
+            Map<String, Object> sliceProfile = getSliceProfile(domain, execution, oofSliceProfile)
+            saveSliceProfile(execution, domain, sliceProfile)
+            logger.debug("OOF sharedNSISolution SliceProfile:"+oofSliceProfile.toString()+",domain:${domain}")
+            logger.debug("OOF sharedNSISolution nsiInstanceId:${nsiInstanceId}, nsiName:${nsiName}, nssiId:${nssiId}, nssiName:${nssiName}")
+        }
+    }
+
+    private void parseServiceProfile(DelegateExecution execution) {
         logger.debug("Start parseServiceProfile")
         String serviceType = execution.getVariable("serviceType")
         Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
-
+        SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
         // set sliceProfile for three domains
-        Map<String, Object> sliceProfileTn = getSliceProfile(serviceType, "TN", serviceProfile)
-        Map<String, Object> sliceProfileCn = getSliceProfile(serviceType, "CN", serviceProfile)
-        Map<String, Object> sliceProfileAn = getSliceProfile(serviceType, "AN", serviceProfile)
+        if(!sliceTaskParams.getSliceProfileAn()){
+            Map<String, Object> sliceProfileAn = getSliceProfile( "AN", execution,null)
+            saveSliceProfile(execution,"AN",sliceProfileAn)
+        }
+
+        if(!sliceTaskParams.getSliceProfileTn()){
+            Map<String, Object> sliceProfileTn = getSliceProfile( "TN", execution,null)
+            saveSliceProfile(execution,"TN",sliceProfileTn)
+        }
 
-        execution.setVariable("sliceProfileTn", sliceProfileTn)
-        execution.setVariable("sliceProfileCn", sliceProfileCn)
-        execution.setVariable("sliceProfileAn", sliceProfileAn)
-        logger.debug("sliceProfileTn: " + sliceProfileTn)
-        logger.debug("sliceProfileCn: " + sliceProfileCn)
-        logger.debug("sliceProfileAn: " + sliceProfileAn)
+        if(!sliceTaskParams.getSliceProfileCn()){
+            Map<String, Object> sliceProfileCn = getSliceProfile( "CN", execution,null, )
+           saveSliceProfile(execution,"CN",sliceProfileCn)
+        }
 
         logger.debug("Finish parseServiceProfile")
     }
 
-    public Map getSliceProfile(String serviceType, String domain, Map<String, Object> serviceProfile) {
-        String variablePath = "nsmf." + serviceType + ".profileMap" + domain
-        String profileMapStr = UrnPropertiesReader.getVariable(variablePath)
-        logger.debug("Profile map for " + domain + " : " + profileMapStr)
-        Map<String, String> profileMaps = objectMapper.readValue(profileMapStr, new TypeReference<Map<String, String>>(){})
-        Map<String, Object> sliceProfileTn = [:]
-        for (Map.Entry<String, String> profileMap : profileMaps) {
-            sliceProfileTn.put(profileMap.key, serviceProfile.get(profileMap.value))
+    private void saveSliceProfile(DelegateExecution execution, String domain, Map<String, Object> sliceProfile){
+        SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
+        if(domain.equalsIgnoreCase("AN")){
+            execution.setVariable("sliceProfileAn", sliceProfile)
+            sliceTaskParams.setSliceProfileAn(sliceProfile)
+            logger.debug("sliceProfileAn: " + sliceProfile)
+        }
+        else if(domain.equalsIgnoreCase("TN")){
+            execution.setVariable("sliceProfileTn", sliceProfile)
+            sliceTaskParams.setSliceProfileTn(sliceProfile)
+            logger.debug("sliceProfileTn: " + sliceProfile)
+        }
+        else if(domain.equalsIgnoreCase("CN")){
+            execution.setVariable("sliceProfileCn", sliceProfile)
+            sliceTaskParams.setSliceProfileCn(sliceProfile)
+            logger.debug("sliceProfileCn: " + sliceProfile)
         }
-
-        return sliceProfileTn
     }
 
+    private void saveNSSIId(String domain, String nssiId, String nssiName, DelegateExecution execution) {
+        SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
+        if(domain.equalsIgnoreCase("AN")){
+            sliceTaskParams.setAnSuggestNssiId(nssiId)
+            sliceTaskParams.setAnSuggestNssiName(nssiName)
+        }
+        else if(domain.equalsIgnoreCase("CN")){
+            sliceTaskParams.setCnSuggestNssiId(nssiId)
+            sliceTaskParams.setCnSuggestNssiName(nssiName)
+        }
+        else if(domain.equalsIgnoreCase("TN")){
+            sliceTaskParams.setTnSuggestNssiId(nssiId)
+            sliceTaskParams.setTnSuggestNssiName(nssiName)
+        }
+    }
 
-    void prepareNSSIList(DelegateExecution execution)
-    {
-        ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
-        List<String> nssiAssociated = new ArrayList<>()
-        Map<String, String> nssimap = new HashMap<>()
-        String nsiInstanceId=execution.getVariable("nsiInstanceId")
-        String globalSubscriberId = execution.getVariable("globalSubscriberId")
-        String serviceType = execution.getVariable("subscriptionServiceType")
-
-        try {
+    private Map getSliceProfile(String domain, DelegateExecution execution, Map<String, Object> oofSliceProfile) {
+        String profileMapStr
+        Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
+        Integer domainLatency = (Integer) serviceProfile.get("latency")/3
+
+        if(domain.equalsIgnoreCase("AN")){
+            profileMapStr = """ {
+                    "latency": ${domainLatency}, 
+                    "sNSSAI": "sNSSAI", 
+                    "uEMobilityLevel": "uEMobilityLevel", 
+                    "coverageAreaTAList": "coverageAreaTAList", 
+                    "5QI": 100
+                }"""
+        }
+        else if(domain.equalsIgnoreCase("TN")){
+            profileMapStr =""" {
+                    "latency":${domainLatency},
+                    "sNSSAI":"sNSSAI", 
+                    "e2eLatency":"latency", 
+                    "bandwidth": 100
+                }"""
+        }
+        else if(domain.equalsIgnoreCase("CN")){
+            profileMapStr = """ {
+                    "areaTrafficCapDL":"areaTrafficCapDL",
+                    "maxNumberofUEs":"maxNumberofUEs",
+                    "latency":${domainLatency},
+                    "expDataRateUL":"expDataRateUL", 
+                    "sNSSAI":"sNSSAI", 
+                    "areaTrafficCapUL":"areaTrafficCapUL",
+                    "uEMobilityLevel":"uEMobilityLevel", 
+                    "expDataRateDL":"expDataRateDL",  
+                    "activityFactor":"activityFactor",
+                    "resourceSharingLevel":"resourceSharingLevel"
+                }"""
+        }
 
-            ServiceInstance si = execution.getVariable("nsiServiceInstance")
-            //List<Relationship> relationships = si.getRelationshipList().getRelationship().stream().filter(relation ->
-            //        relation.getRelatedTo().equalsIgnoreCase("service-instance"))
-            RelationshipList relationshipList = si.getRelationshipList()
-            List<Relationship> relationships = relationshipList.getRelationship()
-            for(Relationship relationship in relationships)
-            {
-                if(relationship.getRelatedTo().equalsIgnoreCase("service-instance"))
-                {
-                    String NSSIassociated = relationship.getRelatedLink().substring(relationship.getRelatedLink().lastIndexOf("/") + 1);
-                    if(!NSSIassociated.equals(nsiInstanceId))
-                        nssiAssociated.add(NSSIassociated)
-                }
+           logger.debug("Profile map for " + domain + " : " + profileMapStr)
+        Map<String, Object> profileMaps = objectMapper.readValue(profileMapStr.trim().replaceAll(" ", ""), new TypeReference<Map<String, String>>(){})
+        Map<String, Object> sliceProfile = [:]
+        for (Map.Entry<String, String> profileMap : profileMaps) {
+            String key = profileMap.key
+            String value = profileMaps.get(key)
+            if(null != oofSliceProfile && oofSliceProfile.keySet().contains(key)){
+                sliceProfile.put(key, oofSliceProfile.get(key))
+                logger.debug("Get from oof, key:${key}, value: ${oofSliceProfile.get(key)}")
+            }
+            else if(serviceProfile.keySet().contains(value)){
+                sliceProfile.put(key, serviceProfile.get(value))
+            }
+            else{
+                sliceProfile.put(key, profileMaps.get(key))
             }
-        }catch(BpmnError e) {
-            throw e
-        }catch(Exception ex) {
-            String msg = "Internal Error in getServiceInstance: " + ex.getMessage()
-            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
         }
-        Map<String, Object> params = execution.getVariable("params")
-        SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
-        for(String nssiID in nssiAssociated)
-        {
-            try {
-                AAIResourcesClient resourceClient = new AAIResourcesClient()
-                AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nssiID)
-                AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class)
-                Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class)
-                org.onap.aai.domain.yang.ServiceInstance nssi = si.get()
+        return sliceProfile
+    }
 
-                String domain = nssi.getEnvironmentContext().toString().toUpperCase()
-                switch (domain) {
-                    case "AN":
-                        sliceTaskParams.setAnSuggestNssiId(nssi.getServiceInstanceId())
-                        sliceTaskParams.setAnSuggestNssiName(nssi.getServiceInstanceName())
-                        break;
-                    case "CN":
-                        sliceTaskParams.setCnSuggestNssiId(nssi.getServiceInstanceId())
-                        sliceTaskParams.setCnSuggestNssiName(nssi.getServiceInstanceName())
-                        break;
-                    case "TN":
-                        sliceTaskParams.setTnSuggestNssiId(nssi.getServiceInstanceId())
-                        sliceTaskParams.setTnSuggestNssiName(nssi.getServiceInstanceName())
-                        break;
-                    default:
-                        break;
-                }
-            }catch(NotFoundException e)
-            {
-                logger.debug("NSSI Service Instance not found in AAI: " + nssiID)
-            }catch(Exception e)
-            {
-                logger.debug("NSSI Service Instance not found in AAI: " + nssiID)
-            }
+    void processDecomposition(DelegateExecution execution){
+        logger.debug("Start processDecomposition")
 
-        }
+        ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
+        SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
         String nstName = serviceDecomposition.getModelInfo().getModelName()
-        sliceTaskParams.setNstName(nstName)
         String nstId = serviceDecomposition.getModelInfo().getModelUuid()
+        sliceTaskParams.setNstName(nstName)
         sliceTaskParams.setNstId(nstId)
-        execution.setVariable("sliceTaskParams",sliceTaskParams)
 
+        logger.debug("End processDecomposition")
     }
 
 
-    void updateOptionsInDB(DelegateExecution execution) {
-        logger.debug("Updating options with default value since not sharable : Begin ")
-        String taskID = execution.getVariable("taskID")
-        String params = execution.getVariable("params")
-        logger.debug("Updating options with default value since not sharable : End ")
-
-    }
-
     void prepareNSTDecompose(DelegateExecution execution) {
 
         String modelUuid = execution.getVariable("nstModelUuid")
@@ -364,14 +348,6 @@ public class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
     }
 
 
-    void updateStatusInDB(DelegateExecution execution) {
-
-        String taskID = execution.getVariable("taskID")
-        //OrchestrationTask orchestrationTask = requestsDbClient.getNetworkSliceOption(taskID);
-        //orchestrationTask.setTaskStage("wait to confirm")
-        //requestsDbClient.updateNetworkSliceOption(orchestrationTask)
-    }
-
     void prepareNSSTlistfromNST(DelegateExecution execution) {
         //Need to update this part from decomposition.
         logger.trace("Enter prepareNSSTlistfromNST()")
@@ -400,7 +376,6 @@ public class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
 
     }
 
-
     void getNSSTOption(DelegateExecution execution) {
         ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
         String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
@@ -483,17 +458,17 @@ public class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
                     case "AN":
                         sliceTaskParams.setAnSuggestNssiId(nssi.getServiceInstanceId())
                         sliceTaskParams.setAnSuggestNssiName(nssi.getServiceInstanceName())
-                        break;
+                        break
                     case "CN":
                         sliceTaskParams.setCnSuggestNssiId(nssi.getServiceInstanceId())
                         sliceTaskParams.setCnSuggestNssiName(nssi.getServiceInstanceName())
-                        break;
+                        break
                     case "TN":
                         sliceTaskParams.setTnSuggestNssiId(nssi.getServiceInstanceId())
                         sliceTaskParams.setTnSuggestNssiName(nssi.getServiceInstanceName())
-                        break;
+                        break
                     default:
-                        break;
+                        break
                 }
             }catch(NotFoundException e)
             {
@@ -503,22 +478,6 @@ public class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
                 logger.debug("NSSI Service Instance not found in AAI: " + nssiInstanceId)
             }
         }
-
-
-        //Prepare send request to OOF - End
-
-//        String content = serviceDecomposition.getServiceInfo().getServiceArtifact().get(0).getContent()
-//        String nsstID = jsonUtil.getJsonValue(content, "metadata.id")
-//        String vendor = jsonUtil.getJsonValue(content, "metadata.vendor")
-//        String domain = jsonUtil.getJsonValue(content, "metadata.domainType")
-//        String type = jsonUtil.getJsonValue(content, "metadata.type")
-//        String nsstContentInfo = """{
-//        "NsstID":"${nsstID}",
-//        "Vendor":"${vendor}",
-//        "type":"${type}"
-//         }"""
-
         logger.debug("Prepare NSSI option completed ")
     }
 }
-