import org.openecomp.mso.bpmn.core.WorkflowException\r
import org.openecomp.mso.rest.APIResponse\r
import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor\r
+import org.openecomp.mso.bpmn.common.scripts.AaiUtil\r
\r
import java.util.UUID;\r
\r
import org.camunda.bpm.engine.delegate.BpmnError\r
-import org.camunda.bpm.engine.runtime.Execution\r
+import org.camunda.bpm.engine.delegate.DelegateExecution\r
import org.json.JSONObject;\r
import org.json.JSONArray;\r
import org.apache.commons.lang3.*\r
import org.apache.commons.codec.binary.Base64;\r
import org.springframework.web.util.UriUtils;\r
+import static org.apache.commons.lang3.StringUtils.*\r
\r
/**\r
* This groovy class supports the <class>DeleteVcpeResCustService.bpmn</class> process.\r
* This method is executed during the preProcessRequest task of the <class>DeleteVcpeResCustService.bpmn</class> process.\r
* @param execution\r
*/\r
- public InitializeProcessVariables(Execution execution){\r
+ public InitializeProcessVariables(DelegateExecution execution){\r
/* Initialize all the process variables in this block */\r
\r
execution.setVariable("DeleteVcpeResCustServiceRequest", "")\r
* This method is executed during the preProcessRequest task of the <class>CreateServiceInstance.bpmn</class> process.\r
* @param execution\r
*/\r
- public void preProcessRequest (Execution execution) {\r
+ public void preProcessRequest (DelegateExecution execution) {\r
def isDebugEnabled=execution.getVariable(DebugFlag)\r
execution.setVariable("prefix",Prefix)\r
\r
utils.log("DEBUG", "Incoming subscriptionServiceType is: " + subscriptionServiceType, isDebugEnabled)\r
\r
// extract cloud configuration\r
- String lcpCloudRegionId = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId")\r
+ String cloudConfiguration = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.cloudConfiguration")\r
+ execution.setVariable("cloudConfiguration", cloudConfiguration)\r
+ utils.log("DEBUG","cloudConfiguration: "+ cloudConfiguration, isDebugEnabled)\r
+ String lcpCloudRegionId = jsonUtil.getJsonValue(cloudConfiguration, "lcpCloudRegionId")\r
execution.setVariable("lcpCloudRegionId", lcpCloudRegionId)\r
utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled)\r
- String tenantId = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.cloudConfiguration.tenantId")\r
+ String tenantId = jsonUtil.getJsonValue(cloudConfiguration, "tenantId")\r
execution.setVariable("tenantId", tenantId)\r
utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled)\r
\r
- String sdncVersion = "1702"\r
+ String sdncVersion = "1707"\r
execution.setVariable("sdncVersion", sdncVersion)\r
utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled)\r
\r
}\r
}\r
\r
- public void sendSyncResponse(Execution execution) {\r
+ public void sendSyncResponse(DelegateExecution execution) {\r
def isDebugEnabled=execution.getVariable(DebugFlag)\r
\r
utils.log("DEBUG", " ***** Inside sendSyncResponse of DeleteVcpeResCustService ***** ", isDebugEnabled)\r
utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled)\r
sendWorkflowResponse(execution, 202, syncResponse)\r
} catch (Exception ex) {\r
- String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Unexpected from method preProcessRequest() - " + ex.getMessage()
+ String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Unexpected from method preProcessRequest() - " + ex.getMessage()\r
exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
}\r
}\r
\r
- public void prepareServiceDelete(Execution execution) {\r
+ public void prepareServiceDelete(DelegateExecution execution) {\r
def isDebugEnabled=execution.getVariable(DebugFlag)\r
- utils.log("DEBUG", " ***** Inside prepareServiceInstanceDelete() of DeleteVcpeResCustService ***** ", isDebugEnabled)\r
+ utils.log("DEBUG", " ***** Inside prepareServiceDelete() of DeleteVcpeResCustService ***** ", isDebugEnabled)\r
\r
try {\r
\r
String serviceInstanceAaiRecord = execution.getVariable("GENGS_service");\r
\r
utils.log("DEBUG", "serviceInstanceAaiRecord: "+serviceInstanceAaiRecord, isDebugEnabled)\r
+ serviceInstanceAaiRecord = utils.removeXmlNamespaces(serviceInstanceAaiRecord)\r
+ \r
+ def (TXC_found, TXC_id) = new Tuple(false, null)\r
+ def (BRG_found, BRG_id) = new Tuple(false, null)\r
+ List relatedVnfIdList = []\r
\r
- // determine if AR needs to be deleted\r
- boolean DVRCS_TunnelXConn = false\r
- boolean DVRCS_BRG = false\r
- String TXC_allottedResourceId\r
- String BRG_allottedResourceId\r
- XmlParser xmlParser = new XmlParser()\r
- def groovy.util.Node siNode = xmlParser.parseText(serviceInstanceAaiRecord)\r
- def groovy.util.Node arList = utils.getChildNode(siNode, 'allotted-resources')\r
- if (arList != null) {\r
- def groovy.util.NodeList ars = utils.getIdenticalChildren(arList, 'allotted-resource')\r
- for (groovy.util.Node ar in ars) {\r
- def type = utils.getChildNodeText(ar, 'type')\r
- if ("TunnelXConn".equals(type)) {\r
- utils.log("DEBUG","TunnelXConn AR found", isDebugEnabled)\r
- def id = utils.getChildNodeText(ar, 'id')\r
- if (id != null){\r
- DVRCS_TunnelXConn = true\r
- TXC_allottedResourceId = id\r
- }\r
- } else if ("BRG".equals(type)) {\r
- utils.log("DEBUG","FW AR found", isDebugEnabled)\r
- def id = utils.getChildNodeText(ar, 'id')\r
- if (id != null){\r
- DVRCS_BRG = true\r
- BRG_allottedResourceId = id\r
- }\r
+ for(Node rel: utils.getMultNodeObjects(serviceInstanceAaiRecord, "relationship")) {\r
+ def relto = utils.getChildNodeText(rel, "related-to")\r
+ def relink = utils.getChildNodeText(rel, "related-link")\r
+ utils.log("DEBUG", "check: "+relto+" link: "+relink, isDebugEnabled)\r
+ \r
+ if(isBlank(relto) || isBlank(relink)) {\r
+ \r
+ } else if(relto == "generic-vnf") {\r
+ def id = relink.substring(relink.indexOf("/generic-vnf/")+13)\r
+ if(id.endsWith("/")) {\r
+ id = id.substring(0, id.length()-1)\r
+ }\r
+ \r
+ relatedVnfIdList.add(id)\r
+ \r
+ } else if(relto == "allotted-resource") {\r
+ def (type, id) = getAaiAr(execution, relink)\r
+ \r
+ if(isBlank(type) || isBlank(id)) {\r
+ \r
+ } else if(type == "TunnelXConn" || type == "Tunnel XConn") {\r
+ utils.log("DEBUG","Tunnel XConn AR found", isDebugEnabled)\r
+ TXC_found = true\r
+ TXC_id = id\r
+ \r
+ } else if(type == "BRG") {\r
+ utils.log("DEBUG","BRG AR found", isDebugEnabled)\r
+ BRG_found = true\r
+ BRG_id = id\r
}\r
}\r
}\r
- execution.setVariable(Prefix+"TunnelXConn", DVRCS_TunnelXConn)\r
- utils.log("DEBUG", Prefix+"TunnelXConn : " + DVRCS_TunnelXConn, isDebugEnabled)\r
- execution.setVariable("TXC_allottedResourceId", TXC_allottedResourceId)\r
- utils.log("DEBUG", "TXC_allottedResourceId : " + TXC_allottedResourceId, isDebugEnabled)\r
\r
- execution.setVariable(Prefix+"BRG", DVRCS_BRG)\r
- utils.log("DEBUG", Prefix+"BRG : " + DVRCS_BRG, isDebugEnabled)\r
- execution.setVariable("BRG_allottedResourceId", BRG_allottedResourceId)\r
- utils.log("DEBUG", "BRG_allottedResourceId : " + BRG_allottedResourceId, isDebugEnabled)\r
- \r
- String relationship = ""\r
- try {\r
- relationship = networkUtils.getFirstNodeXml(serviceInstanceAaiRecord, "relationship-list")\r
- } catch (Exception ex) {\r
- //no relationships found\r
- }\r
- utils.log("DEBUG", " relationship string - " + relationship, isDebugEnabled)\r
- \r
- int vnfsCount = 0\r
+ execution.setVariable(Prefix+"TunnelXConn", TXC_found)\r
+ execution.setVariable("TXC_allottedResourceId", TXC_id)\r
+ utils.log("DEBUG", "TXC_allottedResourceId: " + TXC_id, isDebugEnabled)\r
+ \r
+ execution.setVariable(Prefix+"BRG", BRG_found)\r
+ execution.setVariable("BRG_allottedResourceId", BRG_id)\r
+ utils.log("DEBUG", "BRG_allottedResourceId: " + BRG_id, isDebugEnabled)\r
\r
- if (relationship != null && relationship.length() > 0){\r
- relationship = relationship.trim().replace("tag0:","").replace(":tag0","")\r
- \r
- // Check if Network TableREf is present, then build a List of network policy\r
- List relatedVnfIdList = networkUtils.getRelatedVnfIdList(relationship)\r
- vnfsCount = relatedVnfIdList.size()\r
- execution.setVariable(Prefix+"vnfsCount", vnfsCount)\r
- utils.log("DEBUG", " "+Prefix+"vnfsCount : " + vnfsCount, isDebugEnabled)\r
+ int vnfsCount = relatedVnfIdList.size()\r
+ execution.setVariable(Prefix+"vnfsCount", vnfsCount)\r
+ utils.log("DEBUG", " "+Prefix+"vnfsCount : " + vnfsCount, isDebugEnabled)\r
+ if(vnfsCount > 0) {\r
execution.setVariable(Prefix+"relatedVnfIdList", relatedVnfIdList)\r
- } else {\r
- execution.setVariable(Prefix+"vnfsCount", 0)\r
- utils.log("DEBUG", " "+Prefix+"vnfsCount : " + vnfsCount, isDebugEnabled)\r
}\r
\r
- utils.log("DEBUG", " ***** Completed prepareServiceInstanceDelete() of DeleteVcpeResCustService ***** ", isDebugEnabled)\r
+ utils.log("DEBUG", " ***** Completed prepareServiceDelete() of DeleteVcpeResCustService ***** ", isDebugEnabled)\r
} catch (BpmnError e){\r
throw e;\r
} catch (Exception ex) {\r
sendSyncError(execution)\r
- String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. prepareServiceInstanceDelete() - " + ex.getMessage()\r
- utils.log("DEBUG", exceptionMessage, isDebugEnabled)\r
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
+ String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. prepareServiceDelete() - " + ex.getMessage()\r
+ utils.log("DEBUG", exceptionMessage, isDebugEnabled)\r
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)\r
}\r
}\r
\r
+ private getAaiAr(DelegateExecution execution, String relink) {\r
+ def isDebugEnabled = execution.getVariable(DebugFlag)\r
+ AaiUtil aaiUtil = new AaiUtil(this)\r
+ String aaiEndpoint = execution.getVariable("URN_aai_endpoint") + relink\r
+ \r
+ utils.log("DEBUG", "get AR info " + aaiEndpoint, isDebugEnabled)\r
+ APIResponse response = aaiUtil.executeAAIGetCall(execution, aaiEndpoint)\r
+ \r
+ int responseCode = response.getStatusCode()\r
+ utils.log("DEBUG", "get AR info responseCode:" + responseCode, isDebugEnabled)\r
+ \r
+ String aaiResponse = response.getResponseBodyAsString()\r
+ utils.log("DEBUG", "get AR info " + aaiResponse, isDebugEnabled)\r
+ \r
+ if(responseCode < 200 || responseCode >= 300 || isBlank(aaiResponse)) {\r
+ return new Tuple2(null, null)\r
+ }\r
+ \r
+ def type = utils.getNodeText1(aaiResponse, "type")\r
+ def id = utils.getNodeText1(aaiResponse, "id")\r
+ \r
+ return new Tuple2(type, id)\r
+ }\r
+ \r
\r
// *******************************\r
// \r
// *******************************\r
- public void prepareVnfAndModulesDelete (Execution execution) {\r
+ public void prepareVnfAndModulesDelete (DelegateExecution execution) {\r
def isDebugEnabled=execution.getVariable(DebugFlag)\r
utils.log("DEBUG", " ***** Inside prepareVnfAndModulesDelete of DeleteVcpeResCustService ***** ", isDebugEnabled)\r
\r
// *******************************\r
// Validate Vnf request Section -> increment count\r
// *******************************\r
- public void validateVnfDelete (Execution execution) {\r
+ public void validateVnfDelete (DelegateExecution execution) {\r
def isDebugEnabled=execution.getVariable(DebugFlag)\r
utils.log("DEBUG", " ***** Inside validateVnfDelete of DeleteVcpeResCustService ***** ", isDebugEnabled)\r
\r
// *****************************************\r
// Prepare Completion request Section\r
// *****************************************\r
- public void postProcessResponse (Execution execution) {\r
+ public void postProcessResponse (DelegateExecution execution) {\r
def isDebugEnabled=execution.getVariable(DebugFlag)\r
utils.log("DEBUG", " ***** Inside postProcessResponse of DeleteVcpeResCustService ***** ", isDebugEnabled)\r
\r
}\r
}\r
\r
- public void prepareFalloutRequest(Execution execution){\r
+ public void prepareFalloutRequest(DelegateExecution execution){\r
def isDebugEnabled=execution.getVariable(DebugFlag)\r
utils.log("DEBUG", " *** STARTED DeleteVcpeResCustService prepareFalloutRequest Process *** ", isDebugEnabled)\r
\r
}\r
\r
\r
- public void sendSyncError (Execution execution) {\r
+ public void sendSyncError (DelegateExecution execution) {\r
def isDebugEnabled=execution.getVariable(DebugFlag)\r
utils.log("DEBUG", " ***** Inside sendSyncError() of DeleteVcpeResCustService ***** ", isDebugEnabled)\r
\r
}\r
}\r
\r
- public void processJavaException(Execution execution){\r
+ public void processJavaException(DelegateExecution execution){\r
def isDebugEnabled=execution.getVariable(DebugFlag)\r
execution.setVariable("prefix",Prefix)\r
try{\r