Class RecordLookup

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

@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public final class RecordLookup extends Object
Resolves a record id that arrives as a URL segment (/batch-control/requests/<id>/ and the other detail URLs) or is about to become a link to one (S-39-01).

Every way a lookup can fail answers null, which Stapler renders as 404, exactly like an unknown id or a record the caller may not see (P-09): a malformed id, a missing or unreadable file, a file holding another kind of object, a record stored under another id, an I/O error, or a visibility check that cannot complete. An HTTP 500 would tell an existing record from a missing one.

The id's shape is checked before anything reaches the store. Request and window ids are UUIDs (D-68), earlier request ids and history ids are yyyyMMdd-HHmmss-<6>: letters, digits and - only. A . never passes, so <id>.values or <id>.VALUES cannot reach a run request's values file (D-74) on any file system, and / \ % ~ cannot name another path or a Windows short name. The record read must carry the id that was asked for, so a case-insensitive file system does not serve a record under a second URL either. Nothing but the record the id names is read, and the visibility check runs before anything of it is used.

Logging never writes the raw URL segment: a malformed id is logged at FINE without it, and an id that reached the store has the checked shape, so it cannot start a new log line.

  • Method Details

    • isWellFormed

      public static boolean isWellFormed(@CheckForNull String id)
      Whether id has the shape of a store id (see the class comment).
    • find

      @CheckForNull public static <T> T find(@CheckForNull String id, String what, Function<String,T> load, Function<? super T,String> idOf, Predicate<? super T> visible)
      The record id names if the current user may see it, else null (rendered as 404), whatever the reason.
      Parameters:
      id - the id from the URL or the link; may be anything
      what - what the record is, for the log ("run request"); a constant, never input
      load - the store lookup, null for an unknown id; called only with a well-formed id
      idOf - the stored id of a loaded record
      visible - the P-09 predicate for the current user, applied to the loaded record