diff --git a/models/peer/peer_cache.go b/models/peer/peer_cache.go index eff1895..8509136 100644 --- a/models/peer/peer_cache.go +++ b/models/peer/peer_cache.go @@ -71,16 +71,13 @@ func (p *PeerCache) checkPeerStatus(peerID string, appName string, caller *tools // LaunchPeerExecution launches an execution on a peer func (p *PeerCache) LaunchPeerExecution(peerID string, dataID string, dt tools.DataType, method tools.METHOD, body map[string]interface{}, caller *tools.HTTPCaller) (*PeerExecution, error) { + fmt.Println("Launching peer execution on", caller.URLS, dt, method) methods := caller.URLS[dt] // Get the methods url of the data type - if _, ok := methods[method]; !ok { + if m, ok := methods[method]; !ok || m == "" { return nil, errors.New("no path found") } - meth := methods[method] // Get the method url to execute - if meth == "" { - return nil, errors.New("no path found") - } else { - meth = strings.ReplaceAll(meth, ":id", dataID) // Replace the id in the url in case of a DELETE / UPDATE method (it's a standard naming in OC) - } + meth := methods[method] // Get the method url to execute + meth = strings.ReplaceAll(meth, ":id", dataID) // Replace the id in the url in case of a DELETE / UPDATE method (it's a standard naming in OC) url := "" // Check the status of the peer if mypeer, ok := p.checkPeerStatus(peerID, dt.API(), caller); !ok { diff --git a/models/workflow/workflow_mongo_accessor.go b/models/workflow/workflow_mongo_accessor.go index 82327e8..5f7ce51 100644 --- a/models/workflow/workflow_mongo_accessor.go +++ b/models/workflow/workflow_mongo_accessor.go @@ -192,6 +192,9 @@ func (wfa *workflowMongoAccessor) share(realData *Workflow, delete bool, caller * execution is a create or delete function for the workflow executions depending on the schedule of the workflow */ func (wfa *workflowMongoAccessor) execution(id string, realData *Workflow, delete bool) (int, error) { + if ok, _ := realData.CheckBooking(wfa.Caller); !ok { // check the booking of the workflow + return 409, errors.New("could not book the workflow") + } var err error nats := tools.NewNATSCaller() // create a new nats caller because executions are sent to the nats for daemons if !realData.ScheduleActive { // if the schedule is not active, delete the executions