+ defer trans.Release()
+ xAppEventInstanceID = (int64)(subReqMsg.RequestId.Id)
+ xapp.Logger.Info("Handle SubscriptionRequest index=%v, %s", index, idstring(nil, trans))
+ subRespMsg, err := c.handleSubscriptionRequest(trans, &subReqMsg, meid, restSubId)
+ if err != nil {
+ // Send notification to xApp that prosessing of a Subscription Request has failed.
+ e2EventInstanceID = (int64)(0)
+ resp := &models.SubscriptionResponse{
+ SubscriptionID: restSubId,
+ SubscriptionInstances: []*models.SubscriptionInstance{
+ &models.SubscriptionInstance{E2EventInstanceID: &e2EventInstanceID,
+ ErrorCause: nil, //TODO: Suitable Error cause.
+ XappEventInstanceID: &xAppEventInstanceID},
+ },
+ }
+ // Mark REST subscription request processed.
+ restSubscription.SetProcessed()
+ xapp.Logger.Info("Sending unsuccessful REST notification to endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v, %s",
+ clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID, idstring(nil, trans))
+ xapp.Subscription.Notify(resp, *clientEndpoint)
+ c.UpdateCounter(cRestSubFailNotifToXapp)
+ } else {
+ e2EventInstanceID = (int64)(subRespMsg.RequestId.InstanceId)
+
+ xapp.Logger.Info("SubscriptionRequest index=%v processed successfully. endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v, %s",
+ index, clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID, idstring(nil, trans))
+
+ // Store successfully processed InstanceId for deletion
+ restSubscription.AddE2InstanceId(subRespMsg.RequestId.InstanceId)
+ restSubscription.AddXappIdToE2Id(xAppEventInstanceID, e2EventInstanceID)
+
+ // Send notification to xApp that a Subscription Request has been processed.
+ resp := &models.SubscriptionResponse{
+ SubscriptionID: restSubId,
+ SubscriptionInstances: []*models.SubscriptionInstance{
+ &models.SubscriptionInstance{E2EventInstanceID: &e2EventInstanceID,
+ ErrorCause: nil,
+ XappEventInstanceID: &xAppEventInstanceID},
+ },
+ }
+ // Mark REST subscription request processesd.
+ restSubscription.SetProcessed()
+ xapp.Logger.Info("Sending successful REST notification to endpoint=%v:%v, XappEventInstanceID=%v, E2EventInstanceID=%v, %s",
+ clientEndpoint.Host, *clientEndpoint.HTTPPort, xAppEventInstanceID, e2EventInstanceID, idstring(nil, trans))
+ xapp.Subscription.Notify(resp, *clientEndpoint)
+ c.UpdateCounter(cRestSubNotifToXapp)
+
+ }
+ }