Class RecordLookup
/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 Summary
Modifier and TypeMethodDescriptionstatic <T> Tfind(String id, String what, Function<String, T> load, Function<? super T, String> idOf, Predicate<? super T> visible) The recordidnames if the current user may see it, elsenull(rendered as 404), whatever the reason.static booleanisWellFormed(String id) Whetheridhas the shape of a store id (see the class comment).
-
Method Details
-
isWellFormed
Whetheridhas 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 recordidnames if the current user may see it, elsenull(rendered as 404), whatever the reason.- Parameters:
id- the id from the URL or the link; may be anythingwhat- what the record is, for the log ("run request"); a constant, never inputload- the store lookup,nullfor an unknown id; called only with a well-formed ididOf- the stored id of a loaded recordvisible- the P-09 predicate for the current user, applied to the loaded record
-