X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=mapper%2Fsrc%2Fmain%2Fjava%2Forg%2Fcommscope%2Ftr069adapter%2Fmapper%2Fnetconf%2FNetConfNotificationSender.java;fp=mapper%2Fsrc%2Fmain%2Fjava%2Forg%2Fcommscope%2Ftr069adapter%2Fmapper%2Fnetconf%2FNetConfNotificationSender.java;h=aaf70d3d28acd101fc72d06126e9b4875e68cca0;hb=bf6ffaf6e08b066da8bc69ab7b478d8b5528ce21;hp=15024c29508695906566e0433066525d1d78f970;hpb=6d2eb103a838fee7fdbecc0c1fec2f954535c608;p=oam%2Ftr069-adapter.git diff --git a/mapper/src/main/java/org/commscope/tr069adapter/mapper/netconf/NetConfNotificationSender.java b/mapper/src/main/java/org/commscope/tr069adapter/mapper/netconf/NetConfNotificationSender.java index 15024c2..aaf70d3 100644 --- a/mapper/src/main/java/org/commscope/tr069adapter/mapper/netconf/NetConfNotificationSender.java +++ b/mapper/src/main/java/org/commscope/tr069adapter/mapper/netconf/NetConfNotificationSender.java @@ -86,10 +86,12 @@ public class NetConfNotificationSender { convertTR069ToNetConfParams(parameters, deviceInform.getDeviceDetails().getSoftwareVersion(), deviceInform.getDeviceDetails().getHardwareVersion()); + String nameSpace = metaDataUtil.getMetaDataByTR69Name(deviceInform.getInformType().toString(), + deviceInform.getDeviceDetails().getSoftwareVersion(), + deviceInform.getDeviceDetails().getHardwareVersion()).getURI(); + String notificationXml = - getNetconfResponseXML(parameters, deviceInform.getInformType().toString(), null, - deviceInform.getDeviceDetails().getSoftwareVersion(), - deviceInform.getDeviceDetails().getHardwareVersion()); + getNetconfResponseXML(parameters, deviceInform.getInformType().toString(), nameSpace); NetConfNotificationDTO netConfDTO = new NetConfNotificationDTO( deviceInform.getDeviceDetails().getDeviceId(), notificationXml); @@ -108,7 +110,7 @@ public class NetConfNotificationSender { final String uri = getUri(); LOG.debug("Posting custom notification to netconf server " + uri); try { - String notificationXml = getNetconfResponseXML(parameters, null, nameSpace, null, null); + String notificationXml = getNetconfResponseXML(parameters, null, nameSpace); NetConfNotificationDTO netConfDTO = new NetConfNotificationDTO(deviceId, notificationXml); response = restTemplate.postForObject(uri, netConfDTO, ResponseEntity.class); @@ -158,8 +160,8 @@ public class NetConfNotificationSender { return config.getNbiNotificationUri(); } - private String getNetconfResponseXML(List parameters, String notificationType, - String nameSpace, String swVersion, String hwVersion) { + private static String getNetconfResponseXML(List parameters, + String notificationType, String nameSpace) { if (parameters == null || parameters.isEmpty()) { LOG.debug("There are no parameters found in the response."); return null; @@ -262,12 +264,6 @@ public class NetConfNotificationSender { element.appendChild(element.getOwnerDocument().importNode(eventTime, true)); if (notificationType != null) { - if (nameSpace == null && metaDataUtil.getMetaDataByTR69Name(notificationType, swVersion, - hwVersion) != null) { - nameSpace = - metaDataUtil.getMetaDataByTR69Name(notificationType, swVersion, hwVersion).getURI(); - } - final Element evtTypeElement = doc.createElementNS(nameSpace, notificationType); evtTypeElement.appendChild(dataNode); element.appendChild(element.getOwnerDocument().importNode(evtTypeElement, true)); @@ -278,7 +274,7 @@ public class NetConfNotificationSender { result = convertDocumentToString(element); } } catch (ParserConfigurationException pce) { - LOG.error("Error occured while preparing the notification"); + LOG.error("Exception while converting the notification: {}", pce.getMessage()); } return result; @@ -296,8 +292,7 @@ public class NetConfNotificationSender { } catch (Exception e) { LOG.error("Error while converting Element to String" + e); } - LOG.debug("Converted XML is : " + strxml); + LOG.debug("Converted XML is : {}", strxml); return strxml; } - }