2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.bpmn.infrastructure.scripts;
23 import static org.apache.commons.lang3.StringUtils.*;
24 import groovy.xml.XmlUtil
27 import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition
28 import org.openecomp.mso.bpmn.core.domain.ServiceInstance
29 import org.openecomp.mso.bpmn.core.domain.ModelInfo
30 import org.openecomp.mso.bpmn.core.json.JsonUtils
31 import org.openecomp.mso.bpmn.common.scripts.AaiUtil
32 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
33 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
34 import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
35 import org.openecomp.mso.bpmn.core.RollbackData
36 import org.openecomp.mso.bpmn.core.WorkflowException
37 import org.openecomp.mso.rest.APIResponse;
38 import org.openecomp.mso.rest.RESTClient
39 import org.openecomp.mso.rest.RESTConfig
41 import java.util.UUID;
43 import org.camunda.bpm.engine.delegate.BpmnError
44 import org.camunda.bpm.engine.runtime.Execution
45 import org.json.JSONObject;
46 import org.apache.commons.lang3.*
47 import org.apache.commons.codec.binary.Base64;
48 import org.springframework.web.util.UriUtils;
51 * This groovy class supports the <class>DoCreateServiceInstance.bpmn</class> process.
54 * @param - msoRequestId
55 * @param - globalSubscriberId
56 * @param - subscriptionServiceType
57 * @param - serviceInstanceId
58 * @param - serviceInstanceName - O
59 * @param - serviceModelInfo
60 * @param - productFamilyId
61 * @param - disableRollback
62 * @param - failExists - TODO
63 * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM)
64 * @param - sdncVersion ("1610")
65 * @param - serviceDecomposition - Decomposition for R1710
66 * (if macro provides serviceDecompsition then serviceModelInfo, serviceInstanceId & serviceInstanceName will be ignored)
69 * @param - rollbackData (localRB->null)
70 * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true)
71 * @param - WorkflowException
72 * @param - serviceInstanceName - (GET from AAI if null in input)
75 public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor {
77 String Prefix="DCRESI_"
78 ExceptionUtil exceptionUtil = new ExceptionUtil()
79 JsonUtils jsonUtil = new JsonUtils()
81 public void preProcessRequest (Execution execution) {
82 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
84 utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled)
87 String requestId = execution.getVariable("msoRequestId")
88 execution.setVariable("prefix", Prefix)
91 //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology
92 String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
94 //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology
95 String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
97 //requestDetails.requestParameters. for SDNC assignTopology
98 String productFamilyId = execution.getVariable("productFamilyId") //AAI productFamilyId
100 if (isBlank(globalSubscriberId)) {
101 msg = "Input globalSubscriberId is null"
102 utils.log("DEBUG", msg, isDebugEnabled)
103 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
106 if (isBlank(subscriptionServiceType)) {
107 msg = "Input subscriptionServiceType is null"
108 utils.log("DEBUG", msg, isDebugEnabled)
109 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
112 if (productFamilyId == null) {
113 execution.setVariable("productFamilyId", "")
116 String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback')
117 if (isBlank(sdncCallbackUrl)) {
118 msg = "URN_mso_workflow_sdncadapter_callback is null"
119 utils.log("DEBUG", msg, isDebugEnabled)
120 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
122 execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
123 utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled)
125 //requestDetails.modelInfo.for AAI PUT servieInstanceData & SDNC assignTopology
126 String modelInvariantUuid = ""
127 String modelVersion = ""
128 String modelUuid = ""
129 String modelName = ""
130 String serviceInstanceName = ""
131 //Generated in parent.for AAI PUT
132 String serviceInstanceId = ""
133 String serviceType = ""
134 String serviceRole = ""
136 //requestDetails.requestInfo. for AAI GET/PUT serviceInstanceData & SDNC assignToplology
137 serviceInstanceName = execution.getVariable("serviceInstanceName")
138 serviceInstanceId = execution.getVariable("serviceInstanceId")
140 String serviceModelInfo = execution.getVariable("serviceModelInfo")
141 if (isBlank(serviceModelInfo)) {
142 msg = "Input serviceModelInfo is null"
143 utils.log("DEBUG", msg, isDebugEnabled)
144 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
146 modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid")
147 modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion")
148 modelUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelUuid")
149 modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName")
150 //modelCustomizationUuid NA for SI
152 execution.setVariable("serviceType", serviceType)
153 execution.setVariable("serviceRole", serviceRole)
155 if (serviceInstanceName == null) {
156 execution.setVariable("serviceInstanceName", "")
157 serviceInstanceName = ""
159 if (isBlank(serviceInstanceId)){
160 msg = "Input serviceInstanceId is null"
161 utils.log("DEBUG", msg, isDebugEnabled)
162 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
165 if (modelInvariantUuid == null) {
166 modelInvariantUuid = ""
168 if (modelUuid == null) {
171 if (modelVersion == null) {
174 if (modelName == null) {
178 execution.setVariable("modelInvariantUuid", modelInvariantUuid)
179 execution.setVariable("modelVersion", modelVersion)
180 execution.setVariable("modelUuid", modelUuid)
181 execution.setVariable("modelName", modelName)
183 StringBuilder sbParams = new StringBuilder()
184 Map<String, String> paramsMap = execution.getVariable("serviceInputParams")
185 if (paramsMap != null)
187 sbParams.append("<service-input-parameters>")
188 for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
190 String paramName = entry.getKey()
191 String paramValue = entry.getValue()
194 <name>${paramName}</name>
195 <value>${paramValue}</value>
198 sbParams.append(paramsXml)
200 sbParams.append("</service-input-parameters>")
202 String siParamsXml = sbParams.toString()
203 if (siParamsXml == null)
205 execution.setVariable("siParamsXml", siParamsXml)
208 String oStatus = execution.getVariable("initialStatus") ?: ""
209 if ("TRANSPORT".equalsIgnoreCase(serviceType))
214 String statusLine = isBlank(oStatus) ? "" : "<orchestration-status>${oStatus}</orchestration-status>"
216 AaiUtil aaiUriUtil = new AaiUtil(this)
217 String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution)
218 String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri)
219 String serviceInstanceData =
220 """<service-instance xmlns=\"${namespace}\">
221 <service-instance-name>${serviceInstanceName}</service-instance-name>
222 <service-type>${serviceType}</service-type>
223 <service-role>${serviceRole}</service-role>
225 <model-invariant-id>${modelInvariantUuid}</model-invariant-id>
226 <model-version-id>${modelUuid}</model-version-id>
227 </service-instance>""".trim()
229 execution.setVariable("serviceInstanceData", serviceInstanceData)
230 utils.logAudit(serviceInstanceData)
231 utils.log("DEBUG", " 'payload' to create Service Instance in AAI - " + "\n" + serviceInstanceData, isDebugEnabled)
233 } catch (BpmnError e) {
235 } catch (Exception ex){
236 msg = "Exception in preProcessRequest " + ex.getMessage()
237 utils.log("DEBUG", msg, isDebugEnabled)
238 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
240 utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled)
243 //TODO: Will be able to replace with call to CustomE2EGetService as per the GenericGetService
244 public void getAAICustomerById (Execution execution) {
245 // https://{aaiEP}/aai/v8/business/customers/customer/{globalCustomerId}
246 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
250 String globalCustomerId = execution.getVariable("globalSubscriberId") //UUI to AAI name map
251 utils.log("DEBUG"," ***** getAAICustomerById ***** globalCustomerId:" + globalCustomerId, isDebugEnabled)
253 String aai_endpoint = execution.getVariable("URN_aai_endpoint")
254 AaiUtil aaiUriUtil = new AaiUtil(this)
255 String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution)
256 if (isBlank(aai_endpoint) || isBlank(aai_uri))
258 msg = "AAI URL is invalid. Endpoint:" + aai_endpoint + aai_uri
259 utils.log("DEBUG", msg, isDebugEnabled)
260 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
262 String getAAICustomerUrl = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalCustomerId,"UTF-8")
264 utils.logAudit(getAAICustomerUrl)
265 utils.log("DEBUG", "getAAICustomerById Url:" + getAAICustomerUrl, isDebugEnabled)
266 APIResponse response = aaiUriUtil.executeAAIGetCall(execution, getAAICustomerUrl)
267 String returnCode = response.getStatusCode()
268 String aaiResponseAsString = response.getResponseBodyAsString()
270 msg = "getAAICustomerById ResponseCode:" + returnCode + " ResponseString:" + aaiResponseAsString
271 utils.log("DEBUG",msg, isDebugEnabled)
274 if (returnCode=='200') {
275 // Customer found by ID. FLow to proceed.
276 utils.log("DEBUG",msg, isDebugEnabled)
279 //we might verify that service-subscription with matching name exists
280 //and throw error if not. If not checked, we will get exception in subsequent step on Create call
281 //in 1610 we assume both customer & service subscription were pre-created
284 if (returnCode=='404') {
285 msg = "GlobalCustomerId:" + globalCustomerId + " not found (404) in AAI"
286 utils.log("DEBUG", msg, isDebugEnabled)
287 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
290 if (aaiResponseAsString.contains("RESTFault")) {
291 utils.log("ERROR", aaiResponseAsString)
292 WorkflowException workflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
293 execution.setVariable("WorkflowException", workflowException)
294 throw new BpmnError("MSOWorkflowException")
298 msg = "Error in getAAICustomerById ResponseCode:" + returnCode
299 utils.log("DEBUG", msg, isDebugEnabled)
300 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
305 } catch (BpmnError e) {
307 } catch (Exception ex) {
308 msg = "Exception in getAAICustomerById. " + ex.getMessage()
309 utils.log("DEBUG", msg, isDebugEnabled)
310 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
312 utils.log("DEBUG"," *****Exit getAAICustomerById *****", isDebugEnabled)
316 public void postProcessAAIGET(Execution execution) {
317 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
318 utils.log("DEBUG"," ***** postProcessAAIGET ***** ", isDebugEnabled)
322 String serviceInstanceName = execution.getVariable("serviceInstanceName")
323 boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
324 if(succInAAI != true){
325 utils.log("DEBUG","Error getting Service-instance from AAI", + serviceInstanceName, isDebugEnabled)
326 WorkflowException workflowException = execution.getVariable("WorkflowException")
327 utils.logAudit("workflowException: " + workflowException)
328 if(workflowException != null){
329 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
333 msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI
334 utils.log("DEBUG", msg, isDebugEnabled)
335 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
340 boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
341 if(foundInAAI == true){
342 utils.log("DEBUG","Found Service-instance in AAI", isDebugEnabled)
343 msg = "ServiceInstance already exists in AAI:" + serviceInstanceName
344 utils.log("DEBUG", msg, isDebugEnabled)
345 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
348 } catch (BpmnError e) {
350 } catch (Exception ex) {
351 msg = "Exception in DoCreateServiceInstance.postProcessAAIGET. " + ex.getMessage()
352 utils.log("DEBUG", msg, isDebugEnabled)
353 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
355 utils.log("DEBUG"," *** Exit postProcessAAIGET *** ", isDebugEnabled)
358 public void postProcessAAIPUT(Execution execution) {
359 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
360 utils.log("DEBUG"," ***** postProcessAAIPUT ***** ", isDebugEnabled)
363 String serviceInstanceId = execution.getVariable("serviceInstanceId")
364 boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator")
365 if(succInAAI != true){
366 utils.log("DEBUG","Error putting Service-instance in AAI", + serviceInstanceId, isDebugEnabled)
367 WorkflowException workflowException = execution.getVariable("WorkflowException")
368 utils.logAudit("workflowException: " + workflowException)
369 if(workflowException != null){
370 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
375 //start rollback set up
376 RollbackData rollbackData = new RollbackData()
377 def disableRollback = execution.getVariable("disableRollback")
378 rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString())
379 rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true")
380 rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId)
381 rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
382 rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId"))
383 execution.setVariable("rollbackData", rollbackData)
386 } catch (BpmnError e) {
388 } catch (Exception ex) {
389 msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage()
390 utils.log("DEBUG", msg, isDebugEnabled)
391 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
393 utils.log("DEBUG"," *** Exit postProcessAAIPUT *** ", isDebugEnabled)
396 public void preProcessSDNCAssignRequest(Execution execution) {
397 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
399 utils.log("DEBUG"," ***** preProcessSDNCAssignRequest *****", isDebugEnabled)
402 def serviceInstanceId = execution.getVariable("serviceInstanceId")
403 def serviceInstanceName = execution.getVariable("serviceInstanceName")
404 def callbackURL = execution.getVariable("sdncCallbackUrl")
405 def requestId = execution.getVariable("msoRequestId")
406 def serviceId = execution.getVariable("productFamilyId")
407 def subscriptionServiceType = execution.getVariable("subscriptionServiceType")
408 def globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
409 def serviceType = execution.getVariable("serviceType")
411 def modelInvariantUuid = execution.getVariable("modelInvariantUuid")
412 def modelVersion = execution.getVariable("modelVersion")
413 def modelUuid = execution.getVariable("modelUuid")
414 def modelName = execution.getVariable("modelName")
416 def sdncRequestId = UUID.randomUUID().toString()
418 def siParamsXml = execution.getVariable("siParamsXml")
420 String sdncAssignRequest =
421 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
422 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
423 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
424 <sdncadapter:RequestHeader>
425 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
426 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
427 <sdncadapter:SvcAction>assign</sdncadapter:SvcAction>
428 <sdncadapter:SvcOperation>service-topology-operation</sdncadapter:SvcOperation>
429 <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
430 <sdncadapter:MsoAction>${serviceType}</sdncadapter:MsoAction>
431 </sdncadapter:RequestHeader>
432 <sdncadapterworkflow:SDNCRequestData>
433 <request-information>
434 <request-id>${requestId}</request-id>
439 <request-action>CreateServiceInstance</request-action>
440 </request-information>
441 <service-information>
442 <service-id>${serviceId}</service-id>
443 <subscription-service-type>${subscriptionServiceType}</subscription-service-type>
444 <ecomp-model-information>
445 <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid>
446 <model-uuid>${modelUuid}</model-uuid>
447 <model-version>${modelVersion}</model-version>
448 <model-name>${modelName}</model-name>
449 </ecomp-model-information>
450 <service-instance-id>${serviceInstanceId}</service-instance-id>
452 <global-customer-id>${globalSubscriberId}</global-customer-id>
453 </service-information>
454 <service-request-input>
455 <service-instance-name>${serviceInstanceName}</service-instance-name>
457 </service-request-input>
458 </sdncadapterworkflow:SDNCRequestData>
459 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
461 utils.log("DEBUG","sdncAssignRequest:\n" + sdncAssignRequest, isDebugEnabled)
462 sdncAssignRequest = utils.formatXml(sdncAssignRequest)
463 execution.setVariable("sdncAssignRequest", sdncAssignRequest)
464 utils.logAudit("sdncAssignRequest: " + sdncAssignRequest)
466 def sdncRequestId2 = UUID.randomUUID().toString()
467 String sdncDelete = sdncAssignRequest.replace(">assign<", ">delete<").replace(">CreateServiceInstance<", ">DeleteServiceInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
468 def sdncRequestId3 = UUID.randomUUID().toString()
469 String sdncDeactivate = sdncDelete.replace(">delete<", ">deactivate<").replace(">${sdncRequestId2}<", ">${sdncRequestId3}<")
470 def rollbackData = execution.getVariable("rollbackData")
471 rollbackData.put("SERVICEINSTANCE", "sdncDeactivate", sdncDeactivate)
472 rollbackData.put("SERVICEINSTANCE", "sdncDelete", sdncDelete)
473 execution.setVariable("rollbackData", rollbackData)
475 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
477 } catch (BpmnError e) {
479 } catch(Exception ex) {
480 msg = "Exception in preProcessSDNCAssignRequest. " + ex.getMessage()
481 utils.log("DEBUG", msg, isDebugEnabled)
482 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
484 utils.log("DEBUG"," *****Exit preProcessSDNCAssignRequest *****", isDebugEnabled)
487 public void postProcessSDNCAssign (Execution execution) {
488 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
489 utils.log("DEBUG"," ***** postProcessSDNCAssign ***** ", isDebugEnabled)
491 WorkflowException workflowException = execution.getVariable("WorkflowException")
492 utils.logAudit("workflowException: " + workflowException)
494 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
496 String response = execution.getVariable("sdncAdapterResponse")
497 utils.logAudit("SDNCResponse: " + response)
499 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
500 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
502 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
503 utils.log("DEBUG","Good response from SDNC Adapter for service-instance topology assign: \n" + response, isDebugEnabled)
505 def rollbackData = execution.getVariable("rollbackData")
506 rollbackData.put("SERVICEINSTANCE", "rollbackSDNC", "true")
507 execution.setVariable("rollbackData", rollbackData)
510 utils.log("DEBUG","Bad Response from SDNC Adapter for service-instance assign", isDebugEnabled)
511 throw new BpmnError("MSOWorkflowException")
514 } catch (BpmnError e) {
516 } catch(Exception ex) {
517 msg = "Exception in postProcessSDNCAssign. " + ex.getMessage()
518 utils.log("DEBUG", msg, isDebugEnabled)
519 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
521 utils.log("DEBUG"," *** Exit postProcessSDNCAssign *** ", isDebugEnabled)
524 public void postProcessAAIGET2(Execution execution) {
525 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
526 utils.log("DEBUG"," ***** postProcessAAIGET2 ***** ", isDebugEnabled)
530 String serviceInstanceName = execution.getVariable("serviceInstanceName")
531 boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
532 if(succInAAI != true){
533 utils.log("DEBUG","Error getting Service-instance from AAI in postProcessAAIGET2", + serviceInstanceName, isDebugEnabled)
534 WorkflowException workflowException = execution.getVariable("WorkflowException")
535 utils.logAudit("workflowException: " + workflowException)
536 if(workflowException != null){
537 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
541 msg = "Failure in postProcessAAIGET2 GENGS_SuccessIndicator:" + succInAAI
542 utils.log("DEBUG", msg, isDebugEnabled)
543 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
548 boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
549 if(foundInAAI == true){
550 String aaiService = execution.getVariable("GENGS_service")
551 if (!isBlank(aaiService) && (utils.nodeExists(aaiService, "service-instance-name"))) {
552 execution.setVariable("serviceInstanceName", utils.getNodeText1(aaiService, "service-instance-name"))
553 utils.log("DEBUG","Found Service-instance in AAI.serviceInstanceName:" + execution.getVariable("serviceInstanceName"), isDebugEnabled)
557 } catch (BpmnError e) {
559 } catch (Exception ex) {
560 msg = "Exception in DoCreateServiceInstance.postProcessAAIGET2 " + ex.getMessage()
561 utils.log("DEBUG", msg, isDebugEnabled)
562 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
564 utils.log("DEBUG"," *** Exit postProcessAAIGET2 *** ", isDebugEnabled)
567 public void preProcessRollback (Execution execution) {
568 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
569 utils.log("DEBUG"," ***** preProcessRollback ***** ", isDebugEnabled)
572 Object workflowException = execution.getVariable("WorkflowException");
574 if (workflowException instanceof WorkflowException) {
575 utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled)
576 execution.setVariable("prevWorkflowException", workflowException);
577 //execution.setVariable("WorkflowException", null);
579 } catch (BpmnError e) {
580 utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled)
581 } catch(Exception ex) {
582 String msg = "Exception in preProcessRollback. " + ex.getMessage()
583 utils.log("DEBUG", msg, isDebugEnabled)
585 utils.log("DEBUG"," *** Exit preProcessRollback *** ", isDebugEnabled)
588 public void postProcessRollback (Execution execution) {
589 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
590 utils.log("DEBUG"," ***** postProcessRollback ***** ", isDebugEnabled)
593 Object workflowException = execution.getVariable("prevWorkflowException");
594 if (workflowException instanceof WorkflowException) {
595 utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled)
596 execution.setVariable("WorkflowException", workflowException);
598 execution.setVariable("rollbackData", null)
599 } catch (BpmnError b) {
600 utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled)
602 } catch(Exception ex) {
603 msg = "Exception in postProcessRollback. " + ex.getMessage()
604 utils.log("DEBUG", msg, isDebugEnabled)
606 utils.log("DEBUG"," *** Exit postProcessRollback *** ", isDebugEnabled)
609 public void preInitResourcesOperStatus(Execution execution){
610 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
612 utils.log("DEBUG", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
614 String serviceId = execution.getVariable("serviceInstanceId")
615 String operationId = execution.getVariable("operationId")
616 String operationType = execution.getVariable("operationType")
617 String resourceTemplateUUIDs = ""
618 String result = "processing"
619 String progress = "0"
621 String operationContent = "Prepare service creation"
622 utils.log("DEBUG", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + oprationType, isDebugEnabled)
623 serviceId = UriUtils.encode(serviceId,"UTF-8")
624 execution.setVariable("serviceInstanceId", serviceId)
625 execution.setVariable("operationId", operationId)
626 execution.setVariable("operationType", operationType)
627 def jsonSlurper = new JsonSlurper()
628 def jsonOutput = new JsonOutput()
629 String incomingRequest = execution.getVariable("bpmnRequest")
630 Map serviceReq = jsonSlurper.parseText(incomingRequest)
631 def segmentList = serviceReq.service.parameters.segments
633 if (segmentList != null) {
635 resourceTemplateUUIDs = resourcesUUIDs + it.resourceUUID + ":"
639 def dbAdapterEndpoint = execution.getVariable("URN_mso_openecomp_adapters_db_endpoint")
640 execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
641 utils.log("DEBUG", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
644 """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
645 xmlns:ns="http://org.openecomp.mso/requestsdb">
648 <ns:initResourceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">
649 <serviceId>${serviceId}</serviceId>
650 <operationId>${operationId}</operationId>
651 <operationType>${operationType}</operationType>
652 <resourceTemplateUUIDs>${resourceTemplateUUIDs}</resourceTemplateUUIDs>
653 </ns:initResourceOperationStatus>
655 </soapenv:Envelope>"""
657 payload = utils.formatXml(payload)
658 execution.setVariable("CVFMI_initResOperStatusRequest", payload)
659 utils.log("DEBUG", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled)
660 utils.logAudit("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload)
663 utils.log("ERROR", "Exception Occured Processing preInitResourcesOperStatus. Exception is:\n" + e, isDebugEnabled)
664 execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage())
666 utils.log("DEBUG", "======== COMPLETED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
670 * prepare resource create request
672 public void preResourceRequest(execution, resourceType){
673 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
674 String serviceInstanceName = execution.getVariable("serviceInstanceName")
675 String nsServiceName = nsName + "_" + serviceInstanceName
676 String nsServiceDescription = execution.getVariable("serviceInstanceDescription")
677 execution.setVariable("nsServiceName", nsServiceName)
678 utils.log("DEBUG", "Prepare VFC Request nsServiceName:" + nsServiceName, isDebugEnabled)
679 execution.setVariable("nsServiceDescription", nsServiceDescription)
680 utils.log("DEBUG", "Prepare VFC Request nsServiceDescription:" + nsServiceDescription, isDebugEnabled)
681 String globalSubscriberId = execution.getVariable("globalSubscriberId")
682 String serviceType = execution.getVariable("serviceType")
683 String serviceId = execution.getVariable("serviceId")
684 String operationId = execution.getVariable("operationId")
685 String incomingRequest = execution.getVariable("bpmnRequest")
686 Map serviceReq = jsonSlurper.parseText(incomingRequest)
687 def segmentList = serviceReq.service.parameters.segments
688 if (segmentList != null) {
690 if(StringUtils.containsIgnoreCase(it.resourceName, resourceType)){
691 String resourceUUID = it.resourceUUID
692 String resourceParameters = it.nsParameters
693 execution.setVariable("resourceType", resourceType)
694 execution.setVariable("resourceUUID", resourceUUID)
695 execution.setVariable("resourceParameters", resourceParameters)