Class GrantRequiredFailure

All Implemented Interfaces:
Serializable, org.kohsuke.stapler.HttpResponse

@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public class GrantRequiredFailure extends Failure
The refusal of a change that needs a permission window the user does not hold (SPEC item 8), for example the delete veto (e2e-03 DEF-26). Thrown in place of a plain Failure.

The advice depends on the refused user, and is decided when the refusal is built (in the refused user's own request): a user who may open the Grants screen and request windows (BatchControl/RequestGrant, change control on) is pointed at the new-request form prefilled for the item and action; anyone else is told whom to ask, because the Grants screen would answer 403 to them. Throwable.getMessage() carries the same advice as plain text for the CLI and scripts; in a browser generateResponse(org.kohsuke.stapler.StaplerRequest2, org.kohsuke.stapler.StaplerResponse2, java.lang.Object, java.lang.Throwable) renders index.jelly, which links the form only for the first kind of user. HTTP 400 like the Failure it replaces; it never changes state.

D-71: when no window can allow the change at all — Delete of an item group that is not a job (a folder, a multibranch project, an organization folder), or Create in a group that is not a regular folder — nobody is pointed at the form (the request would be refused at submission); the page and the message say that an administrator has to make the change.

See Also:
  • Constructor Details

    • GrantRequiredFailure

      public GrantRequiredFailure(Item item, GrantAction action, String change)
      Parameters:
      item - the item the refused change is about; for a refused Create, the folder the new item was to be created in (the window would name that folder)
      action - the permission window that would allow it
      change - the refused change in words, for example "deleting" or "creating an item in"
  • Method Details

    • getItemFullName

      public String getItemFullName()
    • getActionLabel

      public String getActionLabel()
      "Delete", "Configure" or "Create", for the page.
    • isCanRequest

      public boolean isCanRequest()
      Whether the refused user may request the window and a window can allow the change (D-71), so the page links the form.
    • isWindowApplies

      public boolean isWindowApplies()
      D-71: whether a permission window can allow the change at all. false for Delete of an item group that is not a job and for Create in a group that is not a regular folder: only an administrator can make such a change.
    • isDelete

      public boolean isDelete()
      Whether the refused change is a delete (the page then says "delete (or move) it").
    • getItemKindName

      public String getItemKindName()
      The kind of the item in words, for example "Folder" or "Multibranch Pipeline".
    • isPartOfJob

      public boolean isPartOfJob()
      Whether the item is part of a job (no window can name it), for the page's wording.
    • isGroup

      public boolean isGroup()
      Whether the item contains other items, for the page's wording of a refused delete.
    • getRequestUrl

      @CheckForNull public String getRequestUrl()
      Root-relative URL of the new-request form prefilled for the item and action (batch-control/grants/new?scopeFullName=<item>&actions=<ACTION>), or null when no window can allow the change. The Grants screen resolves the name again as the viewer, so nothing here is echoed unchecked.
    • generateResponse

      public void generateResponse(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, Object node, @CheckForNull Throwable throwable) throws IOException, jakarta.servlet.ServletException
      Overrides:
      generateResponse in class Failure
      Throws:
      IOException
      jakarta.servlet.ServletException
    • generateResponse

      public void generateResponse(org.kohsuke.stapler.StaplerRequest2 req, org.kohsuke.stapler.StaplerResponse2 rsp, Object node) throws IOException, jakarta.servlet.ServletException
      Specified by:
      generateResponse in interface org.kohsuke.stapler.HttpResponse
      Overrides:
      generateResponse in class Failure
      Throws:
      IOException
      jakarta.servlet.ServletException