2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 
   6  * ================================================================================
 
   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=========================================================
 
  20 package org.openecomp.mso.bpmn.infrastructure.scripts
 
  22 import static org.apache.commons.lang3.StringUtils.*
 
  23 import org.openecomp.mso.bpmn.core.RollbackData
 
  24 import org.camunda.bpm.engine.delegate.BpmnError
 
  25 import org.camunda.bpm.engine.runtime.Execution
 
  26 import org.openecomp.mso.bpmn.common.scripts.AaiUtil
 
  27 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
 
  28 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
 
  29 import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
 
  30 import org.openecomp.mso.bpmn.common.scripts.VidUtils
 
  31 import org.openecomp.mso.bpmn.core.WorkflowException
 
  32 import org.openecomp.mso.bpmn.core.json.JsonUtils
 
  36  * This class supports the DoCreateVnf building block subflow
 
  37  * with the creation of a generic vnf for
 
  41 class DoCreateVnf extends AbstractServiceTaskProcessor {
 
  43         String Prefix="DoCVNF_"
 
  44         ExceptionUtil exceptionUtil = new ExceptionUtil()
 
  45         JsonUtils jsonUtil = new JsonUtils()
 
  46         VidUtils vidUtils = new VidUtils(this)
 
  47         SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
 
  50          * This method gets and validates the incoming
 
  56         public void preProcessRequest(Execution execution) {
 
  57                 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
 
  58                 execution.setVariable("prefix",Prefix)
 
  59                 utils.log("DEBUG", " *** STARTED DoCreateVnf PreProcessRequest Process*** ", isDebugEnabled)
 
  61                 // DISABLE SDNC INTERACTION FOR NOW
 
  62                 execution.setVariable("SDNCInteractionEnabled", false)
 
  69                         String vnfModelInfo = execution.getVariable("vnfModelInfo")                     
 
  70                         String serviceModelInfo = execution.getVariable("serviceModelInfo")
 
  72                         String requestId = execution.getVariable("msoRequestId")
 
  73                         execution.setVariable("DoCVNF_requestId", requestId)
 
  74                         execution.setVariable("mso-request-id", requestId)
 
  75                         utils.log("DEBUG", "Incoming Request Id is: " + requestId, isDebugEnabled)
 
  77                         String serviceInstanceId = execution.getVariable("serviceInstanceId")
 
  78                         execution.setVariable("DoCVNF_serviceInstanceId", serviceInstanceId)
 
  79                         utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled)
 
  81                         String vnfType = execution.getVariable("vnfType")
 
  82                         execution.setVariable("DoCVNF_vnfType", vnfType)
 
  83                         utils.log("DEBUG", "Incoming Vnf Type is: " + vnfType, isDebugEnabled)
 
  85                         String vnfName = execution.getVariable("vnfName")
 
  86                         if (vnfName.equals("") || vnfName.equals("null")) {
 
  89                         execution.setVariable("DoCVNF_vnfName", vnfName)
 
  90                         utils.log("DEBUG", "Incoming Vnf Name is: " + vnfName, isDebugEnabled)
 
  92                         String serviceId = execution.getVariable("productFamilyId")
 
  93                         execution.setVariable("DoCVNF_serviceId", serviceId)
 
  94                         utils.log("DEBUG", "Incoming Service Id is: " + serviceId, isDebugEnabled)
 
  97                         execution.setVariable("DoCVNF_source", source)
 
  98                         utils.log("DEBUG", "Incoming Source is: " + source, isDebugEnabled)
 
 100                         String suppressRollback = execution.getVariable("disableRollback")
 
 101                         execution.setVariable("DoCVNF_suppressRollback", suppressRollback)
 
 102                         utils.log("DEBUG", "Incoming Suppress Rollback is: " + suppressRollback, isDebugEnabled)
 
 104                         String modelInvariantId = jsonUtil.getJsonValue(vnfModelInfo, "modelInvariantId")
 
 105                         execution.setVariable("DoCVNF_modelInvariantId", modelInvariantId)
 
 106                         utils.log("DEBUG", "Incoming Invariant Id is: " + modelInvariantId, isDebugEnabled)
 
 108                         String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelVersionId")
 
 109                         if (modelVersionId == null) {
 
 112                         execution.setVariable("DoCVNF_modelVersionId", modelVersionId)
 
 113                         utils.log("DEBUG", "Incoming Version Id is: " + modelVersionId, isDebugEnabled)
 
 115                         String modelVersion = jsonUtil.getJsonValue(vnfModelInfo, "modelVersion")
 
 116                         execution.setVariable("DoCVNF_modelVersion", modelVersion)
 
 117                         utils.log("DEBUG", "Incoming Model Version is: " + modelVersion, isDebugEnabled)
 
 119                         String modelName = jsonUtil.getJsonValue(vnfModelInfo, "modelName")
 
 120                         execution.setVariable("DoCVNF_modelName", modelName)
 
 121                         utils.log("DEBUG", "Incoming Model Name is: " + modelName, isDebugEnabled)
 
 123                         String modelCustomizationId = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationId")
 
 124                         if (modelCustomizationId == null) {
 
 125                                 modelCustomizationId = ""
 
 127                         execution.setVariable("DoCVNF_modelCustomizationId", modelCustomizationId)
 
 128                         utils.log("DEBUG", "Incoming Model Customization Id is: " + modelCustomizationId, isDebugEnabled)
 
 130                         String cloudSiteId = execution.getVariable("lcpCloudRegionId")
 
 131                         execution.setVariable("DoCVNF_cloudSiteId", cloudSiteId)
 
 132                         utils.log("DEBUG", "Incoming Cloud Site Id is: " + cloudSiteId, isDebugEnabled)
 
 134                         String tenantId = execution.getVariable("tenantId")
 
 135                         execution.setVariable("DoCVNF_tenantId", tenantId)
 
 136                         utils.log("DEBUG", "Incoming Tenant Id is: " + tenantId, isDebugEnabled)                        
 
 138                         String globalSubscriberId = execution.getVariable("globalSubscriberId")
 
 139                         if (globalSubscriberId == null) {
 
 140                                 globalSubscriberId = ""
 
 142                         execution.setVariable("DoCVNF_globalSubscriberId", globalSubscriberId)
 
 143                         utils.log("DEBUG", "Incoming Global Subscriber Id is: " + globalSubscriberId, isDebugEnabled)
 
 145                         String sdncVersion = execution.getVariable("sdncVersion")
 
 146                         if (sdncVersion == null) {
 
 149                         execution.setVariable("DoCVNF_sdncVersion", sdncVersion)
 
 150                         utils.log("DEBUG", "Incoming Sdnc Version is: " + sdncVersion, isDebugEnabled)
 
 152                         //For Completion Handler & Fallout Handler
 
 154                                 """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
 
 155                                         <request-id>${requestId}</request-id>
 
 156                                         <action>CREATE</action>
 
 157                                         <source>${source}</source>
 
 160                         execution.setVariable("DoCVNF_requestInfo", requestInfo)
 
 161                         //TODO: Orch Status - TBD, will come from SDN-C Response in 1702
 
 162                         String orchStatus = "Created"
 
 163                         execution.setVariable("DoCVNF_orchStatus", orchStatus)
 
 165                         //TODO: Equipment Role - Should come from SDN-C Response in 1702
 
 166                         String equipmentRole = " "
 
 167                         execution.setVariable("DoCVNF_equipmentRole", equipmentRole)
 
 168                         String vnfId = execution.getVariable("testVnfId") // for junits
 
 170                                 vnfId = execution.getVariable("vnfId")
 
 171                                 if (isBlank(vnfId)) {
 
 172                                         vnfId = UUID.randomUUID().toString()
 
 173                                         utils.log("DEBUG", "Generated Vnf Id is: " + vnfId, isDebugEnabled)
 
 176                         execution.setVariable("DoCVNF_vnfId", vnfId)
 
 178                         // Setting for Sub Flow Calls
 
 179                         execution.setVariable("DoCVNF_type", "generic-vnf")
 
 180                         execution.setVariable("GENGS_type", "service-instance")
 
 182                         String sdncCallbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
 
 183                         if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
 
 184                                 def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing'
 
 186                                 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
 
 188                         execution.setVariable("DoCVNF_sdncCallbackUrl", sdncCallbackUrl)
 
 189                         utils.logAudit("SDNC Callback URL: " + sdncCallbackUrl)
 
 190                         logDebug("SDNC Callback URL is: " + sdncCallbackUrl, isDebugEnabled)
 
 192                         def rollbackData = execution.getVariable("RollbackData")
 
 193                         if (rollbackData == null) {
 
 194                                 rollbackData = new RollbackData()
 
 197                         execution.setVariable("RollbackData", rollbackData)
 
 200                         utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
 
 203                         utils.log("DEBUG", " Error Occured in DoCreateVnf PreProcessRequest method!" + e.getMessage(), isDebugEnabled)
 
 204                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest")
 
 207                 utils.log("DEBUG", "*** COMPLETED DoCreateVnf PreProcessRequest Process ***", isDebugEnabled)
 
 211         public void prepareCreateGenericVnf (Execution execution) {
 
 212                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
 
 213                 execution.setVariable("prefix",Prefix)
 
 215                 utils.log("DEBUG", " *** STARTED DoCreateVnf PrepareCreateGenericVnf Process *** ", isDebugEnabled)
 
 218                         String vnfId = execution.getVariable("DoCVNF_vnfId")
 
 219                         def vnfName = execution.getVariable("DoCVNF_vnfName")
 
 220                         if (vnfName == null) {
 
 221                                 vnfName = "sdncGenerated"
 
 222                                 utils.log("DEBUG", "Sending a dummy VNF name to AAI - the name will be generated by SDNC: " + vnfName, isDebugEnabled)
 
 224                         def vnfType = execution.getVariable("DoCVNF_vnfType")
 
 225                         def serviceId = execution.getVariable("DoCVNF_serviceId")
 
 226                         def orchStatus = execution.getVariable("DoCVNF_orchStatus")
 
 227                         def modelInvariantId = execution.getVariable("DoCVNF_modelInvariantId")
 
 228                         def modelVersionId = execution.getVariable("DoCVNF_modelVersionId")
 
 229                         def modelCustomizationId = execution.getVariable("DoCVNF_modelCustomizationId")
 
 230                         // TODO: 1702 Variable
 
 231                         def equipmentRole = execution.getVariable("DoCVNF_equipmentRole")
 
 233                         //Get Service Instance Info
 
 234                         def serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId")
 
 235                         String siRelatedLink = execution.getVariable("GENGS_siResourceLink")
 
 237                         int custStart = siRelatedLink.indexOf("customer/")
 
 238                         int custEnd = siRelatedLink.indexOf("/service-subscriptions")
 
 239                         String globalCustId = siRelatedLink.substring(custStart + 9, custEnd)
 
 240                         int serviceStart = siRelatedLink.indexOf("service-subscription/")
 
 241                         int serviceEnd = siRelatedLink.indexOf("/service-instances/")
 
 242                         String serviceType = siRelatedLink.substring(serviceStart + 21, serviceEnd)
 
 245                         AaiUtil aaiUtil = new AaiUtil(this)
 
 246                         def aai_uri = aaiUtil.getNetworkGenericVnfUri(execution)
 
 247                         String namespace = aaiUtil.getNamespaceFromUri(execution, aai_uri)
 
 250                                         """<generic-vnf xmlns="${namespace}">
 
 251                                 <vnf-id>${vnfId}</vnf-id>
 
 252                                 <vnf-name>${vnfName}</vnf-name>
 
 253                                 <service-id>${serviceId}</service-id>
 
 254                                 <vnf-type>${vnfType}</vnf-type>
 
 255                                 <prov-status>PREPROV</prov-status>
 
 256                                 <orchestration-status>${orchStatus}</orchestration-status>
 
 257                                 <model-invariant-id>${modelInvariantId}</model-invariant-id>
 
 258                                 <model-version-id>${modelVersionId}</model-version-id>
 
 259                                 <model-customization-id>${modelCustomizationId}</model-customization-id>
 
 262                         <related-to>service-instance</related-to>
 
 263                         <related-link>${siRelatedLink}</related-link>
 
 265                                 <relationship-key>customer.global-customer-id</relationship-key>
 
 266                                 <relationship-value>${globalCustId}</relationship-value>
 
 269                                 <relationship-key>service-subscription.service-type</relationship-key>
 
 270                                 <relationship-value>${serviceType}</relationship-value>
 
 273                                 <relationship-key>service-instance.service-instance-id</relationship-key>
 
 274                                 <relationship-value>${serviceInstanceId}</relationship-value>
 
 280                         execution.setVariable("DoCVNF_genericVnfPayload", payload)
 
 282                 }catch(Exception ex) {
 
 283                         utils.log("DEBUG", "Error Occured in DoCreateVnf PrepareCreateGenericVnf Process " + ex.getMessage(), isDebugEnabled)
 
 284                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PrepareCreateGenericVnf Process")
 
 286                 utils.log("DEBUG", "*** COMPLETED DoCreateVnf PrepareCreateGenericVnf Process ***", isDebugEnabled)
 
 289         public void postProcessCreateGenericVnf (Execution execution) {
 
 290                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
 
 291                 execution.setVariable("prefix",Prefix)
 
 293                 utils.log("DEBUG", " *** STARTED DoCreateVnf PostProcessCreateGenericVnf Process *** ", isDebugEnabled)
 
 296                         String vnfId = execution.getVariable("DoCVNF_vnfId")
 
 297                         def rollbackData = execution.getVariable("RollbackData")
 
 298                         rollbackData.put("VNF", "vnfId", vnfId)
 
 299                         execution.setVariable("RollbackData", rollbackData)
 
 300                 }catch(Exception ex) {
 
 301                         utils.log("DEBUG", "Error Occured in DoCreateVnf PostProcessCreateGenericVnf Process " + ex.getMessage(), isDebugEnabled)
 
 302                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PostProcessCreateGenericVnf Process")
 
 304                 utils.log("DEBUG", "*** COMPLETED DoCreateVnf PostProcessCreateGenericVnf Process ***", isDebugEnabled)
 
 308         public void preProcessSDNCAssignRequest(Execution execution){
 
 309                 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
 
 310                 execution.setVariable("prefix", Prefix)
 
 311                 logDebug(" ======== STARTED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled)
 
 312                 def vnfId = execution.getVariable("DoCVNF_vnfId")
 
 313                 def serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId")
 
 314                 logDebug("NEW VNF ID: " + vnfId, isDebugLogEnabled)
 
 315                 utils.logAudit("NEW VNF ID: " + vnfId)
 
 320                         String assignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "assign")
 
 322                         assignSDNCRequest = utils.formatXml(assignSDNCRequest)
 
 323                         execution.setVariable("DoCVNF_assignSDNCRequest", assignSDNCRequest)
 
 324                         logDebug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest, isDebugLogEnabled)
 
 325                         utils.logAudit("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest)
 
 328                         utils.log("ERROR", "Exception Occured Processing preProcessSDNCAssignRequest. Exception is:\n" + e, isDebugLogEnabled)
 
 329                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCAssignRequest Method:\n" + e.getMessage())
 
 331                 logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled)
 
 334         public void preProcessSDNCActivateRequest(Execution execution) {
 
 335                 def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' +
 
 336                         'execution=' + execution.getId() +
 
 338                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
 
 339                 logDebug('Entered ' + method, isDebugLogEnabled)
 
 340                 execution.setVariable("prefix", Prefix)
 
 341                 logDebug(" ======== STARTED preProcessSDNCActivateRequest Process ======== ", isDebugLogEnabled)
 
 343                         String vnfId = execution.getVariable("DoCVNF_vnfId")
 
 344                         String serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId")
 
 346                         String activateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "activate")
 
 348                         execution.setVariable("DoCVNF_activateSDNCRequest", activateSDNCRequest)
 
 349                         logDebug("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest, isDebugLogEnabled)
 
 350                         utils.logAudit("Outgoing CommitSDNCRequest is: \n"  + activateSDNCRequest)
 
 353                         log.debug("Exception Occured Processing preProcessSDNCActivateRequest. Exception is:\n" + e, isDebugLogEnabled)
 
 354                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during  preProcessSDNCActivateRequest Method:\n" + e.getMessage())
 
 356                 logDebug("======== COMPLETED  preProcessSDNCActivateRequest Process ======== ", isDebugLogEnabled)
 
 359         public String buildSDNCRequest(Execution execution, String svcInstId, String action){
 
 361                                 String uuid = execution.getVariable('testReqId') // for junits
 
 363                                         uuid = execution.getVariable("mso-request-id") + "-" +          System.currentTimeMillis()
 
 365                                 def callbackURL = execution.getVariable("DoCVNF_sdncCallbackUrl")
 
 366                                 def requestId = execution.getVariable("DoCVNF_requestId")
 
 367                                 def serviceId = execution.getVariable("DoCVNF_serviceId")
 
 368                                 def vnfType = execution.getVariable("DoCVNF_vnfType")
 
 369                                 def vnfName = execution.getVariable("DoCVNF_vnfName")
 
 370                                 // Only send vnfName to SDNC if it is not null, otherwise it will get generated by SDNC on Assign
 
 371                                 String vnfNameString = ""
 
 372                                 if (vnfName != null) {
 
 373                                         vnfNameString = """<vnf-name>${vnfName}</vnf-name>"""                                   
 
 375                                 def tenantId = execution.getVariable("DoCVNF_tenantId")
 
 376                                 def source = execution.getVariable("DoCVNF_source")
 
 377                                 def vnfId = execution.getVariable("DoCVNF_vnfId")
 
 378                                 def cloudSiteId = execution.getVariable("DoCVNF_cloudSiteId")                           
 
 379                                 def modelCustomizationId = execution.getVariable("DoCVNF_modelCustomizationId")
 
 380                                 def serviceModelInfo = execution.getVariable("serviceModelInfo")
 
 381                                 def vnfModelInfo = execution.getVariable("vnfModelInfo")
 
 382                                 String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo)
 
 383                                 String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo)                               
 
 384                                 def globalSubscriberId = execution.getVariable("DoCVNF_globalSubscriberId")
 
 385                                 def sdncVersion = execution.getVariable("DoCVNF_sdncVersion")
 
 387                                 String sdncVNFParamsXml = ""
 
 389                                 if(execution.getVariable("DoCVNF_vnfParamsExistFlag") == true){
 
 390                                         sdncVNFParamsXml = buildSDNCParamsXml(execution)
 
 392                                         sdncVNFParamsXml = ""
 
 396                                 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
 
 397                                                                                                         xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
 
 398                                                                                                         xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
 
 399            <sdncadapter:RequestHeader>
 
 400                                 <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
 
 401                                 <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
 
 402                                 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
 
 403                                 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
 
 404                                 <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
 
 405                                 <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
 
 406                 </sdncadapter:RequestHeader>
 
 407         <sdncadapterworkflow:SDNCRequestData>
 
 408                 <request-information>
 
 409                         <request-id>${requestId}</request-id>
 
 410                         <request-action>CreateVnfInstance</request-action>
 
 411                         <source>${source}</source>
 
 415                 </request-information>
 
 416                 <service-information>
 
 417                         <service-id>${serviceId}</service-id>
 
 418                         <subscription-service-type>${serviceId}</subscription-service-type>
 
 419                         ${serviceEcompModelInformation}                 
 
 420                         <service-instance-id>${svcInstId}</service-instance-id>
 
 421                         <global-customer-id>${globalSubscriberId}</global-customer-id>                  
 
 422                 </service-information>
 
 424                         <vnf-id>${vnfId}</vnf-id>
 
 425                         <vnf-type>${vnfType}</vnf-type>
 
 426                         ${vnfEcompModelInformation}                     
 
 430                         <tenant>${tenantId}</tenant>            
 
 431                         <aic-cloud-region>${cloudSiteId}</aic-cloud-region>                     
 
 434         </sdncadapterworkflow:SDNCRequestData>
 
 435         </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
 
 437                         utils.logAudit("sdncRequest:  " + sdncRequest)
 
 441         public void validateSDNCResponse(Execution execution, String response, String method){
 
 442                 def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
 
 443                 execution.setVariable("prefix",Prefix)
 
 444                 logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled)
 
 446                 WorkflowException workflowException = execution.getVariable("WorkflowException")
 
 447                 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
 
 449                 utils.logAudit("workflowException: " + workflowException)
 
 451                 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
 
 452                 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
 
 454                 utils.logAudit("SDNCResponse: " + response)
 
 456                 String sdncResponse = response
 
 457                 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
 
 458                         logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call.  Response is: \n" + sdncResponse, isDebugLogEnabled)
 
 459                         if(method.equals("get")){
 
 460                                 String topologyGetResponse = execution.getVariable("DoCVNF_getSDNCAdapterResponse")
 
 461                                 String data = utils.getNodeXml(topologyGetResponse, "response-data")
 
 462                                 data = data.replaceAll("<", "<")
 
 463                                 data = data.replaceAll(">", ">")
 
 464                                 utils.log("DEBUG", "topologyGetResponseData: " + data, isDebugLogEnabled)
 
 465                                 String vnfName = utils.getNodeText1(data, "vnf-name")
 
 466                                 utils.log("DEBUG", "vnfName received from SDNC: " + vnfName, isDebugLogEnabled)
 
 467                                 execution.setVariable("vnfName", vnfName)
 
 468                                 execution.setVariable("DoCVNF_vnfName", vnfName)
 
 472                         logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled)
 
 473                         throw new BpmnError("MSOWorkflowException")
 
 475                 logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled)
 
 478         public void preProcessSDNCGetRequest(Execution execution){
 
 479                 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
 
 480                 execution.setVariable("prefix", Prefix)
 
 481                 utils.log("DEBUG", " ======== STARTED preProcessSDNCGetRequest Process ======== ", isDebugLogEnabled)
 
 483                         def serviceInstanceId = execution.getVariable('DoCVNF_serviceInstanceId')
 
 485                         String uuid = execution.getVariable('testReqId') // for junits
 
 487                                 uuid = execution.getVariable("mso-request-id") + "-" +  System.currentTimeMillis()
 
 490                         def callbackUrl = execution.getVariable("DoCVFM_sdncCallbackUrl")
 
 491                         utils.logAudit("callbackUrl:" + callbackUrl)
 
 493                         def vnfId = execution.getVariable('DCVFM_vnfId')
 
 496                         if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
 
 500                                 svcInstId = serviceInstanceId
 
 502                         // serviceOperation will be retrieved from "object-path" element
 
 503                         // in SDNC Assign Response for VNF
 
 504                         String response = execution.getVariable("DoCVNF_assignSDNCAdapterResponse")
 
 505                         utils.logAudit("DoCVNF_assignSDNCAdapterResponse is: \n" + response)
 
 507                         String serviceOperation = ""
 
 509                         String data = utils.getNodeXml(response, "response-data")
 
 510                         data = data.replaceAll("<", "<")
 
 511                         data = data.replaceAll(">", ">")
 
 512                         utils.log("DEBUG", "responseData: " + data, isDebugLogEnabled)
 
 513                         serviceOperation = utils.getNodeText1(data, "object-path")
 
 514                         utils.log("DEBUG", "VNF with sdncVersion of 1707 or later - service operation: " + serviceOperation, isDebugLogEnabled)                 
 
 517                         //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
 
 520                         String SDNCGetRequest =
 
 521                                         """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
 
 522                                                                                         xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
 
 523                                                                                         xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
 
 524                                         <sdncadapter:RequestHeader>
 
 525                                         <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId>
 
 526                                         <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
 
 527                                         <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
 
 528                                         <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation>
 
 529                                         <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
 
 530                                         <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
 
 531                                 </sdncadapter:RequestHeader>
 
 532                                         <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
 
 533                                 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
 
 535                         utils.logAudit("SDNCGetRequest: \n" + SDNCGetRequest)
 
 536                         execution.setVariable("DoCVNF_getSDNCRequest", SDNCGetRequest)
 
 537                         utils.log("DEBUG", "Outgoing GetSDNCRequest is: \n" + SDNCGetRequest, isDebugLogEnabled)
 
 540                         utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + e, isDebugLogEnabled)
 
 541                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage())
 
 543                 utils.log("DEBUG", "======== COMPLETED preProcessSDNCGetRequest Process ======== ", isDebugLogEnabled)
 
 547          * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
 
 549          * @param execution The flow's execution instance.
 
 551         public void prepUpdateAAIGenericVnf(Execution execution) {
 
 552                 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
 
 553                         'execution=' + execution.getId() +
 
 555                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
 
 556                 logDebug('Entered ' + method, isDebugLogEnabled)
 
 559                         def vnfId = execution.getVariable('DoCVNF_vnfId')
 
 560                         logDebug("VNF ID: " + vnfId, isDebugLogEnabled)         
 
 562                         String updateAAIGenericVnfRequest = """
 
 563                                         <UpdateAAIGenericVnfRequest>
 
 564                                                 <vnf-id>${vnfId}</vnf-id>
 
 565                                                 <orchestration-status>Active</orchestration-status>                                             
 
 566                                         </UpdateAAIGenericVnfRequest>
 
 568                                 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
 
 569                                 execution.setVariable('DoCVNF_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
 
 570                                 utils.logAudit("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest)
 
 571                                 logDebug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest, isDebugLogEnabled)
 
 574                         logDebug('Exited ' + method, isDebugLogEnabled)
 
 575                 } catch (BpmnError e) {
 
 577                 } catch (Exception e) {
 
 578                         logError('Caught exception in ' + method, e)
 
 579                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())