VES Heartbeat and Software Management Feature
[oam/tr069-adapter.git] / mapper / src / main / java / org / commscope / tr069adapter / mapper / netconf / NetConfNotificationSender.java
index adb3267..5ec31e7 100644 (file)
@@ -25,6 +25,7 @@ import org.commscope.tr069adapter.acs.common.DeviceInform;
 import org.commscope.tr069adapter.acs.common.ParameterDTO;\r
 import org.commscope.tr069adapter.mapper.MOMetaData;\r
 import org.commscope.tr069adapter.mapper.MapperConfigProperties;\r
+import org.commscope.tr069adapter.mapper.model.NetConfNotificationDTO;\r
 import org.commscope.tr069adapter.mapper.util.MOMetaDataUtil;\r
 import org.slf4j.Logger;\r
 import org.slf4j.LoggerFactory;\r
@@ -58,9 +59,13 @@ public class NetConfNotificationSender {
     try {\r
       LOG.debug("deviceInform : {} {}", deviceInform.getInformTypeList(),\r
           deviceInform.getParameters());\r
-      convertTR069ToNetConfParams(deviceInform);\r
+      NetConfNotificationDTO netConfDTO =\r
+          new NetConfNotificationDTO(deviceInform.getDeviceDetails().getDeviceId(),\r
+              deviceInform.getInformType().toString(), false);\r
+      netConfDTO.setParameters(deviceInform.getParameters());\r
+      convertTR069ToNetConfParams(netConfDTO);\r
       LOG.debug("Posting notification to netconf server");\r
-      response = restTemplate.postForObject(uri, deviceInform, ResponseEntity.class);\r
+      response = restTemplate.postForObject(uri, netConfDTO, ResponseEntity.class);\r
       LOG.debug("Posting notification to netconf server completed ");\r
     } catch (Exception e) {\r
       LOG.error("Exception while sending the notification.", e);\r
@@ -68,10 +73,23 @@ public class NetConfNotificationSender {
     return response;\r
   }\r
 \r
-  private void convertTR069ToNetConfParams(DeviceInform deviceInform) {\r
+  public ResponseEntity sendCustomNotification(NetConfNotificationDTO netConfDTO) {\r
+    ResponseEntity response = null;\r
+    final String uri = getUri();\r
+    LOG.debug("Posting custom notification to netconf server " + uri);\r
+    try {\r
+      response = restTemplate.postForObject(uri, netConfDTO, ResponseEntity.class);\r
+      LOG.debug("Posting custom notification to netconf server sucessfull");\r
+    } catch (Exception e) {\r
+      LOG.error("Exception while sending the custom notification.", e.toString());\r
+    }\r
+    return response;\r
+  }\r
+\r
+  private void convertTR069ToNetConfParams(NetConfNotificationDTO netConfDTO) {\r
     List<ParameterDTO> removeList = new ArrayList<>();\r
-    if (null != deviceInform) {\r
-      for (ParameterDTO param : deviceInform.getParameters()) {\r
+    if (null != netConfDTO) {\r
+      for (ParameterDTO param : netConfDTO.getParameters()) {\r
         if (param.getParamValue() == null || param.getParamValue().trim().length() <= 0) {\r
           continue;\r
         }\r
@@ -85,8 +103,7 @@ public class NetConfNotificationSender {
             removeList.add(param); // unknown parameter found.\r
         }\r
       }\r
-      deviceInform.getParameters().removeAll(removeList); // remove unknown\r
-      // parameters\r
+      netConfDTO.getParameters().removeAll(removeList);\r
     }\r
   }\r
 \r