Class UserPayloads

java.lang.Object
org.codelibs.fess.api.v2.handlers.UserPayloads

public class UserPayloads extends Object
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 Details

    • UserPayloads

      public UserPayloads()
      Creates the user-payload helper. Registered as the DI component v2UserPayloads and obtained via ComponentUtil.getV2UserPayloads().
  • Method Details

    • toJson

      public Map<String,Object> toJson(org.codelibs.fess.mylasta.action.FessUserBean u)
      Builds the canonical user JSON map for the given FessUserBean. 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