Commit 5e9213b1 authored by Yann Garcia's avatar Yann Garcia
Browse files

Fix lint issues & remove useless logs

parent 710cab86
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -681,7 +681,7 @@ func appRegistrationPOST(w http.ResponseWriter, r *http.Request) {
		return
	}

	if appInfo.IsInsByMec == false && appInfo.Endpoint == nil {
	if !appInfo.IsInsByMec && appInfo.Endpoint == nil {
		log.Error("Shall be present when IsInsByMec is FALSE")
		errHandlerProblemDetails(w, "Endpoint shall be present when IsInsByMec is FALSE.", http.StatusBadRequest)
		return
@@ -827,7 +827,7 @@ func appRegistrationPUT(w http.ResponseWriter, r *http.Request) {
		return
	}

	if appInfoPut.IsInsByMec == false && appInfoPut.Endpoint == nil {
	if !appInfoPut.IsInsByMec && appInfoPut.Endpoint == nil {
		log.Error("Shall be present when IsInsByMec is FALSE")
		errHandlerProblemDetails(w, "Shall be present when IsInsByMec is FALSE.", http.StatusBadRequest)
		return
+2 −2
Original line number Diff line number Diff line
@@ -6444,7 +6444,7 @@ func testSubscriptionPost(t *testing.T, appInstanceId string, requestTestNotific
		/******************************
		* Comparing responses
		******************************/
		if validateAppTerminationNotificationSubscription(respBody, expected_appTermNotifSub) == false {
		if !validateAppTerminationNotificationSubscription(respBody, expected_appTermNotifSub) {
			t.Fatalf("Failed to get expected response")
		}

@@ -7255,7 +7255,7 @@ func validateAppInfo(received as.AppInfo, expected as.AppInfo) bool {
		fmt.Println("validateAppInfo: AppInfo.IsInsByMec mismatch")
		return false
	}
	if received.IsInsByMec == false && received.Endpoint == nil {
	if !received.IsInsByMec && received.Endpoint == nil {
		fmt.Println("validateAppInfo: Endpoint shall be present when IsInsByMec is FALSE")
		return false
	}
+9 −0
Original line number Diff line number Diff line
@@ -78,6 +78,15 @@ func convertProblemDetailsToJson(obj *ProblemDetails) string {
	return string(jsonInfo)
}

func convertSubscriptionLinkListToJson(obj *SubscriptionLinkList) string {
	jsonInfo, err := json.Marshal(*obj)
	if err != nil {
		log.Error(err.Error())
		return ""
	}
	return string(jsonInfo)
}

func convertMecServiceMgmtApiSubscriptionLinkListToJson(obj *MecServiceMgmtApiSubscriptionLinkList) string {
	jsonInfo, err := json.Marshal(*obj)
	if err != nil {
+30 −10
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import (
	"sync"
	"time"

	as "github.com/InterDigitalInc/AdvantEDGE/go-apps/meep-app-enablement/server/app-support"
	dkm "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-data-key-mgr"
	log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger"
	mq "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-mq"
@@ -731,9 +730,26 @@ func applicationsSubscriptionGET(w http.ResponseWriter, r *http.Request) {
		return
	}

	// Return original marshalled subscription
	// Create subscription link list
	subscriptionLinkList := &MecServiceMgmtApiSubscriptionLinkList{
		Links: &MecServiceMgmtApiSubscriptionLinkListLinks{
			Self: &LinkType{
				Href: hostUrl.String() + basePath + "applications/" + appId + "/subscriptions",
			},
		},
	}

	// Create subscription reference & append it to link list
	subscription := MecServiceMgmtApiSubscriptionLinkListSubscription{
		Rel:  SER_AVAILABILITY_NOTIF_SUB_TYPE,
		Href: sub.Cfg.Self,
	}
	subscriptionLinkList.Links.Subscriptions = append(subscriptionLinkList.Links.Subscriptions, subscription)

	// Send response
	w.WriteHeader(http.StatusOK)
	fmt.Fprintf(w, sub.JsonSubOrig)
	fmt.Fprint(w, convertMecServiceMgmtApiSubscriptionLinkListToJson(subscriptionLinkList))

}

func applicationsSubscriptionDELETE(w http.ResponseWriter, r *http.Request) {
@@ -794,6 +810,8 @@ func applicationsSubscriptionDELETE(w http.ResponseWriter, r *http.Request) {
}

func applicationsSubscriptionsGET(w http.ResponseWriter, r *http.Request) {
	log.Info("applicationsSubscriptionsGET")

	w.Header().Set("Content-Type", "application/json; charset=UTF-8")
	vars := mux.Vars(r)
	appId := vars["appInstanceId"]
@@ -829,9 +847,9 @@ func applicationsSubscriptionsGET(w http.ResponseWriter, r *http.Request) {
	}

	// Create subscription link list
	subscriptionLinkList := &as.SubscriptionLinkList{
		Links: &as.SubscriptionLinkListLinks{
			Self: &as.LinkType{
	subscriptionLinkList := &SubscriptionLinkList{
		Links: &SubscriptionLinkListLinks{
			Self: &LinkType{
				Href: hostUrl.String() + basePath + "applications/" + appId + "/subscriptions",
			},
		},
@@ -839,22 +857,24 @@ func applicationsSubscriptionsGET(w http.ResponseWriter, r *http.Request) {

	for _, sub := range subList {
		// Create subscription reference & append it to link list
		subscription := as.SubscriptionLinkListSubscription{
		subscription := SubscriptionLinkListLinksSubscriptions{
			// In v2.1.1 it should be SubscriptionType, but spec is expecting "rel" as per v1.1.1
			SubscriptionType: SER_AVAILABILITY_NOTIF_SUB_TYPE,
			Href:             sub.Cfg.Self,
			SubscriptionType: &sub.Cfg.Type,
		}
		subscriptionLinkList.Links.Subscriptions = append(subscriptionLinkList.Links.Subscriptions, subscription)
	}

	// Send response
	w.WriteHeader(http.StatusOK)
	fmt.Fprint(w, convertMecServiceMgmtApiSubscriptionLinkListToJson(subscriptionLinkList))
	fmt.Fprint(w, convertSubscriptionLinkListToJson(subscriptionLinkList))
}

func getIndividualMECService(w http.ResponseWriter, r *http.Request) {
	log.Info("getIndividualMECService")

	w.Header().Set("Content-Type", "application/json; charset=UTF-8")
	// FIXME FSCOM TODO
	// Send response
	w.WriteHeader(http.StatusOK)
}