Class UserPayloads
java.lang.Object
org.codelibs.fess.api.v2.handlers.UserPayloads
Shared helper that produces the canonical v2 user JSON shape.
MJ-28: LoginHandler and MeHandler previously serialized the
same logical fields (user_id, roles, groups,
permissions, editable) in subtly different ways — LoginHandler
used arrayOrEmpty() (always a JSON array), while MeHandler passed raw
String[] (null-capable). Centralising the mapping here guarantees the
two endpoints are wire-identical and any future endpoint returns the same shape.
The fields are emitted in insertion order (LinkedHashMap) for deterministic JSON output and readable debug logs.
MJ-30 i18n note: error.message values in the callers of this class are developer-facing English. Clients MUST use error.code (the V2ErrorCode token) for user-facing i18n.
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
UserPayloads
public UserPayloads()Creates the user-payload helper. Registered as the DI componentv2UserPayloadsand obtained viaComponentUtil.getV2UserPayloads().
-
-
Method Details
-
toJson
Builds the canonical user JSON map for the givenFessUserBean. All array fields (roles,groups,permissions) are guaranteed to be non-null JSON arrays — a null getter result is normalised to an empty list so clients can always iterate without a null-check.- Parameters:
u- the authenticated user bean (must not be null)- Returns:
- a LinkedHashMap suitable for inclusion in a v2 response payload
-