Loading go-apps/meep-loc-serv/server/loc-serv.go +220 −115 Original line number Diff line number Diff line Loading @@ -453,14 +453,14 @@ func usersGet(w http.ResponseWriter, r *http.Request) { zoneIdVar := q.Get("zoneId") accessPointIdVar := q.Get("accessPointId") var response InlineResponse2007 var userList UserList response.UserList = &userList _ = rc.JSONGetList(zoneIdVar, accessPointIdVar, moduleLocServ+":"+typeUser+":", populateUserList, &userList) userList.ResourceURL = basepathURL + "users" jsonResponse, err := json.Marshal(userList) jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) Loading Loading @@ -504,20 +504,33 @@ func populateUserList(key string, jsonInfo string, zoneId string, apId string, u func usersGetById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) jsonInfo, _ := rc.JSONGetEntry(moduleLocServ+":"+typeUser+":"+vars["userId"], ".") if jsonInfo != "" { fmt.Fprintf(w, jsonInfo) var response InlineResponse2008 var userInfo UserInfo response.UserInfo = &userInfo } else { jsonUserInfo, _ := rc.JSONGetEntry(moduleLocServ+":"+typeUser+":"+vars["userId"], ".") if jsonUserInfo == "" { w.WriteHeader(http.StatusNotFound) return } err := json.Unmarshal([]byte(jsonUserInfo), &userInfo) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) fmt.Fprintf(w, string(jsonResponse)) } func zonesByIdGetAps(w http.ResponseWriter, r *http.Request) { Loading @@ -527,17 +540,17 @@ func zonesByIdGetAps(w http.ResponseWriter, r *http.Request) { q := u.Query() interestRealm := q.Get("interestRealm") var response InlineResponse2005 var apList AccessPointList response.AccessPointList = &apList vars := mux.Vars(r) _ = rc.JSONGetList(interestRealm, "", moduleLocServ+":"+typeZone+":"+vars["zoneId"], populateApList, &apList) apList.ZoneId = vars["zoneId"] apList.ResourceURL = basepathURL + "zones/" + vars["zoneId"] + "/accessPoints" jsonResponse, err := json.Marshal(apList) jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) Loading @@ -549,32 +562,46 @@ func zonesByIdGetAps(w http.ResponseWriter, r *http.Request) { func zonesByIdGetApsById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) jsonInfo, _ := rc.JSONGetEntry(moduleLocServ+":"+typeZone+":"+vars["zoneId"]+":"+typeAccessPoint+":"+vars["accessPointId"], ".") if jsonInfo != "" { fmt.Fprintf(w, jsonInfo) var response InlineResponse2006 var apInfo AccessPointInfo response.AccessPointInfo = &apInfo } else { jsonApInfo, _ := rc.JSONGetEntry(moduleLocServ+":"+typeZone+":"+vars["zoneId"]+":"+typeAccessPoint+":"+vars["accessPointId"], ".") if jsonApInfo == "" { w.WriteHeader(http.StatusNotFound) return } err := json.Unmarshal([]byte(jsonApInfo), &apInfo) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) fmt.Fprintf(w, string(jsonResponse)) } func zonesGet(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") var response InlineResponse2003 var zoneList ZoneList response.ZoneList = &zoneList _ = rc.JSONGetList("", "", moduleLocServ+":"+typeZone+":", populateZoneList, &zoneList) zoneList.ResourceURL = basepathURL + "zones" jsonResponse, err := json.Marshal(zoneList) jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) Loading @@ -586,20 +613,33 @@ func zonesGet(w http.ResponseWriter, r *http.Request) { func zonesGetById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) jsonInfo, _ := rc.JSONGetEntry(moduleLocServ+":"+typeZone+":"+vars["zoneId"], ".") if jsonInfo != "" { fmt.Fprintf(w, jsonInfo) var response InlineResponse2004 var zoneInfo ZoneInfo response.ZoneInfo = &zoneInfo } else { jsonZoneInfo, _ := rc.JSONGetEntry(moduleLocServ+":"+typeZone+":"+vars["zoneId"], ".") if jsonZoneInfo == "" { w.WriteHeader(http.StatusNotFound) return } err := json.Unmarshal([]byte(jsonZoneInfo), &zoneInfo) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) fmt.Fprintf(w, string(jsonResponse)) } func populateZoneList(key string, jsonInfo string, dummy1 string, dummy2 string, userData interface{}) error { Loading Loading @@ -646,7 +686,6 @@ func populateApList(key string, jsonInfo string, interestRealm string, dummy str func userTrackingSubDelById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) err := rc.JSONDelEntry(moduleLocServ+":"+typeUserSubscription+":"+vars["subscriptionId"], ".") Loading @@ -656,20 +695,21 @@ func userTrackingSubDelById(w http.ResponseWriter, r *http.Request) { } deregisterUser(vars["subscriptionId"]) w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusNoContent) } func userTrackingSubGet(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") var userList InlineResponse2001NotificationSubscriptionList var response InlineResponse2001 var userTrackingSubList InlineResponse2001NotificationSubscriptionList response.NotificationSubscriptionList = &userTrackingSubList _ = rc.JSONGetList("", "", moduleLocServ+":"+typeUserSubscription, populateUserTrackingList, &userList) _ = rc.JSONGetList("", "", moduleLocServ+":"+typeUserSubscription, populateUserTrackingList, &userTrackingSubList) userList.ResourceURL = basepathURL + "subscriptions/userTracking" jsonResponse, err := json.Marshal(userList) userTrackingSubList.ResourceURL = basepathURL + "subscriptions/userTracking" jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) Loading @@ -681,31 +721,44 @@ func userTrackingSubGet(w http.ResponseWriter, r *http.Request) { func userTrackingSubGetById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) jsonInfo, _ := rc.JSONGetEntry(moduleLocServ+":"+typeUserSubscription+":"+vars["subscriptionId"], ".") if jsonInfo != "" { fmt.Fprintf(w, jsonInfo) var response InlineResponse2011 var userTrackingSub UserTrackingSubscription response.UserTrackingSubscription = &userTrackingSub } else { jsonUserTrackingSub, _ := rc.JSONGetEntry(moduleLocServ+":"+typeUserSubscription+":"+vars["subscriptionId"], ".") if jsonUserTrackingSub == "" { w.WriteHeader(http.StatusNotFound) return } err := json.Unmarshal([]byte(jsonUserTrackingSub), &userTrackingSub) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) fmt.Fprintf(w, string(jsonResponse)) } func userTrackingSubPost(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") subs := new(UserTrackingSubscription) var response InlineResponse2011 userTrackingSub := new(UserTrackingSubscription) response.UserTrackingSubscription = userTrackingSub decoder := json.NewDecoder(r.Body) err := decoder.Decode(&subs) err := decoder.Decode(&userTrackingSub) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) Loading @@ -715,47 +768,54 @@ func userTrackingSubPost(w http.ResponseWriter, r *http.Request) { newSubsId := nextUserSubscriptionIdAvailable nextUserSubscriptionIdAvailable++ subsIdStr := strconv.Itoa(newSubsId) registerUser(subs.Address, subs.UserEventCriteria, subsIdStr) subs.ResourceURL = basepathURL + "subscriptions/userTracking/" + subsIdStr _ = rc.JSONSetEntry(moduleLocServ+":"+typeUserSubscription+":"+subsIdStr, ".", convertUserSubscriptionToJson(subs)) registerUser(userTrackingSub.Address, userTrackingSub.UserEventCriteria, subsIdStr) userTrackingSub.ResourceURL = basepathURL + "subscriptions/userTracking/" + subsIdStr _ = rc.JSONSetEntry(moduleLocServ+":"+typeUserSubscription+":"+subsIdStr, ".", convertUserSubscriptionToJson(userTrackingSub)) jsonResponse, err := json.Marshal(subs) jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusCreated) fmt.Fprintf(w, string(jsonResponse)) } func userTrackingSubPutById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) subs := new(UserTrackingSubscription) var response InlineResponse2011 userTrackingSub := new(UserTrackingSubscription) response.UserTrackingSubscription = userTrackingSub decoder := json.NewDecoder(r.Body) err := decoder.Decode(&subs) err := decoder.Decode(&userTrackingSub) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } subsIdStr := vars["subscriptionId"] subs.ResourceURL = basepathURL + "subscriptions/userTracking/" + subsIdStr userTrackingSub.ResourceURL = basepathURL + "subscriptions/userTracking/" + subsIdStr _ = rc.JSONSetEntry(moduleLocServ+":"+typeUserSubscription+":"+subsIdStr, ".", convertUserSubscriptionToJson(subs)) _ = rc.JSONSetEntry(moduleLocServ+":"+typeUserSubscription+":"+subsIdStr, ".", convertUserSubscriptionToJson(userTrackingSub)) deregisterUser(subsIdStr) registerUser(subs.Address, subs.UserEventCriteria, subsIdStr) registerUser(userTrackingSub.Address, userTrackingSub.UserEventCriteria, subsIdStr) jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) fmt.Fprintf(w, string(jsonResponse)) } func populateUserTrackingList(key string, jsonInfo string, dummy1 string, dummy2 string, userData interface{}) error { Loading @@ -774,7 +834,6 @@ func populateUserTrackingList(key string, jsonInfo string, dummy1 string, dummy2 func zonalTrafficSubDelById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) err := rc.JSONDelEntry(moduleLocServ+":"+typeZonalSubscription+":"+vars["subscriptionId"], ".") Loading @@ -784,19 +843,20 @@ func zonalTrafficSubDelById(w http.ResponseWriter, r *http.Request) { } deregisterZonal(vars["subscriptionId"]) w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusNoContent) } func zonalTrafficSubGet(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") var zoneList InlineResponse200NotificationSubscriptionList _ = rc.JSONGetList("", "", moduleLocServ+":"+typeZonalSubscription, populateZonalTrafficList, &zoneList) var response InlineResponse200 var zonalTrafficSubList InlineResponse200NotificationSubscriptionList response.NotificationSubscriptionList = &zonalTrafficSubList zoneList.ResourceURL = basepathURL + "subcription/zonalTraffic" jsonResponse, err := json.Marshal(zoneList) _ = rc.JSONGetList("", "", moduleLocServ+":"+typeZonalSubscription, populateZonalTrafficList, &zonalTrafficSubList) zonalTrafficSubList.ResourceURL = basepathURL + "subcription/zonalTraffic" jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) Loading @@ -808,30 +868,44 @@ func zonalTrafficSubGet(w http.ResponseWriter, r *http.Request) { func zonalTrafficSubGetById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) jsonInfo, _ := rc.JSONGetEntry(moduleLocServ+":"+typeZonalSubscription+":"+vars["subscriptionId"], ".") if jsonInfo != "" { fmt.Fprintf(w, jsonInfo) var response InlineResponse201 var zonalTrafficSub ZonalTrafficSubscription response.ZonalTrafficSubscription = &zonalTrafficSub } else { jsonZonalTrafficSub, _ := rc.JSONGetEntry(moduleLocServ+":"+typeZonalSubscription+":"+vars["subscriptionId"], ".") if jsonZonalTrafficSub == "" { w.WriteHeader(http.StatusNotFound) return } err := json.Unmarshal([]byte(jsonZonalTrafficSub), &zonalTrafficSub) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) fmt.Fprintf(w, string(jsonResponse)) } func zonalTrafficSubPost(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") subs := new(ZonalTrafficSubscription) var response InlineResponse201 zonalTrafficSub := new(ZonalTrafficSubscription) response.ZonalTrafficSubscription = zonalTrafficSub decoder := json.NewDecoder(r.Body) err := decoder.Decode(&subs) err := decoder.Decode(&zonalTrafficSub) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) Loading @@ -842,45 +916,43 @@ func zonalTrafficSubPost(w http.ResponseWriter, r *http.Request) { nextZonalSubscriptionIdAvailable++ subsIdStr := strconv.Itoa(newSubsId) /* if subs.Duration > 0 { if zonalTrafficSub.Duration > 0 { //TODO start a timer mecanism and expire subscription } //else, lasts forever or until subscription is deleted */ if subs.Duration != "" && subs.Duration != "0" { if zonalTrafficSub.Duration != "" && zonalTrafficSub.Duration != "0" { //TODO start a timer mecanism and expire subscription log.Info("Non zero duration") } //else, lasts forever or until subscription is deleted subs.ResourceURL = basepathURL + "subscriptions/zonalTraffic/" + subsIdStr zonalTrafficSub.ResourceURL = basepathURL + "subscriptions/zonalTraffic/" + subsIdStr _ = rc.JSONSetEntry(moduleLocServ+":"+typeZonalSubscription+":"+subsIdStr, ".", convertZonalSubscriptionToJson(subs)) _ = rc.JSONSetEntry(moduleLocServ+":"+typeZonalSubscription+":"+subsIdStr, ".", convertZonalSubscriptionToJson(zonalTrafficSub)) registerZonal(subs.ZoneId, subs.UserEventCriteria, subsIdStr) registerZonal(zonalTrafficSub.ZoneId, zonalTrafficSub.UserEventCriteria, subsIdStr) jsonResponse, err := json.Marshal(subs) jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusCreated) fmt.Fprintf(w, string(jsonResponse)) } func zonalTrafficSubPutById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) subs := new(ZonalTrafficSubscription) var response InlineResponse201 zonalTrafficSub := new(ZonalTrafficSubscription) response.ZonalTrafficSubscription = zonalTrafficSub decoder := json.NewDecoder(r.Body) err := decoder.Decode(&subs) err := decoder.Decode(&zonalTrafficSub) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) Loading @@ -888,14 +960,21 @@ func zonalTrafficSubPutById(w http.ResponseWriter, r *http.Request) { } subsIdStr := vars["subscriptionId"] subs.ResourceURL = basepathURL + "subscriptions/zonalTraffic/" + subsIdStr zonalTrafficSub.ResourceURL = basepathURL + "subscriptions/zonalTraffic/" + subsIdStr _ = rc.JSONSetEntry(moduleLocServ+":"+typeZonalSubscription+":"+subsIdStr, ".", convertZonalSubscriptionToJson(subs)) _ = rc.JSONSetEntry(moduleLocServ+":"+typeZonalSubscription+":"+subsIdStr, ".", convertZonalSubscriptionToJson(zonalTrafficSub)) deregisterZonal(subsIdStr) registerZonal(subs.ZoneId, subs.UserEventCriteria, subsIdStr) registerZonal(zonalTrafficSub.ZoneId, zonalTrafficSub.UserEventCriteria, subsIdStr) jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) fmt.Fprintf(w, string(jsonResponse)) } func populateZonalTrafficList(key string, jsonInfo string, dummy1 string, dummy2 string, userData interface{}) error { Loading Loading @@ -923,20 +1002,21 @@ func zoneStatusDelById(w http.ResponseWriter, r *http.Request) { } deregisterZoneStatus(vars["subscriptionId"]) w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusNoContent) } func zoneStatusGet(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") var zoneList InlineResponse2002NotificationSubscriptionList var response InlineResponse2002 var zoneStatusSubList InlineResponse2002NotificationSubscriptionList response.NotificationSubscriptionList = &zoneStatusSubList _ = rc.JSONGetList("", "", moduleLocServ+":"+typeZoneStatusSubscription, populateZoneStatusList, &zoneList) _ = rc.JSONGetList("", "", moduleLocServ+":"+typeZoneStatusSubscription, populateZoneStatusList, &zoneStatusSubList) zoneList.ResourceURL = basepathURL + "subscription/zoneStatus" jsonResponse, err := json.Marshal(zoneList) zoneStatusSubList.ResourceURL = basepathURL + "subscription/zoneStatus" jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) Loading @@ -950,26 +1030,42 @@ func zoneStatusGetById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) jsonInfo, _ := rc.JSONGetEntry(moduleLocServ+":"+typeZoneStatusSubscription+":"+vars["subscriptionId"], ".") if jsonInfo != "" { fmt.Fprintf(w, jsonInfo) var response InlineResponse20012 var zoneStatusSub ZoneStatusSubscription response.ZoneStatusSubscription = &zoneStatusSub } else { jsonZoneStatusSub, _ := rc.JSONGetEntry(moduleLocServ+":"+typeZoneStatusSubscription+":"+vars["subscriptionId"], ".") if jsonZoneStatusSub == "" { w.WriteHeader(http.StatusNotFound) return } err := json.Unmarshal([]byte(jsonZoneStatusSub), &zoneStatusSub) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) fmt.Fprintf(w, string(jsonResponse)) } func zoneStatusPost(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") subs := new(ZoneStatusSubscription) decoder := json.NewDecoder(r.Body) err := decoder.Decode(&subs) var response InlineResponse2012 zoneStatusSub := new(ZoneStatusSubscription) response.ZonalTrafficSubscription = zoneStatusSub decoder := json.NewDecoder(r.Body) err := decoder.Decode(&zoneStatusSub) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) Loading @@ -980,20 +1076,20 @@ func zoneStatusPost(w http.ResponseWriter, r *http.Request) { nextZoneStatusSubscriptionIdAvailable++ subsIdStr := strconv.Itoa(newSubsId) subs.ResourceURL = basepathURL + "subscriptions/zoneStatus/" + subsIdStr zoneStatusSub.ResourceURL = basepathURL + "subscriptions/zoneStatus/" + subsIdStr _ = rc.JSONSetEntry(moduleLocServ+":"+typeZoneStatusSubscription+":"+subsIdStr, ".", convertZoneStatusSubscriptionToJson(subs)) _ = rc.JSONSetEntry(moduleLocServ+":"+typeZoneStatusSubscription+":"+subsIdStr, ".", convertZoneStatusSubscriptionToJson(zoneStatusSub)) registerZoneStatus(subs.ZoneId, subs.NumberOfUsersZoneThreshold, subs.NumberOfUsersAPThreshold, subs.OperationStatus, subsIdStr) registerZoneStatus(zoneStatusSub.ZoneId, zoneStatusSub.NumberOfUsersZoneThreshold, zoneStatusSub.NumberOfUsersAPThreshold, zoneStatusSub.OperationStatus, subsIdStr) jsonResponse, err := json.Marshal(subs) jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusCreated) fmt.Fprintf(w, string(jsonResponse)) } Loading @@ -1001,11 +1097,12 @@ func zoneStatusPutById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) subs := new(ZoneStatusSubscription) var response InlineResponse20012 zoneStatusSub := new(ZoneStatusSubscription) response.ZoneStatusSubscription = zoneStatusSub decoder := json.NewDecoder(r.Body) err := decoder.Decode(&subs) err := decoder.Decode(&zoneStatusSub) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) Loading @@ -1013,14 +1110,22 @@ func zoneStatusPutById(w http.ResponseWriter, r *http.Request) { } subsIdStr := vars["subscriptionId"] subs.ResourceURL = basepathURL + "subscriptions/zoneStatus/" + subsIdStr zoneStatusSub.ResourceURL = basepathURL + "subscriptions/zoneStatus/" + subsIdStr _ = rc.JSONSetEntry(moduleLocServ+":"+typeZoneStatusSubscription+":"+subsIdStr, ".", convertZoneStatusSubscriptionToJson(subs)) _ = rc.JSONSetEntry(moduleLocServ+":"+typeZoneStatusSubscription+":"+subsIdStr, ".", convertZoneStatusSubscriptionToJson(zoneStatusSub)) deregisterZoneStatus(subsIdStr) registerZoneStatus(subs.ZoneId, subs.NumberOfUsersZoneThreshold, subs.NumberOfUsersAPThreshold, subs.OperationStatus, subsIdStr) registerZoneStatus(zoneStatusSub.ZoneId, zoneStatusSub.NumberOfUsersZoneThreshold, zoneStatusSub.NumberOfUsersAPThreshold, zoneStatusSub.OperationStatus, subsIdStr) jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) fmt.Fprintf(w, string(jsonResponse)) } func populateZoneStatusList(key string, jsonInfo string, dummy1 string, dummy2 string, userData interface{}) error { Loading Loading
go-apps/meep-loc-serv/server/loc-serv.go +220 −115 Original line number Diff line number Diff line Loading @@ -453,14 +453,14 @@ func usersGet(w http.ResponseWriter, r *http.Request) { zoneIdVar := q.Get("zoneId") accessPointIdVar := q.Get("accessPointId") var response InlineResponse2007 var userList UserList response.UserList = &userList _ = rc.JSONGetList(zoneIdVar, accessPointIdVar, moduleLocServ+":"+typeUser+":", populateUserList, &userList) userList.ResourceURL = basepathURL + "users" jsonResponse, err := json.Marshal(userList) jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) Loading Loading @@ -504,20 +504,33 @@ func populateUserList(key string, jsonInfo string, zoneId string, apId string, u func usersGetById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) jsonInfo, _ := rc.JSONGetEntry(moduleLocServ+":"+typeUser+":"+vars["userId"], ".") if jsonInfo != "" { fmt.Fprintf(w, jsonInfo) var response InlineResponse2008 var userInfo UserInfo response.UserInfo = &userInfo } else { jsonUserInfo, _ := rc.JSONGetEntry(moduleLocServ+":"+typeUser+":"+vars["userId"], ".") if jsonUserInfo == "" { w.WriteHeader(http.StatusNotFound) return } err := json.Unmarshal([]byte(jsonUserInfo), &userInfo) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) fmt.Fprintf(w, string(jsonResponse)) } func zonesByIdGetAps(w http.ResponseWriter, r *http.Request) { Loading @@ -527,17 +540,17 @@ func zonesByIdGetAps(w http.ResponseWriter, r *http.Request) { q := u.Query() interestRealm := q.Get("interestRealm") var response InlineResponse2005 var apList AccessPointList response.AccessPointList = &apList vars := mux.Vars(r) _ = rc.JSONGetList(interestRealm, "", moduleLocServ+":"+typeZone+":"+vars["zoneId"], populateApList, &apList) apList.ZoneId = vars["zoneId"] apList.ResourceURL = basepathURL + "zones/" + vars["zoneId"] + "/accessPoints" jsonResponse, err := json.Marshal(apList) jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) Loading @@ -549,32 +562,46 @@ func zonesByIdGetAps(w http.ResponseWriter, r *http.Request) { func zonesByIdGetApsById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) jsonInfo, _ := rc.JSONGetEntry(moduleLocServ+":"+typeZone+":"+vars["zoneId"]+":"+typeAccessPoint+":"+vars["accessPointId"], ".") if jsonInfo != "" { fmt.Fprintf(w, jsonInfo) var response InlineResponse2006 var apInfo AccessPointInfo response.AccessPointInfo = &apInfo } else { jsonApInfo, _ := rc.JSONGetEntry(moduleLocServ+":"+typeZone+":"+vars["zoneId"]+":"+typeAccessPoint+":"+vars["accessPointId"], ".") if jsonApInfo == "" { w.WriteHeader(http.StatusNotFound) return } err := json.Unmarshal([]byte(jsonApInfo), &apInfo) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) fmt.Fprintf(w, string(jsonResponse)) } func zonesGet(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") var response InlineResponse2003 var zoneList ZoneList response.ZoneList = &zoneList _ = rc.JSONGetList("", "", moduleLocServ+":"+typeZone+":", populateZoneList, &zoneList) zoneList.ResourceURL = basepathURL + "zones" jsonResponse, err := json.Marshal(zoneList) jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) Loading @@ -586,20 +613,33 @@ func zonesGet(w http.ResponseWriter, r *http.Request) { func zonesGetById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) jsonInfo, _ := rc.JSONGetEntry(moduleLocServ+":"+typeZone+":"+vars["zoneId"], ".") if jsonInfo != "" { fmt.Fprintf(w, jsonInfo) var response InlineResponse2004 var zoneInfo ZoneInfo response.ZoneInfo = &zoneInfo } else { jsonZoneInfo, _ := rc.JSONGetEntry(moduleLocServ+":"+typeZone+":"+vars["zoneId"], ".") if jsonZoneInfo == "" { w.WriteHeader(http.StatusNotFound) return } err := json.Unmarshal([]byte(jsonZoneInfo), &zoneInfo) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) fmt.Fprintf(w, string(jsonResponse)) } func populateZoneList(key string, jsonInfo string, dummy1 string, dummy2 string, userData interface{}) error { Loading Loading @@ -646,7 +686,6 @@ func populateApList(key string, jsonInfo string, interestRealm string, dummy str func userTrackingSubDelById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) err := rc.JSONDelEntry(moduleLocServ+":"+typeUserSubscription+":"+vars["subscriptionId"], ".") Loading @@ -656,20 +695,21 @@ func userTrackingSubDelById(w http.ResponseWriter, r *http.Request) { } deregisterUser(vars["subscriptionId"]) w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusNoContent) } func userTrackingSubGet(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") var userList InlineResponse2001NotificationSubscriptionList var response InlineResponse2001 var userTrackingSubList InlineResponse2001NotificationSubscriptionList response.NotificationSubscriptionList = &userTrackingSubList _ = rc.JSONGetList("", "", moduleLocServ+":"+typeUserSubscription, populateUserTrackingList, &userList) _ = rc.JSONGetList("", "", moduleLocServ+":"+typeUserSubscription, populateUserTrackingList, &userTrackingSubList) userList.ResourceURL = basepathURL + "subscriptions/userTracking" jsonResponse, err := json.Marshal(userList) userTrackingSubList.ResourceURL = basepathURL + "subscriptions/userTracking" jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) Loading @@ -681,31 +721,44 @@ func userTrackingSubGet(w http.ResponseWriter, r *http.Request) { func userTrackingSubGetById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) jsonInfo, _ := rc.JSONGetEntry(moduleLocServ+":"+typeUserSubscription+":"+vars["subscriptionId"], ".") if jsonInfo != "" { fmt.Fprintf(w, jsonInfo) var response InlineResponse2011 var userTrackingSub UserTrackingSubscription response.UserTrackingSubscription = &userTrackingSub } else { jsonUserTrackingSub, _ := rc.JSONGetEntry(moduleLocServ+":"+typeUserSubscription+":"+vars["subscriptionId"], ".") if jsonUserTrackingSub == "" { w.WriteHeader(http.StatusNotFound) return } err := json.Unmarshal([]byte(jsonUserTrackingSub), &userTrackingSub) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) fmt.Fprintf(w, string(jsonResponse)) } func userTrackingSubPost(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") subs := new(UserTrackingSubscription) var response InlineResponse2011 userTrackingSub := new(UserTrackingSubscription) response.UserTrackingSubscription = userTrackingSub decoder := json.NewDecoder(r.Body) err := decoder.Decode(&subs) err := decoder.Decode(&userTrackingSub) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) Loading @@ -715,47 +768,54 @@ func userTrackingSubPost(w http.ResponseWriter, r *http.Request) { newSubsId := nextUserSubscriptionIdAvailable nextUserSubscriptionIdAvailable++ subsIdStr := strconv.Itoa(newSubsId) registerUser(subs.Address, subs.UserEventCriteria, subsIdStr) subs.ResourceURL = basepathURL + "subscriptions/userTracking/" + subsIdStr _ = rc.JSONSetEntry(moduleLocServ+":"+typeUserSubscription+":"+subsIdStr, ".", convertUserSubscriptionToJson(subs)) registerUser(userTrackingSub.Address, userTrackingSub.UserEventCriteria, subsIdStr) userTrackingSub.ResourceURL = basepathURL + "subscriptions/userTracking/" + subsIdStr _ = rc.JSONSetEntry(moduleLocServ+":"+typeUserSubscription+":"+subsIdStr, ".", convertUserSubscriptionToJson(userTrackingSub)) jsonResponse, err := json.Marshal(subs) jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusCreated) fmt.Fprintf(w, string(jsonResponse)) } func userTrackingSubPutById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) subs := new(UserTrackingSubscription) var response InlineResponse2011 userTrackingSub := new(UserTrackingSubscription) response.UserTrackingSubscription = userTrackingSub decoder := json.NewDecoder(r.Body) err := decoder.Decode(&subs) err := decoder.Decode(&userTrackingSub) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } subsIdStr := vars["subscriptionId"] subs.ResourceURL = basepathURL + "subscriptions/userTracking/" + subsIdStr userTrackingSub.ResourceURL = basepathURL + "subscriptions/userTracking/" + subsIdStr _ = rc.JSONSetEntry(moduleLocServ+":"+typeUserSubscription+":"+subsIdStr, ".", convertUserSubscriptionToJson(subs)) _ = rc.JSONSetEntry(moduleLocServ+":"+typeUserSubscription+":"+subsIdStr, ".", convertUserSubscriptionToJson(userTrackingSub)) deregisterUser(subsIdStr) registerUser(subs.Address, subs.UserEventCriteria, subsIdStr) registerUser(userTrackingSub.Address, userTrackingSub.UserEventCriteria, subsIdStr) jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) fmt.Fprintf(w, string(jsonResponse)) } func populateUserTrackingList(key string, jsonInfo string, dummy1 string, dummy2 string, userData interface{}) error { Loading @@ -774,7 +834,6 @@ func populateUserTrackingList(key string, jsonInfo string, dummy1 string, dummy2 func zonalTrafficSubDelById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) err := rc.JSONDelEntry(moduleLocServ+":"+typeZonalSubscription+":"+vars["subscriptionId"], ".") Loading @@ -784,19 +843,20 @@ func zonalTrafficSubDelById(w http.ResponseWriter, r *http.Request) { } deregisterZonal(vars["subscriptionId"]) w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusNoContent) } func zonalTrafficSubGet(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") var zoneList InlineResponse200NotificationSubscriptionList _ = rc.JSONGetList("", "", moduleLocServ+":"+typeZonalSubscription, populateZonalTrafficList, &zoneList) var response InlineResponse200 var zonalTrafficSubList InlineResponse200NotificationSubscriptionList response.NotificationSubscriptionList = &zonalTrafficSubList zoneList.ResourceURL = basepathURL + "subcription/zonalTraffic" jsonResponse, err := json.Marshal(zoneList) _ = rc.JSONGetList("", "", moduleLocServ+":"+typeZonalSubscription, populateZonalTrafficList, &zonalTrafficSubList) zonalTrafficSubList.ResourceURL = basepathURL + "subcription/zonalTraffic" jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) Loading @@ -808,30 +868,44 @@ func zonalTrafficSubGet(w http.ResponseWriter, r *http.Request) { func zonalTrafficSubGetById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) jsonInfo, _ := rc.JSONGetEntry(moduleLocServ+":"+typeZonalSubscription+":"+vars["subscriptionId"], ".") if jsonInfo != "" { fmt.Fprintf(w, jsonInfo) var response InlineResponse201 var zonalTrafficSub ZonalTrafficSubscription response.ZonalTrafficSubscription = &zonalTrafficSub } else { jsonZonalTrafficSub, _ := rc.JSONGetEntry(moduleLocServ+":"+typeZonalSubscription+":"+vars["subscriptionId"], ".") if jsonZonalTrafficSub == "" { w.WriteHeader(http.StatusNotFound) return } err := json.Unmarshal([]byte(jsonZonalTrafficSub), &zonalTrafficSub) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) fmt.Fprintf(w, string(jsonResponse)) } func zonalTrafficSubPost(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") subs := new(ZonalTrafficSubscription) var response InlineResponse201 zonalTrafficSub := new(ZonalTrafficSubscription) response.ZonalTrafficSubscription = zonalTrafficSub decoder := json.NewDecoder(r.Body) err := decoder.Decode(&subs) err := decoder.Decode(&zonalTrafficSub) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) Loading @@ -842,45 +916,43 @@ func zonalTrafficSubPost(w http.ResponseWriter, r *http.Request) { nextZonalSubscriptionIdAvailable++ subsIdStr := strconv.Itoa(newSubsId) /* if subs.Duration > 0 { if zonalTrafficSub.Duration > 0 { //TODO start a timer mecanism and expire subscription } //else, lasts forever or until subscription is deleted */ if subs.Duration != "" && subs.Duration != "0" { if zonalTrafficSub.Duration != "" && zonalTrafficSub.Duration != "0" { //TODO start a timer mecanism and expire subscription log.Info("Non zero duration") } //else, lasts forever or until subscription is deleted subs.ResourceURL = basepathURL + "subscriptions/zonalTraffic/" + subsIdStr zonalTrafficSub.ResourceURL = basepathURL + "subscriptions/zonalTraffic/" + subsIdStr _ = rc.JSONSetEntry(moduleLocServ+":"+typeZonalSubscription+":"+subsIdStr, ".", convertZonalSubscriptionToJson(subs)) _ = rc.JSONSetEntry(moduleLocServ+":"+typeZonalSubscription+":"+subsIdStr, ".", convertZonalSubscriptionToJson(zonalTrafficSub)) registerZonal(subs.ZoneId, subs.UserEventCriteria, subsIdStr) registerZonal(zonalTrafficSub.ZoneId, zonalTrafficSub.UserEventCriteria, subsIdStr) jsonResponse, err := json.Marshal(subs) jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusCreated) fmt.Fprintf(w, string(jsonResponse)) } func zonalTrafficSubPutById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) subs := new(ZonalTrafficSubscription) var response InlineResponse201 zonalTrafficSub := new(ZonalTrafficSubscription) response.ZonalTrafficSubscription = zonalTrafficSub decoder := json.NewDecoder(r.Body) err := decoder.Decode(&subs) err := decoder.Decode(&zonalTrafficSub) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) Loading @@ -888,14 +960,21 @@ func zonalTrafficSubPutById(w http.ResponseWriter, r *http.Request) { } subsIdStr := vars["subscriptionId"] subs.ResourceURL = basepathURL + "subscriptions/zonalTraffic/" + subsIdStr zonalTrafficSub.ResourceURL = basepathURL + "subscriptions/zonalTraffic/" + subsIdStr _ = rc.JSONSetEntry(moduleLocServ+":"+typeZonalSubscription+":"+subsIdStr, ".", convertZonalSubscriptionToJson(subs)) _ = rc.JSONSetEntry(moduleLocServ+":"+typeZonalSubscription+":"+subsIdStr, ".", convertZonalSubscriptionToJson(zonalTrafficSub)) deregisterZonal(subsIdStr) registerZonal(subs.ZoneId, subs.UserEventCriteria, subsIdStr) registerZonal(zonalTrafficSub.ZoneId, zonalTrafficSub.UserEventCriteria, subsIdStr) jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) fmt.Fprintf(w, string(jsonResponse)) } func populateZonalTrafficList(key string, jsonInfo string, dummy1 string, dummy2 string, userData interface{}) error { Loading Loading @@ -923,20 +1002,21 @@ func zoneStatusDelById(w http.ResponseWriter, r *http.Request) { } deregisterZoneStatus(vars["subscriptionId"]) w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusNoContent) } func zoneStatusGet(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") var zoneList InlineResponse2002NotificationSubscriptionList var response InlineResponse2002 var zoneStatusSubList InlineResponse2002NotificationSubscriptionList response.NotificationSubscriptionList = &zoneStatusSubList _ = rc.JSONGetList("", "", moduleLocServ+":"+typeZoneStatusSubscription, populateZoneStatusList, &zoneList) _ = rc.JSONGetList("", "", moduleLocServ+":"+typeZoneStatusSubscription, populateZoneStatusList, &zoneStatusSubList) zoneList.ResourceURL = basepathURL + "subscription/zoneStatus" jsonResponse, err := json.Marshal(zoneList) zoneStatusSubList.ResourceURL = basepathURL + "subscription/zoneStatus" jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) Loading @@ -950,26 +1030,42 @@ func zoneStatusGetById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) jsonInfo, _ := rc.JSONGetEntry(moduleLocServ+":"+typeZoneStatusSubscription+":"+vars["subscriptionId"], ".") if jsonInfo != "" { fmt.Fprintf(w, jsonInfo) var response InlineResponse20012 var zoneStatusSub ZoneStatusSubscription response.ZoneStatusSubscription = &zoneStatusSub } else { jsonZoneStatusSub, _ := rc.JSONGetEntry(moduleLocServ+":"+typeZoneStatusSubscription+":"+vars["subscriptionId"], ".") if jsonZoneStatusSub == "" { w.WriteHeader(http.StatusNotFound) return } err := json.Unmarshal([]byte(jsonZoneStatusSub), &zoneStatusSub) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) fmt.Fprintf(w, string(jsonResponse)) } func zoneStatusPost(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") subs := new(ZoneStatusSubscription) decoder := json.NewDecoder(r.Body) err := decoder.Decode(&subs) var response InlineResponse2012 zoneStatusSub := new(ZoneStatusSubscription) response.ZonalTrafficSubscription = zoneStatusSub decoder := json.NewDecoder(r.Body) err := decoder.Decode(&zoneStatusSub) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) Loading @@ -980,20 +1076,20 @@ func zoneStatusPost(w http.ResponseWriter, r *http.Request) { nextZoneStatusSubscriptionIdAvailable++ subsIdStr := strconv.Itoa(newSubsId) subs.ResourceURL = basepathURL + "subscriptions/zoneStatus/" + subsIdStr zoneStatusSub.ResourceURL = basepathURL + "subscriptions/zoneStatus/" + subsIdStr _ = rc.JSONSetEntry(moduleLocServ+":"+typeZoneStatusSubscription+":"+subsIdStr, ".", convertZoneStatusSubscriptionToJson(subs)) _ = rc.JSONSetEntry(moduleLocServ+":"+typeZoneStatusSubscription+":"+subsIdStr, ".", convertZoneStatusSubscriptionToJson(zoneStatusSub)) registerZoneStatus(subs.ZoneId, subs.NumberOfUsersZoneThreshold, subs.NumberOfUsersAPThreshold, subs.OperationStatus, subsIdStr) registerZoneStatus(zoneStatusSub.ZoneId, zoneStatusSub.NumberOfUsersZoneThreshold, zoneStatusSub.NumberOfUsersAPThreshold, zoneStatusSub.OperationStatus, subsIdStr) jsonResponse, err := json.Marshal(subs) jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusCreated) fmt.Fprintf(w, string(jsonResponse)) } Loading @@ -1001,11 +1097,12 @@ func zoneStatusPutById(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json; charset=UTF-8") vars := mux.Vars(r) subs := new(ZoneStatusSubscription) var response InlineResponse20012 zoneStatusSub := new(ZoneStatusSubscription) response.ZoneStatusSubscription = zoneStatusSub decoder := json.NewDecoder(r.Body) err := decoder.Decode(&subs) err := decoder.Decode(&zoneStatusSub) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) Loading @@ -1013,14 +1110,22 @@ func zoneStatusPutById(w http.ResponseWriter, r *http.Request) { } subsIdStr := vars["subscriptionId"] subs.ResourceURL = basepathURL + "subscriptions/zoneStatus/" + subsIdStr zoneStatusSub.ResourceURL = basepathURL + "subscriptions/zoneStatus/" + subsIdStr _ = rc.JSONSetEntry(moduleLocServ+":"+typeZoneStatusSubscription+":"+subsIdStr, ".", convertZoneStatusSubscriptionToJson(subs)) _ = rc.JSONSetEntry(moduleLocServ+":"+typeZoneStatusSubscription+":"+subsIdStr, ".", convertZoneStatusSubscriptionToJson(zoneStatusSub)) deregisterZoneStatus(subsIdStr) registerZoneStatus(subs.ZoneId, subs.NumberOfUsersZoneThreshold, subs.NumberOfUsersAPThreshold, subs.OperationStatus, subsIdStr) registerZoneStatus(zoneStatusSub.ZoneId, zoneStatusSub.NumberOfUsersZoneThreshold, zoneStatusSub.NumberOfUsersAPThreshold, zoneStatusSub.OperationStatus, subsIdStr) jsonResponse, err := json.Marshal(response) if err != nil { log.Error(err.Error()) http.Error(w, err.Error(), http.StatusInternalServerError) return } w.WriteHeader(http.StatusOK) fmt.Fprintf(w, string(jsonResponse)) } func populateZoneStatusList(key string, jsonInfo string, dummy1 string, dummy2 string, userData interface{}) error { Loading