From 8bb7ec5694ec34ba79cef5ccdf8e7c6d6a8120a0 Mon Sep 17 00:00:00 2001 From: Shane Daniel Date: Wed, 3 Oct 2018 16:08:08 -0400 Subject: Fix missing vserver name attribute Issue-ID: LOG-717 Change-Id: Ieb605efdd128251ed057942fff1239ad93c4fdf1 Signed-off-by: Shane Daniel --- .../service/SpringServiceImpl.java | 35 ++++++++++++++-------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/SpringServiceImpl.java b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/SpringServiceImpl.java index 4d22a92..fc2b542 100644 --- a/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/SpringServiceImpl.java +++ b/src/main/java/org/onap/pomba/contextbuilder/networkdiscovery/service/SpringServiceImpl.java @@ -391,16 +391,21 @@ public class SpringServiceImpl implements SpringService { if (null != resource.getAttributeList()) { for (org.onap.sdnc.apps.pomba.networkdiscovery.datamodel.Attribute ndattribute : resource.getAttributeList()) { try { - Attribute attribute = new Attribute(); - attribute.setName(Attribute.Name.valueOf(ndattribute.getName())); - attribute.setValue(ndattribute.getValue()); - attribute.setDataQuality(ndattribute.getDataQuality()); - vm.addAttribute(attribute); + String ndattributeName = ndattribute.getName(); + if (ndattributeName.equals("name")) { + vm.setName(ndattribute.getValue()); + } + else { + Attribute attribute = new Attribute(); + attribute.setName(Attribute.Name.valueOf(ndattributeName)); + attribute.setValue(ndattribute.getValue()); + attribute.setDataQuality(ndattribute.getDataQuality()); + vm.addAttribute(attribute); + } } catch (IllegalArgumentException ex) { // The attribute Name passed back from Network Discovery is not in our enum - log.info("Atribute Name: " + ndattribute.getName() + " for Resource:" + resource.getName() + " Id:" +resource.getId() + " is invalid"); + log.info("Attribute Name: " + ndattribute.getName() + " for Resource:" + resource.getName() + " Id:" +resource.getId() + " is invalid"); } - } } } @@ -411,13 +416,19 @@ public class SpringServiceImpl implements SpringService { if (null != resource.getAttributeList()) { for (org.onap.sdnc.apps.pomba.networkdiscovery.datamodel.Attribute ndattribute : resource.getAttributeList()) { try { - Attribute attribute = new Attribute(); - attribute.setName(Attribute.Name.valueOf(ndattribute.getName())); - attribute.setValue(ndattribute.getValue()); - network.addAttribute(attribute); + String ndattributeName = ndattribute.getName(); + if (ndattributeName.equals("name")) { + network.setName(ndattribute.getValue()); + } + else { + Attribute attribute = new Attribute(); + attribute.setName(Attribute.Name.valueOf(ndattributeName)); + attribute.setValue(ndattribute.getValue()); + network.addAttribute(attribute); + } } catch (IllegalArgumentException ex) { // The attribute Name passed back from Network Discovery is not in our enum - log.info("Atribute Name: " + ndattribute.getName() + " for Resource:" + resource.getName() + " Id:" + resource.getId() + " is invalid"); + log.info("Attribute Name: " + ndattribute.getName() + " for Resource:" + resource.getName() + " Id:" + resource.getId() + " is invalid"); } } } -- cgit 1.2.3-korg