(ctx context.Context, baseModel model.Model)
| 66 | } |
| 67 | |
| 68 | func (e *ContextEnforcer) loadPolicyFromAdapterCtx(ctx context.Context, baseModel model.Model) (model.Model, error) { |
| 69 | newModel := baseModel.Copy() |
| 70 | newModel.ClearPolicy() |
| 71 | |
| 72 | if err := e.adapterCtx.LoadPolicyCtx(ctx, newModel); err != nil && err.Error() != "invalid file path, file path cannot be empty" { |
| 73 | return nil, err |
| 74 | } |
| 75 | |
| 76 | if err := newModel.SortPoliciesBySubjectHierarchy(); err != nil { |
| 77 | return nil, err |
| 78 | } |
| 79 | |
| 80 | if err := newModel.SortPoliciesByPriority(); err != nil { |
| 81 | return nil, err |
| 82 | } |
| 83 | |
| 84 | return newModel, nil |
| 85 | } |
| 86 | |
| 87 | // LoadFilteredPolicyCtx loads all policy rules from the storage with context and filter. |
| 88 | func (e *Enforcer) LoadFilteredPolicyCtx(ctx context.Context, filter interface{}) error { |
no test coverage detected