Class LegacyServerId
uuid in credentials.json) into the
legacyServerUuid value of the device authorization request (attachToServerId
is the panel's field on /v1/device/approve, never sent by the plugin).
There is no automatic migration of old servers (maintainer decision 31): the owner re-attaches
this server's old record on the confirmation page, and UltiCloud finds that record by this value.
canonical(String) must therefore equal the backend's canonicalLegacyUuid (backend
schema decision 22) exactly; a change to either side is made on both.
The decision text lists "remove hyphens" before "the first 36 characters form a hyphenated UUID",
which cannot both hold; this class applies the only order that makes sense -- cut a longer value to
its leading 36-character UUID first, then remove the hyphens (Phase 22 decision S-41). The
backend's golden fixture legacy-uuid-canonicalization.json (contract 2.0.0) confirms that
order, and LegacyServerIdTest runs every one of its cases.
- Since:
- 6.3.1
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static StringThe backend'scanonicalLegacyUuidrule: trim surrounding whitespace; if what remains is longer than 36 characters and its first 36 characters form a standard hyphenated UUID (8-4-4-4-12 hex digits, either case), keep only those 36; remove every-; lower-case ASCIIA-F; return the result only if it is exactly 32 hex digits.private static booleanisAsciiHex(char c) ASCII only:Character.digit(char, int)would also accept non-ASCII digits.private static booleanprivate static booleanisHyphenatedUuid(String value) private static StringlowerAsciiHex(String value) Lower-cases ASCIIA-Fonly, as the rule says.
-
Field Details
-
HEX_LENGTH
private static final int HEX_LENGTH- See Also:
-
HYPHENATED_LENGTH
private static final int HYPHENATED_LENGTH- See Also:
-
-
Constructor Details
-
LegacyServerId
private LegacyServerId()
-
-
Method Details
-
canonical
The backend'scanonicalLegacyUuidrule: trim surrounding whitespace; if what remains is longer than 36 characters and its first 36 characters form a standard hyphenated UUID (8-4-4-4-12 hex digits, either case), keep only those 36; remove every-; lower-case ASCIIA-F; return the result only if it is exactly 32 hex digits. Trimming isString.trim()(U+0000..U+0020 only), as the backend fixture states.- Parameters:
raw- the stored value, ornull- Returns:
- 32 lower-case hex digits, or
nullwhenrawdoes not normalise to them (the field is then omitted and the owner attaches the server by hand in the panel)
-
lowerAsciiHex
Lower-cases ASCIIA-Fonly, as the rule says.String.toLowerCase(java.util.Locale)would also map other characters, some to twochars, which could change the length the 32-digit check depends on. -
isHyphenatedUuid
- Returns:
truefor 8-4-4-4-12 ASCII hex digits separated by hyphens
-
isHex
-
isAsciiHex
private static boolean isAsciiHex(char c) ASCII only:Character.digit(char, int)would also accept non-ASCII digits.
-