From: Serhii Siabruk Date: Thu, 6 Sep 2018 16:07:00 +0000 (+0300) Subject: Move this method into "ResourceTask". X-Git-Tag: 1.4.1~8 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F07%2F65207%2F5;p=sdnc%2Fapps.git Move this method into "ResourceTask". Issue-ID: SDNC-1 Change-Id: Ia9b6c49a5c2e9790445b6fa07643f32a4661b5dd Signed-off-by: Serhii Siabruk --- diff --git a/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/service/SpringServiceImpl.java b/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/service/SpringServiceImpl.java index b8468da..8d0de03 100644 --- a/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/service/SpringServiceImpl.java +++ b/pomba/network-discovery/src/main/java/org/onap/sdnc/apps/pomba/networkdiscovery/service/SpringServiceImpl.java @@ -132,36 +132,6 @@ public class SpringServiceImpl implements SpringService { this.executor.shutdown(); } - private List toAttributeList(String xml, ONAPLogAdapter adapter) throws SAXException, IOException { - Logger log = adapter.unwrap(); - Document doc = this.parser.parse(new InputSource(new StringReader(xml))); - NodeList children = doc.getDocumentElement().getChildNodes(); - List result = new ArrayList<>(); - for (int i = 0; i < children.getLength(); i++) { - Node child = children.item(i); - if (child.getNodeType() == Node.ELEMENT_NODE) { - - // remove white space before conversion - String attributeName = ((Element) child).getTagName().replaceAll("\\s", ""); - - // If the incoming attribute name is not listed in the - // attributeNameMapping, then this attribute will be removed. - String newName = enricherAttributeNameMapping.get(attributeName); - if (newName != null) { - Attribute attr = new Attribute(); - attr.setName(newName); - attr.setValue(((Element) child).getTextContent()); - attr.setDataQuality(DataQuality.ok()); - result.add(attr); - } else { - log.debug("[" + ((Element) child).getTagName() - + "] was removed due to not listed in enricherAttributeNameMapping."); - } - } - } - return result; - } - private void sendNotification(String url, String authorization, Object notification, ONAPLogAdapter adapter) { Invocation.Builder request = this.callbackClient.target(url).request().accept(MediaType.TEXT_PLAIN_TYPE); @@ -296,6 +266,37 @@ public class SpringServiceImpl implements SpringService { // call client back with resource details sendNotification(this.notificationURL, this.notificationAuthorization, notification, adapter); } + + private List toAttributeList(String xml, ONAPLogAdapter adapter) throws SAXException, IOException { + Logger log = adapter.unwrap(); + Document doc = parser.parse(new InputSource(new StringReader(xml))); + NodeList children = doc.getDocumentElement().getChildNodes(); + List result = new ArrayList<>(); + for (int i = 0; i < children.getLength(); i++) { + Node child = children.item(i); + if (child.getNodeType() == Node.ELEMENT_NODE) { + + // remove white space before conversion + String attributeName = ((Element) child).getTagName().replaceAll("\\s", ""); + + // If the incoming attribute name is not listed in the + // attributeNameMapping, then this attribute will be removed. + String newName = enricherAttributeNameMapping.get(attributeName); + if (newName != null) { + Attribute attr = new Attribute(); + attr.setName(newName); + attr.setValue(((Element) child).getTextContent()); + attr.setDataQuality(DataQuality.ok()); + result.add(attr); + } else { + log.debug("[" + ((Element) child).getTagName() + + "] was removed due to not listed in enricherAttributeNameMapping."); + } + } + } + return result; + } + } private static class RequestBuilderWrapper implements RequestBuilder {