applyOperationsToModel applies all buffered operations to the in-memory model.
()
| 209 | |
| 210 | // applyOperationsToModel applies all buffered operations to the in-memory model. |
| 211 | func (tx *Transaction) applyOperationsToModel() error { |
| 212 | // Create new model with all operations applied. |
| 213 | newModel, err := tx.buffer.ApplyOperationsToModel(tx.buffer.GetModelSnapshot()) |
| 214 | if err != nil { |
| 215 | return err |
| 216 | } |
| 217 | |
| 218 | // Replace the enforcer's model. |
| 219 | tx.enforcer.model = newModel |
| 220 | tx.enforcer.invalidateMatcherMap() |
| 221 | |
| 222 | // Rebuild role links if necessary. |
| 223 | if tx.enforcer.autoBuildRoleLinks { |
| 224 | // Check if any operations involved grouping policies. |
| 225 | operations := tx.buffer.GetOperations() |
| 226 | needRoleRebuild := false |
| 227 | |
| 228 | for _, op := range operations { |
| 229 | if op.Section == "g" { |
| 230 | needRoleRebuild = true |
| 231 | break |
| 232 | } |
| 233 | } |
| 234 | |
| 235 | if needRoleRebuild { |
| 236 | if err := tx.enforcer.BuildRoleLinks(); err != nil { |
| 237 | return err |
| 238 | } |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | return nil |
| 243 | } |
| 244 | |
| 245 | // IsCommitted returns true if the transaction has been committed. |
| 246 | func (tx *Transaction) IsCommitted() bool { |
no test coverage detected