import (
"bytes"
"encoding/json"
- sdl "gerrit.oran-osc.org/r/ric-plt/sdlgo"
+ sdl "gerrit.o-ran-sc.org/r/ric-plt/sdlgo"
cmap "github.com/orcaman/concurrent-map"
"github.com/segmentio/ksuid"
"net/http"
"time"
- "gerrit.oran-osc.org/r/ric-plt/appmgr/pkg/appmgr"
- "gerrit.oran-osc.org/r/ric-plt/appmgr/pkg/models"
+ "gerrit.o-ran-sc.org/r/ric-plt/appmgr/pkg/appmgr"
+ "gerrit.o-ran-sc.org/r/ric-plt/appmgr/pkg/models"
)
func NewResthook(restoreData bool) *Resthook {
+ return createResthook(restoreData, sdl.NewSdlInstance("appmgr", sdl.NewDatabase()))
+}
+
+func createResthook(restoreData bool, sdlInst iSdl) *Resthook {
rh := &Resthook{
client: &http.Client{},
- db: sdl.NewSdlInstance("appmgr", sdl.NewDatabase()),
+ db: sdlInst,
}
if restoreData {
r := v.Val.(SubscriptionInfo).req
if *r.Data.TargetURL == *sr.Data.TargetURL && r.Data.EventType == sr.Data.EventType {
appmgr.Logger.Info("Similar subscription already exists!")
- return &models.SubscriptionResponse{}
+ resp := v.Val.(SubscriptionInfo).resp
+ return &resp
}
}
func (rh *Resthook) StoreSubscriptions(m cmap.ConcurrentMap) {
for v := range m.Iter() {
s := v.Val.(SubscriptionInfo)
-
data, err := json.Marshal(s.req)
if err != nil {
appmgr.Logger.Error("json.marshal failed: %v ", err.Error())