Class GrantRequestItem

java.lang.Object
io.jenkins.plugins.batchcontrol.action.GrantRequestItem
All Implemented Interfaces:
ModelObject

@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public class GrantRequestItem extends Object implements ModelObject
One grant request at /batch-control/grants/<id>/: detail view plus the five state-changing POST endpoints (approve, reject, cancel, changeApprover and, for its open window, revoke — R4-12).

Every endpoint is @RequirePOST (GET never changes state) and performs its permission check before delegating; all business rules (approver eligibility, comment requirements, requester-or-Manage cancel rule, atomic state transitions, grant creation on approval) are enforced by GrantRequestService — this class contains zero state logic.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    doApprove(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, String comment)
    POST approve?comment=... — approver decision (comment optional).
    void
    doCancel(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp)
    POST cancel — authenticated users only; service enforces requester-or-Manage.
    void
    doChangeApprover(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp)
    POST changeApprover with the repeated approvers field — replaces the designated set of a PENDING grant request (D-26, D-37).
    void
    doReject(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, String comment)
    POST reject?comment=... — approver decision (service enforces non-empty comment).
    void
    doRevoke(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp)
    POST revoke — R4-12: revokes this request's open window from its own page, with the permission rule of the Grants list's Revoke (BatchControl/Manage, SPEC item 8).
    static String
    How a window ended, in words: "Expired", "Revoked by admin", or for a revocation by the change control switch "Revoked (change control turned off) by admin".
    Jelly form of endedLabel(Grant).
    format(Instant instant)
    Jelly helper: human-readable timestamp.
    The refusal of form form on this request, or an empty one (DEF-09, Jelly).
    Approver candidates for the change-approver form (global list, self excluded).
     
    The permission window of this request once approved (it carries the request's id), or null.
     
     
    D-75 (1), security-39 S-39-04: the name the Scope row shows (tags/scopeItem.jelly).
    Permissions for this screen's l:layout (the same set its section gate checks).
    boolean
    View gating for the cancel link; the service enforces requester-or-Manage.
    boolean
    View gating for the change-approver form; the service enforces requester-only.
    boolean
    View gating for the approve/reject forms: only a member of the designated set sees them (D-29, D-37).
    boolean
    R4-12: view gating for the Revoke button of this page, the rule of the Grants list's Revoke (BatchControl/Manage); doRevoke(org.kohsuke.stapler.StaplerRequest2, org.kohsuke.stapler.StaplerResponse2) and the service re-check.
    boolean
    isDesignated(String approver)
    Whether the change-approver picker starts with this candidate checked.
    boolean
    Whether the current user is the requester (view gating only; the service re-checks).
    boolean
    Whether the request is still awaiting a decision.
    boolean
    D-71a (5), security-34 S-34-02: whether this page states that the settings of the item group the request names reach the items inside it.
    boolean
    D-71c (security-36 S-36-02, S-36-04): whether this page states that a Configure window does not allow renaming the item, for a CONFIGURE request whose item is not an item group (a job, or an item whose kind is no longer known), to the same audience as isShowGroupConfigureNotice(), whose notice already says it for an item group.
    boolean
    D-50a (SPEC item 2): whether this page shows the fixed warning that builds can run as SYSTEM on this instance.
    boolean
    Whether the window is open now.
    join(Collection<?> items)
    Jelly helper: comma-joined action list ("CREATE, CONFIGURE").
    remaining(Instant expiresAt)
    Jelly helper: how much of the window is left.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getRequest

      public GrantRequest getRequest()
    • getId

      public String getId()
    • getDisplayName

      public String getDisplayName()
      Specified by:
      getDisplayName in interface ModelObject
    • format

      public String format(Instant instant)
      Jelly helper: human-readable timestamp.
    • join

      public String join(Collection<?> items)
      Jelly helper: comma-joined action list ("CREATE, CONFIGURE").
    • isPending

      public boolean isPending()
      Whether the request is still awaiting a decision. Compared by status name so the view model does not depend on the concrete status enum type.
    • isOwnedByCurrentUser

      public boolean isOwnedByCurrentUser()
      Whether the current user is the requester (view gating only; the service re-checks).
    • isCanDecide

      public boolean isCanDecide()
      View gating for the approve/reject forms: only a member of the designated set sees them (D-29, D-37). The endpoints and the service re-check for real.
    • isCanChangeApprover

      public boolean isCanChangeApprover()
      View gating for the change-approver form; the service enforces requester-only.
    • getApproverOptions

      public List<String> getApproverOptions()
      Approver candidates for the change-approver form (global list, self excluded).
    • isDesignated

      public boolean isDesignated(String approver)
      Whether the change-approver picker starts with this candidate checked.
    • isCanCancel

      public boolean isCanCancel()
      View gating for the cancel link; the service enforces requester-or-Manage.
    • getGrant

      @CheckForNull public Grant getGrant()
      The permission window of this request once approved (it carries the request's id), or null. Read once per rendering.
    • isWindowOpen

      public boolean isWindowOpen()
      Whether the window is open now.
    • getShownScope

      public ScopeDisplay getShownScope()
      D-75 (1), security-39 S-39-04: the name the Scope row shows (tags/scopeItem.jelly). The window's followed name (currentScope()) only to a viewer who may read the item now, or an administrator; anyone else (the requester and approvers included) sees the approved name with the fixed "moved" note. Unchanged when the name did not change.
    • isCanRevoke

      public boolean isCanRevoke()
      R4-12: view gating for the Revoke button of this page, the rule of the Grants list's Revoke (BatchControl/Manage); doRevoke(org.kohsuke.stapler.StaplerRequest2, org.kohsuke.stapler.StaplerResponse2) and the service re-check.
    • remaining

      public String remaining(@CheckForNull Instant expiresAt)
      Jelly helper: how much of the window is left.
    • endedLabel

      public static String endedLabel(Grant grant)
      How a window ended, in words: "Expired", "Revoked by admin", or for a revocation by the change control switch "Revoked (change control turned off) by admin".
    • endedLabelOf

      public String endedLabelOf(Grant grant)
      Jelly form of endedLabel(Grant).
    • isShowSystemBuildWarning

      public boolean isShowSystemBuildWarning()
      D-50a (SPEC item 2): whether this page shows the fixed warning that builds can run as SYSTEM on this instance. Only for a pending request that includes CONFIGURE, only while SystemBuildCheck.buildsMayRunAsSystem() holds, and only to a viewer who may decide this request (isCanDecide()) or holds BatchControl/Manage; the requester sees it only as one of those. The warning is instance-wide and names nothing, so it tells no viewer anything about the jobs in the scope.
    • isShowGroupConfigureNotice

      public boolean isShowGroupConfigureNotice()
      D-71a (5), security-34 S-34-02: whether this page states that the settings of the item group the request names reach the items inside it. For a request that includes CONFIGURE on an item group that is not a job (a folder, a multibranch project, an organization folder; a multi-configuration project is a job, its configurations are part of it), shown to a designated approver and to the requester, whatever the request's status: a window on the group confers nothing on its children (D-71), but the group's own configuration (for example an implicitly loaded Pipeline library, or a computed folder's sources) still affects them, and the decision and the request should be made knowing it.

      Decided from the kind recorded with the request (its descriptor's item class), or else from the current item as the viewer may see it (Visibility.findVisibleItem(java.lang.String)); either saying "group" is enough. The page already shows that kind next to the name, so the notice discloses nothing more about the item.

    • isShowNoRenameNotice

      public boolean isShowNoRenameNotice()
      D-71c (security-36 S-36-02, S-36-04): whether this page states that a Configure window does not allow renaming the item, for a CONFIGURE request whose item is not an item group (a job, or an item whose kind is no longer known), to the same audience as isShowGroupConfigureNotice(), whose notice already says it for an item group.
    • getViewPermissions

      public Permission[] getViewPermissions()
      Permissions for this screen's l:layout (the same set its section gate checks).
    • doApprove

      public void doApprove(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, @QueryParameter String comment) throws IOException, jakarta.servlet.ServletException
      POST approve?comment=... — approver decision (comment optional).
      Throws:
      IOException
      jakarta.servlet.ServletException
    • doReject

      public void doReject(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, @QueryParameter String comment) throws IOException, jakarta.servlet.ServletException
      POST reject?comment=... — approver decision (service enforces non-empty comment).
      Throws:
      IOException
      jakarta.servlet.ServletException
    • doCancel

      public void doCancel(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException
      POST cancel — authenticated users only; service enforces requester-or-Manage.
      Throws:
      IOException
      jakarta.servlet.ServletException
    • doChangeApprover

      public void doChangeApprover(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException
      POST changeApprover with the repeated approvers field — replaces the designated set of a PENDING grant request (D-26, D-37). The service enforces requester-only, PENDING and eligibility, and records (previous set, new set, by, at).
      Throws:
      IOException
      jakarta.servlet.ServletException
    • doRevoke

      public void doRevoke(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException
      POST revoke — R4-12: revokes this request's open window from its own page, with the permission rule of the Grants list's Revoke (BatchControl/Manage, SPEC item 8). The service re-checks and refuses an unknown or already revoked window; a refusal is shown on this page. Redirects back to this page.
      Throws:
      IOException
      jakarta.servlet.ServletException
    • formErrors

      public FormErrors formErrors(String form)
      The refusal of form form on this request, or an empty one (DEF-09, Jelly).