2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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
20 package org.openecomp.mso.bpmn.infrastructure.scripts;
\r
22 import static org.apache.commons.lang3.StringUtils.*;
\r
23 import groovy.xml.XmlUtil
\r
24 import groovy.json.*
\r
26 import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition
\r
27 import org.openecomp.mso.bpmn.core.domain.ServiceInstance
\r
28 import org.openecomp.mso.bpmn.core.domain.ModelInfo
\r
29 import org.openecomp.mso.bpmn.core.domain.Resource
\r
30 import org.openecomp.mso.bpmn.core.json.JsonUtils
\r
31 import org.openecomp.mso.bpmn.common.scripts.AaiUtil
\r
32 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
\r
33 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
\r
34 import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
\r
35 import org.openecomp.mso.bpmn.core.RollbackData
\r
36 import org.openecomp.mso.bpmn.core.WorkflowException
\r
37 import org.openecomp.mso.rest.APIResponse;
\r
38 import org.openecomp.mso.rest.RESTClient
\r
39 import org.openecomp.mso.rest.RESTConfig
\r
41 import java.util.UUID;
\r
42 import javax.xml.parsers.DocumentBuilder
\r
43 import javax.xml.parsers.DocumentBuilderFactory
\r
45 import org.camunda.bpm.engine.delegate.BpmnError
\r
46 import org.camunda.bpm.engine.delegate.DelegateExecution
\r
47 import org.json.JSONObject;
\r
48 import org.json.JSONArray;
\r
49 import org.apache.commons.lang3.*
\r
50 import org.apache.commons.codec.binary.Base64;
\r
51 import org.springframework.web.util.UriUtils;
\r
53 import org.w3c.dom.Document
\r
54 import org.w3c.dom.Element
\r
55 import org.w3c.dom.Node
\r
56 import org.w3c.dom.NodeList
\r
57 import org.xml.sax.InputSource
\r
59 * This groovy class supports the <class>DoUpdateE2EServiceInstance.bpmn</class> process.
\r
62 * @param - msoRequestId
\r
63 * @param - globalSubscriberId
\r
64 * @param - subscriptionServiceType
\r
65 * @param - serviceInstanceId
\r
66 * @param - serviceInstanceName - O
\r
67 * @param - serviceModelInfo
\r
68 * @param - productFamilyId
\r
69 * @param - disableRollback
\r
70 * @param - failExists - TODO
\r
71 * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM)
\r
72 * @param - sdncVersion ("1610")
\r
73 * @param - serviceDecomposition - Decomposition for R1710
\r
74 * (if macro provides serviceDecompsition then serviceModelInfo, serviceInstanceId & serviceInstanceName will be ignored)
\r
77 * @param - rollbackData (localRB->null)
\r
78 * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true)
\r
79 * @param - WorkflowException
\r
80 * @param - serviceInstanceName - (GET from AAI if null in input)
\r
83 public class DoUpdateE2EServiceInstance extends AbstractServiceTaskProcessor {
\r
85 String Prefix="DUPDSI_"
\r
86 private static final String DebugFlag = "isDebugEnabled"
\r
88 ExceptionUtil exceptionUtil = new ExceptionUtil()
\r
89 JsonUtils jsonUtil = new JsonUtils()
\r
91 public void preProcessRequest (DelegateExecution execution) {
\r
93 execution.setVariable("isDebugLogEnabled","true")
\r
94 execution.setVariable("unit_test", "true")
\r
95 execution.setVariable("skipVFC", "true")
\r
97 def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')'
\r
98 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
99 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
101 utils.log("INFO"," ***** Enter DoUpdateE2EServiceInstance preProcessRequest *****", isDebugEnabled)
\r
103 utils.log("INFO"," unit test : " + execution.getVariable("unit_test"), isDebugEnabled)
\r
106 execution.setVariable("prefix", Prefix)
\r
108 //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology
\r
109 String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
\r
110 utils.log("INFO"," ***** globalSubscriberId *****" + globalSubscriberId, isDebugEnabled)
\r
112 //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology
\r
113 String serviceType = execution.getVariable("serviceType")
\r
114 utils.log("INFO"," ***** serviceType *****" + serviceType, isDebugEnabled)
\r
116 //requestDetails.requestParameters. for SDNC assignTopology
\r
117 String productFamilyId = execution.getVariable("productFamilyId") //AAI productFamilyId
\r
119 if (isBlank(globalSubscriberId)) {
\r
120 msg = "Input globalSubscriberId is null"
\r
121 utils.log("INFO", msg, isDebugEnabled)
\r
122 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
\r
125 if (isBlank(serviceType)) {
\r
126 msg = "Input serviceType is null"
\r
127 utils.log("INFO", msg, isDebugEnabled)
\r
128 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
\r
131 //Generated in parent for AAI
\r
132 String serviceInstanceId = execution.getVariable("serviceInstanceId")
\r
133 if (isBlank(serviceInstanceId)){
\r
134 msg = "Input serviceInstanceId is null"
\r
135 utils.log("INFO", msg, isDebugEnabled)
\r
136 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
\r
139 if (productFamilyId == null) {
\r
140 execution.setVariable("productFamilyId", "")
\r
143 String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback')
\r
144 if (isBlank(sdncCallbackUrl)) {
\r
145 msg = "URN_mso_workflow_sdncadapter_callback is null"
\r
146 utils.log("INFO", msg, isDebugEnabled)
\r
147 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
\r
149 execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
\r
150 utils.log("INFO","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled)
\r
152 //requestDetails.modelInfo.for AAI PUT servieInstanceData
\r
153 //requestDetails.requestInfo. for AAI GET/PUT serviceInstanceData
\r
154 String serviceInstanceName = execution.getVariable("serviceInstanceName")
\r
155 //String serviceInstanceId = execution.getVariable("serviceInstanceId")
\r
156 String uuiRequest = execution.getVariable("uuiRequest")
\r
157 utils.log("INFO","uuiRequest: " + uuiRequest, isDebugEnabled)
\r
159 String modelInvariantUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceDefId")
\r
160 utils.log("INFO","modelInvariantUuid: " + modelInvariantUuid, isDebugEnabled)
\r
162 String modelUuid = jsonUtil.getJsonValue(uuiRequest, "service.templateId")
\r
163 utils.log("INFO","modelUuid: " + modelUuid, isDebugEnabled)
\r
165 String serviceModelName = jsonUtil.getJsonValue(uuiRequest, "service.parameters.templateName")
\r
166 utils.log("INFO","serviceModelName: " + serviceModelName, isDebugEnabled)
\r
167 execution.setVariable("serviceModelName", serviceModelName)
\r
169 //aai serviceType and Role can be setted as fixed value now.
\r
170 String aaiServiceType = serviceType
\r
171 String aaiServiceRole = serviceType+"Role"
\r
173 execution.setVariable("modelInvariantUuid", modelInvariantUuid)
\r
174 execution.setVariable("model-invariant-id-target", modelInvariantUuid)
\r
175 execution.setVariable("modelUuid", modelUuid)
\r
176 execution.setVariable("model-version-id-target", modelUuid)
\r
179 String oStatus = execution.getVariable("initialStatus") ?: ""
\r
180 utils.log("INFO","oStatus: " + oStatus, isDebugEnabled)
\r
181 if ("TRANSPORT".equalsIgnoreCase(serviceType))
\r
186 String statusLine = isBlank(oStatus) ? "" : "<orchestration-status>${oStatus}</orchestration-status>"
\r
187 utils.log("INFO","statusLine: " + statusLine, isDebugEnabled)
\r
188 AaiUtil aaiUriUtil = new AaiUtil(this)
\r
189 utils.log("INFO","start create aai uri: " + aaiUriUtil, isDebugEnabled)
\r
190 String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution)
\r
191 utils.log("INFO","aai_uri: " + aai_uri, isDebugEnabled)
\r
192 String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri)
\r
193 utils.log("INFO","namespace: " + namespace, isDebugEnabled)
\r
195 String serviceInstanceData =
\r
196 """<service-instance xmlns=\"${namespace}\">
\r
197 <service-instance-id>${serviceInstanceId}</service-instance-id>
\r
198 <service-instance-name>${serviceInstanceName}</service-instance-name>
\r
199 <service-type>${aaiServiceType}</service-type>
\r
200 <service-role>${aaiServiceRole}</service-role>
\r
202 <model-invariant-id>${modelInvariantUuid}</model-invariant-id>
\r
203 <model-version-id>${modelUuid}</model-version-id>
\r
204 </service-instance>""".trim()
\r
206 //begin only for test
\r
207 String serviceInstanceData =
\r
208 """<service-instance xmlns=\"${namespace}\">
\r
209 <service-instance-id>${serviceInstanceId}</service-instance-id>
\r
210 <service-instance-name>${serviceInstanceName}</service-instance-name>
\r
211 <service-type>${aaiServiceType}</service-type>
\r
212 <service-role>${aaiServiceRole}</service-role>
\r
214 </service-instance>""".trim()
\r
215 //end only for test
\r
216 execution.setVariable("serviceInstanceData", serviceInstanceData)
\r
217 utils.log("INFO","serviceInstanceData: " + serviceInstanceData, isDebugEnabled)
\r
218 utils.logAudit(serviceInstanceData)
\r
219 utils.log("INFO", " aai_uri " + aai_uri + " namespace:" + namespace, isDebugEnabled)
\r
220 utils.log("INFO", " 'payload' to create Service Instance in AAI - " + "\n" + serviceInstanceData, isDebugEnabled)
\r
222 execution.setVariable("serviceSDNCCreate", "false")
\r
223 execution.setVariable("operationStatus", "Waiting deploy resource...")
\r
225 } catch (BpmnError e) {
\r
227 } catch (Exception ex){
\r
228 msg = "Exception in preProcessRequest " + ex.getMessage()
\r
229 utils.log("INFO", msg, isDebugEnabled)
\r
230 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
\r
232 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
235 public void postProcessAAIGET(DelegateExecution execution) {
\r
236 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
237 utils.log("INFO"," ***** postProcessAAIGET ***** ", isDebugEnabled)
\r
241 String serviceInstanceId = execution.getVariable("serviceInstanceId")
\r
242 boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
\r
243 String serviceType = ""
\r
246 utils.log("INFO","Found Service-instance in AAI", isDebugEnabled)
\r
248 String siData = execution.getVariable("GENGS_service")
\r
249 utils.log("INFO", "SI Data", isDebugEnabled)
\r
250 if (isBlank(siData))
\r
252 msg = "Could not retrive ServiceInstance data from AAI, Id:" + serviceInstanceId
\r
253 utils.log("INFO", msg, isDebugEnabled)
\r
254 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
\r
258 utils.log("INFO", "SI Data" + siData, isDebugEnabled)
\r
260 InputSource source = new InputSource(new StringReader(siData));
\r
261 DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
\r
262 DocumentBuilder docBuilder = docFactory.newDocumentBuilder()
\r
263 Document serviceXml = docBuilder.parse(source)
\r
264 serviceXml.getDocumentElement().normalize()
\r
266 // Get Template uuid and version
\r
267 if (utils.nodeExists(siData, "model-invariant-id") && utils.nodeExists(siData, "model-version-id") ) {
\r
268 utils.log("INFO", "SI Data model-invariant-id and model-version-id exist:", isDebugEnabled)
\r
269 def modelInvariantId = serviceXml.getElementsByTagName("model-invariant-id").item(0).getTextContent()
\r
270 def modelVersionId = serviceXml.getElementsByTagName("model-version-id").item(0).getTextContent()
\r
272 // Set Original Template info
\r
273 execution.setVariable("model-invariant-id-original", modelInvariantId)
\r
274 execution.setVariable("model-version-id-original", modelVersionId)
\r
277 //Confirm there are no related service instances (vnf/network or volume)
\r
278 if (utils.nodeExists(siData, "relationship-list")) {
\r
279 utils.log("INFO", "SI Data relationship-list exists:", isDebugEnabled)
\r
282 NodeList nodeList = serviceXml.getElementsByTagName("relationship")
\r
283 JSONArray jArray = new JSONArray()
\r
284 for (int x = 0; x < nodeList.getLength(); x++) {
\r
285 Node node = nodeList.item(x)
\r
286 if (node.getNodeType() == Node.ELEMENT_NODE) {
\r
287 Element eElement = (Element) node
\r
288 def e = eElement.getElementsByTagName("related-to").item(0).getTextContent() //for ns
\r
289 if(e.equals("service-instance")){
\r
290 def relatedObject = eElement.getElementsByTagName("related-link").item(0).getTextContent()
\r
291 utils.log("INFO", "ServiceInstance Related NS :" + relatedObject, isDebugEnabled)
\r
292 NodeList dataList = node.getChildNodes()
\r
293 if(null != dataList) {
\r
294 JSONObject jObj = new JSONObject()
\r
295 for (int i = 0; i < dataList.getLength(); i++) {
\r
296 Node dNode = dataList.item(i)
\r
297 if(dNode.getNodeName() == "relationship-data") {
\r
298 Element rDataEle = (Element)dNode
\r
299 def eKey = rDataEle.getElementsByTagName("relationship-key").item(0).getTextContent()
\r
300 def eValue = rDataEle.getElementsByTagName("relationship-value").item(0).getTextContent()
\r
301 if(eKey.equals("service-instance.service-instance-id")){
\r
302 jObj.put("resourceInstanceId", eValue)
\r
305 else if(dNode.getNodeName() == "related-to-property"){
\r
306 Element rDataEle = (Element)dNode
\r
307 def eKey = rDataEle.getElementsByTagName("property-key").item(0).getTextContent()
\r
308 def eValue = rDataEle.getElementsByTagName("property-value").item(0).getTextContent()
\r
309 if(eKey.equals("service-instance.service-instance-name")){
\r
310 jObj.put("resourceType", eValue)
\r
314 utils.log("INFO", "Relationship related to Resource:" + jObj.toString(), isDebugEnabled)
\r
317 //for overlay/underlay
\r
318 }else if (e.equals("configuration")){
\r
319 def relatedObject = eElement.getElementsByTagName("related-link").item(0).getTextContent()
\r
320 utils.log("INFO", "ServiceInstance Related Configuration :" + relatedObject, isDebugEnabled)
\r
321 NodeList dataList = node.getChildNodes()
\r
322 if(null != dataList) {
\r
323 JSONObject jObj = new JSONObject()
\r
324 for (int i = 0; i < dataList.getLength(); i++) {
\r
325 Node dNode = dataList.item(i)
\r
326 if(dNode.getNodeName() == "relationship-data") {
\r
327 Element rDataEle = (Element)dNode
\r
328 def eKey = rDataEle.getElementsByTagName("relationship-key").item(0).getTextContent()
\r
329 def eValue = rDataEle.getElementsByTagName("relationship-value").item(0).getTextContent()
\r
330 if(eKey.equals("configuration.configuration-id")){
\r
331 jObj.put("resourceInstanceId", eValue)
\r
334 else if(dNode.getNodeName() == "related-to-property"){
\r
335 Element rDataEle = (Element)dNode
\r
336 def eKey = rDataEle.getElementsByTagName("property-key").item(0).getTextContent()
\r
337 def eValue = rDataEle.getElementsByTagName("property-value").item(0).getTextContent()
\r
338 if(eKey.equals("configuration.configuration-type")){
\r
339 jObj.put("resourceType", eValue)
\r
343 utils.log("INFO", "Relationship related to Resource:" + jObj.toString(), isDebugEnabled)
\r
349 execution.setVariable("serviceRelationShip", jArray.toString())
\r
353 boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
\r
355 utils.log("INFO","Error getting Service-instance from AAI", + serviceInstanceId, isDebugEnabled)
\r
356 WorkflowException workflowException = execution.getVariable("WorkflowException")
\r
357 utils.logAudit("workflowException: " + workflowException)
\r
358 if(workflowException != null){
\r
359 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
\r
363 msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI
\r
364 utils.log("INFO", msg, isDebugEnabled)
\r
365 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
\r
369 utils.log("INFO","Service-instance NOT found in AAI. Silent Success", isDebugEnabled)
\r
371 }catch (BpmnError e) {
\r
373 } catch (Exception ex) {
\r
374 msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIGET. " + ex.getMessage()
\r
375 utils.log("INFO", msg, isDebugEnabled)
\r
376 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
\r
378 utils.log("INFO"," *** Exit postProcessAAIGET *** ", isDebugEnabled)
\r
382 public void preInitResourcesOperStatus(DelegateExecution execution){
\r
383 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
385 utils.log("INFO", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
\r
387 String serviceId = execution.getVariable("serviceInstanceId")
\r
388 String operationId = execution.getVariable("operationId")
\r
389 String operationType = execution.getVariable("operationType")
\r
390 String resourceTemplateUUIDs = ""
\r
391 String result = "processing"
\r
392 String progress = "10"
\r
394 String operationContent = "Prepare service updating"
\r
395 utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType, isDebugEnabled)
\r
396 serviceId = UriUtils.encode(serviceId,"UTF-8")
\r
397 execution.setVariable("serviceInstanceId", serviceId)
\r
398 execution.setVariable("operationId", operationId)
\r
399 execution.setVariable("operationType", operationType)
\r
401 List<Resource> resourceList = new ArrayList<String>()
\r
402 List<Resource> addResourceList = execution.getVariable("addResourceList")
\r
403 List<Resource> delResourceList = execution.setVariable("delResourceList")
\r
404 resourceList.addAll(addResourceList)
\r
405 resourceList.addAll(delResourceList)
\r
406 for(Resource resource : resourceList){
\r
407 resourceTemplateUUIDs = resourceTemplateUUIDs + resource.getModelInfo().getModelCustomizationUuid() + ":"
\r
410 def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter"
\r
411 execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
\r
412 utils.log("INFO", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
\r
415 """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
\r
416 xmlns:ns="http://org.openecomp.mso/requestsdb">
\r
419 <ns:initResourceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">
\r
420 <serviceId>${serviceId}</serviceId>
\r
421 <operationId>${operationId}</operationId>
\r
422 <operationType>${operationType}</operationType>
\r
423 <resourceTemplateUUIDs>${resourceTemplateUUIDs}</resourceTemplateUUIDs>
\r
424 </ns:initResourceOperationStatus>
\r
426 </soapenv:Envelope>"""
\r
428 payload = utils.formatXml(payload)
\r
429 execution.setVariable("CVFMI_initResOperStatusRequest", payload)
\r
430 utils.log("INFO", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled)
\r
431 utils.logAudit("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload)
\r
433 }catch(Exception e){
\r
434 utils.log("ERROR", "Exception Occured Processing preInitResourcesOperStatus. Exception is:\n" + e, isDebugEnabled)
\r
435 execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage())
\r
437 utils.log("INFO", "======== COMPLETED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
\r
441 * Init the service Operation Status
\r
443 public void preUpdateServiceOperationStatus(DelegateExecution execution){
\r
444 def method = getClass().getSimpleName() + '.preUpdateServiceOperationStatus(' +'execution=' + execution.getId() +')'
\r
445 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
446 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
449 String serviceId = execution.getVariable("serviceInstanceId")
\r
450 String operationId = execution.getVariable("operationId")
\r
451 String operationType = execution.getVariable("operationType")
\r
452 String serviceName = execution.getVariable("serviceInstanceName")
\r
454 String result = "processing"
\r
455 String progress = execution.getVariable("progress")
\r
456 utils.log("INFO", "progress: " + progress , isDebugEnabled)
\r
457 if ("100".equalsIgnoreCase(progress))
\r
459 result = "finished"
\r
462 String operationContent = "Prepare service : " + execution.getVariable("operationStatus")
\r
464 utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId, isDebugEnabled)
\r
465 serviceId = UriUtils.encode(serviceId,"UTF-8")
\r
466 execution.setVariable("serviceInstanceId", serviceId)
\r
467 execution.setVariable("operationId", operationId)
\r
468 execution.setVariable("operationType", operationType)
\r
470 def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter"
\r
471 execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
\r
472 utils.log("INFO", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
\r
474 execution.setVariable("URN_mso_openecomp_adapters_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter")
\r
476 """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
\r
477 xmlns:ns="http://org.openecomp.mso/requestsdb">
\r
480 <ns:updateServiceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">
\r
481 <serviceId>${serviceId}</serviceId>
\r
482 <operationId>${operationId}</operationId>
\r
483 <serviceName>${serviceName}</serviceName>
\r
484 <operationType>${operationType}</operationType>
\r
485 <userId>${userId}</userId>
\r
486 <result>${result}</result>
\r
487 <operationContent>${operationContent}</operationContent>
\r
488 <progress>${progress}</progress>
\r
489 <reason>${reason}</reason>
\r
490 </ns:updateServiceOperationStatus>
\r
492 </soapenv:Envelope>"""
\r
494 payload = utils.formatXml(payload)
\r
495 execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload)
\r
496 utils.log("INFO", "Outgoing preUpdateServiceOperationStatus: \n" + payload, isDebugEnabled)
\r
499 }catch(Exception e){
\r
500 utils.log("ERROR", "Exception Occured Processing preUpdateServiceOperationStatus. Exception is:\n" + e, isDebugEnabled)
\r
501 execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preUpdateServiceOperationStatus Method:\n" + e.getMessage())
\r
503 utils.log("INFO", "======== COMPLETED preUpdateServiceOperationStatus Process ======== ", isDebugEnabled)
\r
504 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
507 public void postResourcesOperStatus(DelegateExecution execution) {
\r
508 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
512 public void preCompareModelVersions(DelegateExecution execution) {
\r
513 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
517 public void postCompareModelVersions(DelegateExecution execution) {
\r
518 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
521 public void preProcessForAddResource(DelegateExecution execution) {
\r
522 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
526 public void postProcessForAddResource(DelegateExecution execution) {
\r
527 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
528 utils.log("INFO"," ***** postProcessForAddResource ***** ", isDebugEnabled)
\r
530 ServiceDecomposition serviceDecomposition_Target = execution.getVariable("serviceDecomposition_Target")
\r
531 execution.setVariable("serviceDecomposition", serviceDecomposition_Target)
\r
533 utils.log("INFO"," *** Exit postProcessForAddResource *** ", isDebugEnabled)
\r
536 public void preProcessForDeleteResource(DelegateExecution execution) {
\r
537 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
541 public void postProcessForDeleteResource(DelegateExecution execution) {
\r
542 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
546 public void preProcessAAIGET2(DelegateExecution execution) {
\r
547 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
550 public void postProcessAAIGET2(DelegateExecution execution) {
\r
551 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
552 utils.log("INFO"," ***** postProcessAAIGET2 ***** ", isDebugEnabled)
\r
556 String serviceInstanceName = execution.getVariable("serviceInstanceName")
\r
557 boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
\r
559 utils.log("INFO","Error getting Service-instance from AAI in postProcessAAIGET2", + serviceInstanceName, isDebugEnabled)
\r
560 WorkflowException workflowException = execution.getVariable("WorkflowException")
\r
561 utils.logAudit("workflowException: " + workflowException)
\r
562 if(workflowException != null){
\r
563 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
\r
567 msg = "Failure in postProcessAAIGET2 GENGS_SuccessIndicator:" + succInAAI
\r
568 utils.log("INFO", msg, isDebugEnabled)
\r
569 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
\r
574 boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
\r
576 String aaiService = execution.getVariable("GENGS_service")
\r
577 if (!isBlank(aaiService) && (utils.nodeExists(aaiService, "resource-version"))) {
\r
578 execution.setVariable("serviceInstanceVersion", utils.getNodeText1(aaiService, "resource-version"))
\r
579 utils.log("INFO","Found Service-instance in AAI.serviceInstanceName:" + execution.getVariable("serviceInstanceName"), isDebugEnabled)
\r
583 } catch (BpmnError e) {
\r
585 } catch (Exception ex) {
\r
586 msg = "Exception in DoCreateServiceInstance.postProcessAAIGET2 " + ex.getMessage()
\r
587 utils.log("INFO", msg, isDebugEnabled)
\r
588 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
\r
590 utils.log("INFO"," *** Exit postProcessAAIGET2 *** ", isDebugEnabled)
\r
593 public void preProcessAAIPUT(DelegateExecution execution) {
\r
594 def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')'
\r
595 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
596 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
598 utils.log("INFO"," ***** preProcessAAIPUTt *****", isDebugEnabled)
\r
600 String modelUuid = execution.getVariable("modelUuid")
\r
601 String serviceInstanceVersion = execution.getVariable("serviceInstanceVersion")
\r
602 execution.setVariable("GENPS_serviceResourceVersion", serviceInstanceVersion)
\r
604 AaiUtil aaiUriUtil = new AaiUtil(this)
\r
605 utils.log("INFO","start create aai uri: " + aaiUriUtil, isDebugEnabled)
\r
606 String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution)
\r
607 utils.log("INFO","aai_uri: " + aai_uri, isDebugEnabled)
\r
608 String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri)
\r
609 utils.log("INFO","namespace: " + namespace, isDebugEnabled)
\r
611 String serviceInstanceData =
\r
612 """<service-instance xmlns=\"${namespace}\">
\r
613 <model-version-id">${modelUuid}</model-version-id>
\r
614 </service-instance>""".trim()
\r
616 execution.setVariable("serviceInstanceData", serviceInstanceData)
\r
617 utils.log("INFO","serviceInstanceData: " + serviceInstanceData, isDebugEnabled)
\r
618 utils.logAudit(serviceInstanceData)
\r
619 utils.log("INFO", " aai_uri " + aai_uri + " namespace:" + namespace, isDebugEnabled)
\r
620 utils.log("INFO", " 'payload' to update Service Instance in AAI - " + "\n" + serviceInstanceData, isDebugEnabled)
\r
622 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
625 public void postProcessAAIPUT(DelegateExecution execution) {
\r
626 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
627 utils.log("INFO"," ***** postProcessAAIPUT ***** ", isDebugEnabled)
\r
630 String serviceInstanceId = execution.getVariable("serviceInstanceId")
\r
631 boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator")
\r
633 utils.log("INFO","Error putting Service-instance in AAI", + serviceInstanceId, isDebugEnabled)
\r
634 WorkflowException workflowException = execution.getVariable("WorkflowException")
\r
635 utils.logAudit("workflowException: " + workflowException)
\r
636 if(workflowException != null){
\r
637 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
\r
642 //start rollback set up
\r
643 RollbackData rollbackData = new RollbackData()
\r
644 def disableRollback = execution.getVariable("disableRollback")
\r
645 rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString())
\r
646 rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true")
\r
647 rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId)
\r
648 rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
\r
649 rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId"))
\r
650 execution.setVariable("rollbackData", rollbackData)
\r
653 } catch (BpmnError e) {
\r
655 } catch (Exception ex) {
\r
656 msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage()
\r
657 utils.log("INFO", msg, isDebugEnabled)
\r
658 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
\r
660 utils.log("INFO"," *** Exit postProcessAAIPUT *** ", isDebugEnabled)
\r
663 public void preProcessRollback (DelegateExecution execution) {
\r
664 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
665 utils.log("INFO"," ***** preProcessRollback ***** ", isDebugEnabled)
\r
668 Object workflowException = execution.getVariable("WorkflowException");
\r
670 if (workflowException instanceof WorkflowException) {
\r
671 utils.log("INFO", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled)
\r
672 execution.setVariable("prevWorkflowException", workflowException);
\r
673 //execution.setVariable("WorkflowException", null);
\r
675 } catch (BpmnError e) {
\r
676 utils.log("INFO", "BPMN Error during preProcessRollback", isDebugEnabled)
\r
677 } catch(Exception ex) {
\r
678 String msg = "Exception in preProcessRollback. " + ex.getMessage()
\r
679 utils.log("INFO", msg, isDebugEnabled)
\r
681 utils.log("INFO"," *** Exit preProcessRollback *** ", isDebugEnabled)
\r
684 public void postProcessRollback (DelegateExecution execution) {
\r
685 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
686 utils.log("INFO"," ***** postProcessRollback ***** ", isDebugEnabled)
\r
689 Object workflowException = execution.getVariable("prevWorkflowException");
\r
690 if (workflowException instanceof WorkflowException) {
\r
691 utils.log("INFO", "Setting prevException to WorkflowException: ", isDebugEnabled)
\r
692 execution.setVariable("WorkflowException", workflowException);
\r
694 execution.setVariable("rollbackData", null)
\r
695 } catch (BpmnError b) {
\r
696 utils.log("INFO", "BPMN Error during postProcessRollback", isDebugEnabled)
\r
698 } catch(Exception ex) {
\r
699 msg = "Exception in postProcessRollback. " + ex.getMessage()
\r
700 utils.log("INFO", msg, isDebugEnabled)
\r
702 utils.log("INFO"," *** Exit postProcessRollback *** ", isDebugEnabled)
\r
706 public void postConfigRequest(execution){
\r