Class CatalogueClient
/v1/catalogue/* (plans 22-18 and 22-26,
D-27, D-28).
The routes, the response envelope {data: ...} and the version object follow the frozen
catalogue REST contract "1.0.0" of UltiCloud (UltiKits/ulticloud main
commit 682735c9, packages/contracts/generated/rest-v1/catalogue/1.0.0/), whose
schemas and fixtures the tests read byte for byte. A module is addressed by its identifier; a
version names its sizeBytes, its lower-case sha256, its apiLevel (an
integer, or null when unknown) and a download whose kind is
public (with an absolute https: URL), license_required or withdrawn.
Every kind but public is not downloadable.
A version object that breaks the contract in a field the install relies on -- a sha256
that is not 64 lower-case hex characters, a sizeBytes below 1, a missing or out-of-range
apiLevel, a missing isLatest or version, a public download without a URL --
is unusable: the lookup answers nothing, as for an unreadable body, and no download is requested.
Keys the client does not read, including keys a later contract may add, are ignored.
Only the versions route takes the API-level filter (apiLevel, minApiLevel);
the other routes reject undeclared parameters, so no request carries them. A
download.url is accepted only when it is absolute and stays on the configured base URL's origin
(in production https://api.ultikits.com); a relative path, which the contract never
produces, is refused, so a catalogue answer can never send a download elsewhere.
- Since:
- 6.3.1
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classOne version of one module, as the catalogue describes it. -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final StringThe catalogue REST contract version this client implements; the vendored lock must name the same.(package private) static final StringThe route naming the newest UltiTools version.private static final PatternThe contract's URL rule for icons: an absolutehttps:URL without spaces or control characters.private static final intprivate static final longThe largestsizeBytesthe contract allows (2^53 - 1).private static final intThe longest URL the contract allows.private static final intThe contract'sapiLevelrange.(package private) static final StringThe route prefix of every catalogue request.private static final PatternThe contract'ssha256: 64 lower-case hex characters. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static StringChecks adownload.urlagainst the configured base URL.private static com.google.gson.JsonObjectprivate static com.google.gson.JsonObjectdataObject(CatalogueHttp.Json answer) private static StringencodeSegment(String value) (package private) static VersionLookupLooks up the newest UltiTools version.private static Stringprivate static Dateprivate static BigDecimalinteger(com.google.gson.JsonElement value) private static com.google.gson.JsonArrayitemsOf(CatalogueHttp.Json answer) (package private) static VersionLookuplatestVersion(String identifyString, int level) Looks up a module's newest installable version, for a module the catalogue knows.(package private) static StringlevelQuery(int level) (package private) static List<PluginEntity> list(int page, int pageSize) Reads one page of the catalogue.(package private) static VersionLookuplookUpVersions(String identifyString, int level, List<CatalogueClient.Version> versions) Reads a version list without folding an unknown module into a successful empty list.(package private) static PluginEntityReads one module.(package private) static VersionLookupmoduleKnown(String identifyString) Whether the catalogue knows a module at all.(package private) static StringThe contract's:moduleReffor a module: its identifier (lower-case letter first, segments separated by a single.or-, 1 to 64 characters), asModuleIds.of(String)derives it.(package private) static CatalogueClient.Versionnewest(List<CatalogueClient.Version> versions) private static List<CatalogueClient.Version> parseVersions(CatalogueHttp.Json answer) private static Stringprivate static PluginEntitytoEntity(com.google.gson.JsonObject card) Maps a module card into the entity the public catalogue methods have always returned.private static CatalogueClient.VersiontoVersion(com.google.gson.JsonObject object) Reads one version object, or refuses it:nullwhen a field the install relies on breaks the contract (see the class comment).(package private) static CatalogueClient.VersionReads one version.(package private) static List<CatalogueClient.Version> Reads the versions one framework can install, newest first as the catalogue lists them.
-
Field Details
-
MODULES
The route prefix of every catalogue request.- See Also:
-
FRAMEWORK
The route naming the newest UltiTools version.- See Also:
-
CONTRACT_VERSION
The catalogue REST contract version this client implements; the vendored lock must name the same.- See Also:
-
SHA256
The contract'ssha256: 64 lower-case hex characters. -
HTTPS_URL
The contract's URL rule for icons: an absolutehttps:URL without spaces or control characters. -
MAX_URL_LENGTH
private static final int MAX_URL_LENGTHThe longest URL the contract allows.- See Also:
-
MAX_SIZE_BYTES
private static final long MAX_SIZE_BYTESThe largestsizeBytesthe contract allows (2^53 - 1).- See Also:
-
MIN_API_LEVEL
private static final int MIN_API_LEVELThe contract'sapiLevelrange.- See Also:
-
MAX_API_LEVEL
private static final int MAX_API_LEVEL- See Also:
-
-
Constructor Details
-
CatalogueClient
private CatalogueClient()
-
-
Method Details
-
moduleRef
The contract's:moduleReffor a module: its identifier (lower-case letter first, segments separated by a single.or-, 1 to 64 characters), asModuleIds.of(String)derives it. The framework never addresses a module by its ULID.- Parameters:
identifyString- a module's identify-string- Returns:
- the segment the catalogue addresses it by, or
nullwhen it cannot be one
-
module
Reads one module.- Parameters:
identifyString- the module's identify-string- Returns:
- the module, or
nullwhen the catalogue does not know it or the answer is unusable
-
list
Reads one page of the catalogue.- Parameters:
page- the page number, from 1pageSize- the page size- Returns:
- the modules of that page; empty for every failure, as the public list contract says
-
versions
Reads the versions one framework can install, newest first as the catalogue lists them.- Parameters:
identifyString- the module's identify-stringlevel- this framework's API level- Returns:
- the versions, empty when the module is unknown, or
nullwhen the answer is unusable
-
lookUpVersions
static VersionLookup lookUpVersions(String identifyString, int level, List<CatalogueClient.Version> versions) Reads a version list without folding an unknown module into a successful empty list.- Parameters:
identifyString- the module's identify-stringlevel- this framework's API levelversions- collects the versions on success, including a successful empty list- Returns:
FOUNDwith the module identifier on success,NONEonly for an unknown module, orFAILEDwhen the answer is unusable
-
version
Reads one version.- Parameters:
identifyString- the module's identify-stringversion- the version string- Returns:
- the version, or
nullwhen the catalogue does not offer it
-
moduleKnown
Whether the catalogue knows a module at all.- Parameters:
identifyString- the module's identify-string- Returns:
FOUNDwith its identifier,NONEwhen the catalogue does not know it,FAILEDwhen the lookup established nothing
-
latestVersion
Looks up a module's newest installable version, for a module the catalogue knows.- Parameters:
identifyString- the module's identify-stringlevel- this framework's API level- Returns:
FOUNDwith the version,NONEwhen nothing installable (or nothing at all) is offered,FAILEDwhen the lookup established nothing
-
frameworkNewest
Looks up the newest UltiTools version.- Returns:
FOUNDwith the version, orFAILEDwhen the lookup established nothing
-
absoluteDownloadUrl
Checks adownload.urlagainst the configured base URL. The contract makes every URL absolute (https:in production) and tells callers to use it as an opaque address, so the URL is used as written, and only when it lies under the base URL: another host, another scheme, auser@hostform or a relative path is refused.- Parameters:
url- the value the catalogue answered- Returns:
- the URL, or
nullwhen it is relative or would leave the catalogue's origin
-
levelQuery
- Returns:
- the filter every versions request carries: this framework's level and the floor
-
newest
- Parameters:
versions- the versions to choose from, in any order- Returns:
- the one the catalogue marks as newest, the greatest otherwise, or
null
-
parseVersions
- Returns:
- the versions an answer carries, or
nullwhen it carries no usable list: one version that breaks the contract makes the whole answer unusable, so the newest version is never chosen from a list the catalogue got wrong
-
dataObject
-
itemsOf
-
data
-
toVersion
Reads one version object, or refuses it:nullwhen a field the install relies on breaks the contract (see the class comment). A value of the wrong JSON type is a refusal, never an exception. -
integer
- Returns:
- the JSON number as an integer, or
nullwhen it is absent, not a number or not whole
-
toEntity
Maps a module card into the entity the public catalogue methods have always returned. A v2 module is identified by a ULID and an identifier, and the entity's numericidhas no v2 counterpart, so it stays0;identifyStringis the field callers use. -
httpsUrl
- Returns:
- the URL when it is an absolute
https:URL the contract allows, otherwisenull
-
string
-
instant
-
encodeSegment
-