[RICPLT-2727] Update RoutingMangaerClient UTs + others....
[ric-plt/e2mgr.git] / E2Manager / handlers / rmrmsghandlers / e2_term_init_notification_handler.go
index fd2ec81..55cd6b5 100644 (file)
@@ -22,6 +22,7 @@ import (
        "e2mgr/managers"
        "e2mgr/models"
        "e2mgr/services"
+       "encoding/json"
        "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/common"
 )
 
@@ -42,10 +43,22 @@ func NewE2TermInitNotificationHandler(logger *logger.Logger, ranReconnectionMana
 }
 
 func (h E2TermInitNotificationHandler) Handle(request *models.NotificationRequest) {
+       unmarshalledPayload := models.E2TermInitPayload{}
+       err :=  json.Unmarshal(request.Payload, &unmarshalledPayload)
 
-       h.logger.Infof("#E2TermInitNotificationHandler.Handle - Handling E2_TERM_INIT")
+       if err != nil {
+               h.logger.Errorf("#E2TermInitNotificationHandler.Handle - Error unmarshaling E2 Term Init payload: %s", err)
+               return
+       }
+
+       e2tAddress := unmarshalledPayload.Address
+
+       if len(e2tAddress) == 0 {
+               h.logger.Errorf("#E2TermInitNotificationHandler.Handle - Empty E2T address received")
+               return
+       }
 
-       e2tAddress := string(request.Payload) // TODO: make sure E2T sends this as the only value of the message
+       h.logger.Infof("#E2TermInitNotificationHandler.Handle - E2T address: %s - handling E2_TERM_INIT", e2tAddress)
 
        e2tInstance, err := h.e2tInstancesManager.GetE2TInstance(e2tAddress)