Class ApproverInput

java.lang.Object
io.jenkins.plugins.batchcontrol.ui.ApproverInput

@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public final class ApproverInput extends Object
Reads the designated approver set from a submitted form (SPEC item 3, D-37).

The field is the repeated approvers (one user id per value), which is what the rendered checkbox picker posts. For scripts written against the single-approver contract the old approver field is still read and merged in. When a form arrives only as a json blob (as getSubmittedForm reads it), approvers may be a string or an array of strings there.

A multipart/form-data body (the Request Run form, D-72) keeps only the last part of a repeated field in Stapler, so there the json blob the form posts with it is read as instead (RepeatedField): the rendered checkboxes put the checked ids into it in order, and when it holds ids they are the whole set (the raw part, which Stapler decodes as ISO-8859-1 without a part charset, is then not read). Without ids in the blob the raw part is used.

Validation here is shape only: entries are trimmed, blanks dropped, duplicates collapsed, and the count and length are bounded so a request cannot carry unbounded input. Eligibility (listed approver, not the requester, job restriction) stays in the policy layer.

  • Field Details

    • MAX_APPROVERS

      public static final int MAX_APPROVERS
      Upper bound on the number of designated approvers in one submission.
      See Also:
    • MAX_USER_ID_LENGTH

      public static final int MAX_USER_ID_LENGTH
      Upper bound on one user id.
      See Also:
    • FIELD

      public static final String FIELD
      Field name of the repeated approver field.
      See Also:
    • LEGACY_FIELD

      public static final String LEGACY_FIELD
      Field name of the single-approver field accepted for compatibility.
      See Also:
  • Method Details

    • read

      public static List<String> read(org.kohsuke.stapler.StaplerRequest2 req, @CheckForNull net.sf.json.JSONObject formData)
      Parameters:
      req - the current request
      formData - the parsed json blob when the form carried one, otherwise null (for a multipart request the blob is then read from the request when it carries one)
      Returns:
      the trimmed, de-duplicated approver ids in submission order, possibly empty (the service then refuses the request with its own message)
      Throws:
      Failure - when the input exceeds the count or length bounds