com.github.t1.problemdetail.spring.ProblemDetailXmlMessageConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of problem-details-ri-spring Show documentation
Show all versions of problem-details-ri-spring Show documentation
Problem Detail implementation for Spring Boot
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 extends LinkedHashMap> 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