From 597b7c7a33b3f636263fd7297e3d257eb6b56175 Mon Sep 17 00:00:00 2001 From: cschowdam Date: Sat, 1 Aug 2020 06:51:19 +0000 Subject: [PATCH] netconf response preparing for 2sector 2nd sector netconf response taabluar index issue fixed Issue-Id: OAM-137 Change-Id: I0ea5d04fd2a31710e29e89c66478703940039e59 Signed-off-by: cschowdam --- .../mapper/util/NetconfToTr069MapperUtil.java | 30 +++++++--------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/mapper/src/main/java/org/commscope/tr069adapter/mapper/util/NetconfToTr069MapperUtil.java b/mapper/src/main/java/org/commscope/tr069adapter/mapper/util/NetconfToTr069MapperUtil.java index 4f5f9cf..81245d0 100644 --- a/mapper/src/main/java/org/commscope/tr069adapter/mapper/util/NetconfToTr069MapperUtil.java +++ b/mapper/src/main/java/org/commscope/tr069adapter/mapper/util/NetconfToTr069MapperUtil.java @@ -301,7 +301,7 @@ public class NetconfToTr069MapperUtil { private String getNetconfResponseXML(List parameters, String swVersion, String hwVersion, boolean isCustomparameter) { if (null == parameters || parameters.isEmpty()) { - + // LOG.debug("There are no parameters found in the response."); return null; } Collections.sort(parameters, new SortByParamterName()); @@ -309,8 +309,6 @@ public class NetconfToTr069MapperUtil { String result = null; try { DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - docFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); - docFactory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); Document doc = docBuilder.newDocument(); @@ -325,7 +323,6 @@ public class NetconfToTr069MapperUtil { } String paramValue = paramDto.getParamValue(); if (paramValue == null || paramValue.trim().isEmpty()) { - logger.debug("Values is empty so skipping this parameter."); continue; } StringTokenizer tokenizer = new StringTokenizer(paramName, "."); @@ -343,17 +340,14 @@ public class NetconfToTr069MapperUtil { if (null == dataNode) { dataNode = parentNode; } - + continue; } else if (nodeName.matches(INDEX_REGEX)) { // construct // tabular and // index nodes // get parent tabular node from parent MAP - StringBuilder bld = new StringBuilder(parentNodeKey); - bld.append("."); - bld.append(nodeName); - parentNodeKey = bld.toString(); - Element node = parentNodeMap.computeIfPresent(parentNodeKey, (k, v) -> v); + parentNodeKey = parentNodeKey + "." + nodeName; + Element node = parentNodeMap.get(parentNodeKey); // create a tabular parent node if doesn't exit in MAP if (null == node) { @@ -389,10 +383,7 @@ public class NetconfToTr069MapperUtil { // attribute // is // found - StringBuilder bld = new StringBuilder(parentNodeName); - bld.append("."); - bld.append(nodeName); - parentNodeKey = bld.toString(); + parentNodeKey = parentNodeKey + "." + nodeName; parentNodeName = nodeName; } else { // construct intermediate nodes @@ -414,10 +405,7 @@ public class NetconfToTr069MapperUtil { parentNode.appendChild(node); } - StringBuilder bld = new StringBuilder(parentNodeKey); - bld.append("."); - bld.append(nodeName); - parentNodeKey = bld.toString(); + parentNodeKey = parentNodeKey + "." + nodeName; parentNodeName = nodeName; parentNode = node; } @@ -425,15 +413,15 @@ public class NetconfToTr069MapperUtil { // construct leaf node Element leafNode = doc.createElement(parentNodeName); leafNode.setTextContent(paramValue); - if (null != parentNode) + if (parentNode != null) parentNode.appendChild(leafNode); } if (null != dataNode) { - result = NetconfToTr069MapperUtil.convertDocumentToString(dataNode); + result = convertDocumentToString(dataNode); } } catch (ParserConfigurationException pce) { - logger.error("Exception : {}", pce.getMessage()); + logger.error("Response xml formatting is failed : {} ", pce.toString()); } return result; -- 2.16.6