MCPcopy
hub / github.com/apache/casbin / updatePolicy

Method updatePolicy

internal_api.go:445–462  ·  view source on GitHub ↗
(sec string, ptype string, oldRule []string, newRule []string)

Source from the content-addressed store, hash-verified

443}
444
445func (e *Enforcer) updatePolicy(sec string, ptype string, oldRule []string, newRule []string) (bool, error) {
446 ok, err := e.updatePolicyWithoutNotify(sec, ptype, oldRule, newRule)
447 if !ok || err != nil {
448 return ok, err
449 }
450
451 if e.shouldNotify() {
452 var err error
453 if watcher, ok := e.watcher.(persist.UpdatableWatcher); ok {
454 err = watcher.UpdateForUpdatePolicy(sec, ptype, oldRule, newRule)
455 } else {
456 err = e.watcher.Update()
457 }
458 return true, err
459 }
460
461 return true, nil
462}
463
464func (e *Enforcer) updatePolicies(sec string, ptype string, oldRules [][]string, newRules [][]string) (bool, error) {
465 ok, err := e.updatePoliciesWithoutNotify(sec, ptype, oldRules, newRules)

Callers 2

UpdateNamedPolicyMethod · 0.95

Calls 4

shouldNotifyMethod · 0.95
UpdateForUpdatePolicyMethod · 0.65
UpdateMethod · 0.65

Tested by

no test coverage detected