From aed7a3708a987dc7132229ecac1ee7f42b49ee16 Mon Sep 17 00:00:00 2001 From: Serhii Siabruk Date: Thu, 6 Sep 2018 19:07:00 +0300 Subject: Move this method into "ResourceTask". Issue-ID: SDNC-1 Change-Id: Ia9b6c49a5c2e9790445b6fa07643f32a4661b5dd Signed-off-by: Serhii Siabruk --- .../service/SpringServiceImpl.java | 61 +++++++++++----------- 1 file changed, 31 insertions(+), 30 deletions(-) (limited to 'pomba/network-discovery/src') 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 { -- cgit 1.2.3-korg