Device Software version management
[oam/tr069-adapter.git] / mapper / src / main / java / org / commscope / tr069adapter / mapper / acs / impl / ACSNotificationHandlerImpl.java
index e4bc24e..b6adad7 100644 (file)
@@ -20,7 +20,6 @@ package org.commscope.tr069adapter.mapper.acs.impl;
 \r
 import java.util.ArrayList;\r
 import java.util.List;\r
-\r
 import org.commscope.tr069adapter.acs.common.DeviceInform;\r
 import org.commscope.tr069adapter.acs.common.DeviceRPCResponse;\r
 import org.commscope.tr069adapter.acs.common.InformType;\r
@@ -85,7 +84,9 @@ public class ACSNotificationHandlerImpl implements ACSNotificationHandler {
   @Override\r
   public void handleOperationResponse(DeviceRPCResponse opResult) {\r
     opResult.getOperationResponse().setParameterDTOs(\r
-        filterUnsupportedParameters(opResult.getOperationResponse().getParameterDTOs()));\r
+        filterUnsupportedParameters(opResult.getOperationResponse().getParameterDTOs(),\r
+            opResult.getDeviceDetails().getSoftwareVersion(),\r
+            opResult.getDeviceDetails().getHardwareVersion()));\r
     syncHandler.notifyResult(opResult);\r
   }\r
 \r
@@ -162,12 +163,16 @@ public class ACSNotificationHandlerImpl implements ACSNotificationHandler {
   }\r
 \r
   private NetConfServerDetails createNtConfServer(BootstrapInform bootstrapNotification) {\r
-    String eNodeBName = pnpPreProvisioningHandler\r
-        .getEnodeBName(bootstrapNotification.getDeviceDetails().getDeviceId());\r
+    String eNodeBName = pnpPreProvisioningHandler.getEnodeBName(\r
+        bootstrapNotification.getDeviceDetails().getDeviceId(),\r
+        bootstrapNotification.getDeviceDetails().getSoftwareVersion(),\r
+        bootstrapNotification.getDeviceDetails().getHardwareVersion());\r
     if (eNodeBName == null)\r
       eNodeBName = bootstrapNotification.getDeviceDetails().getDeviceId();\r
-    NetConfServerDetails serverInfo = netconfManager\r
-        .createNetconfServer(bootstrapNotification.getDeviceDetails().getDeviceId(), eNodeBName);\r
+    NetConfServerDetails serverInfo =\r
+        netconfManager.createNetconfServer(bootstrapNotification.getDeviceDetails().getDeviceId(),\r
+            eNodeBName, bootstrapNotification.getDeviceDetails().getSoftwareVersion(),\r
+            bootstrapNotification.getDeviceDetails().getHardwareVersion());\r
     if (serverInfo != null && !NetconfServerManagementError.SUCCESS.equals(serverInfo.getError())) {\r
       logger.error("Failed to handle bootstrap notification. Server INFO: {}", serverInfo);\r
       logger.error("Failed to create the netconf server for device ID: {}  Error: {}",\r
@@ -203,11 +208,13 @@ public class ACSNotificationHandlerImpl implements ACSNotificationHandler {
     return false;\r
   }\r
 \r
-  public List<ParameterDTO> filterUnsupportedParameters(List<ParameterDTO> parameters) {\r
+  public List<ParameterDTO> filterUnsupportedParameters(List<ParameterDTO> parameters,\r
+      String swVersion, String hwVersion) {\r
     List<ParameterDTO> result = new ArrayList<>();\r
     if (null != parameters) {\r
       for (ParameterDTO param : parameters) {\r
-        MOMetaData metaData = metaDataUtil.getMetaDataByTR69Name(param.getParamName());\r
+        MOMetaData metaData =\r
+            metaDataUtil.getMetaDataByTR69Name(param.getParamName(), swVersion, hwVersion);\r
         if (null != metaData) {\r
           result.add(param);\r
         }\r
@@ -327,12 +334,9 @@ public class ACSNotificationHandlerImpl implements ACSNotificationHandler {
         deviceOperDAO.save(fwDetails);\r
 \r
         logger.debug("sending download-event notification to netconfserver");\r
-        NetConfNotificationDTO netConfNotifDTO =\r
-            new NetConfNotificationDTO(notification.getDeviceDetails().getDeviceId(), null, true);\r
-        netConfNotifDTO.setParameters(paramList);\r
-        netConfNotifDTO.setUri(SOFT_MGMT_NS_URI);\r
 \r
-        if (notiSender.sendCustomNotification(netConfNotifDTO).getStatusCode().is2xxSuccessful()) {\r
+        if (notiSender.sendCustomNotification(notification.getDeviceDetails().getDeviceId(),\r
+            paramList, SOFT_MGMT_NS_URI).getStatusCode().is2xxSuccessful()) {\r
           logger.debug("sending download-event notification to netconfserver sucess");\r
         } else {\r
           logger.error("sending download-event notification to netconfserver failed");\r
@@ -376,7 +380,8 @@ public class ACSNotificationHandlerImpl implements ACSNotificationHandler {
         if (notification.getDeviceDetails().getSoftwareVersion()\r
             .equalsIgnoreCase(devDetails.getSwVersion())) {\r
           paramList.add(new ParameterDTO("activation-event.status", "APPLICATION_ERROR"));\r
-          paramList.add(new ParameterDTO("activation-event.error-message", "Same Software Version is reported after upgrade"));\r
+          paramList.add(new ParameterDTO("activation-event.error-message",\r
+              "Same Software Version is reported after upgrade"));\r
           devDetails.setDownLoadStatus(FirwareUpgradeStatus.ACTIVATION_ERROR.getStatus());\r
         } else {\r
           devDetails.setSwVersion(notification.getDeviceDetails().getSoftwareVersion());\r
@@ -386,12 +391,9 @@ public class ACSNotificationHandlerImpl implements ACSNotificationHandler {
         deviceOperDAO.save(devDetails);\r
 \r
         logger.debug("sending activation-event notification to netconfserver");\r
-        NetConfNotificationDTO netConfNotifDTO =\r
-            new NetConfNotificationDTO(notification.getDeviceDetails().getDeviceId(), null, true);\r
-        netConfNotifDTO.setParameters(paramList);\r
-        netConfNotifDTO.setUri(SOFT_MGMT_NS_URI);\r
 \r
-        if (notiSender.sendCustomNotification(netConfNotifDTO).getStatusCode().is2xxSuccessful()) {\r
+        if (notiSender.sendCustomNotification(notification.getDeviceDetails().getDeviceId(),\r
+            paramList, SOFT_MGMT_NS_URI).getStatusCode().is2xxSuccessful()) {\r
           logger.debug("sending activation-event notification to netconfserver sucess");\r
         } else {\r
           logger.error("sending activation-event notification to netconfserver failed");\r