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 TypeMethodDescriptionvoiddoApprove(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, String comment) POSTapprove?comment=...— approver decision (comment optional).voiddoCancel(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) POSTcancel— authenticated users only; service enforces requester-or-Manage.voiddoChangeApprover(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) POSTchangeApproverwith the repeatedapproversfield — replaces the designated set of a PENDING grant request (D-26, D-37).voiddoReject(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, String comment) POSTreject?comment=...— approver decision (service enforces non-empty comment).voiddoRevoke(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) POSTrevoke— 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 StringendedLabel(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(Grant grant) Jelly form ofendedLabel(Grant).Jelly helper: human-readable timestamp.formErrors(String form) The refusal of formformon this request, or an empty one (DEF-09, Jelly).Approver candidates for the change-approver form (global list, self excluded).getGrant()The permission window of this request once approved (it carries the request's id), ornull.getId()D-75 (1), security-39 S-39-04: the name the Scope row shows (tags/scopeItem.jelly).Permissions for this screen'sl:layout(the same set its section gate checks).booleanView gating for the cancel link; the service enforces requester-or-Manage.booleanView gating for the change-approver form; the service enforces requester-only.booleanView gating for the approve/reject forms: only a member of the designated set sees them (D-29, D-37).booleanR4-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.booleanisDesignated(String approver) Whether the change-approver picker starts with this candidate checked.booleanWhether the current user is the requester (view gating only; the service re-checks).booleanWhether the request is still awaiting a decision.booleanD-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.booleanD-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 asisShowGroupConfigureNotice(), whose notice already says it for an item group.booleanD-50a (SPEC item 2): whether this page shows the fixed warning that builds can run as SYSTEM on this instance.booleanWhether the window is open now.join(Collection<?> items) Jelly helper: comma-joined action list ("CREATE, CONFIGURE").Jelly helper: how much of the window is left.
-
Method Details
-
getRequest
-
getId
-
getDisplayName
- Specified by:
getDisplayNamein interfaceModelObject
-
format
Jelly helper: human-readable timestamp. -
join
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
Approver candidates for the change-approver form (global list, self excluded). -
isDesignated
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
The permission window of this request once approved (it carries the request's id), ornull. Read once per rendering. -
isWindowOpen
public boolean isWindowOpen()Whether the window is open now. -
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
Jelly helper: how much of the window is left. -
endedLabel
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
Jelly form ofendedLabel(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 whileSystemBuildCheck.buildsMayRunAsSystem()holds, and only to a viewer who may decide this request (isCanDecide()) or holdsBatchControl/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 asisShowGroupConfigureNotice(), whose notice already says it for an item group. -
getViewPermissions
Permissions for this screen'sl: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 POSTapprove?comment=...— approver decision (comment optional).- Throws:
IOExceptionjakarta.servlet.ServletException
-
doReject
public void doReject(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, @QueryParameter String comment) throws IOException, jakarta.servlet.ServletException POSTreject?comment=...— approver decision (service enforces non-empty comment).- Throws:
IOExceptionjakarta.servlet.ServletException
-
doCancel
public void doCancel(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException POSTcancel— authenticated users only; service enforces requester-or-Manage.- Throws:
IOExceptionjakarta.servlet.ServletException
-
doChangeApprover
public void doChangeApprover(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException POSTchangeApproverwith the repeatedapproversfield — 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:
IOExceptionjakarta.servlet.ServletException
-
doRevoke
public void doRevoke(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp) throws IOException, jakarta.servlet.ServletException POSTrevoke— 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:
IOExceptionjakarta.servlet.ServletException
-
formErrors
The refusal of formformon this request, or an empty one (DEF-09, Jelly).
-