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 org.json.JSONArray;
\r
25 import static org.apache.commons.lang3.StringUtils.*;
\r
26 import groovy.xml.XmlUtil
\r
27 import groovy.json.*
\r
29 import org.openecomp.mso.bpmn.core.json.JsonUtils
\r
30 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
\r
31 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
\r
32 import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
\r
33 import org.openecomp.mso.bpmn.core.WorkflowException
\r
34 import org.openecomp.mso.rest.APIResponse;
\r
35 import org.openecomp.mso.rest.RESTClient
\r
36 import org.openecomp.mso.rest.RESTConfig
\r
38 import org.openecomp.mso.bpmn.common.scripts.AaiUtil
\r
40 import java.util.UUID;
\r
41 import javax.xml.parsers.DocumentBuilder
\r
42 import javax.xml.parsers.DocumentBuilderFactory
\r
44 import org.camunda.bpm.engine.delegate.BpmnError
\r
45 import org.camunda.bpm.engine.runtime.Execution
\r
46 import org.json.JSONObject;
\r
47 import org.apache.commons.lang3.*
\r
48 import org.apache.commons.codec.binary.Base64;
\r
49 import org.springframework.web.util.UriUtils;
\r
50 import org.w3c.dom.Document
\r
51 import org.w3c.dom.Element
\r
52 import org.w3c.dom.Node
\r
53 import org.w3c.dom.NodeList
\r
54 import org.xml.sax.InputSource
\r
56 import com.fasterxml.jackson.jaxrs.json.annotation.JSONP.Def;
\r
59 * This groovy class supports the <class>DoDeleteE2EServiceInstance.bpmn</class> process.
\r
62 * @param - msoRequestId
\r
63 * @param - globalSubscriberId - O
\r
64 * @param - subscriptionServiceType - O
\r
65 * @param - serviceInstanceId
\r
66 * @param - serviceInstanceName - O
\r
67 * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM)
\r
68 * @param - sdncVersion
\r
69 * @param - failNotFound - TODO
\r
70 * @param - serviceInputParams - TODO
\r
73 * @param - WorkflowException
\r
75 * Rollback - Deferred
\r
77 public class DoCustomDeleteE2EServiceInstanceV2 extends AbstractServiceTaskProcessor {
\r
79 String Prefix="DDELSI_"
\r
80 private static final String DebugFlag = "isDebugEnabled"
\r
81 ExceptionUtil exceptionUtil = new ExceptionUtil()
\r
82 JsonUtils jsonUtil = new JsonUtils()
\r
84 public void preProcessRequest (Execution execution) {
\r
86 def method = getClass().getSimpleName() + '.buildAPPCRequest(' +'execution=' + execution.getId() +')'
\r
87 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
88 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
89 utils.log("INFO"," ***** preProcessRequest *****", isDebugEnabled)
\r
93 String requestId = execution.getVariable("msoRequestId")
\r
94 execution.setVariable("prefix",Prefix)
\r
97 //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology
\r
98 String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
\r
99 if (globalSubscriberId == null)
\r
101 execution.setVariable("globalSubscriberId", "")
\r
104 //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology
\r
105 String serviceType = execution.getVariable("serviceType")
\r
106 if (serviceType == null)
\r
108 execution.setVariable("serviceType", "")
\r
111 //Generated in parent for AAI PUT
\r
112 String serviceInstanceId = execution.getVariable("serviceInstanceId")
\r
113 if (isBlank(serviceInstanceId)){
\r
114 msg = "Input serviceInstanceId is null"
\r
115 utils.log("INFO", msg, isDebugEnabled)
\r
116 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
\r
119 String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback')
\r
120 if (isBlank(sdncCallbackUrl)) {
\r
121 msg = "URN_mso_workflow_sdncadapter_callback is null"
\r
122 utils.log("INFO", msg, isDebugEnabled)
\r
123 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
\r
125 execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
\r
126 utils.log("INFO","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled)
\r
128 StringBuilder sbParams = new StringBuilder()
\r
129 Map<String, String> paramsMap = execution.getVariable("serviceInputParams")
\r
130 if (paramsMap != null)
\r
132 sbParams.append("<service-input-parameters>")
\r
133 for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
\r
135 String paramName = entry.getKey()
\r
136 String paramValue = entry.getValue()
\r
139 <name>${paramName}</name>
\r
140 <value>${paramValue}</value>
\r
143 sbParams.append(paramsXml)
\r
145 sbParams.append("</service-input-parameters>")
\r
147 String siParamsXml = sbParams.toString()
\r
148 if (siParamsXml == null)
\r
150 execution.setVariable("siParamsXml", siParamsXml)
\r
151 execution.setVariable("operationStatus", "Waiting delete resource...")
\r
152 execution.setVariable("progress", "0")
\r
154 } catch (BpmnError e) {
\r
156 } catch (Exception ex){
\r
157 msg = "Exception in preProcessRequest " + ex.getMessage()
\r
158 utils.log("INFO", msg, isDebugEnabled)
\r
159 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
\r
161 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
166 public void postProcessAAIGET(Execution execution) {
\r
167 def method = getClass().getSimpleName() + '.postProcessAAIGET(' +'execution=' + execution.getId() +')'
\r
168 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
169 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
174 String serviceInstanceId = execution.getVariable("serviceInstanceId")
\r
175 utils.log("INFO","serviceInstanceId: "+serviceInstanceId, isDebugEnabled)
\r
177 boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
\r
178 utils.log("INFO","foundInAAI: "+foundInAAI, isDebugEnabled)
\r
180 String serviceType = ""
\r
184 utils.log("INFO","Found Service-instance in AAI", isDebugEnabled)
\r
186 String siData = execution.getVariable("GENGS_service")
\r
187 utils.log("INFO", "SI Data", isDebugEnabled)
\r
188 if (isBlank(siData))
\r
190 msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId
\r
191 utils.log("INFO", msg, isDebugEnabled)
\r
192 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
\r
196 boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
\r
198 utils.log("INFO","Error getting Service-instance from AAI", + serviceInstanceId, isDebugEnabled)
\r
199 WorkflowException workflowException = execution.getVariable("WorkflowException")
\r
200 utils.logAudit("workflowException: " + workflowException)
\r
201 if(workflowException != null){
\r
202 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
\r
206 msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI
\r
207 utils.log("INFO", msg, isDebugEnabled)
\r
208 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
\r
212 utils.log("INFO","Service-instance NOT found in AAI. Silent Success", isDebugEnabled)
\r
214 }catch (BpmnError e) {
\r
216 } catch (Exception ex) {
\r
217 msg = "Bpmn error encountered in " + method + "--" + ex.getMessage()
\r
218 utils.log("INFO", msg, isDebugEnabled)
\r
219 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
\r
221 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
224 private void loadResourcesProperties(Execution execution) {
\r
225 def method = getClass().getSimpleName() + '.loadResourcesProperties(' +'execution=' + execution.getId() +')'
\r
226 def isDebugEnabled = execution.getVariable("isDebugEnabled")
\r
227 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
228 String loadFilePath = "/etc/mso/config.d/reources.json"
\r
230 def jsonPayload = new File(loadFilePath).text
\r
231 utils.log("INFO","jsonPayload: " + jsonPayload, isDebugEnabled)
\r
233 String resourcesProperties = jsonUtil.prettyJson(jsonPayload.toString())
\r
234 utils.log("INFO","resourcesProperties: " + resourcesProperties, isDebugEnabled)
\r
236 String createResourceSort = jsonUtil.getJsonValue(resourcesProperties, "CreateResourceSort")
\r
237 //utils.log("INFO","createResourceSort: " + createResourceSort, isDebugEnabled)
\r
238 execution.setVariable("createResourceSort", createResourceSort)
\r
240 String deleteResourceSort = jsonUtil.getJsonValue(resourcesProperties, "DeleteResourceSort")
\r
241 //utils.log("INFO","deleteResourceSort: " + deleteResourceSort, isDebugEnabled)
\r
242 execution.setVariable("deleteResourceSort", deleteResourceSort)
\r
245 String resourceControllerType = jsonUtil.getJsonValue(resourcesProperties, "ResourceControllerType")
\r
246 //utils.log("INFO","resourceControllerType: " + resourceControllerType, isDebugEnabled)
\r
247 execution.setVariable("resourceControllerType", resourceControllerType)
\r
250 }catch(Exception ex){
\r
251 // try error in method block
\r
252 String exceptionMessage = "Bpmn error encountered in " + method + " - " + ex.getMessage()
\r
253 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
\r
254 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
256 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
258 private void sortDeleteResource(Execution execution) {
\r
259 def method = getClass().getSimpleName() + '.sortDeleteResource(' +'execution=' + execution.getId() +')'
\r
260 def isDebugEnabled = execution.getVariable("isDebugEnabled")
\r
261 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
262 String deleteResourceSortDef = """[
\r
264 "resourceType":"GRE_SAR"
\r
267 "resourceType":"VPN_SAR"
\r
270 "resourceType":"APN_AAR"
\r
273 "resourceType":"GRE_AAR"
\r
276 "resourceType":"Overlay"
\r
279 "resourceType":"Underlay"
\r
282 "resourceType":"vIMS"
\r
285 "resourceType":"vCPE"
\r
288 "resourceType":"vFW"
\r
291 "resourceType":"vEPC"
\r
298 loadResourcesProperties(execution)
\r
299 String deleteResourceSort = execution.getVariable("deleteResourceSort")
\r
300 if (isBlank(deleteResourceSort)) {
\r
301 deleteResourceSort = deleteResourceSortDef;
\r
304 List<String> sortResourceList = jsonUtil.StringArrayToList(execution, deleteResourceSort)
\r
305 utils.log("INFO", "sortResourceList : " + sortResourceList, isDebugEnabled)
\r
307 JSONArray newResourceList = new JSONArray()
\r
308 int resSortCount = sortResourceList.size()
\r
310 for ( int currentResource = 0 ; currentResource < resSortCount ; currentResource++ ) {
\r
311 String currentSortResource = sortResourceList[currentResource]
\r
312 String sortResourceType = jsonUtil.getJsonValue(currentSortResource, "resourceType")
\r
313 List<String> resourceList = execution.getVariable(Prefix+"resourceList")
\r
315 for (String resource : resourceList) {
\r
316 //utils.log("INFO", "resource : " + resource, isDebugEnabled)
\r
317 String resourceType = jsonUtil.getJsonValue(resource, "resourceType")
\r
319 if (StringUtils.containsIgnoreCase(resourceType, sortResourceType)) {
\r
320 JSONObject jsonObj = new JSONObject(resource)
\r
321 newResourceList.put(jsonObj)
\r
323 utils.log("INFO", "Get next sort type " , isDebugEnabled)
\r
327 String newResourceStr = newResourceList.toString()
\r
328 List<String> newResourceListStr = jsonUtil.StringArrayToList(execution, newResourceStr)
\r
330 execution.setVariable(Prefix+"resourceList", newResourceListStr)
\r
331 utils.log("INFO", "newResourceList : " + newResourceListStr, isDebugEnabled)
\r
333 }catch(Exception ex){
\r
334 // try error in method block
\r
335 String exceptionMessage = "Bpmn error encountered in " + method + " - " + ex.getMessage()
\r
336 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
\r
337 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
339 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
342 public void prepareServiceDeleteResource(Execution execution) {
\r
343 def method = getClass().getSimpleName() + '.prepareServiceDeleteResource(' +'execution=' + execution.getId() +')'
\r
344 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
345 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
349 String serviceInstanceId = execution.getVariable("serviceInstanceId")
\r
351 // confirm if ServiceInstance was found
\r
352 if ( !execution.getVariable("GENGS_FoundIndicator") )
\r
354 String exceptionMessage = "Bpmn error encountered in DeleteMobileAPNCustService flow. Service Instance was not found in AAI by id: " + serviceInstanceId
\r
355 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
358 execution.setVariable(Prefix+"resourceList", "")
\r
359 execution.setVariable(Prefix+"resourceCount", 0)
\r
360 execution.setVariable(Prefix+"nextResource", 0)
\r
361 execution.setVariable(Prefix+"resourceFinish", true)
\r
363 // get SI extracted by GenericGetService
\r
364 String serviceInstanceAaiRecord = execution.getVariable("GENGS_service");
\r
365 utils.log("INFO", "serviceInstanceAaiRecord: " +serviceInstanceAaiRecord, isDebugEnabled)
\r
367 String aaiJsonRecord = jsonUtil.xml2json(serviceInstanceAaiRecord)
\r
369 //utils.log("INFO", "aaiJsonRecord: " +aaiJsonRecord, isDebugEnabled)
\r
370 def serviceInstanceName = jsonUtil.getJsonValue(aaiJsonRecord, "service-instance.service-instance-name")
\r
371 execution.setVariable("serviceInstanceName",serviceInstanceName)
\r
373 def serviceType = jsonUtil.getJsonValue(aaiJsonRecord, "service-instance.service-type")
\r
374 execution.setVariable("serviceType",serviceType)
\r
377 String relationshipList = jsonUtil.getJsonValue(aaiJsonRecord, "service-instance.relationship-list")
\r
378 //utils.log("INFO", "relationship-list:" + relationshipList, isDebugEnabled)
\r
379 if (! isBlank(relationshipList)){
\r
380 utils.log("INFO", "relationship-list exists" , isDebugEnabled)
\r
381 String relationShip = jsonUtil.getJsonValue(relationshipList, "relationship")
\r
382 utils.log("INFO", "relationship: " + relationShip, isDebugEnabled)
\r
383 JSONArray allResources = new JSONArray()
\r
384 JSONArray serviceResources = new JSONArray()
\r
385 JSONArray networkResources = new JSONArray()
\r
386 JSONArray allottedResources = new JSONArray()
\r
389 if (! isBlank(relationShip)){
\r
390 JSONArray jsonArray = new JSONArray();
\r
391 if (relationShip.startsWith("{") && relationShip.endsWith("}")) {
\r
392 JSONObject jsonObject = new JSONObject(relationShip);
\r
393 jsonArray.put(jsonObject);
\r
394 } else if (relationShip.startsWith("[") && relationShip.endsWith("]")) {
\r
395 jsonArray = new JSONArray(relationShip);
\r
397 utils.log("INFO", "The relationShip fomart is error" , isDebugEnabled)
\r
400 List<String> relationList = jsonUtil.StringArrayToList(execution, jsonArray.toString())
\r
402 utils.log("INFO", "relationList: " + relationList, isDebugEnabled)
\r
404 int relationNum =relationList.size()
\r
405 utils.log("INFO", "**************relationList size: " + relationNum, isDebugEnabled)
\r
407 for ( int currentRelation = 0 ; currentRelation < relationNum ; currentRelation++ ) {
\r
408 utils.log("INFO", "current Relation num: " + currentRelation, isDebugEnabled)
\r
409 String relation = relationList[currentRelation]
\r
410 utils.log("INFO", "relation: " + relation, isDebugEnabled)
\r
412 String relatedTo = jsonUtil.getJsonValue(relation, "related-to")
\r
413 utils.log("INFO", "relatedTo: " + relatedTo, isDebugEnabled)
\r
415 String relatedLink = jsonUtil.getJsonValue(relation, "related-link")
\r
416 utils.log("INFO", "relatedLink: " + relatedLink, isDebugEnabled)
\r
418 if (StringUtils.equalsIgnoreCase(relatedTo, "allotted-resource")) {
\r
419 utils.log("INFO", "allotted-resource exists ", isDebugEnabled)
\r
421 String aaiArRsp = getAaiAr(execution, relatedLink)
\r
422 utils.log("INFO", "aaiArRsp: " + aaiArRsp, isDebugEnabled)
\r
423 if (! isBlank(aaiArRsp)) {
\r
424 def type = utils.getNodeText1(aaiArRsp, "type")
\r
425 def id = utils.getNodeText1(aaiArRsp, "id")
\r
426 def role = utils.getNodeText1(aaiArRsp, "role")
\r
427 def resourceVersion = utils.getNodeText1(aaiArRsp, "resource-version")
\r
429 JSONObject jObject = new JSONObject()
\r
430 jObject.put("resourceType", type)
\r
431 jObject.put("resourceInstanceId", id)
\r
432 jObject.put("resourceRole", role)
\r
433 jObject.put("resourceVersion", resourceVersion)
\r
435 allResources.put(jObject)
\r
436 utils.log("INFO", "allResources: " + allResources, isDebugEnabled)
\r
437 allottedResources.put(jObject)
\r
438 utils.log("INFO", "allottedResources: " + allottedResources, isDebugEnabled)
\r
441 else if (StringUtils.equalsIgnoreCase(relatedTo, "service-instance")){
\r
442 utils.log("INFO", "service-instance exists ", isDebugEnabled)
\r
443 JSONObject jObject = new JSONObject()
\r
445 //relationship-data
\r
446 String rsDataStr = jsonUtil.getJsonValue(relation, "relationship-data")
\r
447 utils.log("INFO", "rsDataStr: " + rsDataStr, isDebugEnabled)
\r
448 List<String> rsDataList = jsonUtil.StringArrayToList(execution, rsDataStr)
\r
449 utils.log("INFO", "rsDataList: " + rsDataList, isDebugEnabled)
\r
450 for(String rsData : rsDataList){
\r
451 utils.log("INFO", "rsData: " + rsData, isDebugEnabled)
\r
452 def eKey = jsonUtil.getJsonValue(rsData, "relationship-key")
\r
453 def eValue = jsonUtil.getJsonValue(rsData, "relationship-value")
\r
454 if(eKey.equals("service-instance.service-instance-id")){
\r
455 jObject.put("resourceInstanceId", eValue)
\r
457 if(eKey.equals("service-subscription.service-type")){
\r
458 jObject.put("resourceType", eValue)
\r
462 //related-to-property
\r
463 String rPropertyStr = jsonUtil.getJsonValue(relation, "related-to-property")
\r
464 utils.log("INFO", "related-to-property: " + rPropertyStr, isDebugEnabled)
\r
465 if (rPropertyStr instanceof JSONArray){
\r
466 List<String> rPropertyList = jsonUtil.StringArrayToList(execution, rPropertyStr)
\r
467 for (String rProperty : rPropertyList) {
\r
468 utils.log("INFO", "rProperty: " + rProperty, isDebugEnabled)
\r
469 def eKey = jsonUtil.getJsonValue(rProperty, "property-key")
\r
470 def eValue = jsonUtil.getJsonValue(rProperty, "property-value")
\r
471 if(eKey.equals("service-instance.service-instance-name")){
\r
472 jObject.put("resourceName", eValue)
\r
477 String rProperty = rPropertyStr
\r
478 utils.log("INFO", "rProperty: " + rProperty, isDebugEnabled)
\r
479 def eKey = jsonUtil.getJsonValue(rProperty, "property-key")
\r
480 def eValue = jsonUtil.getJsonValue(rProperty, "property-value")
\r
481 if (eKey.equals("service-instance.service-instance-name")) {
\r
482 jObject.put("resourceName", eValue)
\r
486 allResources.put(jObject)
\r
487 utils.log("INFO", "allResources: " + allResources, isDebugEnabled)
\r
489 serviceResources.put(jObject)
\r
490 utils.log("INFO", "serviceResources: " + serviceResources, isDebugEnabled)
\r
492 else if (StringUtils.equalsIgnoreCase(relatedTo, "configuration")) {
\r
493 utils.log("INFO", "configuration ", isDebugEnabled)
\r
494 JSONObject jObject = new JSONObject()
\r
496 //relationship-data
\r
497 String rsDataStr = jsonUtil.getJsonValue(relation, "relationship-data")
\r
498 utils.log("INFO", "rsDataStr: " + rsDataStr, isDebugEnabled)
\r
499 List<String> rsDataList = jsonUtil.StringArrayToList(execution, rsDataStr)
\r
500 utils.log("INFO", "rsDataList: " + rsDataList, isDebugEnabled)
\r
501 for (String rsData : rsDataList) {
\r
502 utils.log("INFO", "rsData: " + rsData, isDebugEnabled)
\r
503 def eKey = jsonUtil.getJsonValue(rsData, "relationship-key")
\r
504 def eValue = jsonUtil.getJsonValue(rsData, "relationship-value")
\r
505 if(eKey.equals("configuration.configuration-id")){
\r
506 jObject.put("resourceInstanceId", eValue)
\r
511 //related-to-property
\r
512 String rPropertyStr = jsonUtil.getJsonValue(relation, "related-to-property")
\r
513 utils.log("INFO", "related-to-property: " + rPropertyStr, isDebugEnabled)
\r
514 if (rPropertyStr instanceof JSONArray){
\r
515 List<String> rPropertyList = jsonUtil.StringArrayToList(execution, rPropertyStr)
\r
516 for(String rProperty : rPropertyList){
\r
517 utils.log("INFO", "rProperty: " + rProperty, isDebugEnabled)
\r
518 def eKey = jsonUtil.getJsonValue(rProperty, "property-key")
\r
519 def eValue = jsonUtil.getJsonValue(rProperty, "property-value")
\r
520 if(eKey.equals("configuration.configuration-type")){
\r
521 jObject.put("resourceType", eValue)
\r
526 String rProperty = rPropertyStr
\r
527 utils.log("INFO", "rProperty: " + rProperty, isDebugEnabled)
\r
528 def eKey = jsonUtil.getJsonValue(rProperty, "property-key")
\r
529 def eValue = jsonUtil.getJsonValue(rProperty, "property-value")
\r
530 if(eKey.equals("configuration.configuration-type")){
\r
531 jObject.put("resourceType", eValue)
\r
534 allResources.put(jObject)
\r
535 utils.log("INFO", "allResources: " + allResources, isDebugEnabled)
\r
537 networkResources.put(jObject)
\r
538 utils.log("INFO", "networkResources: " + networkResources, isDebugEnabled)
\r
540 utils.log("INFO", "Get Next releation resource " , isDebugEnabled)
\r
543 utils.log("INFO", "Get releation finished. " , isDebugEnabled)
\r
546 execution.setVariable("serviceRelationShip", allResources.toString())
\r
547 utils.log("INFO", "allResources: " + allResources.toString(), isDebugEnabled)
\r
548 String serviceRelationShip = execution.getVariable("serviceRelationShip")
\r
549 utils.log("INFO", "serviceRelationShip: " + serviceRelationShip, isDebugEnabled)
\r
550 if ((! isBlank(serviceRelationShip)) && (! serviceRelationShip.isEmpty())) {
\r
552 List<String> relationShipList = jsonUtil.StringArrayToList(execution, serviceRelationShip)
\r
553 utils.log("INFO", "relationShipList: " + relationShipList, isDebugEnabled)
\r
554 execution.setVariable(Prefix+"resourceList", relationShipList)
\r
556 int resourceCount = relationShipList.size()
\r
557 utils.log("INFO", "resourceCount: " + resourceCount, isDebugEnabled)
\r
558 execution.setVariable(Prefix+"resourceCount",resourceCount )
\r
560 int resourceNum = 0
\r
561 execution.setVariable(Prefix+"nextResource", resourceNum)
\r
562 utils.log("INFO", "start sort delete resource: ", isDebugEnabled)
\r
563 sortDeleteResource(execution)
\r
566 if (resourceNum < resourceCount) {
\r
567 execution.setVariable(Prefix+"resourceFinish", false)
\r
570 execution.setVariable(Prefix+"resourceFinish", true)
\r
572 utils.log("INFO", "Resource list set end : " + resourceCount, isDebugEnabled)
\r
575 execution.setVariable("serviceResources", serviceResources.toString())
\r
576 utils.log("INFO", "serviceResources: " + serviceResources, isDebugEnabled)
\r
577 String serviceResourcesShip = execution.getVariable("serviceResources")
\r
578 utils.log("INFO", "serviceResourcesShip: " + serviceResourcesShip, isDebugEnabled)
\r
580 if ((! isBlank(serviceResourcesShip)) && (! serviceResourcesShip.isEmpty())) {
\r
581 List<String> serviceResourcesList = jsonUtil.StringArrayToList(execution, serviceResourcesShip)
\r
582 utils.log("INFO", "serviceResourcesList: " + serviceResourcesList, isDebugEnabled)
\r
583 execution.setVariable(Prefix+"serviceResourceList", serviceResourcesList)
\r
584 execution.setVariable(Prefix+"serviceResourceCount", serviceResourcesList.size())
\r
585 execution.setVariable(Prefix+"nextServiceResource", 0)
\r
586 utils.log("INFO", "Service Resource list set end : " + serviceResourcesList.size(), isDebugEnabled)
\r
590 execution.setVariable("allottedResources", allottedResources.toString())
\r
591 utils.log("INFO", "allottedResources: " + allottedResources, isDebugEnabled)
\r
592 String allottedResourcesShip = execution.getVariable("allottedResources")
\r
593 utils.log("INFO", "allottedResourcesShip: " + allottedResourcesShip, isDebugEnabled)
\r
594 if ((! isBlank(allottedResourcesShip)) && (! allottedResourcesShip.isEmpty())) {
\r
595 List<String> allottedResourcesList = jsonUtil.StringArrayToList(execution, allottedResourcesShip)
\r
596 utils.log("INFO", "allottedResourcesList: " + allottedResourcesList, isDebugEnabled)
\r
597 execution.setVariable(Prefix+"allottedResourcesList", allottedResourcesList)
\r
598 execution.setVariable(Prefix+"allottedResourcesListCount", allottedResourcesList.size())
\r
599 execution.setVariable(Prefix+"nextAllottedResourcesList", 0)
\r
600 utils.log("INFO", "Allotted Resource list set end : " + allottedResourcesList.size(), isDebugEnabled)
\r
603 execution.setVariable("networkResources", networkResources.toString())
\r
604 utils.log("INFO", "networkResources: " + networkResources, isDebugEnabled)
\r
605 String networkResourcesShip = execution.getVariable("networkResources")
\r
606 utils.log("INFO", "networkResourcesShip: " + networkResourcesShip, isDebugEnabled)
\r
607 if ((! isBlank(networkResourcesShip)) && (! networkResourcesShip.isEmpty())) {
\r
608 List<String> networkResourcesList = jsonUtil.StringArrayToList(execution, networkResourcesShip)
\r
609 utils.log("INFO", "networkResourcesList: " + networkResourcesList, isDebugEnabled)
\r
610 execution.setVariable(Prefix+"networkResourcesList", networkResourcesList)
\r
611 execution.setVariable(Prefix+"networkResourcesListCount", networkResourcesList.size())
\r
612 execution.setVariable(Prefix+"nextNetworkResourcesList", 0)
\r
613 utils.log("INFO", "Network Resource list set end : " + networkResourcesList.size(), isDebugEnabled)
\r
617 } catch (BpmnError e){
\r
619 } catch (Exception ex) {
\r
620 String exceptionMessage = "Bpmn error encountered in DeleteMobileAPNCustService flow. prepareServiceDeleteResource() - " + ex.getMessage()
\r
621 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
\r
622 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
624 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
627 private String getAaiAr(Execution execution, String relink) {
\r
628 def method = getClass().getSimpleName() + '.getAaiAr(' +'execution=' + execution.getId() +')'
\r
629 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
630 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
631 AaiUtil aaiUtil = new AaiUtil(this)
\r
632 String aaiEndpoint = execution.getVariable("URN_aai_endpoint") + relink
\r
634 utils.log("DEBUG", "get AR info " + aaiEndpoint, isDebugEnabled)
\r
635 APIResponse response = aaiUtil.executeAAIGetCall(execution, aaiEndpoint)
\r
637 int responseCode = response.getStatusCode()
\r
638 utils.log("DEBUG", "get AR info responseCode:" + responseCode, isDebugEnabled)
\r
640 String aaiResponse = response.getResponseBodyAsString()
\r
641 utils.log("DEBUG", "get AR info " + aaiResponse, isDebugEnabled)
\r
643 if(responseCode < 200 || responseCode >= 300 || isBlank(aaiResponse)) {
\r
647 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
651 * prepare Decompose next resource to create request
\r
653 public void preProcessDecomposeNextResource(Execution execution){
\r
654 def method = getClass().getSimpleName() + '.getAaiAr(' +'execution=' + execution.getId() +')'
\r
655 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
656 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
657 utils.log("INFO", " ======== STARTED preProcessDecomposeNextResource Process ======== ", isDebugEnabled)
\r
659 int resourceNum = execution.getVariable(Prefix+"nextServiceResource")
\r
660 List<String> serviceResourceList = execution.getVariable(Prefix+"serviceResourceList")
\r
661 utils.log("INFO", "Service Resource List : " + serviceResourceList, isDebugEnabled)
\r
663 String serviceResource = serviceResourceList[resourceNum]
\r
664 execution.setVariable(Prefix+"serviceResource", serviceResource)
\r
665 utils.log("INFO", "Current Service Resource : " + serviceResource, isDebugEnabled)
\r
667 String resourceType = jsonUtil.getJsonValue(serviceResource, "resourceType")
\r
668 execution.setVariable("resourceType", resourceType)
\r
669 utils.log("INFO", "resourceType : " + resourceType, isDebugEnabled)
\r
671 String resourceInstanceId = jsonUtil.getJsonValue(serviceResource, "resourceInstanceId")
\r
672 execution.setVariable("resourceInstanceId", resourceInstanceId)
\r
673 utils.log("INFO", "resourceInstanceId : " + resourceInstanceId, isDebugEnabled)
\r
675 String resourceRole = jsonUtil.getJsonValue(serviceResource, "resourceRole")
\r
676 execution.setVariable("resourceRole", resourceRole)
\r
677 utils.log("INFO", "resourceRole : " + resourceRole, isDebugEnabled)
\r
679 String resourceVersion = jsonUtil.getJsonValue(serviceResource, "resourceVersion")
\r
680 execution.setVariable("resourceVersion", resourceVersion)
\r
681 utils.log("INFO", "resourceVersion : " + resourceVersion, isDebugEnabled)
\r
683 String resourceName = jsonUtil.getJsonValue(serviceResource, "resourceName")
\r
684 if (isBlank(resourceName)){
\r
685 resourceName = resourceInstanceId
\r
687 execution.setVariable(Prefix+"resourceName", resourceName)
\r
688 utils.log("INFO", "resource Name : " + resourceName, isDebugEnabled)
\r
691 execution.setVariable(Prefix+"nextServiceResource", resourceNum + 1)
\r
693 int serviceResourceCount = execution.getVariable(Prefix+"serviceResourceCount")
\r
694 if (serviceResourceCount >0 ){
\r
695 int progress = (resourceNum*100) / serviceResourceCount
\r
696 execution.setVariable("progress", progress.toString() )
\r
698 execution.setVariable("operationStatus", resourceName )
\r
700 }catch(Exception e){
\r
701 // try error in method block
\r
702 String exceptionMessage = "Bpmn error encountered in CreateMobileAPNCustService flow. Unexpected Error from method preProcessDecomposeNextResource() - " + ex.getMessage()
\r
703 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
\r
704 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
706 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
709 * post Decompose next resource to create request
\r
711 public void postProcessDecomposeNextResource(Execution execution){
\r
712 def method = getClass().getSimpleName() + '.postProcessDecomposeNextResource(' +'execution=' + execution.getId() +')'
\r
713 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
714 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
715 utils.log("INFO", " ======== STARTED postProcessDecomposeNextResource Process ======== ", isDebugEnabled)
\r
717 String resourceName = execution.getVariable(Prefix+"resourceName")
\r
718 int resourceNum = execution.getVariable(Prefix+"nextServiceResource")
\r
719 utils.log("DEBUG", "Current Resource count:"+ execution.getVariable(Prefix+"nextServiceResource"), isDebugEnabled)
\r
721 int resourceCount = execution.getVariable(Prefix+"serviceResourceCount")
\r
722 utils.log("DEBUG", "Total Resource count:"+ execution.getVariable(Prefix+"serviceResourceCount"), isDebugEnabled)
\r
724 if (resourceNum < resourceCount) {
\r
725 execution.setVariable(Prefix+"resourceFinish", false)
\r
728 execution.setVariable(Prefix+"resourceFinish", true)
\r
731 utils.log("DEBUG", "Resource Finished:"+ execution.getVariable(Prefix+"resourceFinish"), isDebugEnabled)
\r
733 if (resourceCount >0 ){
\r
734 int progress = (resourceNum*100) / resourceCount
\r
736 execution.setVariable("progress", progress.toString() )
\r
737 utils.log("DEBUG", "progress :"+ execution.getVariable("progress"), isDebugEnabled)
\r
739 execution.setVariable("operationStatus", resourceName )
\r
742 }catch(Exception e){
\r
743 // try error in method block
\r
744 String exceptionMessage = "Bpmn error encountered in CreateMobileAPNCustService flow. Unexpected Error from method postProcessDecomposeNextResource() - " + ex.getMessage()
\r
745 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
\r
746 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
748 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
751 * prepare post Unkown Resource Type
\r
753 public void postOtherControllerType(Execution execution){
\r
754 def method = getClass().getSimpleName() + '.postOtherControllerType(' +'execution=' + execution.getId() +')'
\r
755 def isDebugEnabled = execution.getVariable("isDebugEnabled")
\r
756 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
760 String resourceName = execution.getVariable(Prefix+"resourceName")
\r
761 String resourceType = execution.getVariable(Prefix+"resourceType")
\r
762 String controllerType = execution.getVariable("controllerType")
\r
764 String msg = "Resource name: "+ resourceName + " resource Type: " + resourceType+ " controller Type: " + controllerType + " can not be processed n the workflow"
\r
765 utils.log("DEBUG", msg, isDebugEnabled)
\r
767 }catch(Exception e){
\r
768 // try error in method block
\r
769 String exceptionMessage = "Bpmn error encountered in DoCreateMobileAPNServiceInstance flow. Unexpected Error from method postOtherControllerType() - " + ex.getMessage()
\r
770 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
\r
771 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
\r
773 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
777 * prepare delete parameters
\r
779 public void preSDNCResourceDelete(execution, resourceName){
\r
780 // we use resource instance ids for delete flow as resourceTemplateUUIDs
\r
782 def method = getClass().getSimpleName() + '.preSDNCResourceDelete(' +'execution=' + execution.getId() +')'
\r
783 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
784 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
786 utils.log("INFO", " ======== STARTED preSDNCResourceDelete Process ======== ", isDebugEnabled)
\r
787 String networkResources = execution.getVariable("networkResources")
\r
790 execution.setVariable("foundResource", false)
\r
791 if (networkResources != null) {
\r
792 def jsonSlurper = new JsonSlurper()
\r
793 List relationShipList = jsonSlurper.parseText(networkResources)
\r
794 relationShipList.each {
\r
795 if(StringUtils.containsIgnoreCase(it.resourceType, resourceName)) {
\r
796 String resourceInstanceUUID = it.resourceInstanceId
\r
797 String resourceTemplateUUID = it.resourceInstanceId
\r
798 execution.setVariable("resourceTemplateId", resourceTemplateUUID)
\r
799 execution.setVariable("resourceInstanceId", resourceInstanceUUID)
\r
800 execution.setVariable("resourceType", resourceName)
\r
801 execution.setVariable("foundResource", true)
\r
802 utils.log("INFO", "Delete Resource Info resourceTemplate Id :" + resourceTemplateUUID + " resourceInstanceId: " + resourceInstanceUUID + " resourceType: " + resourceName, isDebugEnabled)
\r
806 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
808 public void preProcessSDNCDelete (Execution execution) {
\r
809 def method = getClass().getSimpleName() + '.preProcessSDNCDelete(' +'execution=' + execution.getId() +')'
\r
810 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
811 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
812 utils.log("INFO"," ***** preProcessSDNCDelete *****", isDebugEnabled)
\r
816 def serviceInstanceId = execution.getVariable("serviceInstanceId")
\r
817 def serviceInstanceName = execution.getVariable("serviceInstanceName")
\r
818 def callbackURL = execution.getVariable("sdncCallbackUrl")
\r
819 def requestId = execution.getVariable("msoRequestId")
\r
820 def serviceId = execution.getVariable("productFamilyId")
\r
821 def subscriptionServiceType = execution.getVariable("subscriptionServiceType")
\r
822 def globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
\r
824 String serviceModelInfo = execution.getVariable("serviceModelInfo")
\r
825 def modelInvariantUuid = ""
\r
826 def modelVersion = ""
\r
829 if (!isBlank(serviceModelInfo))
\r
831 modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid")
\r
832 modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion")
\r
833 modelUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelUuid")
\r
834 modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName")
\r
836 if (modelInvariantUuid == null) {
\r
837 modelInvariantUuid = ""
\r
839 if (modelVersion == null) {
\r
842 if (modelUuid == null) {
\r
845 if (modelName == null) {
\r
849 if (serviceInstanceName == null) {
\r
850 serviceInstanceName = ""
\r
852 if (serviceId == null) {
\r
856 def siParamsXml = execution.getVariable("siParamsXml")
\r
857 def serviceType = execution.getVariable("serviceType")
\r
858 if (serviceType == null)
\r
863 def sdncRequestId = UUID.randomUUID().toString()
\r
865 String sdncDelete =
\r
866 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
\r
867 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
\r
868 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
\r
869 <sdncadapter:RequestHeader>
\r
870 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
\r
871 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
\r
872 <sdncadapter:SvcAction>delete</sdncadapter:SvcAction>
\r
873 <sdncadapter:SvcOperation>service-topology-operation</sdncadapter:SvcOperation>
\r
874 <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
\r
875 <sdncadapter:MsoAction>${serviceType}</sdncadapter:MsoAction>
\r
876 </sdncadapter:RequestHeader>
\r
877 <sdncadapterworkflow:SDNCRequestData>
\r
878 <request-information>
\r
879 <request-id>${requestId}</request-id>
\r
880 <source>MSO</source>
\r
881 <notification-url/>
\r
884 <request-action>DeleteServiceInstance</request-action>
\r
885 </request-information>
\r
886 <service-information>
\r
887 <service-id>${serviceId}</service-id>
\r
888 <subscription-service-type>${subscriptionServiceType}</subscription-service-type>
\r
889 <onap-model-information>
\r
890 <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid>
\r
891 <model-uuid>${modelUuid}</model-uuid>
\r
892 <model-version>${modelVersion}</model-version>
\r
893 <model-name>${modelName}</model-name>
\r
894 </onap-model-information>
\r
895 <service-instance-id>${serviceInstanceId}</service-instance-id>
\r
897 <global-customer-id>${globalSubscriberId}</global-customer-id>
\r
898 </service-information>
\r
899 <service-request-input>
\r
900 <service-instance-name>${serviceInstanceName}</service-instance-name>
\r
902 </service-request-input>
\r
903 </sdncadapterworkflow:SDNCRequestData>
\r
904 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
\r
906 sdncDelete = utils.formatXml(sdncDelete)
\r
907 def sdncRequestId2 = UUID.randomUUID().toString()
\r
908 String sdncDeactivate = sdncDelete.replace(">delete<", ">deactivate<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
\r
909 execution.setVariable("sdncDelete", sdncDelete)
\r
910 execution.setVariable("sdncDeactivate", sdncDeactivate)
\r
911 utils.log("INFO","sdncDeactivate:\n" + sdncDeactivate, isDebugEnabled)
\r
912 utils.log("INFO","sdncDelete:\n" + sdncDelete, isDebugEnabled)
\r
914 } catch (BpmnError e) {
\r
916 } catch(Exception ex) {
\r
917 msg = "Exception in preProcessSDNCDelete. " + ex.getMessage()
\r
918 utils.log("INFO", msg, isDebugEnabled)
\r
919 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception Occured in preProcessSDNCDelete.\n" + ex.getMessage())
\r
921 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
924 public void postProcessSDNCDelete(Execution execution, String response, String action) {
\r
926 def method = getClass().getSimpleName() + '.postProcessSDNCDelete(' +'execution=' + execution.getId() +')'
\r
927 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
928 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
929 utils.log("INFO"," ***** postProcessSDNC " + action + " *****", isDebugEnabled)
\r
933 WorkflowException workflowException = execution.getVariable("WorkflowException")
\r
934 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
\r
935 utils.log("INFO", "SDNCResponse: " + response, isDebugEnabled)
\r
936 utils.log("INFO", "workflowException: " + workflowException, isDebugEnabled)
\r
938 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
\r
939 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
\r
940 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == "true"){
\r
941 utils.log("INFO","Good response from SDNC Adapter for service-instance " + action + "response:\n" + response, isDebugEnabled)
\r
944 msg = "Bad Response from SDNC Adapter for service-instance " + action
\r
945 utils.log("INFO", msg, isDebugEnabled)
\r
946 exceptionUtil.buildAndThrowWorkflowException(execution, 3500, msg)
\r
948 } catch (BpmnError e) {
\r
950 } catch(Exception ex) {
\r
951 msg = "Exception in postProcessSDNC " + action + " Exception:" + ex.getMessage()
\r
952 utils.log("INFO", msg, isDebugEnabled)
\r
953 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
\r
955 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
958 public void postProcessAAIDEL(Execution execution) {
\r
959 def method = getClass().getSimpleName() + '.postProcessAAIDEL(' +'execution=' + execution.getId() +')'
\r
960 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
961 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
962 utils.log("INFO"," ***** postProcessAAIDEL ***** ", isDebugEnabled)
\r
965 String serviceInstanceId = execution.getVariable("serviceInstanceId")
\r
966 boolean succInAAI = execution.getVariable("GENDS_SuccessIndicator")
\r
968 msg = "Error deleting Service-instance in AAI" + serviceInstanceId
\r
969 utils.log("INFO", msg, isDebugEnabled)
\r
970 WorkflowException workflowException = execution.getVariable("WorkflowException")
\r
971 utils.logAudit("workflowException: " + workflowException)
\r
972 if(workflowException != null){
\r
973 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
\r
977 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
\r
980 } catch (BpmnError e) {
\r
982 } catch (Exception ex) {
\r
983 msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIDEL. " + ex.getMessage()
\r
984 utils.log("INFO", msg, isDebugEnabled)
\r
985 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
\r
987 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
990 * Init the service Operation Status
\r
992 public void preUpdateServiceOperationStatus(Execution execution){
\r
993 def method = getClass().getSimpleName() + '.preUpdateServiceOperationStatus(' +'execution=' + execution.getId() +')'
\r
994 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
995 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
998 String serviceId = execution.getVariable("serviceInstanceId")
\r
999 String operationId = execution.getVariable("operationId")
\r
1000 String serviceName = execution.getVariable("serviceInstanceName")
\r
1001 String operationType = "DELETE"
\r
1002 String userId = ""
\r
1003 String result = "processing"
\r
1004 String progress = execution.getVariable("progress")
\r
1005 utils.log("INFO", "progress: " + progress , isDebugEnabled)
\r
1006 if ("100".equalsIgnoreCase(progress))
\r
1008 result = "finished"
\r
1010 String reason = ""
\r
1011 String operationContent = "Prepare service delete: " + execution.getVariable("operationStatus")
\r
1012 utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId, isDebugEnabled)
\r
1013 serviceId = UriUtils.encode(serviceId,"UTF-8")
\r
1014 execution.setVariable("serviceInstanceId", serviceId)
\r
1015 execution.setVariable("operationId", operationId)
\r
1016 execution.setVariable("operationType", operationType)
\r
1018 def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint")
\r
1019 execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
\r
1020 utils.log("INFO", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
\r
1022 execution.setVariable("URN_mso_openecomp_adapters_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter")
\r
1025 """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
\r
1026 xmlns:ns="http://org.openecomp.mso/requestsdb">
\r
1029 <ns:updateServiceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">
\r
1030 <serviceId>${serviceId}</serviceId>
\r
1031 <operationId>${operationId}</operationId>
\r
1032 <serviceName>${serviceName}</serviceName>
\r
1033 <operationType>${operationType}</operationType>
\r
1034 <userId>${userId}</userId>
\r
1035 <result>${result}</result>
\r
1036 <operationContent>${operationContent}</operationContent>
\r
1037 <progress>${progress}</progress>
\r
1038 <reason>${reason}</reason>
\r
1039 </ns:updateServiceOperationStatus>
\r
1041 </soapenv:Envelope>"""
\r
1043 payload = utils.formatXml(payload)
\r
1044 execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload)
\r
1045 utils.log("INFO", "Outgoing preUpdateServiceOperationStatus: \n" + payload, isDebugEnabled)
\r
1048 }catch(Exception e){
\r
1049 utils.log("ERROR", "Exception Occured Processing preUpdateServiceOperationStatus. Exception is:\n" + e, isDebugEnabled)
\r
1050 execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preUpdateServiceOperationStatus Method:\n" + e.getMessage())
\r
1052 utils.log("INFO", "======== COMPLETED preUpdateServiceOperationStatus Process ======== ", isDebugEnabled)
\r
1053 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
1056 public void preInitResourcesOperStatus(Execution execution){
\r
1057 def method = getClass().getSimpleName() + '.preInitResourcesOperStatus(' +'execution=' + execution.getId() +')'
\r
1058 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
1059 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
1061 utils.log("INFO", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
\r
1064 String serviceId = execution.getVariable("serviceInstanceId")
\r
1065 String operationId = execution.getVariable("operationId")
\r
1066 String operationType = "DELETE"
\r
1067 String resourceTemplateUUIDs = ""
\r
1068 String result = "processing"
\r
1069 String progress = "0"
\r
1070 String reason = ""
\r
1071 String operationContent = "Prepare service delete"
\r
1072 utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType, isDebugEnabled)
\r
1073 serviceId = UriUtils.encode(serviceId,"UTF-8")
\r
1074 execution.setVariable("serviceInstanceId", serviceId)
\r
1075 execution.setVariable("operationId", operationId)
\r
1076 execution.setVariable("operationType", operationType)
\r
1078 String serviceRelationShip = execution.getVariable("serviceRelationShip")
\r
1079 utils.log("INFO", "serviceRelationShip: " + serviceRelationShip, isDebugEnabled)
\r
1080 if (! isBlank(serviceRelationShip)) {
\r
1081 def jsonSlurper = new JsonSlurper()
\r
1082 def jsonOutput = new JsonOutput()
\r
1083 List relationShipList = jsonSlurper.parseText(serviceRelationShip)
\r
1085 if (relationShipList != null) {
\r
1086 relationShipList.each {
\r
1087 resourceTemplateUUIDs = resourceTemplateUUIDs + it.resourceInstanceId + ":"
\r
1091 def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter"
\r
1092 execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
\r
1093 utils.log("INFO", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
\r
1096 """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
\r
1097 xmlns:ns="http://org.openecomp.mso/requestsdb">
\r
1100 <ns:initResourceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">
\r
1101 <serviceId>${serviceId}</serviceId>
\r
1102 <operationId>${operationId}</operationId>
\r
1103 <operationType>${operationType}</operationType>
\r
1104 <resourceTemplateUUIDs>${resourceTemplateUUIDs}</resourceTemplateUUIDs>
\r
1105 </ns:initResourceOperationStatus>
\r
1107 </soapenv:Envelope>"""
\r
1109 payload = utils.formatXml(payload)
\r
1110 execution.setVariable("CVFMI_initResOperStatusRequest", payload)
\r
1111 utils.log("INFO", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled)
\r
1112 utils.logAudit("DoCustomDeleteE2EServiceInstanceV2 Outgoing initResourceOperationStatus Request: " + payload)
\r
1114 }catch (BpmnError e) {
\r
1116 } catch (Exception ex) {
\r
1117 msg = "Exception in DoCustomDeleteE2EServiceInstanceV2.preInitResourcesOperStatus. " + ex.getMessage()
\r
1118 utils.log("INFO", msg, isDebugEnabled)
\r
1119 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
\r
1121 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r
1127 * prepare delete parameters
\r
1129 public void preProcessVFCResourceDelete(execution){
\r
1130 // we use resource instance ids for delete flow as resourceTemplateUUIDs
\r
1132 def method = getClass().getSimpleName() + '.preProcessVFCResourceDelete(' +'execution=' + execution.getId() +')'
\r
1133 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
1134 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
1136 utils.log("INFO", " ======== STARTED preProcessVFCResourceDelete Process ======== ", isDebugEnabled)
\r
1138 String serviceResource = execution.getVariable("serviceResource")
\r
1139 utils.log("INFO", "serviceResource : " + serviceResource, isDebugEnabled)
\r
1141 String resourceInstanceId = execution.getVariable("resourceInstanceId")
\r
1142 utils.log("INFO", "resourceInstanceId : " + resourceInstanceId, isDebugEnabled)
\r
1144 execution.setVariable("resourceTemplateId", resourceInstanceId)
\r
1145 utils.log("INFO", "resourceTemplateId : " + resourceInstanceId, isDebugEnabled)
\r
1147 String resourceType = execution.getVariable("resourceType")
\r
1148 utils.log("INFO", "resourceType : " + resourceType, isDebugEnabled)
\r
1151 String resourceName = execution.getVariable(Prefix+"resourceName")
\r
1152 if (isBlank(resourceName)){
\r
1153 resourceName = resourceInstanceId
\r
1155 execution.setVariable("resourceName", resourceName)
\r
1156 utils.log("INFO", "resource Name : " + resourceName, isDebugEnabled)
\r
1158 utils.log("INFO", "Delete Resource Info: resourceInstanceId :" + resourceInstanceId + " resourceTemplateId: " + resourceInstanceId + " resourceType: " + resourceType, isDebugEnabled)
\r
1159 }catch (BpmnError e) {
\r
1161 } catch (Exception ex) {
\r
1162 msg = "Exception in DoDeleteE2EServiceInstance.preProcessVFCResourceDelete. " + 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
1169 public void postProcessVFCDelete(Execution execution, String response, String action) {
\r
1170 def method = getClass().getSimpleName() + '.postProcessVFCDelete(' +'execution=' + execution.getId() +')'
\r
1171 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
1172 utils.log("INFO","Entered " + method, isDebugEnabled)
\r
1174 utils.log("INFO", " ======== STARTED postProcessVFCDelete Process ======== ", isDebugEnabled)
\r
1177 }catch (BpmnError e) {
\r
1179 } catch (Exception ex) {
\r
1180 msg = "Exception in DoDeleteE2EServiceInstance.postProcessVFCDelete. " + ex.getMessage()
\r
1181 utils.log("INFO", msg, isDebugEnabled)
\r
1182 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
\r
1184 utils.log("INFO", "Exited " + method, isDebugEnabled)
\r