+func (ps *PublishService) checkIfProfileIsNew(aefId string, publishedPofiles []publishapi.AefProfile) bool {
+ for _, profile := range publishedPofiles {
+ if profile.AefId == aefId {
+ return false
+ }
+ }
+ return true
+}
+func (ps *PublishService) addProfile(profile publishapi.AefProfile, publishedService publishapi.ServiceAPIDescription) *[]publishapi.AefProfile {
+ registeredProfiles := *publishedService.AefProfiles
+ newProfiles := append(registeredProfiles, profile)
+ publishedService.AefProfiles = &newProfiles
+ return &newProfiles
+
+}
+
+func (*PublishService) updateProfile(profile publishapi.AefProfile, publishedService publishapi.ServiceAPIDescription, ctx echo.Context) (int, bool, error) {
+ pos, registeredProfile, err := getProfile(profile.AefId, publishedService.AefProfiles)
+ if err != nil {
+ return pos, true, sendCoreError(ctx, http.StatusBadRequest, "Unable to update service due to: "+err.Error())
+ }
+ if profile.DomainName != nil {
+ registeredProfile.DomainName = profile.DomainName
+ (*publishedService.AefProfiles)[pos] = registeredProfile
+ }
+ return -1, false, nil
+}
+
+func getProfile(profileId string, apiProfiles *[]publishapi.AefProfile) (int, publishapi.AefProfile, error) {
+ for pos, profile := range *apiProfiles {
+ if profile.AefId == profileId {
+ return pos, profile, nil
+ }
+ }
+ return 0, publishapi.AefProfile{}, fmt.Errorf("profile with ID %s is not registered for the service", profileId)
+}
+