<commit_before>package net.nemerosa.ontrack.boot.support;

import com.fasterxml.jackson.databind.ObjectMapper;
import net.nemerosa.ontrack.boot.resources.CoreResourceModule;
import net.nemerosa.ontrack.json.ObjectMapperFactory;
import net.nemerosa.ontrack.model.security.SecurityService;
import net.nemerosa.ontrack.ui.controller.URIBuilder;
import net.nemerosa.ontrack.ui.resource.*;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.HttpOutputMessage;
import org.springframework.http.converter.AbstractHttpMessageConverter;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.http.converter.HttpMessageNotWritableException;

import java.io.IOException;
import java.util.Arrays;
import java.util.List;

public class ResourceHttpMessageConverter extends AbstractHttpMessageConverter<Object> {

    private final ResourceObjectMapper resourceObjectMapper;
    @SuppressWarnings("UnusedDeclaration")
    private final String jsonPrefix;
    private final ObjectMapper mapper;

    public ResourceHttpMessageConverter(URIBuilder uriBuilder, SecurityService securityService) {
        jsonPrefix = "{} && ";
        // Resource context
        ResourceContext resourceContext = new DefaultResourceContext(uriBuilder, securityService);
        // Registration of modules
        List<ResourceModule> resourceModules = Arrays.asList(
                new CoreResourceModule()
                // TODO Takes extensions into account
        );
        // Object mapper
        mapper = ObjectMapperFactory.create();
        // Resource mapper
        resourceObjectMapper = new ResourceObjectMapperFactory(mapper).resourceObjectMapper(
                resourceModules,
                resourceContext
        );
    }

    @Override
    protected boolean supports(Class<?> clazz) {
        return true;
    }

    @Override
    protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {
        return mapper.readValue(inputMessage.getBody(), clazz);
    }<commit_msg>Resources: missing supported types for the resource http message converter<commit_after>package net.nemerosa.ontrack.boot.support;

import com.fasterxml.jackson.databind.ObjectMapper;
import net.nemerosa.ontrack.boot.resources.CoreResourceModule;
import net.nemerosa.ontrack.json.ObjectMapperFactory;
import net.nemerosa.ontrack.model.security.SecurityService;
import net.nemerosa.ontrack.ui.controller.URIBuilder;
import net.nemerosa.ontrack.ui.resource.*;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.HttpOutputMessage;
import org.springframework.http.MediaType;
import org.springframework.http.converter.AbstractHttpMessageConverter;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.http.converter.HttpMessageNotWritableException;

import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.List;

public class ResourceHttpMessageConverter extends AbstractHttpMessageConverter<Object> {

    public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");

    private final ResourceObjectMapper resourceObjectMapper;
    private final ObjectMapper mapper;

    public ResourceHttpMessageConverter(URIBuilder uriBuilder, SecurityService securityService) {
        super(
                new MediaType("application", "json", DEFAULT_CHARSET),
                new MediaType("application", "*+json", DEFAULT_CHARSET)
        );
        // Resource context
        ResourceContext resourceContext = new DefaultResourceContext(uriBuilder, securityService);
        // Registration of modules
        List<ResourceModule> resourceModules = Arrays.asList(
                new CoreResourceModule()
                // TODO Takes extensions into account
        );
        // Object mapper
        mapper = ObjectMapperFactory.create();
        // Resource mapper
        resourceObjectMapper = new ResourceObjectMapperFactory(mapper).resourceObjectMapper(
                resourceModules,
                resourceContext
        );
    }

    @Override
    protected boolean supports(Class<?> clazz) {
        return true;
    }

    @Override
    protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {
        return mapper.readValue(inputMessage.getBody(), clazz);
    }
{'fraction_non_alphanumeric': 0.0780693950177936, 'fraction_numerical': 0.00022241992882562276, 'mean_word_length': 3.9635761589403975, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7325757', 'n_tokens_mistral': 1111, 'n_tokens_neox': 1098, 'n_words': 232}