X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=capifcore%2Finternal%2Finvokermanagement%2Finvokermanagement.go;h=fe0c2cbcc5896a18df5f4d43d4126ef5a83d0390;hb=refs%2Fchanges%2F85%2F12585%2F1;hp=f0a4155b42ac629a43a5f40224a172f27fb76695;hpb=4974b9d1c7256e90cb206b327b0c81f7364beeab;p=nonrtric%2Fplt%2Fsme.git diff --git a/capifcore/internal/invokermanagement/invokermanagement.go b/capifcore/internal/invokermanagement/invokermanagement.go index f0a4155..fe0c2cb 100644 --- a/capifcore/internal/invokermanagement/invokermanagement.go +++ b/capifcore/internal/invokermanagement/invokermanagement.go @@ -2,7 +2,8 @@ // ========================LICENSE_START================================= // O-RAN-SC // %% -// Copyright (C) 2022: Nordix Foundation +// Copyright (C) 2022-2023: Nordix Foundation +// Copyright (C) 2024: OpenInfra Foundation Europe // %% // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -113,7 +114,7 @@ func (im *InvokerManager) PostOnboardedInvokers(ctx echo.Context) error { return sendCoreError(ctx, http.StatusForbidden, fmt.Sprintf(errMsg, err)) } - if err = im.validateInvoker(newInvoker, ctx); err != nil { + if err = im.validateInvoker(newInvoker); err != nil { return sendCoreError(ctx, http.StatusBadRequest, fmt.Sprintf(errMsg, err)) } @@ -143,16 +144,18 @@ func (im *InvokerManager) isInvokerOnboarded(newInvoker invokerapi.APIInvokerEnr } func (im *InvokerManager) prepareNewInvoker(newInvoker *invokerapi.APIInvokerEnrolmentDetails) { - var apiList invokerapi.APIList = im.publishRegister.GetAllPublishedServices() - newInvoker.ApiList = &apiList + var apiListRequestedServices invokerapi.APIList = nil + if newInvoker.ApiList != nil { + apiListRequestedServices = *newInvoker.ApiList + } + var allowedPublishedServices invokerapi.APIList = im.publishRegister.GetAllowedPublishedServices(apiListRequestedServices) + newInvoker.ApiList = &allowedPublishedServices im.lock.Lock() defer im.lock.Unlock() newInvoker.PrepareNewInvoker() - im.addClientInKeycloak(newInvoker) - im.onboardedInvokers[*newInvoker.ApiInvokerId] = *newInvoker } @@ -209,7 +212,7 @@ func (im *InvokerManager) PutOnboardedInvokersOnboardingId(ctx echo.Context, onb return sendCoreError(ctx, http.StatusBadRequest, fmt.Sprintf(errMsg, errMismatch)) } - if err := im.validateInvoker(newInvoker, ctx); err != nil { + if err := im.validateInvoker(newInvoker); err != nil { return sendCoreError(ctx, http.StatusBadRequest, fmt.Sprintf(errMsg, err)) } @@ -238,7 +241,7 @@ func (im *InvokerManager) ModifyIndApiInvokeEnrolment(ctx echo.Context, onboardi return ctx.NoContent(http.StatusNotImplemented) } -func (im *InvokerManager) validateInvoker(invoker invokerapi.APIInvokerEnrolmentDetails, ctx echo.Context) error { +func (im *InvokerManager) validateInvoker(invoker invokerapi.APIInvokerEnrolmentDetails) error { if err := invoker.Validate(); err != nil { return err }