Commit 899bd5aa authored by Ikram Haq's avatar Ikram Haq
Browse files

Fix CallbackReferance issue in zone_location_event_subscription

parent 63ce6775
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -163,6 +163,21 @@ func convertJsonToZonalSubscription(jsonInfo string) *ZonalTrafficSubscription {
	return &zonal
}

func convertJsonToZonalSubscription_1(jsonInfo string) *ZoneLocationEventSubscription {

	if jsonInfo == "" {
		return nil
	}

	var zonal ZoneLocationEventSubscription
	err := json.Unmarshal([]byte(jsonInfo), &zonal)
	if err != nil {
		log.Error(err.Error())
		return nil
	}
	return &zonal
}

func convertUserSubscriptionToJson1(userSubs *UserLocationEventSubscription) string {

	jsonInfo, err := json.Marshal(*userSubs)
+6 −10
Original line number Diff line number Diff line
@@ -2033,7 +2033,7 @@ func checkNotificationRegisteredZones1(oldZoneId string, newZoneId string, oldAp

					jsonInfo, _ := rc.JSONGetEntry(baseKey+typeZonalSubscription+":"+subsIdStr, ".")
					if jsonInfo != "" {
						subscription := convertJsonToZonalSubscription(jsonInfo)
						subscription := convertJsonToZonalSubscription_1(jsonInfo)

						var zonal ZoneLocationEventNotification
						zonal.ZoneId = newZoneId
@@ -2046,11 +2046,9 @@ func checkNotificationRegisteredZones1(oldZoneId string, newZoneId string, oldAp
						var timestamp TimeStamp
						timestamp.Seconds = int32(seconds)
						zonal.TimeStamp = &timestamp
						zonal.CallbackData = subscription.CallbackReference.CallbackData
						var inlineZonal InlineZoneLocationEventNotification
						inlineZonal.ZoneLocationEventNotification = &zonal
						// sendZonalPresenceNotification(subscription.CallbackReference.NotifyURL, inlineZonal)
						sendZonalPresenceNotification_L(subscription.CallbackReference.NotifyURL, inlineZonal)
						sendZonalPresenceNotification_L(subscription.CallbackReference, inlineZonal)
						log.Info("Zonal Notify Entering event in zone " + newZoneId + " for user " + userId)
					}
				}
@@ -2063,11 +2061,10 @@ func checkNotificationRegisteredZones1(oldZoneId string, newZoneId string, oldAp
					jsonInfo, _ := rc.JSONGetEntry(baseKey+typeZonalSubscription+":"+subsIdStr, ".")
					if jsonInfo != "" {

						subscription := convertJsonToZonalSubscription(jsonInfo)
						subscription := convertJsonToZonalSubscription_1(jsonInfo)

						var zonal ZoneLocationEventNotification
						zonal.ZoneId = oldZoneId
						// zonal.CurrentAccessPointId = oldApId
						zonal.Address = userId
						event := new(LocationEventType)
						*event = LEAVING_AREA_EVENT
@@ -2076,10 +2073,9 @@ func checkNotificationRegisteredZones1(oldZoneId string, newZoneId string, oldAp
						var timestamp TimeStamp
						timestamp.Seconds = int32(seconds)
						zonal.TimeStamp = &timestamp
						zonal.CallbackData = subscription.CallbackReference.CallbackData
						var inlineZonal InlineZoneLocationEventNotification
						inlineZonal.ZoneLocationEventNotification = &zonal
						sendZonalPresenceNotification_L(subscription.CallbackReference.NotifyURL, inlineZonal)
						sendZonalPresenceNotification_L(subscription.CallbackReference, inlineZonal)
						log.Info("Zonal Notify Leaving event in zone " + oldZoneId + " for user " + userId)
					}
				}
@@ -4046,7 +4042,7 @@ func handlezoneLocationEventSubscriptionPut(w http.ResponseWriter, requestBody [
			}

			//checking for mandatory properties
			if userSubBody.CallbackReference == nil || userSubBody.CallbackReference.NotifyURL == "" {
			if userSubBody.CallbackReference == "" {
				log.Error("Mandatory CallbackReference parameter not present")
				errHandlerProblemDetails(w, "Mandatory CallbackReference parameter not present", http.StatusBadRequest)
				return
@@ -4917,7 +4913,7 @@ func handleZoneLocationEventSubscription(w http.ResponseWriter, requestBody []ma
				return
			}
			//checking for mandatory properties
			if zonalSub.CallbackReference == nil || zonalSub.CallbackReference.NotifyURL == "" {
			if zonalSub.CallbackReference == "" {
				log.Error("Mandatory CallbackReference parameter not present")
				errHandlerProblemDetails(w, "Mandatory CallbackReference parameter not present", http.StatusBadRequest)
				return
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ type ZoneLocationEventSubscription struct {
	// List of the users to be monitored. If not present, all the users need to be monitored.
	AddressList []string `json:"addressList,omitempty"`
	// URI exposed by the client on which to receive notifications via HTTP. See note 1.
	CallbackReference *CallbackReference `json:"callbackReference,omitempty"`
	CallbackReference string `json:"callbackReference,omitempty"`
	// A correlator that the client can use to tag this particular resource representation during a request to create a resource on the server. See note 2.
	ClientCorrelator string `json:"clientCorrelator,omitempty"`