private ContentType getContentTypeByAcceptHeader(final List<String> acceptHeaderContentTypes) { for (String acceptContentType : acceptHeaderContentTypes) { if (ContentType.isParseable(acceptContentType)) { ContentType convertedContentType = ContentType.create(acceptContentType); if (convertedContentType.isWildcard() || ContentType.APPLICATION_XML.equals(convertedContentType) || ContentType.APPLICATION_XML_CS_UTF_8.equals(convertedContentType) || ContentType.APPLICATION_ATOM_XML.equals(convertedContentType) || ContentType.APPLICATION_ATOM_XML_CS_UTF_8.equals(convertedContentType)) { return ContentType.APPLICATION_XML; } else if (ContentType.APPLICATION_JSON.equals(convertedContentType) || ContentType.APPLICATION_JSON_CS_UTF_8.equals(convertedContentType) || ContentType.APPLICATION_JSON_ODATA_VERBOSE.equals(convertedContentType)) { return ContentType.APPLICATION_JSON; } } } return ContentType.APPLICATION_XML; }
private ContentType getContentTypeByAcceptHeader(final List<String> acceptHeaders) { for (String type : acceptHeaders) { if (ContentType.isParseable(type)) { ContentType convertedContentType = ContentType.create(type); if (convertedContentType.isWildcard() || ContentType.APPLICATION_XML.equals(convertedContentType) || ContentType.APPLICATION_XML_CS_UTF_8.equals(convertedContentType) || ContentType.APPLICATION_ATOM_XML.equals(convertedContentType) || ContentType.APPLICATION_ATOM_XML_CS_UTF_8.equals(convertedContentType)) { return ContentType.APPLICATION_XML; } else if (ContentType.APPLICATION_JSON.equals(convertedContentType) || ContentType.APPLICATION_JSON_CS_UTF_8.equals(convertedContentType)) { return ContentType.APPLICATION_JSON; } } } return ContentType.APPLICATION_XML; }
private ContentType getContentTypeByAcceptHeader(final List<String> acceptHeaderContentTypes) { for (String acceptContentType : acceptHeaderContentTypes) { if (ContentType.isParseable(acceptContentType)) { ContentType convertedContentType = ContentType.create(acceptContentType); if (convertedContentType.isWildcard() || ContentType.APPLICATION_XML.equals(convertedContentType) || ContentType.APPLICATION_XML_CS_UTF_8.equals(convertedContentType) || ContentType.APPLICATION_ATOM_XML.equals(convertedContentType) || ContentType.APPLICATION_ATOM_XML_CS_UTF_8.equals(convertedContentType)) { return ContentType.APPLICATION_XML; } else if (ContentType.APPLICATION_JSON.equals(convertedContentType) || ContentType.APPLICATION_JSON_CS_UTF_8.equals(convertedContentType)) { return ContentType.APPLICATION_JSON; } } } return ContentType.APPLICATION_XML; }
private ContentType getContentTypeByAcceptHeader(final List<String> acceptHeaderContentTypes) { for (String acceptContentType : acceptHeaderContentTypes) { if (ContentType.isParseable(acceptContentType)) { ContentType convertedContentType = ContentType.create(acceptContentType); if (convertedContentType.isWildcard() || ContentType.APPLICATION_XML.equals(convertedContentType) || ContentType.APPLICATION_XML_CS_UTF_8.equals(convertedContentType) || ContentType.APPLICATION_ATOM_XML.equals(convertedContentType) || ContentType.APPLICATION_ATOM_XML_CS_UTF_8.equals(convertedContentType)) { return ContentType.APPLICATION_XML; } else if (ContentType.APPLICATION_JSON.equals(convertedContentType) || ContentType.APPLICATION_JSON_CS_UTF_8.equals(convertedContentType) || ContentType.APPLICATION_JSON_ODATA_VERBOSE.equals(convertedContentType)) { return ContentType.APPLICATION_JSON; } } } return ContentType.APPLICATION_XML; }
private ContentType getContentTypeByAcceptHeader(final List<String> acceptHeaders) { for (String type : acceptHeaders) { if (ContentType.isParseable(type)) { ContentType convertedContentType = ContentType.create(type); if (convertedContentType.isWildcard() || ContentType.APPLICATION_XML.equals(convertedContentType) || ContentType.APPLICATION_XML_CS_UTF_8.equals(convertedContentType) || ContentType.APPLICATION_ATOM_XML.equals(convertedContentType) || ContentType.APPLICATION_ATOM_XML_CS_UTF_8.equals(convertedContentType)) { return ContentType.APPLICATION_XML; } else if (ContentType.APPLICATION_JSON.equals(convertedContentType) || ContentType.APPLICATION_JSON_CS_UTF_8.equals(convertedContentType)) { return ContentType.APPLICATION_JSON; } } } return ContentType.APPLICATION_XML; }
private ContentType getContentTypeByAcceptHeader() { for (MediaType type : httpHeaders.getAcceptableMediaTypes()) { if (ContentType.isParseable(type.toString())) { ContentType convertedContentType = ContentType.create(type.toString()); if (convertedContentType.isWildcard() || ContentType.APPLICATION_XML.equals(convertedContentType) || ContentType.APPLICATION_XML_CS_UTF_8.equals(convertedContentType) || ContentType.APPLICATION_ATOM_XML.equals(convertedContentType) || ContentType.APPLICATION_ATOM_XML_CS_UTF_8.equals(convertedContentType)) { return ContentType.APPLICATION_XML; } else if (ContentType.APPLICATION_JSON.equals(convertedContentType) || ContentType.APPLICATION_JSON_CS_UTF_8.equals(convertedContentType)) { return ContentType.APPLICATION_JSON; } } } return ContentType.APPLICATION_XML; }
private ContentType getContentTypeByAcceptHeader(final HttpHeaders httpHeaders) { for (MediaType type : httpHeaders.getAcceptableMediaTypes()) { if (ContentType.isParseable(type.toString())) { ContentType convertedContentType = ContentType.create(type.toString()); if (convertedContentType.isWildcard() || ContentType.APPLICATION_XML.equals(convertedContentType) || ContentType.APPLICATION_XML_CS_UTF_8.equals(convertedContentType) || ContentType.APPLICATION_ATOM_XML.equals(convertedContentType) || ContentType.APPLICATION_ATOM_XML_CS_UTF_8.equals(convertedContentType)) { return ContentType.APPLICATION_XML; } else if (ContentType.APPLICATION_JSON.equals(convertedContentType) || ContentType.APPLICATION_JSON_CS_UTF_8.equals(convertedContentType) || ContentType.APPLICATION_JSON_ODATA_VERBOSE.equals(convertedContentType)) { return ContentType.APPLICATION_JSON; } } } return ContentType.APPLICATION_XML; }
private ContentType getContentTypeByAcceptHeader() { for (MediaType type : httpHeaders.getAcceptableMediaTypes()) { if (ContentType.isParseable(type.toString())) { ContentType convertedContentType = ContentType.create(type.toString()); if (convertedContentType.isWildcard() || ContentType.APPLICATION_XML.equals(convertedContentType) || ContentType.APPLICATION_XML_CS_UTF_8.equals(convertedContentType) || ContentType.APPLICATION_ATOM_XML.equals(convertedContentType) || ContentType.APPLICATION_ATOM_XML_CS_UTF_8.equals(convertedContentType)) { return ContentType.APPLICATION_XML; } else if (ContentType.APPLICATION_JSON.equals(convertedContentType) || ContentType.APPLICATION_JSON_CS_UTF_8.equals(convertedContentType)) { return ContentType.APPLICATION_JSON; } } } return ContentType.APPLICATION_XML; }
private ContentType getContentTypeByAcceptHeader() { for (MediaType type : httpHeaders.getAcceptableMediaTypes()) { if (ContentType.isParseable(type.toString())) { ContentType convertedContentType = ContentType.create(type.toString()); if (convertedContentType.isWildcard() || ContentType.APPLICATION_XML.equals(convertedContentType) || ContentType.APPLICATION_XML_CS_UTF_8.equals(convertedContentType) || ContentType.APPLICATION_ATOM_XML.equals(convertedContentType) || ContentType.APPLICATION_ATOM_XML_CS_UTF_8.equals(convertedContentType)) { return ContentType.APPLICATION_XML; } else if (ContentType.APPLICATION_JSON.equals(convertedContentType) || ContentType.APPLICATION_JSON_CS_UTF_8.equals(convertedContentType)) { return ContentType.APPLICATION_JSON; } } } return ContentType.APPLICATION_XML; }
private ContentType getContentTypeByAcceptHeader(final HttpHeaders httpHeaders) { for (MediaType type : httpHeaders.getAcceptableMediaTypes()) { if (ContentType.isParseable(type.toString())) { ContentType convertedContentType = ContentType.create(type.toString()); if (convertedContentType.isWildcard() || ContentType.APPLICATION_XML.equals(convertedContentType) || ContentType.APPLICATION_XML_CS_UTF_8.equals(convertedContentType) || ContentType.APPLICATION_ATOM_XML.equals(convertedContentType) || ContentType.APPLICATION_ATOM_XML_CS_UTF_8.equals(convertedContentType)) { return ContentType.APPLICATION_XML; } else if (ContentType.APPLICATION_JSON.equals(convertedContentType) || ContentType.APPLICATION_JSON_CS_UTF_8.equals(convertedContentType)) { return ContentType.APPLICATION_JSON; } } } return ContentType.APPLICATION_XML; }
private ContentType getContentTypeByAcceptHeader(final HttpHeaders httpHeaders) { for (MediaType type : httpHeaders.getAcceptableMediaTypes()) { if (ContentType.isParseable(type.toString())) { ContentType convertedContentType = ContentType.create(type.toString()); if (convertedContentType.isWildcard() || ContentType.APPLICATION_XML.equals(convertedContentType) || ContentType.APPLICATION_XML_CS_UTF_8.equals(convertedContentType) || ContentType.APPLICATION_ATOM_XML.equals(convertedContentType) || ContentType.APPLICATION_ATOM_XML_CS_UTF_8.equals(convertedContentType)) { return ContentType.APPLICATION_XML; } else if (ContentType.APPLICATION_JSON.equals(convertedContentType) || ContentType.APPLICATION_JSON_CS_UTF_8.equals(convertedContentType) || ContentType.APPLICATION_JSON_ODATA_VERBOSE.equals(convertedContentType)) { return ContentType.APPLICATION_JSON; } } } return ContentType.APPLICATION_XML; }
/** * Find best match between this {@link ContentType} and the {@link ContentType} in the list. * If a match (this {@link ContentType} is equal to a {@link ContentType} in list) is found either this or the * {@link ContentType} from the list is returned based on which {@link ContentType} has less "**" characters set * (checked with {@link #compareWildcardCounts(ContentType)}. * If no match (none {@link ContentType} in list is equal to this {@link ContentType}) is found <code>NULL</code> is * returned. * * @param toMatchContentTypes list of {@link ContentType}s which are matches against this {@link ContentType} * @return best matched content type in list or <code>NULL</code> if none content type match to this content type * instance */ public ContentType match(final List<ContentType> toMatchContentTypes) { for (ContentType supportedContentType : toMatchContentTypes) { if (equals(supportedContentType)) { if (compareWildcardCounts(supportedContentType) < 0) { return this; } else { return supportedContentType; } } } return null; }
/** * Find best match between this {@link ContentType} and the {@link ContentType} in the list. * If a match (this {@link ContentType} is equal to a {@link ContentType} in list) is found either this or the * {@link ContentType} from the list is returned based on which {@link ContentType} has less "**" characters set * (checked with {@link #compareWildcardCounts(ContentType)}. * If no match (none {@link ContentType} in list is equal to this {@link ContentType}) is found <code>NULL</code> is * returned. * * @param toMatchContentTypes list of {@link ContentType}s which are matches against this {@link ContentType} * @return best matched content type in list or <code>NULL</code> if none content type match to this content type * instance */ public ContentType match(final List<ContentType> toMatchContentTypes) { for (ContentType supportedContentType : toMatchContentTypes) { if (equals(supportedContentType)) { if (compareWildcardCounts(supportedContentType) < 0) { return this; } else { return supportedContentType; } } } return null; }
/** * Find best match between this {@link ContentType} and the {@link ContentType} in the list. * If a match (this {@link ContentType} is equal to a {@link ContentType} in list) is found either this or the * {@link ContentType} from the list is returned based on which {@link ContentType} has less "**" characters set * (checked with {@link #compareWildcardCounts(ContentType)}. * If no match (none {@link ContentType} in list is equal to this {@link ContentType}) is found <code>NULL</code> is * returned. * * @param toMatchContentTypes list of {@link ContentType}s which are matches against this {@link ContentType} * @return best matched content type in list or <code>NULL</code> if none content type match to this content type * instance */ public ContentType match(final List<ContentType> toMatchContentTypes) { for (ContentType supportedContentType : toMatchContentTypes) { if (equals(supportedContentType)) { if (compareWildcardCounts(supportedContentType) < 0) { return this; } else { return supportedContentType; } } } return null; }
/** * * @return <code>true</code> if this {@link ContentType} is text related (in the view of OData) */ public boolean isContentTypeODataTextRelated() { return (ContentType.TEXT_PLAIN.equals(this) || (getODataFormat() == ODataFormat.XML) || (getODataFormat() == ODataFormat.ATOM) || (getODataFormat() == ODataFormat.JSON)); }
/** * * @return <code>true</code> if this {@link ContentType} is text related (in the view of OData) */ public boolean isContentTypeODataTextRelated() { return (ContentType.TEXT_PLAIN.equals(this) || (getODataFormat() == ODataFormat.XML) || (getODataFormat() == ODataFormat.ATOM) || (getODataFormat() == ODataFormat.JSON)); }
/** * * @return <code>true</code> if this {@link ContentType} is text related (in the view of OData) */ public boolean isContentTypeODataTextRelated() { return (ContentType.TEXT_PLAIN.equals(this) || (getODataFormat() == ODataFormat.XML) || (getODataFormat() == ODataFormat.ATOM) || (getODataFormat() == ODataFormat.JSON)); }
private ContentType doContentNegotiationForFormat(final UriInfoImpl uriInfo, final List<ContentType> supportedContentTypes) throws ODataException { validateFormatQuery(uriInfo); ContentType formatContentType = mapFormat(uriInfo); formatContentType = ensureCharset(formatContentType); for (final ContentType contentType : supportedContentTypes) { if (contentType.equals(formatContentType)) { return formatContentType; } } throw new ODataNotAcceptableException(ODataNotAcceptableException.NOT_SUPPORTED_CONTENT_TYPE.addContent(uriInfo .getFormat())); }
private ContentType doContentNegotiationForFormat(final UriInfoImpl uriInfo, final List<ContentType> supportedContentTypes) throws ODataException { validateFormatQuery(uriInfo); ContentType formatContentType = mapFormat(uriInfo); formatContentType = ensureCharset(formatContentType); for (final ContentType contentType : supportedContentTypes) { if (contentType.equals(formatContentType)) { return formatContentType; } } throw new ODataNotAcceptableException(ODataNotAcceptableException.NOT_SUPPORTED_CONTENT_TYPE.addContent(uriInfo .getFormat())); }
private ContentType doContentNegotiationForFormat(final UriInfoImpl uriInfo, final List<ContentType> supportedContentTypes) throws ODataException { validateFormatQuery(uriInfo); ContentType formatContentType = mapFormat(uriInfo); formatContentType = ensureCharset(formatContentType); for (final ContentType contentType : supportedContentTypes) { if (contentType.equals(formatContentType)) { return formatContentType; } } throw new ODataNotAcceptableException(ODataNotAcceptableException.NOT_SUPPORTED_CONTENT_TYPE.addContent(uriInfo .getFormat())); }