+func (ps *PublishService) updateProfiles(pos int, apfId string, updatedServiceDescription *[]publishapi.AefProfile, publishedService *[]publishapi.AefProfile) (int, *[]publishapi.AefProfile, error) {
+ registeredFuncs := ps.serviceRegister.GetAefsForPublisher(apfId)
+ addedProfiles := []publishapi.AefProfile{}
+ changedProfiles := []publishapi.AefProfile{}
+ for _, profile := range *updatedServiceDescription {
+ if !slices.Contains(registeredFuncs, profile.AefId) {
+ return 0, nil, fmt.Errorf("function %s not registered", profile.AefId)
+ }
+ for _, publishedProfile := range *publishedService {
+ if publishedProfile.AefId != profile.AefId {
+ registeredProfiles := *publishedService
+ newProfiles := append(registeredProfiles, profile)
+ publishedService = &newProfiles
+ addedProfiles = append(addedProfiles, profile)
+ } else {
+ pos, registeredProfile, err := getProfile(profile.AefId, publishedService)
+ if err != nil {
+ return pos, updatedServiceDescription, fmt.Errorf("unable to update service due to: %s", err.Error())
+ }
+ if profile.DomainName != nil {
+ registeredProfile.DomainName = profile.DomainName
+ (*publishedService)[pos] = registeredProfile
+ }
+ changedProfiles = append(changedProfiles, profile)
+ }