X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fcontrol%2Fdebug_rest_if.go;h=f5ae4c5fce7f6e5289f61ced37507f77e31b51a4;hb=84662c4f3e2273152fc849f74880108b6346bcad;hp=cc73c7223bc62e61e5a6edda43a3b90d8863e3e7;hpb=92c3855b5c2d86a54f1342498a2772a605073e06;p=ric-plt%2Fsubmgr.git diff --git a/pkg/control/debug_rest_if.go b/pkg/control/debug_rest_if.go index cc73c72..f5ae4c5 100644 --- a/pkg/control/debug_rest_if.go +++ b/pkg/control/debug_rest_if.go @@ -39,7 +39,10 @@ func (c *Control) TestRestHandler(w http.ResponseWriter, r *http.Request) { var splits = strings.Split(s, "=") if subId, err := strconv.ParseInt(splits[1], 10, 64); err == nil { xapp.Logger.Debug("RemoveSubscriptionFromSdl() called. subId = %v", subId) - c.RemoveSubscriptionFromSdl(uint32(subId)) + err := c.RemoveSubscriptionFromSdl(uint32(subId)) + if err != nil { + xapp.Logger.Error("c.RemoveSubscriptionFromSdl failure: %s", err.Error()) + } return } } @@ -47,8 +50,14 @@ func (c *Control) TestRestHandler(w http.ResponseWriter, r *http.Request) { // This can be used to remove all subscriptions db from if s == "emptydb" { xapp.Logger.Debug("RemoveAllSubscriptionsFromSdl() called") - c.RemoveAllSubscriptionsFromSdl() - c.RemoveAllRESTSubscriptionsFromSdl() + err := c.RemoveAllSubscriptionsFromSdl() + if err != nil { + xapp.Logger.Error("RemoveAllSubscriptionsFromSdl() RemoveAllSubscriptionsFromSdl() failure: %s", err.Error()) + } + err = c.RemoveAllRESTSubscriptionsFromSdl() + if err != nil { + xapp.Logger.Error("RemoveAllRESTSubscriptionsFromSdl() RemoveAllSubscriptionsFromSdl() failure: %s", err.Error()) + } return } @@ -68,14 +77,20 @@ func (c *Control) GetAllRestSubscriptions(w http.ResponseWriter, r *http.Request // Get all REST Subscriptions in subscription manager xapp.Logger.Debug("GetAllRestSubscriptions() called") - w.Write(c.registry.GetAllRestSubscriptionsJson()) + _, err := w.Write(c.registry.GetAllRestSubscriptionsJson()) + if err != nil { + xapp.Logger.Error("GetAllRestSubscriptions() w.Write failure: %s", err.Error()) + } } func (c *Control) GetAllE2Nodes(w http.ResponseWriter, r *http.Request) { // Get all E2Nodes in subscription manager xapp.Logger.Debug("GetAllE2Nodes() called") - w.Write(c.e2IfState.GetE2NodesJson()) + _, err := w.Write(c.e2IfState.GetE2NodesJson()) + if err != nil { + xapp.Logger.Error("w.Write failure: %s", err.Error()) + } } func (c *Control) GetAllE2NodeRestSubscriptions(w http.ResponseWriter, r *http.Request) { @@ -86,7 +101,10 @@ func (c *Control) GetAllE2NodeRestSubscriptions(w http.ResponseWriter, r *http.R ranName := pathParams["ranName"] xapp.Logger.Debug("GetAllE2NodeRestSubscriptions() ranName=%s", ranName) if ranName != "" { - w.Write(c.registry.GetAllE2NodeRestSubscriptionsJson(ranName)) + _, err := w.Write(c.registry.GetAllE2NodeRestSubscriptionsJson(ranName)) + if err != nil { + xapp.Logger.Error("GetAllE2NodeRestSubscriptions() w.Write failure: %s", err.Error()) + } } else { xapp.Logger.Debug("GetAllE2NodeRestSubscriptions() Invalid path %s", ranName) w.WriteHeader(400) // Bad request @@ -97,7 +115,10 @@ func (c *Control) GetAllXapps(w http.ResponseWriter, r *http.Request) { // Get all xApps in subscription manager xapp.Logger.Debug("GetAllXapps() called: Req= %v", r.URL.Path) - w.Write(c.registry.GetAllXappsJson()) + _, err := w.Write(c.registry.GetAllXappsJson()) + if err != nil { + xapp.Logger.Error("GetAllXapps() w.Write failure: %s", err.Error()) + } } func (c *Control) GetAllXappRestSubscriptions(w http.ResponseWriter, r *http.Request) { @@ -108,7 +129,10 @@ func (c *Control) GetAllXappRestSubscriptions(w http.ResponseWriter, r *http.Req xappServiceName := pathParams["xappServiceName"] xapp.Logger.Debug("GetAllXappRestSubscriptions() xappServiceName=%s", xappServiceName) if xappServiceName != "" { - w.Write(c.registry.GetAllXappRestSubscriptionsJson(xappServiceName)) + _, err := w.Write(c.registry.GetAllXappRestSubscriptionsJson(xappServiceName)) + if err != nil { + xapp.Logger.Error("GetAllXappRestSubscriptions() w.Write failure: %s", err.Error()) + } } else { xapp.Logger.Debug("GetAllXappRestSubscriptions() Invalid path %s", xappServiceName) w.WriteHeader(400) // Bad request @@ -177,6 +201,9 @@ func (c *Control) GetE2Subscriptions(w http.ResponseWriter, r *http.Request) { if err != nil { w.WriteHeader(404) // Not found } else { - w.Write(e2Subscriptions) + _, err := w.Write(e2Subscriptions) + if err != nil { + xapp.Logger.Error("GetE2Subscriptions() w.Write failure: %s", err.Error()) + } } }