@Override public ODataResponse countEntitySet(GetEntitySetCountUriInfo uriInfo, String contentType) throws ODataException { throw new ODataNotAcceptableException(ODataNotAcceptableException.NOT_SUPPORTED_CONTENT_TYPE .addContent(contentType)); }
@Override public ODataResponse createEntity(PostUriInfo uriInfo, InputStream content, String requestContentType, String contentType) throws ODataException { throw new ODataNotAcceptableException(ODataNotAcceptableException.NOT_SUPPORTED_CONTENT_TYPE .addContent(contentType)); }
public static IHeaderMessageProducer getHeaderMessageProducer(final String contentType) throws ODataException { if (contentType.startsWith(HttpContentType.APPLICATION_JSON)){ return new JsonSAPHeaderMessageProducer(); }else if (contentType.startsWith(HttpContentType.APPLICATION_XML) || contentType.startsWith(HttpContentType.APPLICATION_ATOM_SVC) || contentType.startsWith(HttpContentType.APPLICATION_ATOM_XML)){ return new XmlSAPHeaderMessageProducer(); }else { throw new ODataNotAcceptableException( ODataNotAcceptableException.NOT_SUPPORTED_CONTENT_TYPE .addContent(contentType)); } }
ContentType contentNegotiation(final List<ContentType> acceptedContentTypes, final List<ContentType> supportedContentTypes) throws ODataException { final Set<ContentType> setSupported = new HashSet<ContentType>(supportedContentTypes); if (acceptedContentTypes.isEmpty()) { if (!setSupported.isEmpty()) { return supportedContentTypes.get(0); } } else { for (ContentType contentType : acceptedContentTypes) { contentType = ensureCharset(contentType); final ContentType match = contentType.match(supportedContentTypes); if (match != null) { return match; } } } throw new ODataNotAcceptableException(ODataNotAcceptableException.NOT_SUPPORTED_ACCEPT_HEADER .addContent(acceptedContentTypes.toString())); }
ContentType contentNegotiation(final List<ContentType> acceptedContentTypes, final List<ContentType> supportedContentTypes) throws ODataException { final Set<ContentType> setSupported = new HashSet<ContentType>(supportedContentTypes); if (acceptedContentTypes.isEmpty()) { if (!setSupported.isEmpty()) { return supportedContentTypes.get(0); } } else { for (ContentType contentType : acceptedContentTypes) { contentType = ensureCharset(contentType); final ContentType match = contentType.match(supportedContentTypes); if (match != null) { return match; } } } throw new ODataNotAcceptableException(ODataNotAcceptableException.NOT_SUPPORTED_ACCEPT_HEADER .addContent(acceptedContentTypes.toString())); }
public static IErrorDocumentProducer getErrorDocumentProducer(final String contentType) throws ODataException { if (contentType.startsWith(HttpContentType.APPLICATION_JSON)){ return new JsonErrorDocumentProducer(); }else if (contentType.startsWith(HttpContentType.APPLICATION_XML) || contentType.startsWith(HttpContentType.APPLICATION_ATOM_SVC) || contentType.startsWith(HttpContentType.APPLICATION_ATOM_XML)){ return new XmlErrorDocumentProducer(); }//adding behavior for Count scenarios, giving back JSON Response else if (contentType.startsWith(HttpContentType.TEXT_PLAIN)){ return new JsonErrorDocumentProducer(); }else { throw new ODataNotAcceptableException( ODataNotAcceptableException.NOT_SUPPORTED_CONTENT_TYPE .addContent(contentType)); } }
ContentType contentNegotiation(final List<ContentType> acceptedContentTypes, final List<ContentType> supportedContentTypes) throws ODataException { final Set<ContentType> setSupported = new HashSet<ContentType>(supportedContentTypes); if (acceptedContentTypes.isEmpty()) { if (!setSupported.isEmpty()) { return supportedContentTypes.get(0); } } else { for (ContentType contentType : acceptedContentTypes) { contentType = ensureCharset(contentType); final ContentType match = contentType.match(supportedContentTypes); if (match != null) { return match; } } } throw new ODataNotAcceptableException(ODataNotAcceptableException.NOT_SUPPORTED_ACCEPT_HEADER .addContent(acceptedContentTypes.toString())); }
private void createNotAcceptableResponse(final HttpServletRequest req, final MessageReference messageReference, final HttpServletResponse resp, ODataServiceFactory serviceFactory) throws IOException { ODataExceptionWrapper exceptionWrapper = new ODataExceptionWrapper(req, serviceFactory); ODataResponse response = exceptionWrapper.wrapInExceptionResponse(new ODataNotAcceptableException(messageReference)); createResponse(resp, response); }
private void createNotAcceptableResponse(final HttpServletRequest req, final MessageReference messageReference, final HttpServletResponse resp, ODataServiceFactory serviceFactory) throws IOException { ODataExceptionWrapper exceptionWrapper = new ODataExceptionWrapper(req, serviceFactory); ODataResponse response = exceptionWrapper.wrapInExceptionResponse(new ODataNotAcceptableException(messageReference)); createResponse(resp, response); }
throw new ODataNotAcceptableException(ODataNotAcceptableException.NOT_SUPPORTED_CONTENT_TYPE .addContent(contentType)); throw new ODataNotAcceptableException(ODataNotAcceptableException.NOT_SUPPORTED_CONTENT_TYPE .addContent(contentType));
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())); }
private ContentTypeBasedSerializer createSerializer(ContentType contentType) throws EntityProviderException { try { switch (contentType.getODataFormat()) { case ATOM: case XML: return new AtomSerializerDeserializer(contentType.getODataFormat()); case JSON: return new JsonSerializerDeserializer(); default: throw new ODataNotAcceptableException(ODataNotAcceptableException.NOT_SUPPORTED_CONTENT_TYPE .addContent(contentType)); } } catch (final ODataNotAcceptableException e) { throw new EntityProviderException(EntityProviderException.COMMON, e); } }
private static ContentTypeBasedEntityProvider create(final ContentType contentType) throws EntityProviderException { try { switch (contentType.getODataFormat()) { case ATOM: case XML: return new AtomEntityProvider(contentType.getODataFormat()); case JSON: return new JsonEntityProvider(); default: throw new ODataNotAcceptableException(ODataNotAcceptableException.NOT_SUPPORTED_CONTENT_TYPE .addContent(contentType)); } } catch (final ODataNotAcceptableException e) { throw new EntityProviderException(EntityProviderException.COMMON, e); } }
private ContentTypeBasedDeserializer createDeserializer(ContentType contentType) throws EntityProviderException { try { switch (contentType.getODataFormat()) { case ATOM: case XML: return new AtomSerializerDeserializer(contentType.getODataFormat()); case JSON: return new JsonSerializerDeserializer(); default: throw new ODataNotAcceptableException(ODataNotAcceptableException.NOT_SUPPORTED_CONTENT_TYPE .addContent(contentType)); } } catch (final ODataNotAcceptableException e) { throw new EntityProviderException(EntityProviderException.COMMON, e); } }
private static ContentTypeBasedEntityProvider create(final ContentType contentType) throws EntityProviderException { try { switch (contentType.getODataFormat()) { case ATOM: case XML: return new AtomEntityProvider(contentType.getODataFormat()); case JSON: return new JsonEntityProvider(); default: throw new ODataNotAcceptableException(ODataNotAcceptableException.NOT_SUPPORTED_CONTENT_TYPE .addContent(contentType)); } } catch (final ODataNotAcceptableException e) { throw new EntityProviderException(EntityProviderException.COMMON, e); } }
private static ContentTypeBasedEntityProvider create(final ContentType contentType) throws EntityProviderException { try { switch (contentType.getODataFormat()) { case ATOM: case XML: return new AtomEntityProvider(contentType.getODataFormat()); case JSON: return new JsonEntityProvider(); default: throw new ODataNotAcceptableException(ODataNotAcceptableException.NOT_SUPPORTED_CONTENT_TYPE .addContent(contentType)); } } catch (final ODataNotAcceptableException e) { throw new EntityProviderException(EntityProviderException.COMMON, e); } }
throw new ODataNotAcceptableException(ODataNotAcceptableException.NOT_SUPPORTED_CONTENT_TYPE .addContent(contentType)); throw new ODataNotAcceptableException(ODataNotAcceptableException.NOT_SUPPORTED_CONTENT_TYPE .addContent(contentType));