2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.openecomp.sdc.fe.impl;
23 import javax.servlet.http.HttpServletRequest;
24 import org.openecomp.sdc.common.api.Constants;
25 import org.slf4j.Logger;
32 public static void error(Logger log, HttpRequestInfo requestInfo, int status) {
33 String errorMsg = "Internal Error";
34 if (requestInfo != null && requestInfo.getHeaders() != null) {
35 Map<String, String> requestHeaders = requestInfo.getHeaders();
36 errorMsg = String.format(Constants.ERROR_LOG_FORMAT, requestHeaders.get(Constants.USER_ID_HEADER),
37 requestHeaders.get(Constants.FIRST_NAME_HEADER) + " " + requestHeaders.get(Constants.LAST_NAME_HEADER),
38 requestHeaders.get(Constants.ORIGIN_HEADER), requestHeaders.get(Constants.ACCESS_HEADER), requestInfo.getRequestURL(), status);
43 public static void error(Logger log, HttpServletRequest request, int status) {
44 String errorMsg = "Internal Error";
45 if (request != null) {
46 errorMsg = String.format(Constants.ERROR_LOG_FORMAT, request.getHeader(Constants.USER_ID_HEADER),
47 request.getHeader(Constants.FIRST_NAME_HEADER) + " " + request.getHeader(Constants.LAST_NAME_HEADER),
48 request.getHeader(Constants.ORIGIN_HEADER), request.getHeader(Constants.ACCESS_HEADER), request.getRequestURL(), status);
53 public static void info(Logger log, HttpRequestInfo requestInfo, int status) {
54 String errorMsg = "Internal Error";
55 if (requestInfo != null && requestInfo.getHeaders() != null) {
56 Map<String, String> requestHeaders = requestInfo.getHeaders();
57 errorMsg = String.format(Constants.ERROR_LOG_FORMAT, requestHeaders.get(Constants.USER_ID_HEADER),
58 requestHeaders.get(Constants.FIRST_NAME_HEADER) + " " + requestHeaders.get(Constants.LAST_NAME_HEADER),
59 requestHeaders.get(Constants.ORIGIN_HEADER), requestHeaders.get(Constants.ACCESS_HEADER), requestInfo.getRequestURL(), status);