X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=a1-go%2Fpkg%2Fresthooks%2Fresthooks.go;h=cb87040507c2d9b6ef532920caa0db4822176991;hb=refs%2Fchanges%2F32%2F9932%2F7;hp=8fb07dfc1cbab40c8fb5a28153d61e1fb8314160;hpb=a5d992815f470a349dea86d616509222eb051f97;p=ric-plt%2Fa1.git diff --git a/a1-go/pkg/resthooks/resthooks.go b/a1-go/pkg/resthooks/resthooks.go index 8fb07df..cb87040 100644 --- a/a1-go/pkg/resthooks/resthooks.go +++ b/a1-go/pkg/resthooks/resthooks.go @@ -30,6 +30,8 @@ import ( "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/a1" "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/models" + "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/policy" + "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/restapi/operations/a1_mediator" "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/rmr" "gerrit.o-ran-sc.org/r/ric-plt/sdlgo" "github.com/santhosh-tekuri/jsonschema/v5" @@ -85,14 +87,18 @@ func (rh *Resthook) IsValidJson(err error) bool { return err == invalidJsonSchema } func NewResthook() *Resthook { - return createResthook(sdlgo.NewSyncStorage(), rmr.NewRMRSender()) + sdl := sdlgo.NewSyncStorage() + policyManager := policy.NewPolicyManager(sdl) + return createResthook(sdl, rmr.NewRMRSender(policyManager)) } func createResthook(sdlInst iSdl, rmrSenderInst rmr.IRmrSender) *Resthook { - return &Resthook{ + rh := &Resthook{ db: sdlInst, iRmrSenderInst: rmrSenderInst, } + + return rh } func (rh *Resthook) GetA1Health() bool { @@ -388,7 +394,7 @@ func (rh *Resthook) CreatePolicyInstance(policyTypeId models.PolicyTypeID, polic } message := rmr.Message{} - rmrMessage, err = message.PolicyMessage(strconv.FormatInt((int64(policyTypeId)), 10), string(policyInstanceID), httpBodyString, operation) + rmrMessage, err := message.PolicyMessage(strconv.FormatInt((int64(policyTypeId)), 10), string(policyInstanceID), httpBodyString, operation) if err != nil { a1.Logger.Error("error : %v", err) return err @@ -677,10 +683,10 @@ func (rh *Resthook) DeletePolicyInstance(policyTypeId models.PolicyTypeID, polic rh.storeDeletedPolicyInstanceMetadata(policyTypeId, policyInstanceID, creation_timestamp.(string)) message := rmr.Message{} - rmrMessage, err = message.PolicyMessage(strconv.FormatInt((int64(policyTypeId)), 10), string(policyInstanceID), "", "DELETE") - if err != nil { - a1.Logger.Error("error : %v", err) - return err + rmrMessage, err1 := message.PolicyMessage(strconv.FormatInt((int64(policyTypeId)), 10), string(policyInstanceID), "", "DELETE") + if err1 != nil { + a1.Logger.Error("error : %v", err1) + return err1 } isSent := rh.iRmrSenderInst.RmrSendToXapp(rmrMessage, a1PolicyRequest) if isSent {