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
25 import groovy.util.XmlParser
\r
27 import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition
\r
28 import org.openecomp.mso.bpmn.core.domain.ServiceInstance
\r
29 import org.openecomp.mso.bpmn.core.domain.ModelInfo
\r
30 import org.openecomp.mso.bpmn.core.domain.Resource
\r
31 import org.openecomp.mso.bpmn.core.json.JsonUtils
\r
32 import org.openecomp.mso.bpmn.common.scripts.AaiUtil
\r
33 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
\r
34 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
\r
35 import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
\r
36 import org.openecomp.mso.bpmn.core.RollbackData
\r
37 import org.openecomp.mso.bpmn.core.WorkflowException
\r
38 import org.openecomp.mso.rest.APIResponse;
\r
39 import org.openecomp.mso.rest.RESTClient
\r
40 import org.openecomp.mso.rest.RESTConfig
\r
42 import java.util.UUID;
\r
43 import javax.xml.parsers.DocumentBuilder
\r
44 import javax.xml.parsers.DocumentBuilderFactory
\r
46 import org.camunda.bpm.engine.delegate.BpmnError
\r
47 import org.camunda.bpm.engine.delegate.DelegateExecution
\r
48 import org.json.JSONObject;
\r
49 import org.json.JSONArray;
\r
50 import org.apache.commons.lang3.*
\r
51 import org.apache.commons.codec.binary.Base64;
\r
52 import org.springframework.web.util.UriUtils;
\r
56 * This groovy class supports the <class>DoUpdateE2EServiceInstance.bpmn</class> process.
\r
59 * @param - msoRequestId
\r
60 * @param - globalSubscriberId
\r
61 * @param - subscriptionServiceType
\r
62 * @param - serviceInstanceId
\r
63 * @param - serviceInstanceName - O
\r
64 * @param - serviceModelInfo
\r
65 * @param - productFamilyId
\r
66 * @param - disableRollback
\r
67 * @param - failExists - TODO
\r
68 * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM)
\r
69 * @param - sdncVersion ("1610")
\r
70 * @param - serviceDecomposition - Decomposition for R1710
\r
71 * (if macro provides serviceDecompsition then serviceModelInfo, serviceInstanceId & serviceInstanceName will be ignored)
\r
74 * @param - rollbackData (localRB->null)
\r
75 * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true)
\r
76 * @param - WorkflowException
\r
77 * @param - serviceInstanceName - (GET from AAI if null in input)
\r
80 public class DoUpdateE2EServiceInstance extends AbstractServiceTaskProcessor {
\r
82 String Prefix="DUPDSI_"
\r
83 private static final String DebugFlag = "isDebugEnabled"
\r
85 ExceptionUtil exceptionUtil = new ExceptionUtil()
\r
86 JsonUtils jsonUtil = new JsonUtils()
\r
88 public void preProcessRequest (DelegateExecution execution) {
\r
89 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
91 def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')'
\r
92 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
94 utils.log("INFO"," ***** Enter DoUpdateE2EServiceInstance preProcessRequest *****", isDebugEnabled)
\r
97 execution.setVariable("prefix", Prefix)
\r
99 //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology
\r
100 String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
\r
101 utils.log("INFO"," ***** globalSubscriberId *****" + globalSubscriberId, isDebugEnabled)
\r
103 //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology
\r
104 String serviceType = execution.getVariable("serviceType")
\r
105 utils.log("INFO"," ***** serviceType *****" + serviceType, isDebugEnabled)
\r
107 //requestDetails.requestParameters. for SDNC assignTopology
\r
108 String productFamilyId = execution.getVariable("productFamilyId") //AAI productFamilyId
\r
110 if (isBlank(globalSubscriberId)) {
\r
111 msg = "Input globalSubscriberId is null"
\r
112 utils.log("INFO", msg, isDebugEnabled)
\r
113 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
\r
116 if (isBlank(serviceType)) {
\r
117 msg = "Input serviceType is null"
\r
118 utils.log("INFO", msg, isDebugEnabled)
\r
119 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
\r
122 //Generated in parent for AAI
\r
123 String serviceInstanceId = execution.getVariable("serviceInstanceId")
\r
124 if (isBlank(serviceInstanceId)){
\r
125 msg = "Input serviceInstanceId is null"
\r
126 utils.log("INFO", msg, isDebugEnabled)
\r
127 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
\r
130 if (productFamilyId == null) {
\r
131 execution.setVariable("productFamilyId", "")
\r
134 String serviceInstanceName = execution.getVariable("serviceInstanceName")
\r
135 String uuiRequest = execution.getVariable("uuiRequest")
\r
136 utils.log("INFO","uuiRequest: " + uuiRequest, isDebugEnabled)
\r
138 String modelInvariantUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceInvariantUuid")
\r
139 utils.log("INFO","modelInvariantUuid: " + modelInvariantUuid, isDebugEnabled)
\r
140 execution.setVariable("modelInvariantUuid", modelInvariantUuid)
\r
141 execution.setVariable("model-invariant-id-target", modelInvariantUuid)
\r
143 String modelUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceUuid")
\r
144 utils.log("INFO","modelUuid: " + modelUuid, isDebugEnabled)
\r
145 execution.setVariable("modelUuid", modelUuid)
\r
146 execution.setVariable("model-version-id-target", modelUuid)
\r
148 String serviceModelName = jsonUtil.getJsonValue(uuiRequest, "service.parameters.templateName")
\r
149 utils.log("INFO","serviceModelName: " + serviceModelName, isDebugEnabled)
\r
150 if(serviceModelName == null) {
\r
151 serviceModelName = ""
\r
153 execution.setVariable("serviceModelName", serviceModelName)
\r
155 } catch (BpmnError e) {
\r
157 } catch (Exception ex){
\r
158 msg = "Exception in preProcessRequest " + ex.getMessage()
\r
159 utils.log("INFO", msg, isDebugEnabled)
\r
160 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
\r
162 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
165 public void postProcessAAIGET(DelegateExecution execution) {
\r
166 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
167 utils.log("INFO"," ***** postProcessAAIGET ***** ", isDebugEnabled)
\r
171 String serviceInstanceId = execution.getVariable("serviceInstanceId")
\r
172 boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
\r
173 String serviceType = ""
\r
176 utils.log("INFO","Found Service-instance in AAI", isDebugEnabled)
\r
178 String siData = execution.getVariable("GENGS_service")
\r
179 utils.log("INFO", "SI Data", isDebugEnabled)
\r
180 if (isBlank(siData))
\r
182 msg = "Could not retrive ServiceInstance data from AAI, Id:" + serviceInstanceId
\r
183 utils.log("INFO", msg, isDebugEnabled)
\r
184 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
\r
187 utils.log("INFO", "SI Data" + siData, isDebugEnabled)
\r
189 // Get Template uuid and version
\r
190 if (utils.nodeExists(siData, "model-invariant-id") && utils.nodeExists(siData, "model-version-id") ) {
\r
191 utils.log("INFO", "SI Data model-invariant-id and model-version-id exist:", isDebugEnabled)
\r
193 def modelInvariantId = utils.getNodeText1(siData, "model-invariant-id")
\r
194 def modelVersionId = utils.getNodeText1(siData, "model-version-id")
\r
196 // Set Original Template info
\r
197 execution.setVariable("model-invariant-id-original", modelInvariantId)
\r
198 execution.setVariable("model-version-id-original", modelVersionId)
\r
201 //get related service instances (vnf/network or volume) for delete
\r
202 if (utils.nodeExists(siData, "relationship-list")) {
\r
203 utils.log("INFO", "SI Data relationship-list exists:", isDebugEnabled)
\r
205 JSONArray jArray = new JSONArray()
\r
207 XmlParser xmlParser = new XmlParser()
\r
208 Node root = xmlParser.parseText(siData)
\r
209 def relation_list = utils.getChildNode(root, 'relationship-list')
\r
210 def relationships = utils.getIdenticalChildren(relation_list, 'relationship')
\r
212 for (def relation: relationships) {
\r
213 def jObj = getRelationShipData(relation, isDebugEnabled)
\r
217 execution.setVariable("serviceRelationShip", jArray.toString())
\r
220 boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
\r
222 utils.log("INFO","Error getting Service-instance from AAI", + serviceInstanceId, isDebugEnabled)
\r
223 WorkflowException workflowException = execution.getVariable("WorkflowException")
\r
224 utils.logAudit("workflowException: " + workflowException)
\r
225 if(workflowException != null){
\r
226 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
\r
230 msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI
\r
231 utils.log("INFO", msg, isDebugEnabled)
\r
232 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
\r
236 utils.log("INFO","Service-instance NOT found in AAI. Silent Success", isDebugEnabled)
\r
238 }catch (BpmnError e) {
\r
240 } catch (Exception ex) {
\r
241 msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIGET. " + ex.getMessage()
\r
242 utils.log("INFO", msg, isDebugEnabled)
\r
243 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
\r
245 utils.log("INFO"," *** Exit postProcessAAIGET *** ", isDebugEnabled)
\r
248 private JSONObject getRelationShipData(node, isDebugEnabled){
\r
249 JSONObject jObj = new JSONObject()
\r
251 def relation = utils.nodeToString(node)
\r
252 def rt = utils.getNodeText1(relation, "related-to")
\r
254 def rl = utils.getNodeText1(relation, "related-link")
\r
255 utils.log("INFO", "ServiceInstance Related NS/Configuration :" + rl, isDebugEnabled)
\r
257 def rl_datas = utils.getIdenticalChildren(node, "relationship-data")
\r
258 for(def rl_data : rl_datas) {
\r
259 def eKey = utils.getChildNodeText(rl_data, "relationship-key")
\r
260 def eValue = utils.getChildNodeText(rl_data, "relationship-value")
\r
262 if ((rt == "service-instance" && eKey.equals("service-instance.service-instance-id"))
\r
263 //for overlay/underlay
\r
264 || (rt == "configuration" && eKey.equals("configuration.configuration-id"))){
\r
265 jObj.put("resourceInstanceId", eValue)
\r
269 def rl_props = utils.getIdenticalChildren(node, "related-to-property")
\r
270 for(def rl_prop : rl_props) {
\r
271 def eKey = utils.getChildNodeText(rl_prop, "property-key")
\r
272 def eValue = utils.getChildNodeText(rl_prop, "property-value")
\r
273 if((rt == "service-instance" && eKey.equals("service-instance.service-instance-name"))
\r
274 //for overlay/underlay
\r
275 || (rt == "configuration" && eKey.equals("configuration.configuration-type"))){
\r
276 jObj.put("resourceType", eValue)
\r
280 utils.log("INFO", "Relationship related to Resource:" + jObj.toString(), isDebugEnabled)
\r
285 public void preInitResourcesOperStatus(DelegateExecution execution){
\r
286 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
288 utils.log("INFO", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
\r
290 String serviceId = execution.getVariable("serviceInstanceId")
\r
291 String operationId = execution.getVariable("operationId")
\r
292 String operationType = execution.getVariable("operationType")
\r
293 String resourceTemplateUUIDs = ""
\r
294 String result = "processing"
\r
295 String progress = "10"
\r
297 String operationContent = "Prepare service updating"
\r
298 utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType, isDebugEnabled)
\r
299 serviceId = UriUtils.encode(serviceId,"UTF-8")
\r
300 execution.setVariable("serviceInstanceId", serviceId)
\r
301 execution.setVariable("operationId", operationId)
\r
302 execution.setVariable("operationType", operationType)
\r
304 List<Resource> resourceList = new ArrayList<String>()
\r
305 List<Resource> addResourceList = execution.getVariable("addResourceList")
\r
306 List<Resource> delResourceList = execution.getVariable("delResourceList")
\r
307 resourceList.addAll(addResourceList)
\r
308 resourceList.addAll(delResourceList)
\r
309 for(Resource resource : resourceList){
\r
310 resourceTemplateUUIDs = resourceTemplateUUIDs + resource.getModelInfo().getModelCustomizationUuid() + ":"
\r
313 def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter"
\r
314 execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
\r
315 utils.log("INFO", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
\r
318 """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
\r
319 xmlns:ns="http://org.openecomp.mso/requestsdb">
\r
322 <ns:initResourceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">
\r
323 <serviceId>${serviceId}</serviceId>
\r
324 <operationId>${operationId}</operationId>
\r
325 <operationType>${operationType}</operationType>
\r
326 <resourceTemplateUUIDs>${resourceTemplateUUIDs}</resourceTemplateUUIDs>
\r
327 </ns:initResourceOperationStatus>
\r
329 </soapenv:Envelope>"""
\r
331 payload = utils.formatXml(payload)
\r
332 execution.setVariable("CVFMI_initResOperStatusRequest", payload)
\r
333 utils.log("INFO", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled)
\r
334 utils.logAudit("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload)
\r
336 }catch(Exception e){
\r
337 utils.log("ERROR", "Exception Occured Processing preInitResourcesOperStatus. Exception is:\n" + e, isDebugEnabled)
\r
338 execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage())
\r
340 utils.log("INFO", "======== COMPLETED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
\r
344 * Init the service Operation Status
\r
346 public void preUpdateServiceOperationStatus(DelegateExecution execution){
\r
347 def method = getClass().getSimpleName() + '.preUpdateServiceOperationStatus(' +'execution=' + execution.getId() +')'
\r
348 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
349 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
352 String serviceId = execution.getVariable("serviceInstanceId")
\r
353 String operationId = execution.getVariable("operationId")
\r
354 String operationType = execution.getVariable("operationType")
\r
355 String serviceName = execution.getVariable("serviceInstanceName")
\r
357 String result = "processing"
\r
358 String progress = execution.getVariable("progress")
\r
359 utils.log("INFO", "progress: " + progress , isDebugEnabled)
\r
360 if ("100".equalsIgnoreCase(progress))
\r
362 result = "finished"
\r
365 String operationContent = "Prepare service : " + execution.getVariable("operationStatus")
\r
367 utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId, isDebugEnabled)
\r
368 serviceId = UriUtils.encode(serviceId,"UTF-8")
\r
369 execution.setVariable("serviceInstanceId", serviceId)
\r
370 execution.setVariable("operationId", operationId)
\r
371 execution.setVariable("operationType", operationType)
\r
373 def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter"
\r
374 execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
\r
375 utils.log("INFO", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
\r
377 execution.setVariable("URN_mso_openecomp_adapters_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter")
\r
379 """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
\r
380 xmlns:ns="http://org.openecomp.mso/requestsdb">
\r
383 <ns:updateServiceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">
\r
384 <serviceId>${serviceId}</serviceId>
\r
385 <operationId>${operationId}</operationId>
\r
386 <serviceName>${serviceName}</serviceName>
\r
387 <operationType>${operationType}</operationType>
\r
388 <userId>${userId}</userId>
\r
389 <result>${result}</result>
\r
390 <operationContent>${operationContent}</operationContent>
\r
391 <progress>${progress}</progress>
\r
392 <reason>${reason}</reason>
\r
393 </ns:updateServiceOperationStatus>
\r
395 </soapenv:Envelope>"""
\r
397 payload = utils.formatXml(payload)
\r
398 execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload)
\r
399 utils.log("INFO", "Outgoing preUpdateServiceOperationStatus: \n" + payload, isDebugEnabled)
\r
402 }catch(Exception e){
\r
403 utils.log("ERROR", "Exception Occured Processing preUpdateServiceOperationStatus. Exception is:\n" + e, isDebugEnabled)
\r
404 execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preUpdateServiceOperationStatus Method:\n" + e.getMessage())
\r
406 utils.log("INFO", "======== COMPLETED preUpdateServiceOperationStatus Process ======== ", isDebugEnabled)
\r
407 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
410 public void postResourcesOperStatus(DelegateExecution execution) {
\r
411 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
415 public void preCompareModelVersions(DelegateExecution execution) {
\r
416 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
420 public void postCompareModelVersions(DelegateExecution execution) {
\r
421 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
424 public void preProcessForAddResource(DelegateExecution execution) {
\r
425 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
426 utils.log("INFO"," ***** preProcessForAddResource ***** ", isDebugEnabled)
\r
428 execution.setVariable("operationType", "create")
\r
430 utils.log("INFO"," *** Exit preProcessForAddResource *** ", isDebugEnabled)
\r
433 public void postProcessForAddResource(DelegateExecution execution) {
\r
434 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
435 utils.log("INFO"," ***** postProcessForAddResource ***** ", isDebugEnabled)
\r
437 execution.setVariable("operationType", "update")
\r
439 utils.log("INFO"," *** Exit postProcessForAddResource *** ", isDebugEnabled)
\r
442 public void preProcessForDeleteResource(DelegateExecution execution) {
\r
443 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
444 utils.log("INFO"," ***** preProcessForDeleteResource ***** ", isDebugEnabled)
\r
446 execution.setVariable("operationType", "delete")
\r
448 utils.log("INFO"," *** Exit preProcessForDeleteResource *** ", isDebugEnabled)
\r
452 public void postProcessForDeleteResource(DelegateExecution execution) {
\r
453 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
454 utils.log("INFO"," ***** postProcessForDeleteResource ***** ", isDebugEnabled)
\r
456 execution.setVariable("operationType", "update")
\r
458 utils.log("INFO"," *** Exit postProcessForDeleteResource *** ", isDebugEnabled)
\r
461 public void preProcessAAIGET2(DelegateExecution execution) {
\r
462 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
465 public void postProcessAAIGET2(DelegateExecution execution) {
\r
466 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
467 utils.log("INFO"," ***** postProcessAAIGET2 ***** ", isDebugEnabled)
\r
471 String serviceInstanceName = execution.getVariable("serviceInstanceName")
\r
472 boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
\r
474 utils.log("INFO","Error getting Service-instance from AAI in postProcessAAIGET2", + serviceInstanceName, isDebugEnabled)
\r
475 WorkflowException workflowException = execution.getVariable("WorkflowException")
\r
476 utils.logAudit("workflowException: " + workflowException)
\r
477 if(workflowException != null){
\r
478 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
\r
482 msg = "Failure in postProcessAAIGET2 GENGS_SuccessIndicator:" + succInAAI
\r
483 utils.log("INFO", msg, isDebugEnabled)
\r
484 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
\r
489 boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
\r
491 String aaiService = execution.getVariable("GENGS_service")
\r
492 if (!isBlank(aaiService) && (utils.nodeExists(aaiService, "resource-version"))) {
\r
493 execution.setVariable("serviceInstanceVersion", utils.getNodeText1(aaiService, "resource-version"))
\r
494 utils.log("INFO","Found Service-instance in AAI.serviceInstanceName:" + execution.getVariable("serviceInstanceName"), isDebugEnabled)
\r
498 } catch (BpmnError e) {
\r
500 } catch (Exception ex) {
\r
501 msg = "Exception in DoCreateServiceInstance.postProcessAAIGET2 " + ex.getMessage()
\r
502 utils.log("INFO", msg, isDebugEnabled)
\r
503 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
\r
505 utils.log("INFO"," *** Exit postProcessAAIGET2 *** ", isDebugEnabled)
\r
508 public void preProcessAAIPUT(DelegateExecution execution) {
\r
509 def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')'
\r
510 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
511 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
513 utils.log("INFO"," ***** preProcessAAIPUTt *****", isDebugEnabled)
\r
515 String modelUuid = execution.getVariable("modelUuid")
\r
516 String serviceInstanceVersion = execution.getVariable("serviceInstanceVersion")
\r
517 execution.setVariable("GENPS_serviceResourceVersion", serviceInstanceVersion)
\r
519 AaiUtil aaiUriUtil = new AaiUtil(this)
\r
520 utils.log("INFO","start create aai uri: " + aaiUriUtil, isDebugEnabled)
\r
521 String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution)
\r
522 utils.log("INFO","aai_uri: " + aai_uri, isDebugEnabled)
\r
523 String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri)
\r
524 utils.log("INFO","namespace: " + namespace, isDebugEnabled)
\r
526 String serviceInstanceData =
\r
527 """<service-instance xmlns=\"${namespace}\">
\r
528 <model-version-id">${modelUuid}</model-version-id>
\r
529 </service-instance>""".trim()
\r
531 execution.setVariable("serviceInstanceData", serviceInstanceData)
\r
532 utils.log("INFO","serviceInstanceData: " + serviceInstanceData, isDebugEnabled)
\r
533 utils.logAudit(serviceInstanceData)
\r
534 utils.log("INFO", " aai_uri " + aai_uri + " namespace:" + namespace, isDebugEnabled)
\r
535 utils.log("INFO", " 'payload' to update Service Instance in AAI - " + "\n" + serviceInstanceData, isDebugEnabled)
\r
537 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
540 public void postProcessAAIPUT(DelegateExecution execution) {
\r
541 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
542 utils.log("INFO"," ***** postProcessAAIPUT ***** ", isDebugEnabled)
\r
545 String serviceInstanceId = execution.getVariable("serviceInstanceId")
\r
546 boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator")
\r
548 utils.log("INFO","Error putting Service-instance in AAI", + serviceInstanceId, isDebugEnabled)
\r
549 WorkflowException workflowException = execution.getVariable("WorkflowException")
\r
550 utils.logAudit("workflowException: " + workflowException)
\r
551 if(workflowException != null){
\r
552 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
\r
557 //start rollback set up
\r
558 RollbackData rollbackData = new RollbackData()
\r
559 def disableRollback = execution.getVariable("disableRollback")
\r
560 rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString())
\r
561 rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true")
\r
562 rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId)
\r
563 rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
\r
564 rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId"))
\r
565 execution.setVariable("rollbackData", rollbackData)
\r
568 } catch (BpmnError e) {
\r
570 } catch (Exception ex) {
\r
571 msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage()
\r
572 utils.log("INFO", msg, isDebugEnabled)
\r
573 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
\r
575 utils.log("INFO"," *** Exit postProcessAAIPUT *** ", isDebugEnabled)
\r
578 public void preProcessRollback (DelegateExecution execution) {
\r
579 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
580 utils.log("INFO"," ***** preProcessRollback ***** ", isDebugEnabled)
\r
583 Object workflowException = execution.getVariable("WorkflowException");
\r
585 if (workflowException instanceof WorkflowException) {
\r
586 utils.log("INFO", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled)
\r
587 execution.setVariable("prevWorkflowException", workflowException);
\r
588 //execution.setVariable("WorkflowException", null);
\r
590 } catch (BpmnError e) {
\r
591 utils.log("INFO", "BPMN Error during preProcessRollback", isDebugEnabled)
\r
592 } catch(Exception ex) {
\r
593 String msg = "Exception in preProcessRollback. " + ex.getMessage()
\r
594 utils.log("INFO", msg, isDebugEnabled)
\r
596 utils.log("INFO"," *** Exit preProcessRollback *** ", isDebugEnabled)
\r
599 public void postProcessRollback (DelegateExecution execution) {
\r
600 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
601 utils.log("INFO"," ***** postProcessRollback ***** ", isDebugEnabled)
\r
604 Object workflowException = execution.getVariable("prevWorkflowException");
\r
605 if (workflowException instanceof WorkflowException) {
\r
606 utils.log("INFO", "Setting prevException to WorkflowException: ", isDebugEnabled)
\r
607 execution.setVariable("WorkflowException", workflowException);
\r
609 execution.setVariable("rollbackData", null)
\r
610 } catch (BpmnError b) {
\r
611 utils.log("INFO", "BPMN Error during postProcessRollback", isDebugEnabled)
\r
613 } catch(Exception ex) {
\r
614 msg = "Exception in postProcessRollback. " + ex.getMessage()
\r
615 utils.log("INFO", msg, isDebugEnabled)
\r
617 utils.log("INFO"," *** Exit postProcessRollback *** ", isDebugEnabled)
\r
621 public void postConfigRequest(execution){
\r