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

Method removeFilteredPolicy

internal_api.go:504–521  ·  view source on GitHub ↗

removeFilteredPolicy removes rules based on field filters from the current policy.

(sec string, ptype string, fieldIndex int, fieldValues []string)

Source from the content-addressed store, hash-verified

502
503// removeFilteredPolicy removes rules based on field filters from the current policy.
504func (e *Enforcer) removeFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues []string) (bool, error) {
505 ok, err := e.removeFilteredPolicyWithoutNotify(sec, ptype, fieldIndex, fieldValues)
506 if !ok || err != nil {
507 return ok, err
508 }
509
510 if e.shouldNotify() {
511 var err error
512 if watcher, ok := e.watcher.(persist.WatcherEx); ok {
513 err = watcher.UpdateForRemoveFilteredPolicy(sec, ptype, fieldIndex, fieldValues...)
514 } else {
515 err = e.watcher.Update()
516 }
517 return true, err
518 }
519
520 return true, nil
521}
522
523func (e *Enforcer) updateFilteredPolicies(sec string, ptype string, newRules [][]string, fieldIndex int, fieldValues ...string) (bool, error) {
524 oldRules, err := e.updateFilteredPoliciesWithoutNotify(sec, ptype, newRules, fieldIndex, fieldValues...)

Calls 4

shouldNotifyMethod · 0.95
UpdateMethod · 0.65

Tested by

no test coverage detected