From d71cf913f5b9ec1629ab8581ad6ca0fb68267d78 Mon Sep 17 00:00:00 2001 From: kun Date: Wed, 12 Jun 2024 06:39:51 +0000 Subject: [PATCH] remove unused code --- internal/sbi/api_discovery.go | 33 -------------------------- internal/sbi/api_management.go | 8 +++---- internal/sbi/processor/nfdiscovery.go | 4 ---- internal/sbi/processor/nfmanagement.go | 19 ++------------- 4 files changed, 6 insertions(+), 58 deletions(-) diff --git a/internal/sbi/api_discovery.go b/internal/sbi/api_discovery.go index 4630ed7..5f0d326 100644 --- a/internal/sbi/api_discovery.go +++ b/internal/sbi/api_discovery.go @@ -40,39 +40,6 @@ func (s *Server) getSearchNFInstances(c *gin.Context) { return } - // req := httpwrapper.NewRequest(c.Request, nil) - // req.Query = c.Request.URL.Query() - // httpResponse := s.processor.HandleNFDiscoveryRequest(req) query := c.Request.URL.Query() s.Processor().NFDiscoveryProcedure(c, query) - - //--------------------第2層 - //response, problemDetails := NFDiscoveryProcedure(url.Values(query)) - // Send Response - // if response != nil { - // c.JSON(http.StatusOK, response) - // } else if problemDetails != nil { - - // } else { - // problemDetails = &models.ProblemDetails{ - // Status: http.StatusForbidden, - // Cause: "UNSPECIFIED", - // } - // c.JSON(http.StatusForbidden, problemDetails) // 問一下為什麼這個用不到 - // } - - //------------------- - - // responseBody, err := openapi.Serialize(httpResponse.Body, "application/json") - // if err != nil { - // logger.DiscLog.Warnln(err) - // problemDetails := models.ProblemDetails{ - // Status: http.StatusInternalServerError, - // Cause: "SYSTEM_FAILURE", - // Detail: err.Error(), - // } - // c.JSON(http.StatusInternalServerError, problemDetails) - // } else { - // c.Data(httpResponse.Status, "application/json", responseBody) - // } } diff --git a/internal/sbi/api_management.go b/internal/sbi/api_management.go index 69f2a99..bf876b9 100644 --- a/internal/sbi/api_management.go +++ b/internal/sbi/api_management.go @@ -71,7 +71,7 @@ func (s *Server) getNFManagementRoutes() []Route { } // DeregisterNFInstance - Deregisters a given NF Instance -func (s *Server) DeregisterNFInstance(c *gin.Context) { // OK +func (s *Server) DeregisterNFInstance(c *gin.Context) { auth_err := authorizationCheck(c, "nnrf-nfm") if auth_err != nil { c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()}) @@ -85,7 +85,7 @@ func (s *Server) DeregisterNFInstance(c *gin.Context) { // OK } // GetNFInstance - Read the profile of a given NF Instance -func (s *Server) NFInstance(c *gin.Context) { // OK +func (s *Server) NFInstance(c *gin.Context) { auth_err := authorizationCheck(c, "nnrf-nfm") if auth_err != nil { c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()}) @@ -98,7 +98,7 @@ func (s *Server) NFInstance(c *gin.Context) { // OK s.Processor().GetNFInstanceProcedure(c, nfInstanceId) } -func (s *Server) RegisterNFInstance(c *gin.Context) { // OK +func (s *Server) RegisterNFInstance(c *gin.Context) { auth_err := authorizationCheck(c, "nnrf-nfm") if auth_err != nil { c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()}) @@ -164,7 +164,7 @@ func (s *Server) RegisterNFInstance(c *gin.Context) { // OK } // UpdateNFInstance - Update NF Instance profile -func (s *Server) getUpdateNFInstance(c *gin.Context) { // OK +func (s *Server) getUpdateNFInstance(c *gin.Context) { auth_err := authorizationCheck(c, "nnrf-nfm") if auth_err != nil { c.JSON(http.StatusUnauthorized, gin.H{"error": auth_err.Error()}) diff --git a/internal/sbi/processor/nfdiscovery.go b/internal/sbi/processor/nfdiscovery.go index 7aab814..dbf0a43 100644 --- a/internal/sbi/processor/nfdiscovery.go +++ b/internal/sbi/processor/nfdiscovery.go @@ -77,7 +77,6 @@ func (p *Processor) NFDiscoveryProcedure(c *gin.Context, queryParameters url.Val Status: http.StatusBadRequest, Cause: "Loss mandatory parameter", } - // return nil, problemDetails c.JSON(int(problemDetails.Status), problemDetails) } @@ -100,7 +99,6 @@ func (p *Processor) NFDiscoveryProcedure(c *gin.Context, queryParameters url.Val {Param: "complexQuery"}, }, } - // return nil, problemDetails c.JSON(int(problemDetails.Status), problemDetails) } } @@ -121,7 +119,6 @@ func (p *Processor) NFDiscoveryProcedure(c *gin.Context, queryParameters url.Val Detail: err.Error(), Cause: "SYSTEM_FAILURE", } - // return nil, problemDetails c.JSON(int(problemDetails.Status), problemDetails) } @@ -135,7 +132,6 @@ func (p *Processor) NFDiscoveryProcedure(c *gin.Context, queryParameters url.Val Detail: err.Error(), Cause: "SYSTEM_FAILURE", } - // return nil, problemDetails c.JSON(int(problemDetails.Status), problemDetails) } diff --git a/internal/sbi/processor/nfmanagement.go b/internal/sbi/processor/nfmanagement.go index 66a69e1..6a4f72f 100644 --- a/internal/sbi/processor/nfmanagement.go +++ b/internal/sbi/processor/nfmanagement.go @@ -24,26 +24,21 @@ import ( func (p *Processor) HandleRemoveSubscriptionRequest(c *gin.Context, subscriptionID string) { logger.NfmLog.Infoln("Handle RemoveSubscription") - // subscriptionID := request.Params["subscriptionID"] RemoveSubscriptionProcedure(subscriptionID) c.JSON(http.StatusNoContent, nil) - // return httpwrapper.NewResponse(http.StatusNoContent, nil, nil) } func (p *Processor) HandleCreateSubscriptionRequest(c *gin.Context, subscription models.NrfSubscriptionData) { logger.NfmLog.Infoln("Handle CreateSubscriptionRequest") - // subscription := request.Body.(models.NrfSubscriptionData) response, problemDetails := CreateSubscriptionProcedure(subscription) if response != nil { logger.NfmLog.Traceln("CreateSubscription success") - // return httpwrapper.NewResponse(http.StatusCreated, nil, response) c.JSON(http.StatusCreated, response) } else if problemDetails != nil { logger.NfmLog.Traceln("CreateSubscription failed") - // return httpwrapper.NewResponse(int(problemDetails.Status), nil, problemDetails) c.JSON(int(problemDetails.Status), problemDetails) } problemDetails = &models.ProblemDetails{ @@ -51,7 +46,6 @@ func (p *Processor) HandleCreateSubscriptionRequest(c *gin.Context, subscription Cause: "UNSPECIFIED", } logger.NfmLog.Traceln("CreateSubscription failed") - // return httpwrapper.NewResponse(http.StatusForbidden, nil, problemDetails) c.JSON(http.StatusForbidden, problemDetails) } @@ -101,7 +95,6 @@ func CreateSubscriptionProcedure(subscription models.NrfSubscriptionData) (bson. } func (p *Processor) UpdateSubscriptionProcedure(c *gin.Context, subscriptionID string, patchJSON []byte) { - // map[string]interface{} { //OK collName := "Subscriptions" filter := bson.M{"subscriptionId": subscriptionID} @@ -113,13 +106,10 @@ func (p *Processor) UpdateSubscriptionProcedure(c *gin.Context, subscriptionID s Detail: err.Error(), } c.JSON(http.StatusInternalServerError, problemDetails) - // return nil } else { if response, err := mongoapi.RestfulAPIGetOne(collName, filter); err == nil { c.JSON(http.StatusOK, response) - // return response } - // return nil } } @@ -132,9 +122,9 @@ func RemoveSubscriptionProcedure(subscriptionID string) { } } -func (p *Processor) GetNFInstancesProcedure( // OK +func (p *Processor) GetNFInstancesProcedure( c *gin.Context, nfType string, limit int, -) { // (*nrf_context.UriList, *models.ProblemDetails) { +) { collName := "urilist" filter := bson.M{"nfType": nfType} if nfType == "" { @@ -151,7 +141,6 @@ func (p *Processor) GetNFInstancesProcedure( // OK Detail: err.Error(), Cause: "SYSTEM_FAILURE", } - // return nil, problemDetail c.JSON(int(problemDetail.Status), problemDetail) } logger.NfmLog.Infoln("ULs: ", ULs) @@ -167,9 +156,6 @@ func (p *Processor) GetNFInstancesProcedure( // OK Cause: "SYSTEM_FAILURE", } c.JSON(http.StatusInternalServerError, problemDetail) - // return nil, problemDetail - // c.JSON(int(problemDetail.Status), problemDetail) - // c.Data(http.StatusInternalServerError, "application/json", []byte("error in GetNFInstancesProcedure")) } rspUriList.Link.Item = append(rspUriList.Link.Item, originalUL.Link.Item...) if nfType != "" && rspUriList.NfType == "" { @@ -178,7 +164,6 @@ func (p *Processor) GetNFInstancesProcedure( // OK } nrf_context.NnrfUriListLimit(rspUriList, limit) - // return rspUriList, nil c.JSON(http.StatusOK, rspUriList) logger.NfmLog.Traceln("GetNFInstances failed")