2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 VMware, Inc. All rights reserved.
6 * Copyright (C) 2019-2020 Nokia. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.dcae.common;
24 import java.util.Collections;
26 import java.util.stream.Collectors;
27 import javax.servlet.http.HttpServletRequest;
28 import org.springframework.http.HttpHeaders;
29 import org.springframework.stereotype.Component;
32 * A class with methods used in HTTP header management.
35 public class HeaderUtils {
37 public String getRestApiIdentify(String uri) {
38 return isBatchRequest(uri) ? "eventListener_eventBatch" : "eventListener";
41 public Map<String, String> extractHeaders(HttpServletRequest request) {
42 return Collections.list(request.getHeaderNames()).stream()
43 .collect(Collectors.toMap(h -> h, request::getHeader));
46 public HttpHeaders fillHeaders(Map<String, String> headers) {
47 HttpHeaders httpHeaders = new HttpHeaders();
48 httpHeaders.setAll(headers);
52 private boolean isBatchRequest(String request) {
53 return request.contains("eventBatch");