From 5b82bcab5593479a28649fd82d30f18d12d09771 Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Fri, 13 Apr 2018 14:50:06 +0000 Subject: Fix parsing from AAI response Fix parsing from AAI response Change-Id: Ie9020148a5ca6d3e434f2d2acc42b61f3f797a78 Issue-ID: SO-422 Signed-off-by: subhash kumar singh --- .../scripts/DoDeleteE2EServiceInstance.groovy | 30 ++++++++++++++-------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'bpmn/MSOInfrastructureBPMN/src/main/groovy') diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy index 1c8a5e70fe..003210f602 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy @@ -187,6 +187,11 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { } else { + InputSource source = new InputSource(new StringReader(siData)); + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = docFactory.newDocumentBuilder() + Document serviceXml = docBuilder.parse(source) + serviceXml.getDocumentElement().normalize() // get model invariant id // Get Template uuid and version if (utils.nodeExists(siData, "model-invariant-id") && utils.nodeExists(siData, "model-version-id") ) { @@ -203,13 +208,8 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { //Confirm there are no related service instances (vnf/network or volume) if (utils.nodeExists(siData, "relationship-list")) { utils.log("INFO", "SI Data relationship-list exists:", isDebugEnabled) - InputSource source = new InputSource(new StringReader(siData)); - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = docFactory.newDocumentBuilder() - Document serviceXml = docBuilder.parse(source) - serviceXml.getDocumentElement().normalize() //test(siData) - NodeList nodeList = serviceXml.getElementsByTagName("relationship") + NodeList nodeList = serviceXml.getElementsByTagName("relationship").item(0).getChildNodes() JSONArray jArray = new JSONArray() for (int x = 0; x < nodeList.getLength(); x++) { Node node = nodeList.item(x) @@ -225,12 +225,20 @@ public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { for (int i = 0; i < dataList.getLength(); i++) { Node dNode = dataList.item(i) if(dNode.getNodeName() == "relationship-data") { - Element rDataEle = (Element)dNode - def eKey = rDataEle.getElementsByTagName("relationship-key").item(0).getTextContent() - def eValue = rDataEle.getElementsByTagName("relationship-value").item(0).getTextContent() - if(eKey.equals("service-instance.service-instance-id")){ - jObj.put("resourceInstanceId", eValue) + + NodeList rdNodes = dNode.getChildNodes() + for(int j = 0; j < rdNodes.getLength(); j++) { + Node rdNode = rdNodes.item(j); + if (rdNode instanceof Element) { + Element rDataEle = (Element) rdNode + def eKey = rDataEle.getElementsByTagName("relationship-key").item(0).getTextContent() + def eValue = rDataEle.getElementsByTagName("relationship-value").item(0).getTextContent() + if (eKey.equals("service-instance.service-instance-id")) { + jObj.put("resourceInstanceId", eValue) + } + } } + } else if(dNode.getNodeName() == "related-to-property"){ Element rDataEle = (Element)dNode -- cgit 1.2.3-korg