af46bf65b8178c1ab6a81ad2675aacc56ad59a6b
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.so.bpmn.infrastructure.scripts
22
23 import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory
24
25 import static org.apache.commons.lang3.StringUtils.*;
26
27 import org.camunda.bpm.engine.delegate.BpmnError
28 import org.camunda.bpm.engine.delegate.DelegateExecution;
29 import org.json.JSONArray;
30 import org.json.JSONObject;
31 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor;
32 import org.onap.so.bpmn.common.scripts.CatalogDbUtils;
33 import org.onap.so.bpmn.common.scripts.ExceptionUtil;
34 import org.onap.so.bpmn.common.scripts.MsoUtils
35 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils;
36 import org.onap.so.bpmn.common.scripts.VidUtils;
37 import org.onap.so.bpmn.core.UrnPropertiesReader
38 import org.onap.so.bpmn.core.WorkflowException
39 import org.onap.so.bpmn.core.domain.VnfResource
40 import org.onap.so.bpmn.core.json.JsonUtils;
41 import org.onap.so.bpmn.infrastructure.aai.groovyflows.AAICreateResources;
42 import org.onap.so.logger.MessageEnum
43 import org.onap.so.logger.MsoLogger
44
45
46 /**
47  * This class supports the CreateVnfInfra Flow
48  * with the creation of a generic vnf for
49  * infrastructure.
50  */
51 class CreateVnfInfra extends AbstractServiceTaskProcessor {
52         
53         private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CreateVnfInfra.class);
54         
55
56         String Prefix="CREVI_"
57         ExceptionUtil exceptionUtil = new ExceptionUtil()
58         JsonUtils jsonUtil = new JsonUtils()
59         VidUtils vidUtils = new VidUtils(this)
60         CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create()
61
62         /**
63          * This method gets and validates the incoming
64          * request.
65          *
66          * @param - execution
67          *
68          */
69         public void preProcessRequest(DelegateExecution execution) {
70                 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
71                 execution.setVariable("prefix",Prefix)
72                 msoLogger.trace("STARTED CreateVnfInfra PreProcessRequest Process")
73                 
74                 setBasicDBAuthHeader(execution, isDebugEnabled)
75                 execution.setVariable("CREVI_sentSyncResponse", false)
76
77                 try{
78                         // Get Variables
79                         String createVnfRequest = execution.getVariable("bpmnRequest")
80                         execution.setVariable("CREVI_createVnfRequest", createVnfRequest)
81                         msoLogger.debug("Incoming CreateVnfInfra Request is: \n" + createVnfRequest)
82
83                         if(createVnfRequest != null){
84
85                                 String requestId = execution.getVariable("mso-request-id")
86                                 execution.setVariable("CREVI_requestId", requestId)
87                                 msoLogger.debug("Incoming Request Id is: " + requestId)
88
89                                 String serviceInstanceId = execution.getVariable("serviceInstanceId")
90                                 execution.setVariable("CREVI_serviceInstanceId", serviceInstanceId)
91                                 msoLogger.debug("Incoming Service Instance Id is: " + serviceInstanceId)
92
93                                 String vnfType = execution.getVariable("vnfType")
94                                 execution.setVariable("CREVI_vnfType", vnfType)
95                                 msoLogger.debug("Incoming Vnf Type is: " + vnfType)
96
97                                 String vnfName = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.requestInfo.instanceName")
98                                 execution.setVariable("CREVI_vnfName", vnfName)
99                                 msoLogger.debug("Incoming Vnf Name is: " + vnfName)
100
101                                 String serviceId = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.requestInfo.productFamilyId")
102                                 execution.setVariable("CREVI_serviceId", serviceId)
103                                 msoLogger.debug("Incoming Service Id is: " + serviceId)
104
105                                 String source = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.requestInfo.source")
106                                 execution.setVariable("CREVI_source", source)
107                                 msoLogger.debug("Incoming Source is: " + source)
108
109                                 String suppressRollback = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.requestInfo.suppressRollback")
110                                 execution.setVariable("CREVI_suppressRollback", suppressRollback)
111                                 msoLogger.debug("Incoming Suppress Rollback is: " + suppressRollback)
112                                 
113                                 def vnfModelInfo = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.modelInfo")
114                                 execution.setVariable("CREVI_vnfModelInfo", vnfModelInfo)
115
116                                 String modelInvariantId = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.modelInfo.modelInvariantUuid")
117                                 execution.setVariable("CREVI_modelInvariantId", modelInvariantId)
118                                 msoLogger.debug("Incoming Invariant Id is: " + modelInvariantId)
119
120                                 String modelVersion = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.modelInfo.modelVersion")
121                                 execution.setVariable("CREVI_modelVersion", modelVersion)
122                                 msoLogger.debug("Incoming Model Version is: " + modelVersion)
123                                 
124                                 def cloudConfiguration = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.cloudConfiguration")
125                                 execution.setVariable("CREVI_cloudConfiguration", cloudConfiguration)
126                                 
127                                 String cloudSiteId = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId")
128                                 execution.setVariable("CREVI_cloudSiteId", cloudSiteId)
129                                 msoLogger.debug("Incoming Cloud Site Id is: " + cloudSiteId)
130                                 
131                                 String tenantId = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.cloudConfiguration.tenantId")
132                                 execution.setVariable("CREVI_tenantId", tenantId)
133                                 msoLogger.debug("Incoming Tenant Id is: " + tenantId)
134
135                                 //For Completion Handler & Fallout Handler
136                                 String requestInfo =
137                                 """<request-info xmlns="http://org.onap/so/infra/vnf-request/v1">
138                                         <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
139                                         <action>CREATE</action>
140                                         <source>${MsoUtils.xmlEscape(source)}</source>
141                                    </request-info>"""
142
143                                 execution.setVariable("CREVI_requestInfo", requestInfo)
144
145                                 //TODO: Orch Status - TBD, will come from SDN-C Response in 1702
146                                 String orchStatus = "Created"
147                                 execution.setVariable("CREVI_orchStatus", orchStatus)
148
149                                 //TODO: Equipment Role - Should come from SDN-C Response in 1702
150                                 String equipmentRole = " "
151                                 execution.setVariable("CREVI_equipmentRole", equipmentRole)
152
153                                 String vnfId = execution.getVariable("testVnfId") // for junits
154                                 if(isBlank(vnfId)){
155                                         vnfId = UUID.randomUUID().toString()
156                                         msoLogger.debug("Generated Vnf Id is: " + vnfId)
157                                 }
158                                 execution.setVariable("CREVI_vnfId", vnfId)
159
160                                 // Setting for Sub Flow Calls
161                                 execution.setVariable("CREVI_type", "generic-vnf")
162                                 execution.setVariable("GENGS_type", "service-instance")
163                                 
164                                 String sdncCallbackUrl = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
165                                 if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
166                                         def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing'
167                                         msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError);
168                                         
169                                         exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
170                                 }
171                                 execution.setVariable("CREVI_sdncCallbackUrl", sdncCallbackUrl)
172                                 
173                                 def vnfInputParameters = null
174                                 try {
175                                         vnfInputParameters = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.requestParameters.userParams")
176                                 }
177                                 catch (Exception e) {
178                                         msoLogger.debug("userParams are not present in the request")
179                                 }
180                                 execution.setVariable("CREVI_vnfInputParameters", vnfInputParameters)
181                                 
182                                 
183                                 msoLogger.debug("SDNC Callback URL: " + sdncCallbackUrl)
184                         }else{
185                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Bpmn Request is Null.")
186                         }
187
188                 }catch(BpmnError b){
189                         msoLogger.debug("Rethrowing MSOWorkflowException")
190                         throw b
191                 }catch(Exception e){
192                         msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Error Occurred in CreateVnfInfra PreProcessRequest method", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e)
193                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occurred in CreateVnfInfra PreProcessRequest")
194
195                 }
196                 msoLogger.trace("COMPLETED CreateVnfInfra PreProcessRequest Process")
197         }
198
199         public void sendSyncResponse (DelegateExecution execution) {
200                 execution.setVariable("prefix",Prefix)
201
202                 msoLogger.trace("STARTED CreateVnfInfra SendSyncResponse Process")
203
204                 try {
205                         String requestId = execution.getVariable("CREVI_requestId")
206                         String vnfId = execution.getVariable("CREVI_vnfId")
207
208                         String createVnfResponse = """{"requestReferences":{"instanceId":"${vnfId}","requestId":"${requestId}"}}""".trim()
209
210                         msoLogger.debug("CreateVnfInfra Sync Response is: \n"  + createVnfResponse)
211
212                         sendWorkflowResponse(execution, 202, createVnfResponse)
213
214                         execution.setVariable("CREVI_sentSyncResponse", true)
215
216                 } catch (Exception ex) {
217                         msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Error Occurred in CreateVnfInfra SendSyncResponse Process", "BPMN", MsoLogger.getServiceName(),
218                                 MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e)
219                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVnfInfra SendSyncResponse Process")
220
221                 }
222                 msoLogger.trace("COMPLETED CreateVnfInfra SendSyncResponse Process")
223         }
224
225         
226         public void preProcessSDNCAssignRequest(DelegateExecution execution){
227                 execution.setVariable("prefix", Prefix)
228                 msoLogger.trace("STARTED preProcessSDNCAssignRequest")
229                 def vnfId = execution.getVariable("CREVI_vnfId")                
230                 def serviceInstanceId = execution.getVariable("CREVI_serviceInstanceId")
231                 msoLogger.debug("NEW VNF ID: " + vnfId)
232
233                 try{
234                         //Build SDNC Request
235                         
236                         String assignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "assign")
237
238                         assignSDNCRequest = utils.formatXml(assignSDNCRequest)
239                         execution.setVariable("CREVI_assignSDNCRequest", assignSDNCRequest)
240                         msoLogger.debug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest)
241
242                 }catch(Exception e){
243                         msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occurred Processing preProcessSDNCAssignRequest", "BPMN", MsoLogger.getServiceName(),
244                                 MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e)
245                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareProvision Method:\n" + e.getMessage())
246                 }
247                 msoLogger.trace("COMPLETED preProcessSDNCAssignRequest")
248         }
249         
250         public void preProcessSDNCActivateRequest(DelegateExecution execution) {
251                 def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' +
252                         'execution=' + execution.getId() +
253                         ')'
254                 msoLogger.trace('Entered ' + method)
255                 execution.setVariable("prefix", Prefix)
256                 msoLogger.trace("STARTED preProcessSDNCActivateRequest Process")
257                 try{
258                         String vnfId = execution.getVariable("CREVI_vnfId")                     
259                         String serviceInstanceId = execution.getVariable("CREVI_serviceInstanceId")
260
261                         String activateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "activate")
262
263                         execution.setVariable("CREVI_activateSDNCRequest", activateSDNCRequest)
264                         msoLogger.debug("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest)
265
266                 }catch(Exception e){
267                         msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessSDNCActivateRequest", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e)
268                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during  preProcessSDNCActivateRequest Method:\n" + e.getMessage())
269                 }
270                 msoLogger.trace("COMPLETED  preProcessSDNCActivateRequest Process")
271         }
272         
273         public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){
274                 
275                                 String uuid = execution.getVariable('testReqId') // for junits
276                                 if(uuid==null){
277                                         uuid = execution.getVariable("mso-request-id") + "-" +          System.currentTimeMillis()
278                                 }
279                                 def callbackURL = execution.getVariable("CREVI_sdncCallbackUrl")
280                                 def requestId = execution.getVariable("CREVI_requestId")
281                                 def serviceId = execution.getVariable("CREVI_serviceId")
282                                 def vnfType = execution.getVariable("CREVI_vnfType")
283                                 def vnfName = execution.getVariable("CREVI_vnfName")
284                                 def tenantId = execution.getVariable("CREVI_tenantId")
285                                 def source = execution.getVariable("CREVI_source")                              
286                                 def vnfId = execution.getVariable("CREVI_vnfId")
287                                 def cloudSiteId = execution.getVariable("CREVI_cloudSiteId")
288                 
289                                 String sdncVNFParamsXml = ""
290                 
291                                 if(execution.getVariable("CREVI_vnfParamsExistFlag") == true){
292                                         sdncVNFParamsXml = buildSDNCParamsXml(execution)
293                                 }else{
294                                         sdncVNFParamsXml = ""
295                                 }
296                 
297                                 String sdncRequest =
298                                 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
299                                                                                                         xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
300                                                                                                         xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
301            <sdncadapter:RequestHeader>
302                                 <sdncadapter:RequestId>${MsoUtils.xmlEscape(requestId)}</sdncadapter:RequestId>
303                                 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
304                                 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
305                                 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
306                                 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
307                 </sdncadapter:RequestHeader>
308         <sdncadapterworkflow:SDNCRequestData>
309                 <request-information>
310                         <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
311                         <request-action>VNFActivateRequest</request-action>
312                         <source>${MsoUtils.xmlEscape(source)}</source>
313                         <notification-url/>
314                 </request-information>
315                 <service-information>
316                         <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
317                         <service-type>${MsoUtils.xmlEscape(serviceId)}</service-type>
318                         <service-instance-id>${MsoUtils.xmlEscape(svcInstId)}</service-instance-id>
319                         <subscriber-name>notsurewecare</subscriber-name>
320                 </service-information>
321                 <vnf-request-information>                       
322                         <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
323                         <vnf-name>${MsoUtils.xmlEscape(vnfName)}</vnf-name>
324                         <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type>
325                         <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region>
326                         <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
327                 ${sdncVNFParamsXml}
328                 </vnf-request-information>
329         </sdncadapterworkflow:SDNCRequestData>
330         </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
331                 
332                         msoLogger.debug("sdncRequest:  " + sdncRequest)
333                         return sdncRequest              
334         }
335                 
336         public void validateSDNCResponse(DelegateExecution execution, String response, String method){
337                 execution.setVariable("prefix",Prefix)
338                 msoLogger.debug("STARTED ValidateSDNCResponse Process")
339
340                 WorkflowException workflowException = execution.getVariable("WorkflowException")
341                 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
342
343                 msoLogger.debug("workflowException: " + workflowException)
344
345                 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
346                 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
347
348                 msoLogger.debug("SDNCResponse: " + response)
349
350                 String sdncResponse = response
351                 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
352                         msoLogger.trace("Received a Good Response from SDNC Adapter for " + method + " SDNC Call.  Response is: \n" + sdncResponse)
353                         
354                 }else{
355                         msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.")
356                         throw new BpmnError("MSOWorkflowException")
357                 }
358                 msoLogger.trace("COMPLETED ValidateSDNCResponse Process")
359         }
360
361         public void prepareCompletionHandlerRequest(DelegateExecution execution){
362                 execution.setVariable("prefix",Prefix)
363
364                 msoLogger.trace("STARTED CreateVnfInfra PrepareCompletionHandlerRequest Process")
365
366                 try {
367                         String requestInfo = execution.getVariable("CREVI_requestInfo")
368                         String vnfId = execution.getVariable("CREVI_vnfId")
369                         requestInfo = utils.removeXmlPreamble(requestInfo)
370
371                         String request =
372                                 """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
373                                                                         xmlns:ns="http://org.onap/so/request/types/v1">
374                                                         ${requestInfo}
375                                                         <status-message>Vnf has been created successfully.</status-message>
376                                                         <vnfId>${MsoUtils.xmlEscape(vnfId)}</vnfId>
377                                                         <mso-bpel-name>CreateVnfInfra</mso-bpel-name>
378                                                 </aetgt:MsoCompletionRequest>"""
379
380                         execution.setVariable("CREVI_completionHandlerRequest", request)
381                         msoLogger.debug("Completion Handler Request is: " + request)
382
383                         execution.setVariable("WorkflowResponse", "Success") // for junits
384
385                 } catch (Exception ex) {
386                         msoLogger.debug("Error Occured in CreateVnfInfra PrepareCompletionHandlerRequest Process " + ex.getMessage())
387                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVnfInfra PrepareCompletionHandlerRequest Process")
388
389                 }
390                 msoLogger.trace("COMPLETED CreateVnfInfra PrepareCompletionHandlerRequest Process")
391         }
392
393         public void sendErrorResponse(DelegateExecution execution){
394                 execution.setVariable("prefix",Prefix)
395
396                 msoLogger.trace("STARTED CreateVnfInfra sendErrorResponse Process")
397                 try {
398                         def sentSyncResponse = execution.getVariable("CREVI_sentSyncResponse")
399                         if(sentSyncResponse == false){
400                                 WorkflowException wfex = execution.getVariable("WorkflowException")
401                                 String response = exceptionUtil.buildErrorResponseXml(wfex)
402
403                                 msoLogger.debug(response)
404                                 sendWorkflowResponse(execution, 500, response)
405                         }else{
406                                 msoLogger.debug("Not Sending Error Response.  Sync Response Already Sent")
407                         }
408
409                 } catch (Exception ex) {
410                         msoLogger.debug("Error Occured in CreateVnfInfra sendErrorResponse Process " + ex.getMessage())
411                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVnfInfra sendErrorResponse Process")
412
413                 }
414                 msoLogger.trace("COMPLETED CreateVnfInfra sendErrorResponse Process")
415         }
416
417         public void prepareFalloutRequest(DelegateExecution execution){
418                 execution.setVariable("prefix",Prefix)
419
420                 msoLogger.trace("STARTED CreateVnfInfra prepareFalloutRequest Process")
421
422                 try {
423                         WorkflowException wfex = execution.getVariable("WorkflowException")
424                         msoLogger.debug(" Incoming Workflow Exception: " + wfex.toString())
425                         String requestInfo = execution.getVariable("CREVI_requestInfo")
426                         msoLogger.debug(" Incoming Request Info: " + requestInfo)
427
428                         String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo)
429
430                         execution.setVariable("CREVI_falloutRequest", falloutRequest)
431
432
433                 } catch (Exception ex) {
434                         msoLogger.debug("Error Occured in CreateVnfInfra prepareFalloutRequest Process " + ex.getMessage())
435                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVnfInfra prepareFalloutRequest Process")
436
437                 }
438                 msoLogger.trace("COMPLETED CreateVnfInfra prepareFalloutRequest Process")
439         }
440
441         
442         public void queryCatalogDB (DelegateExecution execution) {
443                 execution.setVariable("prefix",Prefix)
444
445                 msoLogger.trace("STARTED CreateVnfInfra QueryCatalogDB Process")
446                 try {
447                         //Get Vnf Info
448                         String vnfModelInfo = execution.getVariable("CREVI_vnfModelInfo")
449                         String vnfModelCustomizationUuid = jsonUtil.getJsonValueForKey(vnfModelInfo, "modelCustomizationUuid")
450                         msoLogger.debug("querying Catalog DB by vnfModelCustomizationUuid: " + vnfModelCustomizationUuid)
451                                                 
452                         JSONArray vnfs = catalogDbUtils.getAllVnfsByVnfModelCustomizationUuid(execution,
453                                                         vnfModelCustomizationUuid, "v2")
454                         msoLogger.debug("obtained VNF list: " + vnfs)
455                         
456                         if (vnfs == null) {
457                                 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "No matching VNFs in Catalog DB for vnfModelCustomizationUuid=" + vnfModelCustomizationUuid, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
458                                 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "No matching VNFs in Catalog DB for vnfModelCustomizationUuid=" + vnfModelCustomizationUuid)
459                         }
460                         
461                         // Only one match here
462                         JSONObject vnf = vnfs.get(0)
463                         
464                         if (vnf == null) {
465                                 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "No matching VNF in Catalog DB for vnfModelCustomizationUuid=" + vnfModelCustomizationUuid, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
466                                 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "No matching VNF in Catalog DB for vnfModelCustomizationUuid=" + vnfModelCustomizationUuid)
467                         }                       
468                         
469                         VnfResource vnfResource = new VnfResource()
470                         String nfType = jsonUtil.getJsonValueForKey(vnf, "nfType")
471                         vnfResource.setNfType(nfType)
472                         String nfRole = jsonUtil.getJsonValueForKey(vnf, "nfRole")
473                         vnfResource.setNfRole(nfRole)
474                         String nfFunction = jsonUtil.getJsonValueForKey(vnf, "nfFunction")
475                         vnfResource.setNfFunction(nfFunction)
476                         String nfNamingCode = jsonUtil.getJsonValueForKey(vnf, "nfNamingCode")
477                         vnfResource.setNfNamingCode(nfNamingCode)
478                         
479                         execution.setVariable("CREVI_vnfResourceDecomposition", vnfResource)
480                         
481                 }catch(BpmnError e) {
482                         throw e;                        
483                 }catch(Exception ex) {
484                         msoLogger.debug("Error Occurred in CreateVnfInfra QueryCatalogDB Process " + ex.getMessage())
485                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occurred in CreateVnfInfra QueryCatalogDB Process")
486                 }
487                 
488                 
489                 msoLogger.trace("COMPLETED CreateVnfInfra QueryCatalogDb Process")
490         }
491         public void createPlatform (DelegateExecution execution) {
492                 msoLogger.trace("START createPlatform")
493                 
494                 String request = execution.getVariable("bpmnRequest")
495                 String platformName = jsonUtil.getJsonValue(request, "requestDetails.platform.platformName")
496                 String vnfId = execution.getVariable("CREVI_vnfId")
497         
498                 msoLogger.debug("Platform NAME: " + platformName)
499                 msoLogger.debug("VnfID: " + vnfId)
500                 
501                 if(platformName == null||platformName.equals("")){
502                         String msg = "Exception in createPlatform. platformName was not found in the request.";
503                         msoLogger.debug(msg)
504                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
505                 }else{
506                         msoLogger.debug("platformName was found.")
507                         try{
508                                 AAICreateResources aaiCR = new AAICreateResources()
509                                 aaiCR.createAAIPlatform(platformName, vnfId)
510                         }catch(Exception ex){
511                                 String msg = "Exception in createPlatform. " + ex.getMessage();
512                                 msoLogger.debug(msg)
513                                 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
514                         }
515                 }
516                 msoLogger.trace("Exit createPlatform")
517         }
518         public void createLineOfBusiness (DelegateExecution execution) {
519                 msoLogger.trace("START createLineOfBusiness")
520                 
521                 String request = execution.getVariable("bpmnRequest")
522                 String lineOfBusiness = jsonUtil.getJsonValue(request, "requestDetails.lineOfBusiness.lineOfBusinessName")
523                 String vnfId = execution.getVariable("CREVI_vnfId")
524         
525                 msoLogger.debug("LineOfBusiness NAME: " + lineOfBusiness)
526                 msoLogger.debug("VnfID: " + vnfId)
527                 
528                 if(lineOfBusiness == null || lineOfBusiness.equals("")){
529                         msoLogger.debug("LineOfBusiness was not found. Continuing on with flow...")
530                 }else{
531                         msoLogger.debug("LineOfBusiness was found.")
532                         try{
533                                 AAICreateResources aaiCR = new AAICreateResources()
534                                 aaiCR.createAAILineOfBusiness(lineOfBusiness, vnfId)
535                         }catch(Exception ex){
536                                 String msg = "Exception in LineOfBusiness. " + ex.getMessage();
537                                 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + ex)
538                                 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
539                         }
540                 }
541                 msoLogger.trace("Exit createLineOfBusiness")
542         }
543 }