Skip to content

Commit

Permalink
Fix: Rename function name GetSelf()
Browse files Browse the repository at this point in the history
  • Loading branch information
andy89923 committed Nov 1, 2023
1 parent 0f91e05 commit 9783f5e
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 73 deletions.
16 changes: 8 additions & 8 deletions internal/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const (
)

func Init() {
Getself().NfService = make(map[models.ServiceName]models.NfService)
Getself().EeSubscriptionIDGenerator = idgenerator.NewGenerator(1, math.MaxInt32)
GetSelf().NfService = make(map[models.ServiceName]models.NfService)
GetSelf().EeSubscriptionIDGenerator = idgenerator.NewGenerator(1, math.MaxInt32)
}

type UDMContext struct {
Expand Down Expand Up @@ -386,12 +386,12 @@ func (context *UDMContext) GetAmfNon3gppRegContext(supi string) *models.AmfNon3G
func (ue *UdmUeContext) GetLocationURI(types int) string {
switch types {
case LocationUriAmf3GppAccessRegistration:
return Getself().GetIPv4Uri() + factory.UdmUecmResUriPrefix + "/" + ue.Supi + "/registrations/amf-3gpp-access"
return GetSelf().GetIPv4Uri() + factory.UdmUecmResUriPrefix + "/" + ue.Supi + "/registrations/amf-3gpp-access"
case LocationUriAmfNon3GppAccessRegistration:
return Getself().GetIPv4Uri() + factory.UdmUecmResUriPrefix + "/" + ue.Supi + "/registrations/amf-non-3gpp-access"
return GetSelf().GetIPv4Uri() + factory.UdmUecmResUriPrefix + "/" + ue.Supi + "/registrations/amf-non-3gpp-access"
case LocationUriSmfRegistration:

return Getself().GetIPv4Uri() +
return GetSelf().GetIPv4Uri() +
factory.UdmUecmResUriPrefix + "/" + ue.Supi + "/registrations/smf-registrations/" + ue.PduSessionID
}
return ""
Expand All @@ -400,9 +400,9 @@ func (ue *UdmUeContext) GetLocationURI(types int) string {
func (ue *UdmUeContext) GetLocationURI2(types int, supi string) string {
switch types {
case LocationUriSharedDataSubscription:
// return Getself().GetIPv4Uri() + UdmSdmResUriPrefix +"/shared-data-subscriptions/" + nf.SubscriptionID
// return GetSelf().GetIPv4Uri() + UdmSdmResUriPrefix +"/shared-data-subscriptions/" + nf.SubscriptionID
case LocationUriSdmSubscription:
return Getself().GetIPv4Uri() + factory.UdmSdmResUriPrefix + "/" + supi + "/sdm-subscriptions/"
return GetSelf().GetIPv4Uri() + factory.UdmSdmResUriPrefix + "/" + supi + "/sdm-subscriptions/"
}
return ""
}
Expand Down Expand Up @@ -478,6 +478,6 @@ func (context *UDMContext) InitNFService(serviceName []string, version string) {
}
}

func Getself() *UDMContext {
func GetSelf() *UDMContext {
return &udmContext
}
2 changes: 1 addition & 1 deletion internal/sbi/consumer/nf_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func SendNFIntances(nrfUri string, targetNfType, requestNfType models.NfType,
}

func SendNFIntancesUDR(id string, types int) string {
self := udm_context.Getself()
self := udm_context.GetSelf()
targetNfType := models.NfType_UDR
requestNfType := models.NfType_UDM
localVarOptionals := Nnrf_NFDiscovery.SearchNFInstancesParamOpts{
Expand Down
2 changes: 1 addition & 1 deletion internal/sbi/consumer/nf_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func SendRegisterNFInstance(nrfUri, nfInstanceId string, profile models.NfProfil
func SendDeregisterNFInstance() (problemDetails *models.ProblemDetails, err error) {
logger.ConsumerLog.Infof("Send Deregister NFInstance")

udmSelf := udm_context.Getself()
udmSelf := udm_context.GetSelf()
// Set client and set url
configuration := Nnrf_NFManagement.NewConfiguration()
configuration.SetBasePath(udmSelf.NrfUri)
Expand Down
2 changes: 1 addition & 1 deletion internal/sbi/producer/callback/callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

func DataChangeNotificationProcedure(notifyItems []models.NotifyItem, supi string) *models.ProblemDetails {
ue, _ := udm_context.Getself().UdmUeFindBySupi(supi)
ue, _ := udm_context.GetSelf().UdmUeFindBySupi(supi)
configuration := Nudm_SubscriberDataManagement.NewConfiguration()
clientAPI := Nudm_SubscriberDataManagement.NewAPIClient(configuration)

Expand Down
6 changes: 3 additions & 3 deletions internal/sbi/producer/event_exposure.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func HandleCreateEeSubscription(request *httpwrapper.Request) *httpwrapper.Respo
func CreateEeSubscriptionProcedure(ueIdentity string,
eesubscription models.EeSubscription,
) (*models.CreatedEeSubscription, *models.ProblemDetails) {
udmSelf := udm_context.Getself()
udmSelf := udm_context.GetSelf()

logger.EeLog.Debugf("udIdentity: %s", ueIdentity)
switch {
Expand Down Expand Up @@ -135,7 +135,7 @@ func HandleDeleteEeSubscription(request *httpwrapper.Request) *httpwrapper.Respo

// TODO: complete this procedure based on TS 29503 5.5
func DeleteEeSubscriptionProcedure(ueIdentity string, subscriptionID string) {
udmSelf := udm_context.Getself()
udmSelf := udm_context.GetSelf()

switch {
case strings.HasPrefix(ueIdentity, "msisdn-"):
Expand Down Expand Up @@ -186,7 +186,7 @@ func HandleUpdateEeSubscription(request *httpwrapper.Request) *httpwrapper.Respo
func UpdateEeSubscriptionProcedure(ueIdentity string, subscriptionID string,
patchList []models.PatchItem,
) *models.ProblemDetails {
udmSelf := udm_context.Getself()
udmSelf := udm_context.GetSelf()

switch {
case strings.HasPrefix(ueIdentity, "msisdn-"):
Expand Down
4 changes: 2 additions & 2 deletions internal/sbi/producer/generate_auth_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func GenerateAuthDataProcedure(authInfoRequest models.AuthenticationInfoRequest,

response = &models.AuthenticationInfoResult{}
rand.Seed(time.Now().UnixNano())
supi, err := suci.ToSupi(supiOrSuci, udm_context.Getself().SuciProfiles)
supi, err := suci.ToSupi(supiOrSuci, udm_context.GetSelf().SuciProfiles)
if err != nil {
problemDetails = &models.ProblemDetails{
Status: http.StatusForbidden,
Expand Down Expand Up @@ -417,7 +417,7 @@ func GenerateAuthDataProcedure(authInfoRequest models.AuthenticationInfoRequest,
keyIndex)
} else {
logger.UeauLog.Errorln("Re-Sync Failed UDM Public Key ",
udm_context.Getself().SuciProfiles[keyIndex-1].PublicKey)
udm_context.GetSelf().SuciProfiles[keyIndex-1].PublicKey)
}
}
logger.UeauLog.Errorln("MACS ", macS)
Expand Down
74 changes: 37 additions & 37 deletions internal/sbi/producer/subscriber_data_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ func getAmDataProcedure(supi string, plmnID string, supportedFeatures string) (
}()

if res.StatusCode == http.StatusOK {
udmUe, ok := udm_context.Getself().UdmUeFindBySupi(supi)
udmUe, ok := udm_context.GetSelf().UdmUeFindBySupi(supi)
if !ok {
udmUe = udm_context.Getself().NewUdmUe(supi)
udmUe = udm_context.GetSelf().NewUdmUe(supi)
}
udmUe.SetAMSubsriptionData(&accessAndMobilitySubscriptionDataResp)
return &accessAndMobilitySubscriptionDataResp, nil
Expand Down Expand Up @@ -248,11 +248,11 @@ func getSupiProcedure(supi string, plmnID string, dataSetNames []string, support

queryAmDataParamOpts.SupportedFeatures = optional.NewString(supportedFeatures)
querySmfSelectDataParamOpts.SupportedFeatures = optional.NewString(supportedFeatures)
udm_context.Getself().CreateSubsDataSetsForUe(supi, subsDataSetBody)
udm_context.GetSelf().CreateSubsDataSetsForUe(supi, subsDataSetBody)

if containDataSetName(dataSetNames, string(models.DataSetName_AM)) {
var body models.AccessAndMobilitySubscriptionData
udm_context.Getself().CreateAccessMobilitySubsDataForUe(supi, body)
udm_context.GetSelf().CreateAccessMobilitySubsDataForUe(supi, body)
amData, res, err := clientAPI.AccessAndMobilitySubscriptionDataDocumentApi.QueryAmData(
context.Background(), supi, plmnID, &queryAmDataParamOpts)
if err != nil {
Expand All @@ -276,9 +276,9 @@ func getSupiProcedure(supi string, plmnID string, dataSetNames []string, support
}
}()
if res.StatusCode == http.StatusOK {
udmUe, ok := udm_context.Getself().UdmUeFindBySupi(supi)
udmUe, ok := udm_context.GetSelf().UdmUeFindBySupi(supi)
if !ok {
udmUe = udm_context.Getself().NewUdmUe(supi)
udmUe = udm_context.GetSelf().NewUdmUe(supi)
}
udmUe.SetAMSubsriptionData(&amData)
subscriptionDataSets.AmData = &amData
Expand All @@ -294,7 +294,7 @@ func getSupiProcedure(supi string, plmnID string, dataSetNames []string, support

if containDataSetName(dataSetNames, string(models.DataSetName_SMF_SEL)) {
var smfSelSubsbody models.SmfSelectionSubscriptionData
udm_context.Getself().CreateSmfSelectionSubsDataforUe(supi, smfSelSubsbody)
udm_context.GetSelf().CreateSmfSelectionSubsDataforUe(supi, smfSelSubsbody)
smfSelData, res, err := clientAPI.SMFSelectionSubscriptionDataDocumentApi.QuerySmfSelectData(context.Background(),
supi, plmnID, &querySmfSelectDataParamOpts)
if err != nil {
Expand All @@ -318,9 +318,9 @@ func getSupiProcedure(supi string, plmnID string, dataSetNames []string, support
}
}()
if res.StatusCode == http.StatusOK {
udmUe, ok := udm_context.Getself().UdmUeFindBySupi(supi)
udmUe, ok := udm_context.GetSelf().UdmUeFindBySupi(supi)
if !ok {
udmUe = udm_context.Getself().NewUdmUe(supi)
udmUe = udm_context.GetSelf().NewUdmUe(supi)
}
udmUe.SetSmfSelectionSubsData(&smfSelData)
subscriptionDataSets.SmfSelData = &smfSelData
Expand All @@ -338,7 +338,7 @@ func getSupiProcedure(supi string, plmnID string, dataSetNames []string, support
var UeContextInSmfbody models.UeContextInSmfData
var querySmfRegListParamOpts Nudr.QuerySmfRegListParamOpts
querySmfRegListParamOpts.SupportedFeatures = optional.NewString(supportedFeatures)
udm_context.Getself().CreateUeContextInSmfDataforUe(supi, UeContextInSmfbody)
udm_context.GetSelf().CreateUeContextInSmfDataforUe(supi, UeContextInSmfbody)
pdusess, res, err := clientAPI.SMFRegistrationsCollectionApi.QuerySmfRegList(
context.Background(), supi, &querySmfRegListParamOpts)
if err != nil {
Expand Down Expand Up @@ -381,9 +381,9 @@ func getSupiProcedure(supi string, plmnID string, dataSetNames []string, support
ueContextInSmfDataResp.PgwInfo = pgwInfoArray

if res.StatusCode == http.StatusOK {
udmUe, ok := udm_context.Getself().UdmUeFindBySupi(supi)
udmUe, ok := udm_context.GetSelf().UdmUeFindBySupi(supi)
if !ok {
udmUe = udm_context.Getself().NewUdmUe(supi)
udmUe = udm_context.GetSelf().NewUdmUe(supi)
}
udmUe.UeCtxtInSmfData = &ueContextInSmfDataResp
subscriptionDataSets.UecSmfData = &ueContextInSmfDataResp
Expand Down Expand Up @@ -426,11 +426,11 @@ func getSupiProcedure(supi string, plmnID string, dataSetNames []string, support
}
}()
if res.StatusCode == http.StatusOK {
udmUe, ok := udm_context.Getself().UdmUeFindBySupi(supi)
udmUe, ok := udm_context.GetSelf().UdmUeFindBySupi(supi)
if !ok {
udmUe = udm_context.Getself().NewUdmUe(supi)
udmUe = udm_context.GetSelf().NewUdmUe(supi)
}
smData, _, _, _ := udm_context.Getself().ManageSmData(sessionManagementSubscriptionData, "", "")
smData, _, _, _ := udm_context.GetSelf().ManageSmData(sessionManagementSubscriptionData, "", "")
udmUe.SetSMSubsData(smData)
subscriptionDataSets.SmData = sessionManagementSubscriptionData
} else {
Expand All @@ -445,7 +445,7 @@ func getSupiProcedure(supi string, plmnID string, dataSetNames []string, support

if containDataSetName(dataSetNames, string(models.DataSetName_TRACE)) {
var TraceDatabody models.TraceData
udm_context.Getself().CreateTraceDataforUe(supi, TraceDatabody)
udm_context.GetSelf().CreateTraceDataforUe(supi, TraceDatabody)
traceData, res, err := clientAPI.TraceDataDocumentApi.QueryTraceData(
context.Background(), supi, plmnID, &queryTraceDataParamOpts)
if err != nil {
Expand All @@ -468,9 +468,9 @@ func getSupiProcedure(supi string, plmnID string, dataSetNames []string, support
}
}()
if res.StatusCode == http.StatusOK {
udmUe, ok := udm_context.Getself().UdmUeFindBySupi(supi)
udmUe, ok := udm_context.GetSelf().UdmUeFindBySupi(supi)
if !ok {
udmUe = udm_context.Getself().NewUdmUe(supi)
udmUe = udm_context.GetSelf().NewUdmUe(supi)
}
udmUe.TraceData = &traceData
udmUe.TraceDataResponse.TraceData = &traceData
Expand Down Expand Up @@ -554,7 +554,7 @@ func getSharedDataProcedure(sharedDataIds []string, supportedFeatures string) (
}()

if res.StatusCode == http.StatusOK {
udm_context.Getself().SharedSubsDataMap = udm_context.MappingSharedData(sharedDataResp)
udm_context.GetSelf().SharedSubsDataMap = udm_context.MappingSharedData(sharedDataResp)
sharedData := udm_context.ObtainRequiredSharedData(sharedDataIds, sharedDataResp)
return sharedData, nil
} else {
Expand Down Expand Up @@ -638,11 +638,11 @@ func getSmDataProcedure(supi string, plmnID string, Dnn string, Snssai string, s
}()

if res.StatusCode == http.StatusOK {
udmUe, ok := udm_context.Getself().UdmUeFindBySupi(supi)
udmUe, ok := udm_context.GetSelf().UdmUeFindBySupi(supi)
if !ok {
udmUe = udm_context.Getself().NewUdmUe(supi)
udmUe = udm_context.GetSelf().NewUdmUe(supi)
}
smData, snssaikey, AllDnnConfigsbyDnn, AllDnns := udm_context.Getself().ManageSmData(
smData, snssaikey, AllDnnConfigsbyDnn, AllDnns := udm_context.GetSelf().ManageSmData(
sessionManagementSubscriptionDataResp, Snssai, Dnn)
udmUe.SetSMSubsData(smData)

Expand Down Expand Up @@ -750,9 +750,9 @@ func getNssaiProcedure(supi string, plmnID string, supportedFeatures string) (
nssaiResp = *accessAndMobilitySubscriptionDataResp.Nssai

if res.StatusCode == http.StatusOK {
udmUe, ok := udm_context.Getself().UdmUeFindBySupi(supi)
udmUe, ok := udm_context.GetSelf().UdmUeFindBySupi(supi)
if !ok {
udmUe = udm_context.Getself().NewUdmUe(supi)
udmUe = udm_context.GetSelf().NewUdmUe(supi)
}
udmUe.Nssai = &nssaiResp
return udmUe.Nssai, nil
Expand Down Expand Up @@ -809,7 +809,7 @@ func getSmfSelectDataProcedure(supi string, plmnID string, supportedFeatures str
return nil, openapi.ProblemDetailsSystemFailure(err.Error())
}

udm_context.Getself().CreateSmfSelectionSubsDataforUe(supi, body)
udm_context.GetSelf().CreateSmfSelectionSubsDataforUe(supi, body)

smfSelectionSubscriptionDataResp, res, err := clientAPI.SMFSelectionSubscriptionDataDocumentApi.
QuerySmfSelectData(context.Background(), supi, plmnID, &querySmfSelectDataParamOpts)
Expand All @@ -836,9 +836,9 @@ func getSmfSelectDataProcedure(supi string, plmnID string, supportedFeatures str
}()

if res.StatusCode == http.StatusOK {
udmUe, ok := udm_context.Getself().UdmUeFindBySupi(supi)
udmUe, ok := udm_context.GetSelf().UdmUeFindBySupi(supi)
if !ok {
udmUe = udm_context.Getself().NewUdmUe(supi)
udmUe = udm_context.GetSelf().NewUdmUe(supi)
}
udmUe.SetSmfSelectionSubsData(&smfSelectionSubscriptionDataResp)
return udmUe.SmfSelSubsData, nil
Expand Down Expand Up @@ -904,8 +904,8 @@ func subscribeToSharedDataProcedure(sdmSubscription *models.SdmSubscription) (

if res.StatusCode == http.StatusCreated {
header = make(http.Header)
udm_context.Getself().CreateSubstoNotifSharedData(sdmSubscriptionResp.SubscriptionId, &sdmSubscriptionResp)
reourceUri := udm_context.Getself().GetSDMUri() + "//shared-data-subscriptions/" + sdmSubscriptionResp.SubscriptionId
udm_context.GetSelf().CreateSubstoNotifSharedData(sdmSubscriptionResp.SubscriptionId, &sdmSubscriptionResp)
reourceUri := udm_context.GetSelf().GetSDMUri() + "//shared-data-subscriptions/" + sdmSubscriptionResp.SubscriptionId
header.Set("Location", reourceUri)
return header, &sdmSubscriptionResp, nil
} else if res.StatusCode == http.StatusNotFound {
Expand Down Expand Up @@ -982,9 +982,9 @@ func subscribeProcedure(sdmSubscription *models.SdmSubscription, supi string) (

if res.StatusCode == http.StatusCreated {
header = make(http.Header)
udmUe, _ := udm_context.Getself().UdmUeFindBySupi(supi)
udmUe, _ := udm_context.GetSelf().UdmUeFindBySupi(supi)
if udmUe == nil {
udmUe = udm_context.Getself().NewUdmUe(supi)
udmUe = udm_context.GetSelf().NewUdmUe(supi)
}
udmUe.CreateSubscriptiontoNotifChange(sdmSubscriptionResp.SubscriptionId, &sdmSubscriptionResp)
header.Set("Location", udmUe.GetLocationURI2(udm_context.LocationUriSdmSubscription, supi))
Expand Down Expand Up @@ -1305,7 +1305,7 @@ func getTraceDataProcedure(supi string, plmnID string) (
return nil, openapi.ProblemDetailsSystemFailure(err.Error())
}

udm_context.Getself().CreateTraceDataforUe(supi, body)
udm_context.GetSelf().CreateTraceDataforUe(supi, body)

traceDataRes, res, err := clientAPI.TraceDataDocumentApi.QueryTraceData(
context.Background(), supi, plmnID, &queryTraceDataParamOpts)
Expand All @@ -1331,9 +1331,9 @@ func getTraceDataProcedure(supi string, plmnID string) (
}()

if res.StatusCode == http.StatusOK {
udmUe, ok := udm_context.Getself().UdmUeFindBySupi(supi)
udmUe, ok := udm_context.GetSelf().UdmUeFindBySupi(supi)
if !ok {
udmUe = udm_context.Getself().NewUdmUe(supi)
udmUe = udm_context.GetSelf().NewUdmUe(supi)
}
udmUe.TraceData = &traceDataRes
udmUe.TraceDataResponse.TraceData = &traceDataRes
Expand Down Expand Up @@ -1389,7 +1389,7 @@ func getUeContextInSmfDataProcedure(supi string, supportedFeatures string) (
}

pduSessionMap := make(map[string]models.PduSession)
udm_context.Getself().CreateUeContextInSmfDataforUe(supi, body)
udm_context.GetSelf().CreateUeContextInSmfDataforUe(supi, body)

pdusess, res, err := clientAPI.SMFRegistrationsCollectionApi.QuerySmfRegList(
context.Background(), supi, &querySmfRegListParamOpts)
Expand Down Expand Up @@ -1434,9 +1434,9 @@ func getUeContextInSmfDataProcedure(supi string, supportedFeatures string) (
ueContextInSmfData.PgwInfo = pgwInfoArray

if res.StatusCode == http.StatusOK {
udmUe, ok := udm_context.Getself().UdmUeFindBySupi(supi)
udmUe, ok := udm_context.GetSelf().UdmUeFindBySupi(supi)
if !ok {
udmUe = udm_context.Getself().NewUdmUe(supi)
udmUe = udm_context.GetSelf().NewUdmUe(supi)
}
udmUe.UeCtxtInSmfData = &ueContextInSmfData
return udmUe.UeCtxtInSmfData, nil
Expand Down
Loading

0 comments on commit 9783f5e

Please sign in to comment.