2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
\r
7 * ================================================================================
\r
8 * Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * you may not use this file except in compliance with the License.
\r
10 * You may obtain a copy of the License at
\r
12 * http://www.apache.org/licenses/LICENSE-2.0
\r
14 * Unless required by applicable law or agreed to in writing, software
\r
15 * distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * See the License for the specific language governing permissions and
\r
18 * limitations under the License.
\r
19 * ============LICENSE_END=========================================================
\r
21 package org.openecomp.mso.bpmn.infrastructure.scripts
\r
23 import static org.apache.commons.lang3.StringUtils.*;
\r
25 import org.apache.commons.lang3.*
\r
26 import org.camunda.bpm.engine.delegate.BpmnError
\r
27 import org.camunda.bpm.engine.delegate.DelegateExecution
\r
28 import org.json.JSONArray;
\r
29 import org.json.JSONObject;
\r
30 import org.openecomp.mso.bpmn.common.scripts.AaiUtil
\r
31 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
\r
32 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
\r
33 import org.openecomp.mso.bpmn.core.WorkflowException
\r
34 import org.openecomp.mso.bpmn.core.json.JsonUtils
\r
35 import org.openecomp.mso.rest.APIResponse;
\r
36 import org.springframework.web.util.UriUtils;
\r
38 import groovy.json.*
\r
41 * This groovy class supports the <class>DoDeleteE2EServiceInstance.bpmn</class> process.
\r
44 * @param - msoRequestId
\r
45 * @param - globalSubscriberId - O
\r
46 * @param - subscriptionServiceType - O
\r
47 * @param - serviceInstanceId
\r
48 * @param - serviceInstanceName - O
\r
49 * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM)
\r
50 * @param - sdncVersion
\r
51 * @param - failNotFound - TODO
\r
52 * @param - serviceInputParams - TODO
\r
55 * @param - WorkflowException
\r
57 * Rollback - Deferred
\r
59 public class DoCustomDeleteE2EServiceInstanceV2 extends AbstractServiceTaskProcessor {
\r
61 String Prefix="DDELSI_"
\r
62 private static final String DebugFlag = "isDebugEnabled"
\r
63 ExceptionUtil exceptionUtil = new ExceptionUtil()
\r
64 JsonUtils jsonUtil = new JsonUtils()
\r
66 public void preProcessRequest (DelegateExecution execution) {
\r
68 def method = getClass().getSimpleName() + '.buildAPPCRequest(' +'execution=' + execution.getId() +')'
\r
69 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
70 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
71 utils.log("INFO"," ***** preProcessRequest *****", isDebugEnabled)
\r
75 String requestId = execution.getVariable("msoRequestId")
\r
76 execution.setVariable("prefix",Prefix)
\r
79 //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology
\r
80 String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
\r
81 if (globalSubscriberId == null)
\r
83 execution.setVariable("globalSubscriberId", "")
\r
86 //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology
\r
87 String serviceType = execution.getVariable("serviceType")
\r
88 if (serviceType == null)
\r
90 execution.setVariable("serviceType", "")
\r
93 //Generated in parent for AAI PUT
\r
94 String serviceInstanceId = execution.getVariable("serviceInstanceId")
\r
95 if (isBlank(serviceInstanceId)){
\r
96 msg = "Input serviceInstanceId is null"
\r
97 utils.log("INFO", msg, isDebugEnabled)
\r
98 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
\r
101 String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback')
\r
102 if (isBlank(sdncCallbackUrl)) {
\r
103 msg = "URN_mso_workflow_sdncadapter_callback is null"
\r
104 utils.log("INFO", msg, isDebugEnabled)
\r
105 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
\r
107 execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
\r
108 utils.log("INFO","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled)
\r
110 StringBuilder sbParams = new StringBuilder()
\r
111 Map<String, String> paramsMap = execution.getVariable("serviceInputParams")
\r
112 if (paramsMap != null)
\r
114 sbParams.append("<service-input-parameters>")
\r
115 for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
\r
117 String paramName = entry.getKey()
\r
118 String paramValue = entry.getValue()
\r
121 <name>${paramName}</name>
\r
122 <value>${paramValue}</value>
\r
125 sbParams.append(paramsXml)
\r
127 sbParams.append("</service-input-parameters>")
\r
129 String siParamsXml = sbParams.toString()
\r
130 if (siParamsXml == null)
\r
132 execution.setVariable("siParamsXml", siParamsXml)
\r
133 execution.setVariable("operationStatus", "Waiting delete resource...")
\r
134 execution.setVariable("progress", "0")
\r
136 } catch (BpmnError e) {
\r
138 } catch (Exception ex){
\r
139 msg = "Exception in preProcessRequest " + ex.getMessage()
\r
140 utils.log("INFO", msg, isDebugEnabled)
\r
141 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
\r
143 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
148 public void postProcessAAIGET(DelegateExecution execution) {
\r
149 def method = getClass().getSimpleName() + '.postProcessAAIGET(' +'execution=' + execution.getId() +')'
\r
150 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
151 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
156 String serviceInstanceId = execution.getVariable("serviceInstanceId")
\r
157 utils.log("INFO","serviceInstanceId: "+serviceInstanceId, isDebugEnabled)
\r
159 boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
\r
160 utils.log("INFO","foundInAAI: "+foundInAAI, isDebugEnabled)
\r
162 String serviceType = ""
\r
166 utils.log("INFO","Found Service-instance in AAI", isDebugEnabled)
\r
168 String siData = execution.getVariable("GENGS_service")
\r
169 utils.log("INFO", "SI Data", isDebugEnabled)
\r
170 if (isBlank(siData))
\r
172 msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId
\r
173 utils.log("INFO", msg, isDebugEnabled)
\r
174 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
\r
178 boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
\r
180 utils.log("INFO","Error getting Service-instance from AAI", + serviceInstanceId, isDebugEnabled)
\r
181 WorkflowException workflowException = execution.getVariable("WorkflowException")
\r
182 utils.logAudit("workflowException: " + workflowException)
\r
183 if(workflowException != null){
\r
184 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
\r
188 msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI
\r
189 utils.log("INFO", msg, isDebugEnabled)
\r
190 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
\r
194 utils.log("INFO","Service-instance NOT found in AAI. Silent Success", isDebugEnabled)
\r
196 }catch (BpmnError e) {
\r
198 } catch (Exception ex) {
\r
199 msg = "Bpmn error encountered in " + method + "--" + ex.getMessage()
\r
200 utils.log("INFO", msg, isDebugEnabled)
\r
201 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
\r
203 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
206 private void loadResourcesProperties(DelegateExecution execution) {
\r
207 def method = getClass().getSimpleName() + '.loadResourcesProperties(' +'execution=' + execution.getId() +')'
\r
208 def isDebugEnabled = execution.getVariable("isDebugEnabled")
\r
209 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
210 String loadFilePath = "/etc/mso/config.d/reources.json"
\r
212 def jsonPayload = new File(loadFilePath).text
\r
213 utils.log("INFO","jsonPayload: " + jsonPayload, isDebugEnabled)
\r
215 String resourcesProperties = jsonUtil.prettyJson(jsonPayload.toString())
\r
216 utils.log("INFO","resourcesProperties: " + resourcesProperties, isDebugEnabled)
\r
218 String createResourceSort = jsonUtil.getJsonValue(resourcesProperties, "CreateResourceSort")
\r
219 //utils.log("INFO","createResourceSort: " + createResourceSort, isDebugEnabled)
\r
220 execution.setVariable("createResourceSort", createResourceSort)
\r
222 String deleteResourceSort = jsonUtil.getJsonValue(resourcesProperties, "DeleteResourceSort")
\r
223 //utils.log("INFO","deleteResourceSort: " + deleteResourceSort, isDebugEnabled)
\r
224 execution.setVariable("deleteResourceSort", deleteResourceSort)
\r
227 String resourceControllerType = jsonUtil.getJsonValue(resourcesProperties, "ResourceControllerType")
\r
228 //utils.log("INFO","resourceControllerType: " + resourceControllerType, isDebugEnabled)
\r
229 execution.setVariable("resourceControllerType", resourceControllerType)
\r
232 }catch(Exception ex){
\r
233 // try error in method block
\r
234 String exceptionMessage = "Bpmn error encountered in " + method + " - " + ex.getMessage()
\r
235 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
\r
236 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
238 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
240 private void sortDeleteResource(DelegateExecution execution) {
\r
241 def method = getClass().getSimpleName() + '.sortDeleteResource(' +'execution=' + execution.getId() +')'
\r
242 def isDebugEnabled = execution.getVariable("isDebugEnabled")
\r
243 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
244 String deleteResourceSortDef = """[
\r
246 "resourceType":"GRE_SAR"
\r
249 "resourceType":"VPN_SAR"
\r
252 "resourceType":"APN_AAR"
\r
255 "resourceType":"GRE_AAR"
\r
258 "resourceType":"Overlay"
\r
261 "resourceType":"Underlay"
\r
264 "resourceType":"vIMS"
\r
267 "resourceType":"vCPE"
\r
270 "resourceType":"vFW"
\r
273 "resourceType":"vEPC"
\r
280 loadResourcesProperties(execution)
\r
281 String deleteResourceSort = execution.getVariable("deleteResourceSort")
\r
282 if (isBlank(deleteResourceSort)) {
\r
283 deleteResourceSort = deleteResourceSortDef;
\r
286 List<String> sortResourceList = jsonUtil.StringArrayToList(execution, deleteResourceSort)
\r
287 utils.log("INFO", "sortResourceList : " + sortResourceList, isDebugEnabled)
\r
289 JSONArray newResourceList = new JSONArray()
\r
290 int resSortCount = sortResourceList.size()
\r
292 for ( int currentResource = 0 ; currentResource < resSortCount ; currentResource++ ) {
\r
293 String currentSortResource = sortResourceList[currentResource]
\r
294 String sortResourceType = jsonUtil.getJsonValue(currentSortResource, "resourceType")
\r
295 List<String> resourceList = execution.getVariable(Prefix+"resourceList")
\r
297 for (String resource : resourceList) {
\r
298 //utils.log("INFO", "resource : " + resource, isDebugEnabled)
\r
299 String resourceType = jsonUtil.getJsonValue(resource, "resourceType")
\r
301 if (StringUtils.containsIgnoreCase(resourceType, sortResourceType)) {
\r
302 JSONObject jsonObj = new JSONObject(resource)
\r
303 newResourceList.put(jsonObj)
\r
305 utils.log("INFO", "Get next sort type " , isDebugEnabled)
\r
309 String newResourceStr = newResourceList.toString()
\r
310 List<String> newResourceListStr = jsonUtil.StringArrayToList(execution, newResourceStr)
\r
312 execution.setVariable(Prefix+"resourceList", newResourceListStr)
\r
313 utils.log("INFO", "newResourceList : " + newResourceListStr, isDebugEnabled)
\r
315 }catch(Exception ex){
\r
316 // try error in method block
\r
317 String exceptionMessage = "Bpmn error encountered in " + method + " - " + ex.getMessage()
\r
318 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
\r
319 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
321 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
324 public void prepareServiceDeleteResource(DelegateExecution execution) {
\r
325 def method = getClass().getSimpleName() + '.prepareServiceDeleteResource(' +'execution=' + execution.getId() +')'
\r
326 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
327 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
331 String serviceInstanceId = execution.getVariable("serviceInstanceId")
\r
333 // confirm if ServiceInstance was found
\r
334 if ( !execution.getVariable("GENGS_FoundIndicator") )
\r
336 String exceptionMessage = "Bpmn error encountered in DeleteMobileAPNCustService flow. Service Instance was not found in AAI by id: " + serviceInstanceId
\r
337 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
340 execution.setVariable(Prefix+"resourceList", "")
\r
341 execution.setVariable(Prefix+"resourceCount", 0)
\r
342 execution.setVariable(Prefix+"nextResource", 0)
\r
343 execution.setVariable(Prefix+"resourceFinish", true)
\r
345 // get SI extracted by GenericGetService
\r
346 String serviceInstanceAaiRecord = execution.getVariable("GENGS_service");
\r
347 utils.log("INFO", "serviceInstanceAaiRecord: " +serviceInstanceAaiRecord, isDebugEnabled)
\r
349 String aaiJsonRecord = jsonUtil.xml2json(serviceInstanceAaiRecord)
\r
351 //utils.log("INFO", "aaiJsonRecord: " +aaiJsonRecord, isDebugEnabled)
\r
352 def serviceInstanceName = jsonUtil.getJsonValue(aaiJsonRecord, "service-instance.service-instance-name")
\r
353 execution.setVariable("serviceInstanceName",serviceInstanceName)
\r
355 def serviceType = jsonUtil.getJsonValue(aaiJsonRecord, "service-instance.service-type")
\r
356 execution.setVariable("serviceType",serviceType)
\r
359 String relationshipList = jsonUtil.getJsonValue(aaiJsonRecord, "service-instance.relationship-list")
\r
360 //utils.log("INFO", "relationship-list:" + relationshipList, isDebugEnabled)
\r
361 if (! isBlank(relationshipList)){
\r
362 utils.log("INFO", "relationship-list exists" , isDebugEnabled)
\r
363 String relationShip = jsonUtil.getJsonValue(relationshipList, "relationship")
\r
364 utils.log("INFO", "relationship: " + relationShip, isDebugEnabled)
\r
365 JSONArray allResources = new JSONArray()
\r
366 JSONArray serviceResources = new JSONArray()
\r
367 JSONArray networkResources = new JSONArray()
\r
368 JSONArray allottedResources = new JSONArray()
\r
371 if (! isBlank(relationShip)){
\r
372 JSONArray jsonArray = new JSONArray();
\r
373 if (relationShip.startsWith("{") && relationShip.endsWith("}")) {
\r
374 JSONObject jsonObject = new JSONObject(relationShip);
\r
375 jsonArray.put(jsonObject);
\r
376 } else if (relationShip.startsWith("[") && relationShip.endsWith("]")) {
\r
377 jsonArray = new JSONArray(relationShip);
\r
379 utils.log("INFO", "The relationShip fomart is error" , isDebugEnabled)
\r
382 List<String> relationList = jsonUtil.StringArrayToList(execution, jsonArray.toString())
\r
384 utils.log("INFO", "relationList: " + relationList, isDebugEnabled)
\r
386 int relationNum =relationList.size()
\r
387 utils.log("INFO", "**************relationList size: " + relationNum, isDebugEnabled)
\r
389 for ( int currentRelation = 0 ; currentRelation < relationNum ; currentRelation++ ) {
\r
390 utils.log("INFO", "current Relation num: " + currentRelation, isDebugEnabled)
\r
391 String relation = relationList[currentRelation]
\r
392 utils.log("INFO", "relation: " + relation, isDebugEnabled)
\r
394 String relatedTo = jsonUtil.getJsonValue(relation, "related-to")
\r
395 utils.log("INFO", "relatedTo: " + relatedTo, isDebugEnabled)
\r
397 String relatedLink = jsonUtil.getJsonValue(relation, "related-link")
\r
398 utils.log("INFO", "relatedLink: " + relatedLink, isDebugEnabled)
\r
400 if (StringUtils.equalsIgnoreCase(relatedTo, "allotted-resource")) {
\r
401 utils.log("INFO", "allotted-resource exists ", isDebugEnabled)
\r
403 String aaiArRsp = getAaiAr(execution, relatedLink)
\r
404 utils.log("INFO", "aaiArRsp: " + aaiArRsp, isDebugEnabled)
\r
405 if (! isBlank(aaiArRsp)) {
\r
406 def type = utils.getNodeText1(aaiArRsp, "type")
\r
407 def id = utils.getNodeText1(aaiArRsp, "id")
\r
408 def role = utils.getNodeText1(aaiArRsp, "role")
\r
409 def resourceVersion = utils.getNodeText1(aaiArRsp, "resource-version")
\r
411 JSONObject jObject = new JSONObject()
\r
412 jObject.put("resourceType", type)
\r
413 jObject.put("resourceInstanceId", id)
\r
414 jObject.put("resourceRole", role)
\r
415 jObject.put("resourceVersion", resourceVersion)
\r
417 allResources.put(jObject)
\r
418 utils.log("INFO", "allResources: " + allResources, isDebugEnabled)
\r
419 allottedResources.put(jObject)
\r
420 utils.log("INFO", "allottedResources: " + allottedResources, isDebugEnabled)
\r
423 else if (StringUtils.equalsIgnoreCase(relatedTo, "service-instance")){
\r
424 utils.log("INFO", "service-instance exists ", isDebugEnabled)
\r
425 JSONObject jObject = new JSONObject()
\r
427 //relationship-data
\r
428 String rsDataStr = jsonUtil.getJsonValue(relation, "relationship-data")
\r
429 utils.log("INFO", "rsDataStr: " + rsDataStr, isDebugEnabled)
\r
430 List<String> rsDataList = jsonUtil.StringArrayToList(execution, rsDataStr)
\r
431 utils.log("INFO", "rsDataList: " + rsDataList, isDebugEnabled)
\r
432 for(String rsData : rsDataList){
\r
433 utils.log("INFO", "rsData: " + rsData, isDebugEnabled)
\r
434 def eKey = jsonUtil.getJsonValue(rsData, "relationship-key")
\r
435 def eValue = jsonUtil.getJsonValue(rsData, "relationship-value")
\r
436 if(eKey.equals("service-instance.service-instance-id")){
\r
437 jObject.put("resourceInstanceId", eValue)
\r
439 if(eKey.equals("service-subscription.service-type")){
\r
440 jObject.put("resourceType", eValue)
\r
444 //related-to-property
\r
445 String rPropertyStr = jsonUtil.getJsonValue(relation, "related-to-property")
\r
446 utils.log("INFO", "related-to-property: " + rPropertyStr, isDebugEnabled)
\r
447 if (rPropertyStr instanceof JSONArray){
\r
448 List<String> rPropertyList = jsonUtil.StringArrayToList(execution, rPropertyStr)
\r
449 for (String rProperty : rPropertyList) {
\r
450 utils.log("INFO", "rProperty: " + rProperty, isDebugEnabled)
\r
451 def eKey = jsonUtil.getJsonValue(rProperty, "property-key")
\r
452 def eValue = jsonUtil.getJsonValue(rProperty, "property-value")
\r
453 if(eKey.equals("service-instance.service-instance-name")){
\r
454 jObject.put("resourceName", eValue)
\r
459 String rProperty = rPropertyStr
\r
460 utils.log("INFO", "rProperty: " + rProperty, isDebugEnabled)
\r
461 def eKey = jsonUtil.getJsonValue(rProperty, "property-key")
\r
462 def eValue = jsonUtil.getJsonValue(rProperty, "property-value")
\r
463 if (eKey.equals("service-instance.service-instance-name")) {
\r
464 jObject.put("resourceName", eValue)
\r
468 allResources.put(jObject)
\r
469 utils.log("INFO", "allResources: " + allResources, isDebugEnabled)
\r
471 serviceResources.put(jObject)
\r
472 utils.log("INFO", "serviceResources: " + serviceResources, isDebugEnabled)
\r
474 else if (StringUtils.equalsIgnoreCase(relatedTo, "configuration")) {
\r
475 utils.log("INFO", "configuration ", isDebugEnabled)
\r
476 JSONObject jObject = new JSONObject()
\r
478 //relationship-data
\r
479 String rsDataStr = jsonUtil.getJsonValue(relation, "relationship-data")
\r
480 utils.log("INFO", "rsDataStr: " + rsDataStr, isDebugEnabled)
\r
481 List<String> rsDataList = jsonUtil.StringArrayToList(execution, rsDataStr)
\r
482 utils.log("INFO", "rsDataList: " + rsDataList, isDebugEnabled)
\r
483 for (String rsData : rsDataList) {
\r
484 utils.log("INFO", "rsData: " + rsData, isDebugEnabled)
\r
485 def eKey = jsonUtil.getJsonValue(rsData, "relationship-key")
\r
486 def eValue = jsonUtil.getJsonValue(rsData, "relationship-value")
\r
487 if(eKey.equals("configuration.configuration-id")){
\r
488 jObject.put("resourceInstanceId", eValue)
\r
493 //related-to-property
\r
494 String rPropertyStr = jsonUtil.getJsonValue(relation, "related-to-property")
\r
495 utils.log("INFO", "related-to-property: " + rPropertyStr, isDebugEnabled)
\r
496 if (rPropertyStr instanceof JSONArray){
\r
497 List<String> rPropertyList = jsonUtil.StringArrayToList(execution, rPropertyStr)
\r
498 for(String rProperty : rPropertyList){
\r
499 utils.log("INFO", "rProperty: " + rProperty, isDebugEnabled)
\r
500 def eKey = jsonUtil.getJsonValue(rProperty, "property-key")
\r
501 def eValue = jsonUtil.getJsonValue(rProperty, "property-value")
\r
502 if(eKey.equals("configuration.configuration-type")){
\r
503 jObject.put("resourceType", eValue)
\r
508 String rProperty = rPropertyStr
\r
509 utils.log("INFO", "rProperty: " + rProperty, isDebugEnabled)
\r
510 def eKey = jsonUtil.getJsonValue(rProperty, "property-key")
\r
511 def eValue = jsonUtil.getJsonValue(rProperty, "property-value")
\r
512 if(eKey.equals("configuration.configuration-type")){
\r
513 jObject.put("resourceType", eValue)
\r
516 allResources.put(jObject)
\r
517 utils.log("INFO", "allResources: " + allResources, isDebugEnabled)
\r
519 networkResources.put(jObject)
\r
520 utils.log("INFO", "networkResources: " + networkResources, isDebugEnabled)
\r
522 utils.log("INFO", "Get Next releation resource " , isDebugEnabled)
\r
525 utils.log("INFO", "Get releation finished. " , isDebugEnabled)
\r
528 execution.setVariable("serviceRelationShip", allResources.toString())
\r
529 utils.log("INFO", "allResources: " + allResources.toString(), isDebugEnabled)
\r
530 String serviceRelationShip = execution.getVariable("serviceRelationShip")
\r
531 utils.log("INFO", "serviceRelationShip: " + serviceRelationShip, isDebugEnabled)
\r
532 if ((! isBlank(serviceRelationShip)) && (! serviceRelationShip.isEmpty())) {
\r
534 List<String> relationShipList = jsonUtil.StringArrayToList(execution, serviceRelationShip)
\r
535 utils.log("INFO", "relationShipList: " + relationShipList, isDebugEnabled)
\r
536 execution.setVariable(Prefix+"resourceList", relationShipList)
\r
538 int resourceCount = relationShipList.size()
\r
539 utils.log("INFO", "resourceCount: " + resourceCount, isDebugEnabled)
\r
540 execution.setVariable(Prefix+"resourceCount",resourceCount )
\r
542 int resourceNum = 0
\r
543 execution.setVariable(Prefix+"nextResource", resourceNum)
\r
544 utils.log("INFO", "start sort delete resource: ", isDebugEnabled)
\r
545 sortDeleteResource(execution)
\r
548 if (resourceNum < resourceCount) {
\r
549 execution.setVariable(Prefix+"resourceFinish", false)
\r
552 execution.setVariable(Prefix+"resourceFinish", true)
\r
554 utils.log("INFO", "Resource list set end : " + resourceCount, isDebugEnabled)
\r
557 execution.setVariable("serviceResources", serviceResources.toString())
\r
558 utils.log("INFO", "serviceResources: " + serviceResources, isDebugEnabled)
\r
559 String serviceResourcesShip = execution.getVariable("serviceResources")
\r
560 utils.log("INFO", "serviceResourcesShip: " + serviceResourcesShip, isDebugEnabled)
\r
562 if ((! isBlank(serviceResourcesShip)) && (! serviceResourcesShip.isEmpty())) {
\r
563 List<String> serviceResourcesList = jsonUtil.StringArrayToList(execution, serviceResourcesShip)
\r
564 utils.log("INFO", "serviceResourcesList: " + serviceResourcesList, isDebugEnabled)
\r
565 execution.setVariable(Prefix+"serviceResourceList", serviceResourcesList)
\r
566 execution.setVariable(Prefix+"serviceResourceCount", serviceResourcesList.size())
\r
567 execution.setVariable(Prefix+"nextServiceResource", 0)
\r
568 utils.log("INFO", "Service Resource list set end : " + serviceResourcesList.size(), isDebugEnabled)
\r
572 execution.setVariable("allottedResources", allottedResources.toString())
\r
573 utils.log("INFO", "allottedResources: " + allottedResources, isDebugEnabled)
\r
574 String allottedResourcesShip = execution.getVariable("allottedResources")
\r
575 utils.log("INFO", "allottedResourcesShip: " + allottedResourcesShip, isDebugEnabled)
\r
576 if ((! isBlank(allottedResourcesShip)) && (! allottedResourcesShip.isEmpty())) {
\r
577 List<String> allottedResourcesList = jsonUtil.StringArrayToList(execution, allottedResourcesShip)
\r
578 utils.log("INFO", "allottedResourcesList: " + allottedResourcesList, isDebugEnabled)
\r
579 execution.setVariable(Prefix+"allottedResourcesList", allottedResourcesList)
\r
580 execution.setVariable(Prefix+"allottedResourcesListCount", allottedResourcesList.size())
\r
581 execution.setVariable(Prefix+"nextAllottedResourcesList", 0)
\r
582 utils.log("INFO", "Allotted Resource list set end : " + allottedResourcesList.size(), isDebugEnabled)
\r
585 execution.setVariable("networkResources", networkResources.toString())
\r
586 utils.log("INFO", "networkResources: " + networkResources, isDebugEnabled)
\r
587 String networkResourcesShip = execution.getVariable("networkResources")
\r
588 utils.log("INFO", "networkResourcesShip: " + networkResourcesShip, isDebugEnabled)
\r
589 if ((! isBlank(networkResourcesShip)) && (! networkResourcesShip.isEmpty())) {
\r
590 List<String> networkResourcesList = jsonUtil.StringArrayToList(execution, networkResourcesShip)
\r
591 utils.log("INFO", "networkResourcesList: " + networkResourcesList, isDebugEnabled)
\r
592 execution.setVariable(Prefix+"networkResourcesList", networkResourcesList)
\r
593 execution.setVariable(Prefix+"networkResourcesListCount", networkResourcesList.size())
\r
594 execution.setVariable(Prefix+"nextNetworkResourcesList", 0)
\r
595 utils.log("INFO", "Network Resource list set end : " + networkResourcesList.size(), isDebugEnabled)
\r
599 } catch (BpmnError e){
\r
601 } catch (Exception ex) {
\r
602 String exceptionMessage = "Bpmn error encountered in DeleteMobileAPNCustService flow. prepareServiceDeleteResource() - " + ex.getMessage()
\r
603 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
\r
604 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
606 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
609 private String getAaiAr(DelegateExecution execution, String relink) {
\r
610 def method = getClass().getSimpleName() + '.getAaiAr(' +'execution=' + execution.getId() +')'
\r
611 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
612 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
613 AaiUtil aaiUtil = new AaiUtil(this)
\r
614 String aaiEndpoint = execution.getVariable("URN_aai_endpoint") + relink
\r
616 utils.log("DEBUG", "get AR info " + aaiEndpoint, isDebugEnabled)
\r
617 APIResponse response = aaiUtil.executeAAIGetCall(execution, aaiEndpoint)
\r
619 int responseCode = response.getStatusCode()
\r
620 utils.log("DEBUG", "get AR info responseCode:" + responseCode, isDebugEnabled)
\r
622 String aaiResponse = response.getResponseBodyAsString()
\r
623 utils.log("DEBUG", "get AR info " + aaiResponse, isDebugEnabled)
\r
625 if(responseCode < 200 || responseCode >= 300 || isBlank(aaiResponse)) {
\r
629 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
633 * prepare Decompose next resource to create request
\r
635 public void preProcessDecomposeNextResource(DelegateExecution execution){
\r
636 def method = getClass().getSimpleName() + '.getAaiAr(' +'execution=' + execution.getId() +')'
\r
637 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
638 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
639 utils.log("INFO", " ======== STARTED preProcessDecomposeNextResource Process ======== ", isDebugEnabled)
\r
641 int resourceNum = execution.getVariable(Prefix+"nextServiceResource")
\r
642 List<String> serviceResourceList = execution.getVariable(Prefix+"serviceResourceList")
\r
643 utils.log("INFO", "Service Resource List : " + serviceResourceList, isDebugEnabled)
\r
645 String serviceResource = serviceResourceList[resourceNum]
\r
646 execution.setVariable(Prefix+"serviceResource", serviceResource)
\r
647 utils.log("INFO", "Current Service Resource : " + serviceResource, isDebugEnabled)
\r
649 String resourceType = jsonUtil.getJsonValue(serviceResource, "resourceType")
\r
650 execution.setVariable("resourceType", resourceType)
\r
651 utils.log("INFO", "resourceType : " + resourceType, isDebugEnabled)
\r
653 String resourceInstanceId = jsonUtil.getJsonValue(serviceResource, "resourceInstanceId")
\r
654 execution.setVariable("resourceInstanceId", resourceInstanceId)
\r
655 utils.log("INFO", "resourceInstanceId : " + resourceInstanceId, isDebugEnabled)
\r
657 String resourceRole = jsonUtil.getJsonValue(serviceResource, "resourceRole")
\r
658 execution.setVariable("resourceRole", resourceRole)
\r
659 utils.log("INFO", "resourceRole : " + resourceRole, isDebugEnabled)
\r
661 String resourceVersion = jsonUtil.getJsonValue(serviceResource, "resourceVersion")
\r
662 execution.setVariable("resourceVersion", resourceVersion)
\r
663 utils.log("INFO", "resourceVersion : " + resourceVersion, isDebugEnabled)
\r
665 String resourceName = jsonUtil.getJsonValue(serviceResource, "resourceName")
\r
666 if (isBlank(resourceName)){
\r
667 resourceName = resourceInstanceId
\r
669 execution.setVariable(Prefix+"resourceName", resourceName)
\r
670 utils.log("INFO", "resource Name : " + resourceName, isDebugEnabled)
\r
673 execution.setVariable(Prefix+"nextServiceResource", resourceNum + 1)
\r
675 int serviceResourceCount = execution.getVariable(Prefix+"serviceResourceCount")
\r
676 if (serviceResourceCount >0 ){
\r
677 int progress = (resourceNum*100) / serviceResourceCount
\r
678 execution.setVariable("progress", progress.toString() )
\r
680 execution.setVariable("operationStatus", resourceName )
\r
682 }catch(Exception e){
\r
683 // try error in method block
\r
684 String exceptionMessage = "Bpmn error encountered in CreateMobileAPNCustService flow. Unexpected Error from method preProcessDecomposeNextResource() - " + ex.getMessage()
\r
685 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
\r
686 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
688 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
691 * post Decompose next resource to create request
\r
693 public void postProcessDecomposeNextResource(DelegateExecution execution){
\r
694 def method = getClass().getSimpleName() + '.postProcessDecomposeNextResource(' +'execution=' + execution.getId() +')'
\r
695 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
696 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
697 utils.log("INFO", " ======== STARTED postProcessDecomposeNextResource Process ======== ", isDebugEnabled)
\r
699 String resourceName = execution.getVariable(Prefix+"resourceName")
\r
700 int resourceNum = execution.getVariable(Prefix+"nextServiceResource")
\r
701 utils.log("DEBUG", "Current Resource count:"+ execution.getVariable(Prefix+"nextServiceResource"), isDebugEnabled)
\r
703 int resourceCount = execution.getVariable(Prefix+"serviceResourceCount")
\r
704 utils.log("DEBUG", "Total Resource count:"+ execution.getVariable(Prefix+"serviceResourceCount"), isDebugEnabled)
\r
706 if (resourceNum < resourceCount) {
\r
707 execution.setVariable(Prefix+"resourceFinish", false)
\r
710 execution.setVariable(Prefix+"resourceFinish", true)
\r
713 utils.log("DEBUG", "Resource Finished:"+ execution.getVariable(Prefix+"resourceFinish"), isDebugEnabled)
\r
715 if (resourceCount >0 ){
\r
716 int progress = (resourceNum*100) / resourceCount
\r
718 execution.setVariable("progress", progress.toString() )
\r
719 utils.log("DEBUG", "progress :"+ execution.getVariable("progress"), isDebugEnabled)
\r
721 execution.setVariable("operationStatus", resourceName )
\r
724 }catch(Exception e){
\r
725 // try error in method block
\r
726 String exceptionMessage = "Bpmn error encountered in CreateMobileAPNCustService flow. Unexpected Error from method postProcessDecomposeNextResource() - " + ex.getMessage()
\r
727 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
\r
728 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
730 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
733 * prepare post Unkown Resource Type
\r
735 public void postOtherControllerType(DelegateExecution execution){
\r
736 def method = getClass().getSimpleName() + '.postOtherControllerType(' +'execution=' + execution.getId() +')'
\r
737 def isDebugEnabled = execution.getVariable("isDebugEnabled")
\r
738 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
742 String resourceName = execution.getVariable(Prefix+"resourceName")
\r
743 String resourceType = execution.getVariable(Prefix+"resourceType")
\r
744 String controllerType = execution.getVariable("controllerType")
\r
746 String msg = "Resource name: "+ resourceName + " resource Type: " + resourceType+ " controller Type: " + controllerType + " can not be processed n the workflow"
\r
747 utils.log("DEBUG", msg, isDebugEnabled)
\r
749 }catch(Exception e){
\r
750 // try error in method block
\r
751 String exceptionMessage = "Bpmn error encountered in DoCreateMobileAPNServiceInstance flow. Unexpected Error from method postOtherControllerType() - " + ex.getMessage()
\r
752 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
\r
753 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
755 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
759 * prepare delete parameters
\r
761 public void preSDNCResourceDelete(execution, resourceName){
\r
762 // we use resource instance ids for delete flow as resourceTemplateUUIDs
\r
764 def method = getClass().getSimpleName() + '.preSDNCResourceDelete(' +'execution=' + execution.getId() +')'
\r
765 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
766 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
768 utils.log("INFO", " ======== STARTED preSDNCResourceDelete Process ======== ", isDebugEnabled)
\r
769 String networkResources = execution.getVariable("networkResources")
\r
772 execution.setVariable("foundResource", false)
\r
773 if (networkResources != null) {
\r
774 def jsonSlurper = new JsonSlurper()
\r
775 List relationShipList = jsonSlurper.parseText(networkResources)
\r
776 relationShipList.each {
\r
777 if(StringUtils.containsIgnoreCase(it.resourceType, resourceName)) {
\r
778 String resourceInstanceUUID = it.resourceInstanceId
\r
779 String resourceTemplateUUID = it.resourceInstanceId
\r
780 execution.setVariable("resourceTemplateId", resourceTemplateUUID)
\r
781 execution.setVariable("resourceInstanceId", resourceInstanceUUID)
\r
782 execution.setVariable("resourceType", resourceName)
\r
783 execution.setVariable("foundResource", true)
\r
784 utils.log("INFO", "Delete Resource Info resourceTemplate Id :" + resourceTemplateUUID + " resourceInstanceId: " + resourceInstanceUUID + " resourceType: " + resourceName, isDebugEnabled)
\r
788 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
790 public void preProcessSDNCDelete (DelegateExecution execution) {
\r
791 def method = getClass().getSimpleName() + '.preProcessSDNCDelete(' +'execution=' + execution.getId() +')'
\r
792 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
793 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
794 utils.log("INFO"," ***** preProcessSDNCDelete *****", isDebugEnabled)
\r
798 def serviceInstanceId = execution.getVariable("serviceInstanceId")
\r
799 def serviceInstanceName = execution.getVariable("serviceInstanceName")
\r
800 def callbackURL = execution.getVariable("sdncCallbackUrl")
\r
801 def requestId = execution.getVariable("msoRequestId")
\r
802 def serviceId = execution.getVariable("productFamilyId")
\r
803 def subscriptionServiceType = execution.getVariable("subscriptionServiceType")
\r
804 def globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
\r
806 String serviceModelInfo = execution.getVariable("serviceModelInfo")
\r
807 def modelInvariantUuid = ""
\r
808 def modelVersion = ""
\r
811 if (!isBlank(serviceModelInfo))
\r
813 modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid")
\r
814 modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion")
\r
815 modelUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelUuid")
\r
816 modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName")
\r
818 if (modelInvariantUuid == null) {
\r
819 modelInvariantUuid = ""
\r
821 if (modelVersion == null) {
\r
824 if (modelUuid == null) {
\r
827 if (modelName == null) {
\r
831 if (serviceInstanceName == null) {
\r
832 serviceInstanceName = ""
\r
834 if (serviceId == null) {
\r
838 def siParamsXml = execution.getVariable("siParamsXml")
\r
839 def serviceType = execution.getVariable("serviceType")
\r
840 if (serviceType == null)
\r
845 def sdncRequestId = UUID.randomUUID().toString()
\r
847 String sdncDelete =
\r
848 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
\r
849 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
\r
850 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
\r
851 <sdncadapter:RequestHeader>
\r
852 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
\r
853 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
\r
854 <sdncadapter:SvcAction>delete</sdncadapter:SvcAction>
\r
855 <sdncadapter:SvcOperation>service-topology-operation</sdncadapter:SvcOperation>
\r
856 <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
\r
857 <sdncadapter:MsoAction>${serviceType}</sdncadapter:MsoAction>
\r
858 </sdncadapter:RequestHeader>
\r
859 <sdncadapterworkflow:SDNCRequestData>
\r
860 <request-information>
\r
861 <request-id>${requestId}</request-id>
\r
862 <source>MSO</source>
\r
863 <notification-url/>
\r
866 <request-action>DeleteServiceInstance</request-action>
\r
867 </request-information>
\r
868 <service-information>
\r
869 <service-id>${serviceId}</service-id>
\r
870 <subscription-service-type>${subscriptionServiceType}</subscription-service-type>
\r
871 <onap-model-information>
\r
872 <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid>
\r
873 <model-uuid>${modelUuid}</model-uuid>
\r
874 <model-version>${modelVersion}</model-version>
\r
875 <model-name>${modelName}</model-name>
\r
876 </onap-model-information>
\r
877 <service-instance-id>${serviceInstanceId}</service-instance-id>
\r
879 <global-customer-id>${globalSubscriberId}</global-customer-id>
\r
880 </service-information>
\r
881 <service-request-input>
\r
882 <service-instance-name>${serviceInstanceName}</service-instance-name>
\r
884 </service-request-input>
\r
885 </sdncadapterworkflow:SDNCRequestData>
\r
886 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
\r
888 sdncDelete = utils.formatXml(sdncDelete)
\r
889 def sdncRequestId2 = UUID.randomUUID().toString()
\r
890 String sdncDeactivate = sdncDelete.replace(">delete<", ">deactivate<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
\r
891 execution.setVariable("sdncDelete", sdncDelete)
\r
892 execution.setVariable("sdncDeactivate", sdncDeactivate)
\r
893 utils.log("INFO","sdncDeactivate:\n" + sdncDeactivate, isDebugEnabled)
\r
894 utils.log("INFO","sdncDelete:\n" + sdncDelete, isDebugEnabled)
\r
896 } catch (BpmnError e) {
\r
898 } catch(Exception ex) {
\r
899 msg = "Exception in preProcessSDNCDelete. " + ex.getMessage()
\r
900 utils.log("INFO", msg, isDebugEnabled)
\r
901 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception Occured in preProcessSDNCDelete.\n" + ex.getMessage())
\r
903 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
906 public void postProcessSDNCDelete(DelegateExecution execution, String response, String action) {
\r
908 def method = getClass().getSimpleName() + '.postProcessSDNCDelete(' +'execution=' + execution.getId() +')'
\r
909 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
910 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
911 utils.log("INFO"," ***** postProcessSDNC " + action + " *****", isDebugEnabled)
\r
915 WorkflowException workflowException = execution.getVariable("WorkflowException")
\r
916 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
\r
917 utils.log("INFO", "SDNCResponse: " + response, isDebugEnabled)
\r
918 utils.log("INFO", "workflowException: " + workflowException, isDebugEnabled)
\r
920 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
\r
921 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
\r
922 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == "true"){
\r
923 utils.log("INFO","Good response from SDNC Adapter for service-instance " + action + "response:\n" + response, isDebugEnabled)
\r
926 msg = "Bad Response from SDNC Adapter for service-instance " + action
\r
927 utils.log("INFO", msg, isDebugEnabled)
\r
928 exceptionUtil.buildAndThrowWorkflowException(execution, 3500, msg)
\r
930 } catch (BpmnError e) {
\r
932 } catch(Exception ex) {
\r
933 msg = "Exception in postProcessSDNC " + action + " Exception:" + ex.getMessage()
\r
934 utils.log("INFO", msg, isDebugEnabled)
\r
935 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
\r
937 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
940 public void postProcessAAIDEL(DelegateExecution execution) {
\r
941 def method = getClass().getSimpleName() + '.postProcessAAIDEL(' +'execution=' + execution.getId() +')'
\r
942 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
943 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
944 utils.log("INFO"," ***** postProcessAAIDEL ***** ", isDebugEnabled)
\r
947 String serviceInstanceId = execution.getVariable("serviceInstanceId")
\r
948 boolean succInAAI = execution.getVariable("GENDS_SuccessIndicator")
\r
950 msg = "Error deleting Service-instance in AAI" + serviceInstanceId
\r
951 utils.log("INFO", msg, isDebugEnabled)
\r
952 WorkflowException workflowException = execution.getVariable("WorkflowException")
\r
953 utils.logAudit("workflowException: " + workflowException)
\r
954 if(workflowException != null){
\r
955 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
\r
959 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
\r
962 } catch (BpmnError e) {
\r
964 } catch (Exception ex) {
\r
965 msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIDEL. " + ex.getMessage()
\r
966 utils.log("INFO", msg, isDebugEnabled)
\r
967 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
\r
969 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
972 * Init the service Operation Status
\r
974 public void preUpdateServiceOperationStatus(DelegateExecution execution){
\r
975 def method = getClass().getSimpleName() + '.preUpdateServiceOperationStatus(' +'execution=' + execution.getId() +')'
\r
976 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
977 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
980 String serviceId = execution.getVariable("serviceInstanceId")
\r
981 String operationId = execution.getVariable("operationId")
\r
982 String serviceName = execution.getVariable("serviceInstanceName")
\r
983 String operationType = "DELETE"
\r
985 String result = "processing"
\r
986 String progress = execution.getVariable("progress")
\r
987 utils.log("INFO", "progress: " + progress , isDebugEnabled)
\r
988 if ("100".equalsIgnoreCase(progress))
\r
990 result = "finished"
\r
993 String operationContent = "Prepare service delete: " + execution.getVariable("operationStatus")
\r
994 utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId, isDebugEnabled)
\r
995 serviceId = UriUtils.encode(serviceId,"UTF-8")
\r
996 execution.setVariable("serviceInstanceId", serviceId)
\r
997 execution.setVariable("operationId", operationId)
\r
998 execution.setVariable("operationType", operationType)
\r
1000 def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint")
\r
1001 execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
\r
1002 utils.log("INFO", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
\r
1004 execution.setVariable("URN_mso_openecomp_adapters_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter")
\r
1007 """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
\r
1008 xmlns:ns="http://org.openecomp.mso/requestsdb">
\r
1011 <ns:updateServiceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">
\r
1012 <serviceId>${serviceId}</serviceId>
\r
1013 <operationId>${operationId}</operationId>
\r
1014 <serviceName>${serviceName}</serviceName>
\r
1015 <operationType>${operationType}</operationType>
\r
1016 <userId>${userId}</userId>
\r
1017 <result>${result}</result>
\r
1018 <operationContent>${operationContent}</operationContent>
\r
1019 <progress>${progress}</progress>
\r
1020 <reason>${reason}</reason>
\r
1021 </ns:updateServiceOperationStatus>
\r
1023 </soapenv:Envelope>"""
\r
1025 payload = utils.formatXml(payload)
\r
1026 execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload)
\r
1027 utils.log("INFO", "Outgoing preUpdateServiceOperationStatus: \n" + payload, isDebugEnabled)
\r
1030 }catch(Exception e){
\r
1031 utils.log("ERROR", "Exception Occured Processing preUpdateServiceOperationStatus. Exception is:\n" + e, isDebugEnabled)
\r
1032 execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preUpdateServiceOperationStatus Method:\n" + e.getMessage())
\r
1034 utils.log("INFO", "======== COMPLETED preUpdateServiceOperationStatus Process ======== ", isDebugEnabled)
\r
1035 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
1038 public void preInitResourcesOperStatus(DelegateExecution execution){
\r
1039 def method = getClass().getSimpleName() + '.preInitResourcesOperStatus(' +'execution=' + execution.getId() +')'
\r
1040 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
1041 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
1043 utils.log("INFO", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
\r
1046 String serviceId = execution.getVariable("serviceInstanceId")
\r
1047 String operationId = execution.getVariable("operationId")
\r
1048 String operationType = "DELETE"
\r
1049 String resourceTemplateUUIDs = ""
\r
1050 String result = "processing"
\r
1051 String progress = "0"
\r
1052 String reason = ""
\r
1053 String operationContent = "Prepare service delete"
\r
1054 utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType, isDebugEnabled)
\r
1055 serviceId = UriUtils.encode(serviceId,"UTF-8")
\r
1056 execution.setVariable("serviceInstanceId", serviceId)
\r
1057 execution.setVariable("operationId", operationId)
\r
1058 execution.setVariable("operationType", operationType)
\r
1060 String serviceRelationShip = execution.getVariable("serviceRelationShip")
\r
1061 utils.log("INFO", "serviceRelationShip: " + serviceRelationShip, isDebugEnabled)
\r
1062 if (! isBlank(serviceRelationShip)) {
\r
1063 def jsonSlurper = new JsonSlurper()
\r
1064 def jsonOutput = new JsonOutput()
\r
1065 List relationShipList = jsonSlurper.parseText(serviceRelationShip)
\r
1067 if (relationShipList != null) {
\r
1068 relationShipList.each {
\r
1069 resourceTemplateUUIDs = resourceTemplateUUIDs + it.resourceInstanceId + ":"
\r
1073 def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter"
\r
1074 execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
\r
1075 utils.log("INFO", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
\r
1078 """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
\r
1079 xmlns:ns="http://org.openecomp.mso/requestsdb">
\r
1082 <ns:initResourceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">
\r
1083 <serviceId>${serviceId}</serviceId>
\r
1084 <operationId>${operationId}</operationId>
\r
1085 <operationType>${operationType}</operationType>
\r
1086 <resourceTemplateUUIDs>${resourceTemplateUUIDs}</resourceTemplateUUIDs>
\r
1087 </ns:initResourceOperationStatus>
\r
1089 </soapenv:Envelope>"""
\r
1091 payload = utils.formatXml(payload)
\r
1092 execution.setVariable("CVFMI_initResOperStatusRequest", payload)
\r
1093 utils.log("INFO", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled)
\r
1094 utils.logAudit("DoCustomDeleteE2EServiceInstanceV2 Outgoing initResourceOperationStatus Request: " + payload)
\r
1096 }catch (BpmnError e) {
\r
1098 } catch (Exception ex) {
\r
1099 msg = "Exception in DoCustomDeleteE2EServiceInstanceV2.preInitResourcesOperStatus. " + ex.getMessage()
\r
1100 utils.log("INFO", msg, isDebugEnabled)
\r
1101 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
\r
1103 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
1109 * prepare delete parameters
\r
1111 public void preProcessVFCResourceDelete(execution){
\r
1112 // we use resource instance ids for delete flow as resourceTemplateUUIDs
\r
1114 def method = getClass().getSimpleName() + '.preProcessVFCResourceDelete(' +'execution=' + execution.getId() +')'
\r
1115 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
1116 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
1118 utils.log("INFO", " ======== STARTED preProcessVFCResourceDelete Process ======== ", isDebugEnabled)
\r
1120 String serviceResource = execution.getVariable("serviceResource")
\r
1121 utils.log("INFO", "serviceResource : " + serviceResource, isDebugEnabled)
\r
1123 String resourceInstanceId = execution.getVariable("resourceInstanceId")
\r
1124 utils.log("INFO", "resourceInstanceId : " + resourceInstanceId, isDebugEnabled)
\r
1126 execution.setVariable("resourceTemplateId", resourceInstanceId)
\r
1127 utils.log("INFO", "resourceTemplateId : " + resourceInstanceId, isDebugEnabled)
\r
1129 String resourceType = execution.getVariable("resourceType")
\r
1130 utils.log("INFO", "resourceType : " + resourceType, isDebugEnabled)
\r
1133 String resourceName = execution.getVariable(Prefix+"resourceName")
\r
1134 if (isBlank(resourceName)){
\r
1135 resourceName = resourceInstanceId
\r
1137 execution.setVariable("resourceName", resourceName)
\r
1138 utils.log("INFO", "resource Name : " + resourceName, isDebugEnabled)
\r
1140 utils.log("INFO", "Delete Resource Info: resourceInstanceId :" + resourceInstanceId + " resourceTemplateId: " + resourceInstanceId + " resourceType: " + resourceType, isDebugEnabled)
\r
1141 }catch (BpmnError e) {
\r
1143 } catch (Exception ex) {
\r
1144 msg = "Exception in DoDeleteE2EServiceInstance.preProcessVFCResourceDelete. " + ex.getMessage()
\r
1145 utils.log("INFO", msg, isDebugEnabled)
\r
1146 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
\r
1148 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
1151 public void postProcessVFCDelete(DelegateExecution execution, String response, String action) {
\r
1152 def method = getClass().getSimpleName() + '.postProcessVFCDelete(' +'execution=' + execution.getId() +')'
\r
1153 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
1154 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
1156 utils.log("INFO", " ======== STARTED postProcessVFCDelete Process ======== ", isDebugEnabled)
\r
1159 }catch (BpmnError e) {
\r
1161 } catch (Exception ex) {
\r
1162 msg = "Exception in DoDeleteE2EServiceInstance.postProcessVFCDelete. " + ex.getMessage()
\r
1163 utils.log("INFO", msg, isDebugEnabled)
\r
1164 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
\r
1166 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r