Record Class RowJobSubmit

java.lang.Object
java.lang.Record
org.apache.juneau.console.views.RowJobSubmit
Record Components:
action - The submitted action id.
targetId - The submitted row id.
idempotencyKey - The submitted key value.
fields - The submitted fields; empty when the body omitted them.

public record RowJobSubmit(String action, String targetId, String idempotencyKey, JsonMap fields) extends Record
The action-envelope submit of a row job: {action, targetId, idempotencyKey, fields}, the shape the row-action dialog and the job-log card's envelope: "action" both send.

parse(JsonMap) checks the shape; verify(JobKeyLedger, String, String) checks the action, then the key's recorded binding. The row identity is targetId() plus that binding — never anything in fields(), which is user-tamperable request data. An endpoint that also carries the row id in its path should check targetId().equals(pathId) first.

Example:

var submit = RowJobSubmit.parse(json); if (! submit.targetId().equals(id)) return refuse(res, RowJobSubmit.bindingRefusal()); var grant = submit.verify(jobKeys, "restock-species", actor); if (grant.isEmpty()) return refuse(res, RowJobSubmit.bindingRefusal()); // answered 409

See Also:
Since:
10.0.0
  • Field Details

  • Constructor Details

    • RowJobSubmit

      public RowJobSubmit(String action, String targetId, String idempotencyKey, JsonMap fields)
      Creates an instance of a RowJobSubmit record class.
      Parameters:
      action - the value for the action record component
      targetId - the value for the targetId record component
      idempotencyKey - the value for the idempotencyKey record component
      fields - the value for the fields record component
  • Method Details

    • parse

      public static RowJobSubmit parse(JsonMap body)
      Parses the envelope.
      Parameters:
      body - The request body.
      Returns:
      The submit.
      Throws:
      BadRequest - On a non-object body, a blank action, targetId or idempotencyKey, or a fields member that is not an object. A missing fields reads as empty.
    • verify

      public Optional<JobKeyLedger.Grant> verify(JobKeyLedger ledger, String expectedAction)
      Checks the action, then the key's binding to (action, targetId).
      Parameters:
      ledger - The ledger the key was issued from.
      expectedAction - The action this endpoint performs.
      Returns:
      The grant, or empty when the action differs or the key does not verify.
    • verify

      public Optional<JobKeyLedger.Grant> verify(JobKeyLedger ledger, String expectedAction, String principal)
      Checks the action, then the key's binding to (action, targetId, principal).
      Parameters:
      ledger - The ledger the key was issued from.
      expectedAction - The action this endpoint performs.
      principal - The actor, resolved the same way the key endpoint resolved it.
      Returns:
      The grant, or empty when the action differs or the key does not verify.
    • bindingRefusal

      public static ActionResult bindingRefusal()
      The standard refusal for a failed verify; answer it with REFUSAL_STATUS.

      One code and one message for every kind of miss (see JobKeyLedger).

      Returns:
      A new refusal.
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • action

      public String action()
      Returns the value of the action record component.
      Returns:
      the value of the action record component
    • targetId

      public String targetId()
      Returns the value of the targetId record component.
      Returns:
      the value of the targetId record component
    • idempotencyKey

      Returns the value of the idempotencyKey record component.
      Returns:
      the value of the idempotencyKey record component
    • fields

      public JsonMap fields()
      Returns the value of the fields record component.
      Returns:
      the value of the fields record component