(sec string, ptype string, oldRule []string, newRule []string)
| 163 | } |
| 164 | |
| 165 | func (e *Enforcer) updatePolicyWithoutNotify(sec string, ptype string, oldRule []string, newRule []string) (bool, error) { |
| 166 | if e.dispatcher != nil && e.autoNotifyDispatcher { |
| 167 | return true, e.dispatcher.UpdatePolicy(sec, ptype, oldRule, newRule) |
| 168 | } |
| 169 | |
| 170 | if e.shouldPersist() { |
| 171 | if err := e.adapter.(persist.UpdatableAdapter).UpdatePolicy(sec, ptype, oldRule, newRule); err != nil { |
| 172 | if err.Error() != notImplemented { |
| 173 | return false, err |
| 174 | } |
| 175 | } |
| 176 | } |
| 177 | ruleUpdated, err := e.model.UpdatePolicy(sec, ptype, oldRule, newRule) |
| 178 | if !ruleUpdated || err != nil { |
| 179 | return ruleUpdated, err |
| 180 | } |
| 181 | |
| 182 | if sec == "g" { |
| 183 | err := e.BuildIncrementalRoleLinks(model.PolicyRemove, ptype, [][]string{oldRule}) // remove the old rule |
| 184 | if err != nil { |
| 185 | return ruleUpdated, err |
| 186 | } |
| 187 | err = e.BuildIncrementalRoleLinks(model.PolicyAdd, ptype, [][]string{newRule}) // add the new rule |
| 188 | if err != nil { |
| 189 | return ruleUpdated, err |
| 190 | } |
| 191 | |
| 192 | // Validate constraints after updating grouping policy |
| 193 | if err := e.validateConstraintsForGroupingPolicy(); err != nil { |
| 194 | return false, err |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | return ruleUpdated, nil |
| 199 | } |
| 200 | |
| 201 | func (e *Enforcer) updatePoliciesWithoutNotify(sec string, ptype string, oldRules [][]string, newRules [][]string) (bool, error) { |
| 202 | if len(newRules) != len(oldRules) { |
no test coverage detected