Fix parsing from AAI response

Fix parsing from AAI response

Change-Id: Ie9020148a5ca6d3e434f2d2acc42b61f3f797a78
Issue-ID: SO-422
Signed-off-by: subhash kumar singh <subhash.kumar.singh@huawei.com>
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 1c8a5e7..003210f 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 @@
                 }
                 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 @@
                     //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 @@
                                         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