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

Method removeFilteredPolicyWithoutNotify

internal_api.go:280–315  ·  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

278
279// removeFilteredPolicy removes rules based on field filters from the current policy.
280func (e *Enforcer) removeFilteredPolicyWithoutNotify(sec string, ptype string, fieldIndex int, fieldValues []string) (bool, error) {
281 if len(fieldValues) == 0 {
282 return false, Err.ErrInvalidFieldValuesParameter
283 }
284
285 if e.dispatcher != nil && e.autoNotifyDispatcher {
286 return true, e.dispatcher.RemoveFilteredPolicy(sec, ptype, fieldIndex, fieldValues...)
287 }
288
289 if e.shouldPersist() {
290 if err := e.adapter.RemoveFilteredPolicy(sec, ptype, fieldIndex, fieldValues...); err != nil {
291 if err.Error() != notImplemented {
292 return false, err
293 }
294 }
295 }
296
297 ruleRemoved, effects, err := e.model.RemoveFilteredPolicy(sec, ptype, fieldIndex, fieldValues...)
298 if !ruleRemoved || err != nil {
299 return ruleRemoved, err
300 }
301
302 if sec == "g" {
303 err := e.BuildIncrementalRoleLinks(model.PolicyRemove, ptype, effects)
304 if err != nil {
305 return ruleRemoved, err
306 }
307
308 // Validate constraints after removing filtered grouping policies
309 if err := e.validateConstraintsForGroupingPolicy(); err != nil {
310 return false, err
311 }
312 }
313
314 return ruleRemoved, nil
315}
316
317func (e *Enforcer) updateFilteredPoliciesWithoutNotify(sec string, ptype string, newRules [][]string, fieldIndex int, fieldValues ...string) ([][]string, error) {
318 var (

Callers 2

removeFilteredPolicyMethod · 0.95

Calls 5

shouldPersistMethod · 0.95
RemoveFilteredPolicyMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected