Class MLFieldDeserializerHandler

java.lang.Object
com.jalios.jcms.restv2.deserializer.MLFieldDeserializerHandler

public class MLFieldDeserializerHandler extends Object
Utility class responsible for handling deserialization of multilingual (ML) fields.

This handler converts a JSON object representing multilingual values (e.g. {"fr": "Bonjour", "en": "Hello"}) into the corresponding internal representation and updates the target object accordingly.

It supports both full updates and partial updates:

  • Full update: replaces all existing multilingual values with the incoming ones
  • Partial update: updates only the requested languages, keeping existing values for others

Partial update mode is enabled when:

  • The deserialization context indicates an update operation
  • Specific languages are provided in the request context

The handler relies on reflection to:

  • Retrieve existing multilingual values via get<FieldName>ML()
  • Update them via set<FieldName>ML(Map)
  • Access the default field value via get<FieldName>()

When returning a value:

  • In partial update mode, the current field value is preserved if the main language is not updated
  • Otherwise, the value for the main language is returned

The list of languages to update is retrieved from the request context (via RestV2Context).

Invalid input formats (e.g. a plain string instead of a JSON object) will result in a JsonMappingException.

See Also:
  • Field Details

    • MAPPER

      protected static final com.fasterxml.jackson.databind.ObjectMapper MAPPER
  • Constructor Details

    • MLFieldDeserializerHandler

      public MLFieldDeserializerHandler()
  • Method Details

    • handleMLField

      public static Object handleMLField(Object target, com.fasterxml.jackson.databind.JsonNode node, com.fasterxml.jackson.core.JsonParser parser, com.fasterxml.jackson.databind.DeserializationContext context, org.apache.log4j.Logger logger, String fieldName) throws IOException
      Throws:
      IOException
    • getNeededLanguages

      public static List<String> getNeededLanguages()