import org.commscope.tr069adapter.acs.common.dto.TR069InformType;\r
import org.commscope.tr069adapter.acs.common.inform.BootInform;\r
import org.commscope.tr069adapter.acs.common.inform.BootstrapInform;\r
+import org.commscope.tr069adapter.acs.common.inform.ConnectionRequestInform;\r
import org.commscope.tr069adapter.acs.common.inform.PeriodicInform;\r
+import org.commscope.tr069adapter.acs.common.inform.TransferCompleteInform;\r
import org.commscope.tr069adapter.acs.common.inform.ValueChangeInform;\r
import org.commscope.tr069adapter.mapper.MOMetaData;\r
import org.commscope.tr069adapter.mapper.MapperConfigProperties;\r
import org.commscope.tr069adapter.mapper.acs.ACSNotificationHandler;\r
+import org.commscope.tr069adapter.mapper.dao.DeviceOperationsDAO;\r
+import org.commscope.tr069adapter.mapper.entity.DeviceOperationDetails;\r
+import org.commscope.tr069adapter.mapper.model.NetConfNotificationDTO;\r
import org.commscope.tr069adapter.mapper.model.NetConfServerDetails;\r
import org.commscope.tr069adapter.mapper.model.NetconfServerManagementError;\r
import org.commscope.tr069adapter.mapper.netconf.NetConfNotificationSender;\r
import org.commscope.tr069adapter.mapper.netconf.NetConfServerManager;\r
import org.commscope.tr069adapter.mapper.sync.SynchronizedRequestHandler;\r
+import org.commscope.tr069adapter.mapper.util.FirwareUpgradeErrorCode;\r
+import org.commscope.tr069adapter.mapper.util.FirwareUpgradeStatus;\r
import org.commscope.tr069adapter.mapper.util.MOMetaDataUtil;\r
import org.commscope.tr069adapter.mapper.ves.VESNotificationSender;\r
import org.slf4j.Logger;\r
public class ACSNotificationHandlerImpl implements ACSNotificationHandler {\r
\r
private static final Logger logger = LoggerFactory.getLogger(ACSNotificationHandlerImpl.class);\r
+ private static final String SOFT_MGMT_NS_URI = "urn:o-ran:software-management:1.0";\r
\r
@Autowired\r
SynchronizedRequestHandler syncHandler;\r
@Autowired\r
NetConfServerManager netconfManager;\r
\r
+ @Autowired\r
+ DeviceOperationsDAO deviceOperDAO;\r
+\r
@Override\r
public void handleOperationResponse(DeviceRPCResponse opResult) {\r
opResult.getOperationResponse().setParameterDTOs(\r
if (notification instanceof BootstrapInform) {\r
logger.info("BootStrap notification received");\r
BootstrapInform bootstrapNotification = (BootstrapInform) notification;\r
+\r
+ DeviceOperationDetails deviceDetails =\r
+ deviceOperDAO.findByDeviceId(notification.getDeviceDetails().getDeviceId());\r
+ if (deviceDetails == null) {\r
+ deviceDetails = new DeviceOperationDetails();\r
+ deviceDetails.setDeviceId(notification.getDeviceDetails().getDeviceId());\r
+ deviceDetails.setSwVersion(notification.getDeviceDetails().getSoftwareVersion());\r
+ deviceOperDAO.save(deviceDetails);\r
+ }\r
+\r
+ checkForActivateNotification(notification);\r
+\r
// send request to create the netconf server instance for the bootstrap device\r
// id\r
NetConfServerDetails serverInfo = createNtConfServer(bootstrapNotification);\r
notiSender.sendNotification(bsInform);\r
} else if (notification instanceof BootInform) {\r
logger.info("Boot notification received");\r
+ checkForActivateNotification(notification);\r
BootInform bootNotification = (BootInform) notification;\r
BootInform bInform = getDeviceBootNotification(bootNotification, TR069InformType.BOOT);\r
if (bootNotification.getValueChangeNotification() != null) {\r
vesnotiSender.sendNotification(pINotificaiton, null);\r
notiSender.sendNotification(pINotificaiton);\r
logger.info("VC notification received");\r
+ } else if (notification instanceof ConnectionRequestInform) {\r
+ ConnectionRequestInform crNotificaiton = (ConnectionRequestInform) notification;\r
+ vesnotiSender.sendNotification(crNotificaiton, null);\r
+ logger.info("ConnectionRequestInform notification received");\r
} else if (notification instanceof ValueChangeInform) {\r
ValueChangeInform valueChgNotificaiton = (ValueChangeInform) notification;\r
processVCNotification(valueChgNotificaiton, isAlarmVC);\r
+ } else if (notification instanceof TransferCompleteInform) {\r
+ TransferCompleteInform tfNotificaiton = (TransferCompleteInform) notification;\r
+ if (tfNotificaiton.getCommandKey() != null && tfNotificaiton.getCommandKey()\r
+ .equalsIgnoreCase(tfNotificaiton.getDeviceDetails().getDeviceId())) {\r
+ logger.debug("TransferCompleteInform is recevied at mapper");\r
+ processTransferCompleteInform(tfNotificaiton);\r
+ logger.debug("TransferCompleteInform processing completed at mapper");\r
+ }\r
}\r
\r
pnpPreProvisioningHandler.onDeviceNotification(notification);\r
}\r
return isIPv6;\r
}\r
+\r
+ private void processTransferCompleteInform(TransferCompleteInform notification) {\r
+\r
+ try {\r
+ ArrayList<ParameterDTO> paramList = new ArrayList<ParameterDTO>();\r
+ DeviceOperationDetails fwDetails =\r
+ deviceOperDAO.findByDeviceId(notification.getDeviceDetails().getDeviceId());\r
+ if (fwDetails == null || fwDetails.getFileName() == null) {\r
+ logger.debug(\r
+ "TransferCompleteInform recevied for invaild device, there is no entry exist in the database");\r
+ return;\r
+ }\r
+ if (fwDetails.getDownLoadStatus() == FirwareUpgradeStatus.DOWNLOAD_INTIATED.getStatus()) {\r
+ paramList.add(new ParameterDTO("download-event.file-name", fwDetails.getFileName()));\r
+\r
+ String status = FirwareUpgradeErrorCode.getErrorCodeMapping(notification.getFaultCode());\r
+ paramList.add(new ParameterDTO("download-event.status", status));\r
+ if (notification.getFaultCode() != 0) {\r
+ fwDetails.setDownLoadStatus(FirwareUpgradeStatus.DOWNLOAD_FAILED.getStatus());\r
+ paramList\r
+ .add(new ParameterDTO("download-event.error-message", notification.getFaultString()));\r
+ } else {\r
+ fwDetails.setDownLoadStatus(FirwareUpgradeStatus.DOWNLOAD_COMPLETED.getStatus());\r
+ logger.debug("downloading file completed on the device successfully.");\r
+ }\r
+ 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
+ logger.debug("sending download-event notification to netconfserver sucess");\r
+ } else {\r
+ logger.error("sending download-event notification to netconfserver failed");\r
+ }\r
+ } else {\r
+ logger.debug(\r
+ "TransferCompleteInform recevied after boot is received; already software is activated");\r
+ }\r
+ } catch (Exception e) {\r
+ logger.debug("Exception occured while processing TransferCompleteInform " + e.toString());\r
+ }\r
+ }\r
+\r
+ private void checkForActivateNotification(DeviceInform notification) {\r
+\r
+ try {\r
+ ArrayList<ParameterDTO> paramList = new ArrayList<ParameterDTO>();\r
+ DeviceOperationDetails devDetails =\r
+ deviceOperDAO.findByDeviceId(notification.getDeviceDetails().getDeviceId());\r
+\r
+ if (devDetails == null\r
+ || devDetails.getDownLoadStatus() == FirwareUpgradeStatus.NOT_STARTED.getStatus()) {\r
+ logger.debug("firmware upgrade is not in progress");\r
+ return;\r
+ }\r
+\r
+ if (!notification.getDeviceDetails().getSoftwareVersion()\r
+ .equalsIgnoreCase(devDetails.getSwVersion())\r
+ && devDetails.getDownLoadStatus() == FirwareUpgradeStatus.DOWNLOAD_INTIATED.getStatus()) {\r
+ logger.debug("received the boot/bootstrap before the transfer complete recevied");\r
+ TransferCompleteInform inform = new TransferCompleteInform();\r
+ inform.setDeviceDetails(notification.getDeviceDetails());\r
+ inform.setFaultCode(0);\r
+ processTransferCompleteInform(inform);\r
+ }\r
+\r
+ devDetails = deviceOperDAO.findByDeviceId(notification.getDeviceDetails().getDeviceId());\r
+ if (devDetails.getDownLoadStatus() == FirwareUpgradeStatus.DOWNLOAD_COMPLETED.getStatus()) {\r
+ paramList.add(new ParameterDTO("activation-event.slot-name", "Active-Partion"));\r
+ // check for software change\r
+ if (notification.getDeviceDetails().getSoftwareVersion()\r
+ .equalsIgnoreCase(devDetails.getSwVersion())) {\r
+ paramList.add(new ParameterDTO("activation-event.status", "APPLICATION_ERROR"));\r
+ devDetails.setDownLoadStatus(FirwareUpgradeStatus.ACTIVATION_ERROR.getStatus());\r
+ } else {\r
+ devDetails.setSwVersion(notification.getDeviceDetails().getSoftwareVersion());\r
+ devDetails.setDownLoadStatus(FirwareUpgradeStatus.ACTIVATION_COMPLETED.getStatus());\r
+ paramList.add(new ParameterDTO("activation-event.status", "COMPLETED"));\r
+ }\r
+ 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
+ logger.debug("sending activation-event notification to netconfserver sucess");\r
+ } else {\r
+ logger.error("sending activation-event notification to netconfserver failed");\r
+ }\r
+ }\r
+ } catch (Exception e) {\r
+ logger.debug(\r
+ "Exception occured while processing ProcessFirmWareActivateNotification " + e.toString());\r
+ }\r
+ }\r
}\r