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