Class WriteCheck

java.lang.Object
com.axelor.ai.governance.access.WriteCheck

public final class WriteCheck extends Object
The one way the AI checks a write: every field it sets must be one the user may write.

Checked after the names and values are known to be valid, so a misspelling is reported as one rather than as a denial. Nested values are held to the model they are written to: a nested map with an id updates that record, so the user and the agent must be allowed to update it; one without creates one, so they must be allowed to create on its model. A map carrying only an id (and its version) links a record and writes none of its fields, but the record must be one they may read: a link to a record out of their reach is refused. An id is read as the write reads it, a number written as text included. A custom relational field only links, so each record it names must be one they may read.

  • Constructor Details

    • WriteCheck

      public WriteCheck(Access access)
  • Method Details

    • denial

      public String denial(Class<? extends Model> model, Map<String,Object> values)
      The refusal naming every field of values the user may not write, each by its path (items[2].discount); null when there is none.
    • denial

      public String denial(MetaJsonModel model, Map<String,Object> values)
      The same for a custom model's record, whose values are its own fields.
    • pathDenial

      public String pathDenial(ModelRef form, Collection<String> paths)
      The refusal for form fields a procedure sets, each named by its path on the form: a field (note), or a line's field after the line (items[-1].qty, items[#42].qty). A line is written through its collection, so the collection must be writable too. A name that is no field of its model — a dummy, a display key — stores nothing and is not checked.
      Parameters:
      form - the model the form edits