private ContentType mapFormat(final UriInfoImpl uriInfo) { final String format = uriInfo.getFormat(); if (URI_INFO_FORMAT_XML.equals(format)) { return ContentType.APPLICATION_XML; } else if (URI_INFO_FORMAT_ATOM.equals(format)) { if (uriInfo.getUriType() == UriType.URI0) { // special handling for serviceDocument uris (UriType.URI0) return ContentType.APPLICATION_ATOM_SVC; } else if (uriInfo.getUriType() == UriType.URI1) { return ContentType.APPLICATION_ATOM_XML_FEED; } else if (uriInfo.getUriType() == UriType.URI2) { return ContentType.APPLICATION_ATOM_XML_ENTRY; } } else if (URI_INFO_FORMAT_JSON.equals(format)) { return ContentType.APPLICATION_JSON; } return ContentType.createAsCustom(format); }
private ContentType mapFormat(final UriInfoImpl uriInfo) { final String format = uriInfo.getFormat(); if (URI_INFO_FORMAT_XML.equals(format)) { return ContentType.APPLICATION_XML; } else if (URI_INFO_FORMAT_ATOM.equals(format)) { if (uriInfo.getUriType() == UriType.URI0) { // special handling for serviceDocument uris (UriType.URI0) return ContentType.APPLICATION_ATOM_SVC; } else if (uriInfo.getUriType() == UriType.URI1) { return ContentType.APPLICATION_ATOM_XML_FEED; } else if (uriInfo.getUriType() == UriType.URI2 || uriInfo.getUriType() == UriType.URI10) { return ContentType.APPLICATION_ATOM_XML_ENTRY; } } else if (URI_INFO_FORMAT_JSON.equals(format)) { return ContentType.APPLICATION_JSON; } return ContentType.createAsCustom(format); }
private ContentType mapFormat(final UriInfoImpl uriInfo) { final String format = uriInfo.getFormat(); if (URI_INFO_FORMAT_XML.equals(format)) { return ContentType.APPLICATION_XML; } else if (URI_INFO_FORMAT_ATOM.equals(format)) { if (uriInfo.getUriType() == UriType.URI0) { // special handling for serviceDocument uris (UriType.URI0) return ContentType.APPLICATION_ATOM_SVC; } else if (uriInfo.getUriType() == UriType.URI1) { return ContentType.APPLICATION_ATOM_XML_FEED; } else if (uriInfo.getUriType() == UriType.URI2 || uriInfo.getUriType() == UriType.URI10) { return ContentType.APPLICATION_ATOM_XML_ENTRY; } } else if (URI_INFO_FORMAT_JSON.equals(format)) { return ContentType.APPLICATION_JSON; } return ContentType.createAsCustom(format); }
case URI1: case URI6B: if (uriInfo.getFormat() != null || uriInfo.getFilter() != null || uriInfo.getInlineCount() != null || uriInfo.getOrderBy() != null || uriInfo.getSkipToken() != null || uriInfo.getSkip() != null || uriInfo.getTop() != null || !uriInfo.getExpand().isEmpty() || !uriInfo.getSelect().isEmpty()) { if (uriInfo.getFormat() != null || !uriInfo.getExpand().isEmpty() || !uriInfo.getSelect().isEmpty()) { throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH); if (uriInfo.getFormat() != null) { throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH); case URI5: if (method == ODataHttpMethod.PUT || method == ODataHttpMethod.PATCH || method == ODataHttpMethod.MERGE) { if (!uriInfo.isValue() && uriInfo.getFormat() != null) { throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH); if (uriInfo.getFormat() != null || uriInfo.getFilter() != null) { throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH); if (uriInfo.getFormat() != null || uriInfo.getFilter() != null || uriInfo.getInlineCount() != null || uriInfo.getOrderBy() != null || uriInfo.getSkipToken() != null || uriInfo.getSkip() != null || uriInfo.getTop() != null) { if (uriInfo.getFormat() != null || uriInfo.getFilter() != null) { throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
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())); }
case URI1: case URI6B: if (uriInfo.getFormat() != null || uriInfo.getFilter() != null || uriInfo.getInlineCount() != null || uriInfo.getOrderBy() != null || uriInfo.getSkipToken() != null || uriInfo.getSkip() != null || uriInfo.getTop() != null || !uriInfo.getExpand().isEmpty() || !uriInfo.getSelect().isEmpty()) { if (uriInfo.getFormat() != null || !uriInfo.getExpand().isEmpty() || !uriInfo.getSelect().isEmpty()) { throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH); if (uriInfo.getFormat() != null) { throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH); case URI5: if (method == ODataHttpMethod.PUT || method == ODataHttpMethod.PATCH || method == ODataHttpMethod.MERGE) { if (!uriInfo.isValue() && uriInfo.getFormat() != null) { throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH); if (uriInfo.getFormat() != null || uriInfo.getFilter() != null) { throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH); if (uriInfo.getFormat() != null || uriInfo.getFilter() != null || uriInfo.getInlineCount() != null || uriInfo.getOrderBy() != null || uriInfo.getSkipToken() != null || uriInfo.getSkip() != null || uriInfo.getTop() != null) { if (uriInfo.getFormat() != null || uriInfo.getFilter() != null) { throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
case URI1: case URI6B: if (uriInfo.getFormat() != null || uriInfo.getFilter() != null || uriInfo.getInlineCount() != null || uriInfo.getOrderBy() != null || uriInfo.getSkipToken() != null || uriInfo.getSkip() != null || uriInfo.getTop() != null || !uriInfo.getExpand().isEmpty() || !uriInfo.getSelect().isEmpty()) { if (uriInfo.getFormat() != null || !uriInfo.getExpand().isEmpty() || !uriInfo.getSelect().isEmpty()) { throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH); if (uriInfo.getFormat() != null) { throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH); case URI5: if (method == ODataHttpMethod.PUT || method == ODataHttpMethod.PATCH || method == ODataHttpMethod.MERGE) { if (!uriInfo.isValue() && uriInfo.getFormat() != null) { throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH); if (uriInfo.getFormat() != null || uriInfo.getFilter() != null) { throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH); if (uriInfo.getFormat() != null || uriInfo.getFilter() != null || uriInfo.getInlineCount() != null || uriInfo.getOrderBy() != null || uriInfo.getSkipToken() != null || uriInfo.getSkip() != null || uriInfo.getTop() != null) { if (uriInfo.getFormat() != null || uriInfo.getFilter() != null) { throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH);
if (uriInfo.getFormat() == null) { return doContentNegotiationForAcceptHeader(odataRequest.getAcceptHeaders(), ContentType .create(supportedContentTypes));
if (uriInfo.getFormat() == null) { return doContentNegotiationForAcceptHeader(odataRequest.getAcceptHeaders(), ContentType .create(supportedContentTypes));
if (uriInfo.getFormat() == null) { return doContentNegotiationForAcceptHeader(odataRequest.getAcceptHeaders(), ContentType .create(supportedContentTypes));
throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH); } else { if (uriInfo.getFormat() != null) {
throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH); } else { if (uriInfo.getFormat() != null) { throw new ODataBadRequestException(ODataBadRequestException.INVALID_SYNTAX);
throw new ODataMethodNotAllowedException(ODataMethodNotAllowedException.DISPATCH); } else { if (uriInfo.getFormat() != null) { throw new ODataBadRequestException(ODataBadRequestException.INVALID_SYNTAX);