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

Method removePoliciesWithoutNotify

internal_api.go:243–277  ·  view source on GitHub ↗

removePolicies removes rules from the current policy.

(sec string, ptype string, rules [][]string)

Source from the content-addressed store, hash-verified

241
242// removePolicies removes rules from the current policy.
243func (e *Enforcer) removePoliciesWithoutNotify(sec string, ptype string, rules [][]string) (bool, error) {
244 if hasPolicies, err := e.model.HasPolicies(sec, ptype, rules); !hasPolicies || err != nil {
245 return hasPolicies, err
246 }
247
248 if e.dispatcher != nil && e.autoNotifyDispatcher {
249 return true, e.dispatcher.RemovePolicies(sec, ptype, rules)
250 }
251
252 if e.shouldPersist() {
253 if err := e.adapter.(persist.BatchAdapter).RemovePolicies(sec, ptype, rules); err != nil {
254 if err.Error() != notImplemented {
255 return false, err
256 }
257 }
258 }
259
260 rulesRemoved, err := e.model.RemovePolicies(sec, ptype, rules)
261 if !rulesRemoved || err != nil {
262 return rulesRemoved, err
263 }
264
265 if sec == "g" {
266 err := e.BuildIncrementalRoleLinks(model.PolicyRemove, ptype, rules)
267 if err != nil {
268 return rulesRemoved, err
269 }
270
271 // Validate constraints after removing grouping policies
272 if err := e.validateConstraintsForGroupingPolicy(); err != nil {
273 return false, err
274 }
275 }
276 return rulesRemoved, nil
277}
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) {

Callers 2

removePoliciesMethod · 0.95
SelfRemovePoliciesMethod · 0.95

Calls 6

shouldPersistMethod · 0.95
HasPoliciesMethod · 0.80
RemovePoliciesMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected