Java Code Examples for org.apache.olingo.server.api.ODataRequest#getHeader()
The following examples show how to use
org.apache.olingo.server.api.ODataRequest#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: BatchPartHandler.java From olingo-odata4 with Apache License 2.0 | 6 votes |
public ODataResponse handle(final ODataRequest request, final boolean isChangeSet) throws BatchDeserializerException { ODataResponse response; if (isChangeSet) { rewriter.replaceReference(request); response = oDataHandler.process(request); rewriter.addMapping(request, response); } else { response = oDataHandler.process(request); } // Add content id to response final String contentId = request.getHeader(HttpHeader.CONTENT_ID); if (contentId != null) { response.setHeader(HttpHeader.CONTENT_ID, contentId); } return response; }
Example 2
Source File: MockedBatchHandlerTest.java From olingo-odata4 with Apache License 2.0 | 6 votes |
private ODataResponse buildResponse(final ODataRequest request) { final ODataResponse oDataResponse = new ODataResponse(); if (request.getMethod() == HttpMethod.POST) { oDataResponse.setStatusCode(HttpStatusCode.CREATED.getStatusCode()); oDataResponse.setHeader(HttpHeader.LOCATION, createResourceUri(request)); } else { oDataResponse.setStatusCode(HttpStatusCode.OK.getStatusCode()); } final String contentId = request.getHeader(HttpHeader.CONTENT_ID); if (contentId != null) { oDataResponse.setHeader(HttpHeader.CONTENT_ID, contentId); } return oDataResponse; }
Example 3
Source File: BatchReferenceRewriter.java From olingo-odata4 with Apache License 2.0 | 5 votes |
public void addMapping(final ODataRequest request, final ODataResponse response) throws BatchDeserializerException { final String resourceUri = getODataPath(request, response); final String contentId = request.getHeader(HttpHeader.CONTENT_ID); contentIdMapping.put(contentId, resourceUri); }
Example 4
Source File: ODataHandlerImpl.java From olingo-odata4 with Apache License 2.0 | 5 votes |
private void validateODataVersion(final ODataRequest request) throws ODataHandlerException { final String odataVersion = request.getHeader(HttpHeader.ODATA_VERSION); if (odataVersion != null && !ODataServiceVersion.isValidODataVersion(odataVersion)) { throw new ODataHandlerException("ODataVersion not supported: " + odataVersion, ODataHandlerException.MessageKeys.ODATA_VERSION_NOT_SUPPORTED, odataVersion); } final String maxVersion = request.getHeader(HttpHeader.ODATA_MAX_VERSION); if (maxVersion != null && !ODataServiceVersion.isValidMaxODataVersion(maxVersion)) { throw new ODataHandlerException("ODataVersion not supported: " + maxVersion, ODataHandlerException.MessageKeys.ODATA_VERSION_NOT_SUPPORTED, maxVersion); } }
Example 5
Source File: ODataDispatcher.java From olingo-odata4 with Apache License 2.0 | 5 votes |
private void validatePreconditions(final ODataRequest request, final boolean isMediaValue) throws PreconditionException { // If needed perform preconditions validation. final CustomETagSupport eTagSupport = handler.getCustomETagSupport(); if (eTagSupport != null && new PreconditionsValidator(uriInfo).mustValidatePreconditions(eTagSupport, isMediaValue) && request.getHeader(HttpHeader.IF_MATCH) == null && request.getHeader(HttpHeader.IF_NONE_MATCH) == null) { throw new PreconditionException("Expected an if-match or if-none-match header.", PreconditionException.MessageKeys.MISSING_HEADER); } }
Example 6
Source File: OData4HttpHandler.java From olingo-odata4 with Apache License 2.0 | 5 votes |
void validateODataVersion(final ODataRequest request, final ODataResponse response) throws ODataHandlerException { final String maxVersion = request.getHeader(HttpHeader.ODATA_MAX_VERSION); response.setHeader(HttpHeader.ODATA_VERSION, ODataServiceVersion.V40.toString()); if (maxVersion != null && ODataServiceVersion.isBiggerThan(ODataServiceVersion.V40.toString(), maxVersion)) { throw new ODataHandlerException("ODataVersion not supported: " + maxVersion, //$NON-NLS-1$ ODataHandlerException.MessageKeys.ODATA_VERSION_NOT_SUPPORTED, maxVersion); } }
Example 7
Source File: ServiceDispatcher.java From olingo-odata4 with Apache License 2.0 | 4 votes |
private void internalExecute(UriInfo uriInfo, ODataRequest odRequest, ODataResponse odResponse) throws ODataLibraryException, ODataApplicationException { new UriValidator().validate(uriInfo, odRequest.getMethod()); // part1, 8.2.6 String isolation = odRequest.getHeader(HttpHeader.ODATA_ISOLATION); if (isolation != null && "snapshot".equals(isolation) && !this.handler.supportsDataIsolation()) { odResponse.setStatusCode(HttpStatusCode.PRECONDITION_FAILED.getStatusCode()); return; } visit(uriInfo); // this should cover for any unsupported calls until they are implemented if (this.request == null) { this.request = new ServiceRequest(this.odata, this.metadata) { @Override public ContentType getResponseContentType() throws ContentNegotiatorException { return ContentType.APPLICATION_JSON; } @Override public void execute(ServiceHandler handler, ODataResponse response) throws ODataLibraryException, ODataApplicationException { handler.anyUnsupported(getODataRequest(), response); } }; } // To handle $entity?$id=http://localhost/EntitySet(key) as // http://localhost/EntitySet(key) if (this.idOption != null) { try { this.request.setODataRequest(odRequest); this.request = this.request.parseLink(new URI(this.idOption)); } catch (URISyntaxException e) { throw new ODataHandlerException("Invalid $id value", ODataHandlerException.MessageKeys.FUNCTIONALITY_NOT_IMPLEMENTED, this.idOption); } } this.request.setODataRequest(odRequest); this.request.setUriInfo(uriInfo); this.request.setCustomContentTypeSupport(this.customContentSupport); this.request.execute(this.handler, odResponse); }
Example 8
Source File: BatchRequest.java From olingo-odata4 with Apache License 2.0 | 4 votes |
private void addContentID(ODataRequest batchPartRequest, ODataResponse batchPartResponse) { final String contentId = batchPartRequest.getHeader(HttpHeader.CONTENT_ID); if (contentId != null) { batchPartResponse.setHeader(HttpHeader.CONTENT_ID, contentId); } }