All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.t1.problemdetail.spring.ProblemDetailXmlMessageConverter Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
package com.github.t1.problemdetail.spring;

import com.github.t1.problemdetail.ri.lib.ProblemXml;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.HttpOutputMessage;
import org.springframework.http.MediaType;
import org.springframework.http.converter.AbstractGenericHttpMessageConverter;
import org.springframework.http.converter.HttpMessageNotWritableException;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.lang.reflect.Type;
import java.util.LinkedHashMap;

import static com.github.t1.problemdetail.Constants.PROBLEM_DETAIL_XML;

@Component
public class ProblemDetailXmlMessageConverter extends AbstractGenericHttpMessageConverter> {
    public ProblemDetailXmlMessageConverter() { super(MediaType.valueOf(PROBLEM_DETAIL_XML)); }

    @Override protected LinkedHashMap readInternal(Class> clazz, HttpInputMessage inputMessage) {
        throw new UnsupportedOperationException();
    }

    @Override public LinkedHashMap read(Type type, @Nullable Class contextClass, HttpInputMessage inputMessage) {
        throw new UnsupportedOperationException();
    }

    @Override protected void writeInternal(LinkedHashMap map, @Nullable Type type, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
        new ProblemXml(map).writeTo(outputMessage.getBody());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy