Add "Problem Details for HTTP APIs" media types

See RFC 7807: Problem Details for HTTP APIs

* application/problem+json
* application/problem+xml

Issue: SPR-15110
This commit is contained in:
Kazuki Shimizu 2017-01-08 14:48:02 +09:00 committed by Brian Clozel
parent 35d5dca571
commit 053ac64101
1 changed files with 28 additions and 0 deletions

View File

@ -43,6 +43,7 @@ import org.springframework.util.comparator.CompoundComparator;
* @author Juergen Hoeller
* @author Rossen Stoyanchev
* @author Sebastien Deleuze
* @author Kazuki Shimizu
* @since 3.0
* @see <a href="http://tools.ietf.org/html/rfc7231#section-3.1.1.1">HTTP 1.1: Semantics and Content, section 3.1.1.1</a>
*/
@ -251,6 +252,31 @@ public class MediaType extends MimeType implements Serializable {
*/
public final static String TEXT_XML_VALUE = "text/xml";
/**
* Public constant media type for {@code application/problem+json}.
* @since 5.0.0
* @see <a href="https://tools.ietf.org/html/rfc7807#section-6.1">Problem Details for HTTP APIs, 6.1. application/problem+json</a>
*/
public final static MediaType APPLICATION_PROBLEM_JSON;
/**
* A String equivalent of {@link MediaType#APPLICATION_PROBLEM_JSON}.
* @since 5.0.0
*/
public final static String APPLICATION_PROBLEM_JSON_VALUE = "application/problem+json";
/**
* Public constant media type for {@code application/problem+xml}.
* @since 5.0.0
* @see <a href="https://tools.ietf.org/html/rfc7807#section-6.2">Problem Details for HTTP APIs, 6.2. application/problem+xml</a>
*/
public final static MediaType APPLICATION_PROBLEM_XML;
/**
* A String equivalent of {@link MediaType#APPLICATION_PROBLEM_XML}.
* @since 5.0.0
*/
public final static String APPLICATION_PROBLEM_XML_VALUE = "application/problem+xml";
private static final String PARAM_QUALITY_FACTOR = "q";
@ -263,6 +289,8 @@ public class MediaType extends MimeType implements Serializable {
APPLICATION_JSON_UTF8 = valueOf(APPLICATION_JSON_UTF8_VALUE);
APPLICATION_OCTET_STREAM = valueOf(APPLICATION_OCTET_STREAM_VALUE);
APPLICATION_PDF = valueOf(APPLICATION_PDF_VALUE);
APPLICATION_PROBLEM_JSON = valueOf(APPLICATION_PROBLEM_JSON_VALUE);
APPLICATION_PROBLEM_XML = valueOf(APPLICATION_PROBLEM_XML_VALUE);
APPLICATION_RSS_XML = valueOf(APPLICATION_RSS_XML_VALUE);
APPLICATION_XHTML_XML = valueOf(APPLICATION_XHTML_XML_VALUE);
APPLICATION_XML = valueOf(APPLICATION_XML_VALUE);