[OLINGO-990] Fix for adding Custom headers in case of metadata call Signed-off-by: Christian Amend <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/9a30d757 Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/9a30d757 Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/9a30d757 Branch: refs/heads/master Commit: 9a30d75711f0549e02e14e521828b4b1c0234539 Parents: 7c38280 Author: Kanika Jashrapuria <[email protected]> Authored: Mon Apr 25 16:45:51 2016 +0530 Committer: Christian Amend <[email protected]> Committed: Wed Jul 27 14:41:34 2016 +0200 ---------------------------------------------------------------------- .../request/retrieve/EdmMetadataRequestImpl.java | 17 +++++++++++------ .../request/retrieve/XMLMetadataRequestImpl.java | 9 +++++++-- 2 files changed, 18 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9a30d757/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java index e3eef12..9639e18 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/EdmMetadataRequestImpl.java @@ -1,18 +1,18 @@ /* * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file + * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file + * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at + * with the License. You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the + * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ @@ -55,6 +55,11 @@ class EdmMetadataRequestImpl extends AbstractMetadataRequestImpl<Edm> implements if (getIfNoneMatch() != null) { request.setIfNoneMatch(getIfNoneMatch()); } + if (getHeader() != null) { + for (String key : getHeaderNames()) { + request.addCustomHeader(key, odataHeaders.getHeader(key)); + } + } final ODataRetrieveResponse<XMLMetadata> xmlMetadataResponse = request.execute(); privateResponse = new EdmMetadataResponseImpl(odataClient, httpClient, xmlMetadataResponse); @@ -79,7 +84,7 @@ class EdmMetadataRequestImpl extends AbstractMetadataRequestImpl<Edm> implements private XMLMetadata metadata = null; private EdmMetadataResponseImpl(final ODataClient odataClient, final HttpClient httpClient, - final ODataRetrieveResponse<XMLMetadata> xmlMetadataResponse) { + final ODataRetrieveResponse<XMLMetadata> xmlMetadataResponse) { super(odataClient, httpClient, null); this.xmlMetadataResponse = xmlMetadataResponse; http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/9a30d757/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/XMLMetadataRequestImpl.java ---------------------------------------------------------------------- diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/XMLMetadataRequestImpl.java b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/XMLMetadataRequestImpl.java index b5248d4..af9dbf2 100644 --- a/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/XMLMetadataRequestImpl.java +++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/communication/request/retrieve/XMLMetadataRequestImpl.java @@ -57,6 +57,11 @@ public class XMLMetadataRequestImpl if (getIfNoneMatch() != null) { rootReq.setIfNoneMatch(getIfNoneMatch()); } + if (getHeader() != null) { + for (String key : getHeaderNames()) { + rootReq.addCustomHeader(key, odataHeaders.getHeader(key)); + } + } final ODataRetrieveResponse<XMLMetadata> rootRes = rootReq.execute(); if (rootRes.getStatusCode() != HttpStatusCode.OK.getStatusCode()) { @@ -98,9 +103,9 @@ public class XMLMetadataRequestImpl // (Qualifier was either not provided or matches) if ((StringUtils.isBlank(include.getTargetNamespace()) || include.getTargetNamespace().equals( - StringUtils.substringBeforeLast(annotationGroup.getTarget(), "."))) + StringUtils.substringBeforeLast(annotationGroup.getTarget(), "."))) && (StringUtils.isBlank(include.getQualifier()) - || include.getQualifier().equals(annotationGroup.getQualifier()))) { + || include.getQualifier().equals(annotationGroup.getQualifier()))) { final CsdlAnnotations toBeIncluded = new CsdlAnnotations(); toBeIncluded.setTarget(annotationGroup.getTarget());
