Java Code Examples for org.apache.olingo.server.api.ODataResponse#getHeader()
The following examples show how to use
org.apache.olingo.server.api.ODataResponse#getHeader() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ODataHandlerImplTest.java From olingo-odata4 with Apache License 2.0 | 6 votes |
@Test public void serviceDocumentDefault() throws Exception { final ODataResponse response = dispatch(HttpMethod.GET, "/", null); assertEquals(HttpStatusCode.OK.getStatusCode(), response.getStatusCode()); String ct = response.getHeader(HttpHeader.CONTENT_TYPE); assertThat(ct, containsString("application/json")); assertThat(ct, containsString("odata.metadata=minimal")); assertNotNull(response.getContent()); String doc = IOUtils.toString(response.getContent()); assertThat(doc, containsString("\"@odata.context\":\"$metadata\"")); assertThat(doc, containsString("\"value\":")); final ODataResponse response2 = dispatch(HttpMethod.HEAD, "/", null); assertEquals(HttpStatusCode.OK.getStatusCode(), response2.getStatusCode()); assertNull(response2.getHeader(HttpHeader.CONTENT_TYPE)); assertNull(response2.getContent()); }
Example 2
Source File: DebugTabBody.java From olingo-odata4 with Apache License 2.0 | 6 votes |
public DebugTabBody(final ODataResponse response) { this.response = response; if (response != null) { final String contentTypeString = response.getHeader(HttpHeader.CONTENT_TYPE); if (contentTypeString != null) { if (contentTypeString.startsWith("application/json")) { responseContent = ResponseContent.JSON; } else if (contentTypeString.startsWith("image/")) { responseContent = ResponseContent.IMAGE; } else if (contentTypeString.contains("xml")) { responseContent = ResponseContent.XML; } else { responseContent = ResponseContent.TEXT; } } else { responseContent = ResponseContent.TEXT; } } else { responseContent = ResponseContent.TEXT; } }
Example 3
Source File: BatchReferenceRewriter.java From olingo-odata4 with Apache License 2.0 | 6 votes |
private String getODataPath(final ODataRequest request, final ODataResponse response) throws BatchDeserializerException { String resourceUri = null; if (request.getMethod() == HttpMethod.POST) { // Create entity // The URI of the new resource will be generated by the server and published in the location header final String locationHeader = response.getHeader(HttpHeader.LOCATION); resourceUri = locationHeader == null ? null : parseODataPath(locationHeader, request.getRawBaseUri()); } else { // Update, Upsert (PUT, PATCH, Delete) // These methods still addresses a given resource, so we use the URI given by the request resourceUri = request.getRawODataPath(); } return resourceUri; }
Example 4
Source File: BatchResponseSerializer.java From olingo-odata4 with Apache License 2.0 | 5 votes |
private void appendBodyPartHeader(final ODataResponse response, final BodyBuilder builder, final boolean isChangeSet) throws BatchSerializerException { appendHeader(HttpHeader.CONTENT_TYPE, ContentType.APPLICATION_HTTP.toContentTypeString(), builder); appendHeader(BatchParserCommon.CONTENT_TRANSFER_ENCODING, BatchParserCommon.BINARY_ENCODING, builder); if (isChangeSet) { if (response.getHeader(HttpHeader.CONTENT_ID) != null) { appendHeader(HttpHeader.CONTENT_ID, response.getHeader(HttpHeader.CONTENT_ID), builder); } else { throw new BatchSerializerException("Missing content id", MessageKeys.MISSING_CONTENT_ID); } } }