2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package org.openecomp.mso.bpmn.infrastructure.scripts;
\r
23 import groovy.json.JsonSlurper
\r
24 import groovy.json.JsonOutput
\r
26 import javax.xml.parsers.DocumentBuilder
\r
27 import javax.xml.parsers.DocumentBuilderFactory
\r
29 import org.w3c.dom.Document
\r
30 import org.w3c.dom.Element
\r
31 import org.w3c.dom.Node
\r
32 import org.w3c.dom.NodeList
\r
33 import org.xml.sax.InputSource
\r
35 import org.camunda.bpm.engine.delegate.BpmnError
\r
36 import org.camunda.bpm.engine.delegate.DelegateExecution
\r
37 import org.onap.appc.client.lcm.model.Action
\r
38 import org.apache.commons.lang3.*
\r
39 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor;
\r
40 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil;
\r
41 import org.openecomp.mso.bpmn.common.scripts.NetworkUtils;
\r
42 import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils;
\r
43 import org.openecomp.mso.bpmn.common.scripts.VidUtils;
\r
44 import org.openecomp.mso.bpmn.core.RollbackData
\r
45 import org.openecomp.mso.bpmn.core.WorkflowException
\r
46 import org.openecomp.mso.bpmn.core.json.JsonUtils
\r
47 import org.openecomp.mso.bpmn.infrastructure.aai.AAICreateResources;
\r
48 import org.onap.aai.domain.yang.v12.GenericVnf;
\r
50 public class CreateVfModuleInfra extends AbstractServiceTaskProcessor {
\r
52 ExceptionUtil exceptionUtil = new ExceptionUtil()
\r
53 JsonUtils jsonUtil = new JsonUtils()
\r
55 private AbstractServiceTaskProcessor taskProcessor
\r
57 public SDNCAdapterUtils(AbstractServiceTaskProcessor taskProcessor) {
\r
58 this.taskProcessor = taskProcessor
\r
62 * Validates the request message and sets up the workflow.
\r
63 * @param execution the execution
\r
65 public void preProcessRequest(DelegateExecution execution) {
\r
66 def method = getClass().getSimpleName() + '.preProcessRequest(' +
\r
67 'execution=' + execution.getId() +
\r
69 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
70 logDebug('Entered ' + method, isDebugLogEnabled)
\r
72 execution.setVariable("CVFMI_sentSyncResponse", false)
\r
74 def prefix = 'CVFMI_'
\r
75 logDebug('Entered 1' + method, isDebugLogEnabled)
\r
76 execution.setVariable('prefix', prefix)
\r
77 logDebug('Entered 2' + method, isDebugLogEnabled)
\r
78 execution.setVariable("isVidRequest", "false")
\r
80 logDebug("Set variables", isDebugLogEnabled)
\r
82 def rollbackData = execution.getVariable("RollbackData")
\r
83 if (rollbackData == null) {
\r
84 rollbackData = new RollbackData()
\r
86 execution.setVariable("RollbackData", rollbackData)
\r
88 logDebug("Set rollback data", isDebugLogEnabled)
\r
89 def incomingRequest = execution.getVariable('bpmnRequest')
\r
91 utils.log("DEBUG", "Incoming Infra Request: " + incomingRequest, isDebugLogEnabled)
\r
92 utils.logAudit("CreateVfModule Infra incoming Request: " + incomingRequest)
\r
94 setBasicDBAuthHeader(execution, isDebugLogEnabled)
\r
96 // check if request is xml or json
\r
98 def jsonSlurper = new JsonSlurper()
\r
99 def jsonOutput = new JsonOutput()
\r
100 Map reqMap = jsonSlurper.parseText(incomingRequest)
\r
101 utils.log("DEBUG", " Request is in JSON format.", isDebugLogEnabled)
\r
103 def serviceInstanceId = execution.getVariable('serviceInstanceId')
\r
104 def vnfId = execution.getVariable('vnfId')
\r
106 execution.setVariable(prefix + 'serviceInstanceId', serviceInstanceId)
\r
107 execution.setVariable(prefix+'vnfId', vnfId)
\r
108 execution.setVariable("isVidRequest", "true")
\r
111 def asdcServiceModelVersion = ''
\r
112 def serviceModelInfo = null
\r
113 def vnfModelInfo = null
\r
115 def relatedInstanceList = reqMap.requestDetails?.relatedInstanceList
\r
117 if (relatedInstanceList != null) {
\r
118 relatedInstanceList.each {
\r
119 if (it.relatedInstance.modelInfo?.modelType == 'service') {
\r
120 asdcServiceModelVersion = it.relatedInstance.modelInfo?.modelVersion
\r
121 serviceModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo)
\r
124 if (it.relatedInstance.modelInfo.modelType == 'vnf') {
\r
125 vnfName = it.relatedInstance.instanceName ?: ''
\r
126 vnfModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo)
\r
131 execution.setVariable(prefix + 'vnfName', vnfName)
\r
132 execution.setVariable(prefix + 'asdcServiceModelVersion', asdcServiceModelVersion)
\r
133 execution.setVariable(prefix + 'serviceModelInfo', serviceModelInfo)
\r
134 execution.setVariable(prefix + 'vnfModelInfo', vnfModelInfo)
\r
137 def vnfType = execution.getVariable('vnfType')
\r
138 execution.setVariable(prefix + 'vnfType', vnfType)
\r
139 def vfModuleId = execution.getVariable('vfModuleId')
\r
140 execution.setVariable(prefix + 'vfModuleId', vfModuleId)
\r
141 def volumeGroupId = execution.getVariable('volumeGroupId')
\r
142 execution.setVariable(prefix + 'volumeGroupId', volumeGroupId)
\r
143 def userParams = reqMap.requestDetails?.requestParameters?.userParams
\r
145 Map<String, String> userParamsMap = [:]
\r
146 if (userParams != null) {
\r
147 userParams.each { userParam ->
\r
148 userParamsMap.put(userParam.name, jsonOutput.toJson(userParam.value).toString())
\r
152 utils.log("DEBUG", 'Processed user params: ' + userParamsMap, isDebugLogEnabled)
\r
154 execution.setVariable(prefix + 'vfModuleInputParams', userParamsMap)
\r
156 def isBaseVfModule = "false"
\r
157 if (execution.getVariable('isBaseVfModule') == true) {
\r
158 isBaseVfModule = "true"
\r
161 execution.setVariable(prefix + 'isBaseVfModule', isBaseVfModule)
\r
163 def requestId = execution.getVariable("mso-request-id")
\r
164 execution.setVariable(prefix + 'requestId', requestId)
\r
166 def vfModuleModelInfo = jsonOutput.toJson(reqMap.requestDetails?.modelInfo)
\r
167 execution.setVariable(prefix + 'vfModuleModelInfo', vfModuleModelInfo)
\r
169 def suppressRollback = reqMap.requestDetails?.requestInfo?.suppressRollback
\r
172 def backoutOnFailure = ""
\r
173 if(suppressRollback != null){
\r
174 if ( suppressRollback == true) {
\r
175 backoutOnFailure = "false"
\r
176 } else if ( suppressRollback == false) {
\r
177 backoutOnFailure = "true"
\r
181 execution.setVariable('disableRollback', suppressRollback)
\r
183 def vfModuleName = reqMap.requestDetails?.requestInfo?.instanceName ?: null
\r
184 execution.setVariable(prefix + 'vfModuleName', vfModuleName)
\r
186 def serviceId = reqMap.requestDetails?.requestParameters?.serviceId ?: ''
\r
187 execution.setVariable(prefix + 'serviceId', serviceId)
\r
189 def usePreload = reqMap.requestDetails?.requestParameters?.usePreload
\r
190 execution.setVariable(prefix + 'usePreload', usePreload)
\r
192 // This is aLaCarte flow, so aLaCarte flag is always on
\r
193 execution.setVariable(prefix + 'aLaCarte', true)
\r
195 def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration
\r
196 def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId
\r
197 execution.setVariable(prefix + 'lcpCloudRegionId', lcpCloudRegionId)
\r
198 def tenantId = cloudConfiguration.tenantId
\r
199 execution.setVariable(prefix + 'tenantId', tenantId)
\r
201 def globalSubscriberId = reqMap.requestDetails?.subscriberInfo?.globalSubscriberId ?: ''
\r
202 execution.setVariable(prefix + 'globalSubscriberId', globalSubscriberId)
\r
204 execution.setVariable(prefix + 'sdncVersion', '1702')
\r
206 execution.setVariable("CreateVfModuleInfraSuccessIndicator", false)
\r
207 execution.setVariable("RollbackCompleted", false)
\r
209 execution.setVariable("isDebugLogEnabled", isDebugLogEnabled)
\r
212 def source = reqMap.requestDetails?.requestInfo?.source
\r
213 execution.setVariable("CVFMI_source", source)
\r
215 //For Completion Handler & Fallout Handler
\r
216 String requestInfo =
\r
217 """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
\r
218 <request-id>${requestId}</request-id>
\r
219 <action>CREATE</action>
\r
220 <source>${source}</source>
\r
223 execution.setVariable("CVFMI_requestInfo", requestInfo)
\r
227 execution.setVariable("CVFMI_originalWorkflowException", null)
\r
230 def newVfModuleId = UUID.randomUUID().toString()
\r
231 execution.setVariable("newVfModuleId", newVfModuleId)
\r
232 execution.setVariable(prefix + 'vfModuleId', newVfModuleId)
\r
233 execution.setVariable('actionHealthCheck', Action.HealthCheck)
\r
234 execution.setVariable('actionConfigScaleOut', Action.ConfigScaleOut)
\r
235 def controllerType = execution.getVariable('controllerType')
\r
236 execution.setVariable(prefix + 'controllerType', controllerType)
\r
237 execution.setVariable('healthCheckIndex0', 0)
\r
239 logDebug('RequestInfo: ' + execution.getVariable("CVFMI_requestInfo"), isDebugLogEnabled)
\r
241 logDebug('rollbackEnabled: ' + execution.getVariable("CVFMI_rollbackEnabled"), isDebugLogEnabled)
\r
243 logDebug('Exited ' + method, isDebugLogEnabled)
\r
244 } catch (BpmnError bpmnError) {
\r
247 catch(groovy.json.JsonException je) {
\r
248 utils.log("DEBUG", " Request is not in JSON format.", isDebugLogEnabled)
\r
249 exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - During PreProcessRequest")
\r
251 catch(Exception e) {
\r
252 String restFaultMessage = e.getMessage()
\r
253 //execution.setVariable("CVFMODVOL2_RESTFault", restFaultMessage)
\r
254 //execution.setVariable("CVFMODVOL2_isDataOk", false)
\r
255 utils.log("ERROR", " Exception Encountered - " + "\n" + restFaultMessage, isDebugLogEnabled)
\r
256 exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - During PreProcessRequest")
\r
262 * Validates a workflow response.
\r
263 * @param execution the execution
\r
264 * @param responseVar the execution variable in which the response is stored
\r
265 * @param responseCodeVar the execution variable in which the response code is stored
\r
266 * @param errorResponseVar the execution variable in which the error response is stored
\r
268 public void validateWorkflowResponse(DelegateExecution execution, String responseVar,
\r
269 String responseCodeVar, String errorResponseVar) {
\r
270 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
\r
271 sdncAdapterUtils.validateSDNCResponse(execution, responseVar, responseCodeVar, errorResponseVar)
\r
276 * Sends the empty, synchronous response back to the API Handler.
\r
277 * @param execution the execution
\r
279 public void sendResponse(DelegateExecution execution) {
\r
280 def method = getClass().getSimpleName() + '.sendResponse(' +
\r
281 'execution=' + execution.getId() +
\r
283 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
284 logDebug('Entered ' + method, isDebugLogEnabled)
\r
287 def requestInfo = execution.getVariable('CVFMI_requestInfo')
\r
288 def requestId = execution.getVariable('CVFMI_requestId')
\r
289 def source = execution.getVariable('CVFMI_source')
\r
291 // RESTResponse (for API Handler (APIH) Reply Task)
\r
292 def newVfModuleId = execution.getVariable("newVfModuleId")
\r
293 String synchResponse = """{"requestReferences":{"instanceId":"${newVfModuleId}","requestId":"${requestId}"}}""".trim()
\r
295 sendWorkflowResponse(execution, 200, synchResponse)
\r
297 execution.setVariable("CVFMI_sentSyncResponse", true)
\r
298 utils.logAudit("CreateVfModule Infra Response: " + synchResponse)
\r
299 logDebug('Exited ' + method, isDebugLogEnabled)
\r
300 } catch (BpmnError e) {
\r
302 } catch (Exception e) {
\r
303 logError('Caught exception in ' + method, e)
\r
304 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage())
\r
309 * Query AAI for vnf orchestration status to determine if health check and config scaling should be run
\r
311 public void queryAAIForVnfOrchestrationStatus(DelegateExecution execution) {
\r
312 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
313 def vnfId = execution.getVariable("CVFMI_vnfId")
\r
314 execution.setVariable("runHealthCheck", false);
\r
315 execution.setVariable("runConfigScaleOut", false);
\r
316 AAICreateResources aaiCreateResources = new AAICreateResources();
\r
317 Optional<GenericVnf> vnf = aaiCreateResources.getVnfInstance(vnfId);
\r
318 if(vnf.isPresent()){
\r
319 def vnfOrchestrationStatus = vnf.get().getOrchestrationStatus();
\r
320 if("active".equalsIgnoreCase(vnfOrchestrationStatus)){
\r
321 execution.setVariable("runHealthCheck", true);
\r
322 execution.setVariable("runConfigScaleOut", true);
\r
328 * Retrieve data for ConfigScaleOut from SDNC topology
\r
331 public void retreiveConfigScaleOutData(DelegateExecution execution){
\r
332 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
333 def vfModuleId = execution.getVariable("CVFMI_vfModuleId")
\r
334 String ipAddress = "";
\r
335 String oamIpAddress = "";
\r
336 String vnfHostIpAddress = "";
\r
338 String vnfGetSDNC = execution.getVariable("DCVFM_getSDNCAdapterResponse");
\r
340 String data = utils.getNodeXml(vnfGetSDNC, "response-data")
\r
341 data = data.replaceAll("<", "<")
\r
342 data = data.replaceAll(">", ">")
\r
344 InputSource source = new InputSource(new StringReader(data));
\r
345 DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
\r
346 docFactory.setNamespaceAware(true)
\r
347 DocumentBuilder docBuilder = docFactory.newDocumentBuilder()
\r
348 Document responseXml = docBuilder.parse(source)
\r
350 NodeList paramsList = responseXml.getElementsByTagNameNS("*", "vnf-parameters")
\r
351 for (int z = 0; z < paramsList.getLength(); z++) {
\r
352 Node node = paramsList.item(z)
\r
353 Element eElement = (Element) node
\r
354 String vnfParameterName = utils.getElementText(eElement, "vnf-parameter-name")
\r
355 String vnfParameterValue = utils.getElementText(eElement, "vnf-parameter-value")
\r
356 if (vnfParameterName.equals("vlb_private_ip_1")) {
\r
357 vnfHostIpAddress = vnfParameterValue
\r
359 else if (vnfParameterName.equals("vdns_private_ip_0")) {
\r
360 ipAddress = vnfParameterValue
\r
362 else if (vnfParameterName.equals("vdns_private_ip_1")) {
\r
363 oamIpAddress = vnfParameterValue
\r
367 String payload = "{\"request-parameters\":{\"vnf-host-ip-address\":" + vnfHostIpAddress + ",\"vf-module-id\":" + vfModuleId + "},\"configuration-parameters\":{\"ip-addr\":" + ipAddress +", \"oam-ip-addr\":"+ oamIpAddress +",\"enabled\":\"true\"}}"
\r
368 execution.setVariable("payload", payload);
\r
373 * @param execution the execution
\r
375 public void postProcessResponse(DelegateExecution execution){
\r
376 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
378 utils.log("DEBUG", " ======== STARTED PostProcessResponse Process ======== ", isDebugEnabled)
\r
380 def requestInfo = execution.getVariable("CVFMI_requestInfo")
\r
381 def action = utils.getNodeText1(requestInfo, "action")
\r
383 utils.log("DEBUG", "requestInfo is: " + requestInfo, isDebugEnabled)
\r
384 utils.log("DEBUG", "action is: " + action, isDebugEnabled)
\r
387 """ <aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
\r
388 xmlns:ns="http://org.openecomp/mso/request/types/v1"
\r
389 xmlns:ns8="http://org.openecomp/mso/workflow/schema/v1">
\r
390 <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
\r
393 <ns8:status-message>Vf Module has been created successfully.</ns8:status-message>
\r
394 <ns8:mso-bpel-name>BPMN</ns8:mso-bpel-name>
\r
395 </aetgt:MsoCompletionRequest>"""
\r
397 payload = utils.formatXml(payload)
\r
398 execution.setVariable("CVFMI_SuccessFlag", true)
\r
399 execution.setVariable("CVFMI_msoCompletionRequest", payload)
\r
400 utils.logAudit("CreateVfModuleInfra completion request: " + payload)
\r
401 utils.log("DEBUG", "Outgoing MsoCompletionRequest: \n" + payload, isDebugEnabled)
\r
403 }catch(Exception e){
\r
404 utils.log("ERROR", "Exception Occured Processing PostProcessResponse. Exception is:\n" + e, isDebugEnabled)
\r
405 execution.setVariable("CVFMI_ErrorResponse", "Error Occured during PostProcessResponse Method:\n" + e.getMessage())
\r
407 utils.log("DEBUG", "======== COMPLETED PostProcessResponse Process ======== ", isDebugEnabled)
\r
415 * Validates the request, request id and service instance id. If a problem is found,
\r
416 * a WorkflowException is generated and an MSOWorkflowException event is thrown. This
\r
417 * method also sets up the log context for the workflow.
\r
418 * @param execution the execution
\r
419 * @return the validated request
\r
421 public String validateInfraRequest(DelegateExecution execution) {
\r
422 def method = getClass().getSimpleName() + '.validateInfraRequest(' +
\r
423 'execution=' + execution.getId() +
\r
425 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
426 logDebug('Entered ' + method, isDebugLogEnabled)
\r
428 String processKey = getProcessKey(execution);
\r
429 def prefix = execution.getVariable("prefix")
\r
431 if (prefix == null) {
\r
432 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " prefix is null")
\r
436 def request = execution.getVariable(prefix + 'Request')
\r
438 if (request == null) {
\r
439 request = execution.getVariable(processKey + 'Request')
\r
441 if (request == null) {
\r
442 request = execution.getVariable('bpmnRequest')
\r
445 setVariable(execution, processKey + 'Request', null);
\r
446 setVariable(execution, 'bpmnRequest', null);
\r
447 setVariable(execution, prefix + 'Request', request);
\r
450 if (request == null) {
\r
451 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request is null")
\r
456 def requestId = execution.getVariable("mso-request-id")
\r
458 if (requestId == null) {
\r
459 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request has no mso-request-id")
\r
462 setVariable(execution, prefix + 'requestId', requestId)
\r
464 def serviceInstanceId = execution.getVariable("mso-service-instance-id")
\r
466 if (serviceInstanceId == null) {
\r
467 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request message has no mso-service-instance-id")
\r
470 utils.logContext(requestId, serviceInstanceId)
\r
472 utils.logAudit("CreateVfModule incoming request: " + request)
\r
473 logDebug('Incoming message: ' + System.lineSeparator() + request, isDebugLogEnabled)
\r
474 logDebug('Exited ' + method, isDebugLogEnabled)
\r
476 } catch (BpmnError e) {
\r
478 } catch (Exception e) {
\r
479 logError('Caught exception in ' + method, e)
\r
480 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Invalid Message")
\r
484 public void prepareUpdateInfraRequest(DelegateExecution execution){
\r
485 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
487 utils.log("DEBUG", " ======== STARTED prepareUpdateInfraRequest Process ======== ", isDebugEnabled)
\r
491 String requestInfo = execution.getVariable("CVFMI_requestInfo")
\r
492 def aicCloudRegion = execution.getVariable("CVFMI_lcpCloudRegionId")
\r
493 def tenantId = execution.getVariable("CVFMI_tenantId")
\r
494 def requestId = utils.getNodeText1(requestInfo, "request-id")
\r
495 def vnfId = execution.getVariable("CVFMI_vnfId")
\r
496 def vfModuleId = execution.getVariable("CVFMI_vfModuleId")
\r
497 // vfModuleName may be generated by DoCreateVfModule subprocess if it is not specified on the input
\r
498 def vfModuleName = execution.getVariable("CVFMI_vfModuleName")
\r
500 def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint")
\r
501 execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
\r
502 utils.log("DEBUG", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
\r
505 """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
\r
506 xmlns:ns="http://org.openecomp.mso/requestsdb">
\r
509 <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb">
\r
510 <requestId>${requestId}</requestId>
\r
511 <lastModifiedBy>BPMN</lastModifiedBy>
\r
512 <statusMessage>VF Module successfully created</statusMessage>
\r
513 <responseBody></responseBody>
\r
514 <requestStatus>COMPLETE</requestStatus>
\r
515 <progress>100</progress>
\r
516 <vnfOutputs><vnf-outputs xmlns="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:aetgt="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"><vnf-id>${vnfId}</vnf-id><vf-module-id>${vfModuleId}</vf-module-id></vnf-outputs></vnfOutputs>
\r
517 <vfModuleId>${vfModuleId}</vfModuleId>
\r
518 <vfModuleName>${vfModuleName}</vfModuleName>
\r
519 </ns:updateInfraRequest>
\r
521 </soapenv:Envelope>"""
\r
523 payload = utils.formatXml(payload)
\r
524 execution.setVariable("CVFMI_updateInfraRequest", payload)
\r
525 utils.log("DEBUG", "Outgoing UpdateInfraRequest: \n" + payload, isDebugEnabled)
\r
526 utils.logAudit("CreateVfModuleInfra Outgoing UpdateInfra Request: " + payload)
\r
528 }catch(Exception e){
\r
529 utils.log("ERROR", "Exception Occured Processing prepareUpdateInfraRequest. Exception is:\n" + e, isDebugEnabled)
\r
530 execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during prepareUpdateInfraRequest Method:\n" + e.getMessage())
\r
532 utils.log("DEBUG", "======== COMPLETED prepareUpdateInfraRequest Process ======== ", isDebugEnabled)
\r
536 * Builds a "FalloutHandler" request and stores it in the specified execution variable.
\r
538 * @param execution the execution
\r
539 * @param resultVar the execution variable in which the result will be stored
\r
541 public void falloutHandlerPrep(DelegateExecution execution, String resultVar) {
\r
542 def method = getClass().getSimpleName() + '.falloutHandlerPrep(' +
\r
543 'execution=' + execution.getId() +
\r
544 ', resultVar=' + resultVar +
\r
546 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
547 logDebug('Entered ' + method, isDebugLogEnabled)
\r
551 def WorkflowException workflowException = execution.getVariable("WorkflowException")
\r
552 def requestInformation = execution.getVariable("CVFMI_requestInfo")
\r
553 def errorResponseCode = workflowException.getErrorCode()
\r
554 def errorResponseMsg = workflowException.getErrorMessage()
\r
555 def encErrorResponseMsg = ""
\r
556 if (errorResponseMsg != null) {
\r
557 encErrorResponseMsg = errorResponseMsg.replace("&", "&").replace("<", "<").replace(">", ">")
\r
560 String content = """
\r
561 <aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
\r
562 xmlns:reqtype="http://org.openecomp/mso/request/types/v1"
\r
563 xmlns:msoservtypes="http://org.openecomp/mso/request/types/v1"
\r
564 xmlns:structuredtypes="http://org.openecomp/mso/structured/types/v1">
\r
565 ${requestInformation}
\r
566 <aetgt:WorkflowException>
\r
567 <aetgt:ErrorMessage>${encErrorResponseMsg}</aetgt:ErrorMessage>
\r
568 <aetgt:ErrorCode>${errorResponseCode}</aetgt:ErrorCode>
\r
569 </aetgt:WorkflowException>
\r
570 </aetgt:FalloutHandlerRequest>
\r
573 logDebug("CONTENT before translation: " + content, isDebugLogEnabled)
\r
574 content = utils.formatXml(content)
\r
575 logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled)
\r
576 utils.logAudit("CreateVfModuleInfra FallOutHander Request: " + content)
\r
577 execution.setVariable(resultVar, content)
\r
579 logDebug('Exited ' + method, isDebugLogEnabled)
\r
580 } catch (BpmnError e) {
\r
582 } catch (Exception e) {
\r
583 logError('Caught exception in ' + method, e)
\r
584 exceptionUtil.buildWorkflowException(execution, 2000, 'Internal Error')
\r
588 public void logAndSaveOriginalException(DelegateExecution execution) {
\r
589 def method = getClass().getSimpleName() + '.validateRollbackResponse(' +
\r
590 'execution=' + execution.getId() +
\r
592 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
593 logDebug('Entered ' + method, isDebugLogEnabled)
\r
595 logWorkflowException(execution, 'CreateVfModuleInfra caught an event')
\r
596 saveWorkflowException(execution, 'CVFMI_originalWorkflowException')
\r
599 public void validateRollbackResponse(DelegateExecution execution) {
\r
600 def method = getClass().getSimpleName() + '.validateRollbackResponse(' +
\r
601 'execution=' + execution.getId() +
\r
603 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
604 logDebug('Entered ' + method, isDebugLogEnabled)
\r
606 def originalException = execution.getVariable("CVFMI_originalWorkflowException")
\r
607 execution.setVariable("WorkflowException", originalException)
\r
609 execution.setVariable("RollbackCompleted", true)
\r
613 public void sendErrorResponse(DelegateExecution execution){
\r
614 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
616 utils.log("DEBUG", " *** STARTED CreateVfModulenfra sendErrorResponse Process *** ", isDebugEnabled)
\r
618 def sentSyncResponse = execution.getVariable("CVFMI_sentSyncResponse")
\r
619 if(sentSyncResponse == false){
\r
620 WorkflowException wfex = execution.getVariable("WorkflowException")
\r
621 String response = exceptionUtil.buildErrorResponseXml(wfex)
\r
623 utils.logAudit(response)
\r
624 sendWorkflowResponse(execution, 500, response)
\r
626 utils.log("DEBUG", "Not Sending Error Response. Sync Response Already Sent", isDebugEnabled)
\r
629 } catch (Exception ex) {
\r
630 utils.log("DEBUG", "Error Occured in CreateVfModuleInfra sendErrorResponse Process " + ex.getMessage(), isDebugEnabled)
\r
631 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVfModuleInfra sendErrorResponse Process")
\r
634 utils.log("DEBUG", "*** COMPLETED CreateVfModuleInfra sendErrorResponse Process ***", isDebugEnabled)
\r