2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2018 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=========================================================
21 package org.onap.so.logging.cxf.interceptor;
24 import org.apache.cxf.binding.soap.SoapMessage;
25 import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
26 import org.apache.cxf.interceptor.Fault;
27 import org.apache.cxf.message.Message;
28 import org.apache.cxf.phase.Phase;
29 import org.onap.logging.ref.slf4j.ONAPLogConstants;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
36 public class SOAPLoggingOutInterceptor extends AbstractSoapInterceptor {
38 private static final String _500 = "500";
40 protected static Logger logger = LoggerFactory.getLogger(SOAPLoggingOutInterceptor.class);
44 public SOAPLoggingOutInterceptor() {
49 public void handleMessage(SoapMessage message) throws Fault {
51 Exception ex = message.getContent(Exception.class);
53 MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE,
54 ONAPLogConstants.ResponseStatus.COMPLETED.toString());
57 responseCode = (int) message.get(Message.RESPONSE_CODE);
58 if (responseCode != 0)
59 MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, String.valueOf(responseCode));
61 MDC.put(ONAPLogConstants.MDCs.RESPONSE_CODE, _500);
63 MDC.put(ONAPLogConstants.MDCs.RESPONSE_STATUS_CODE, ONAPLogConstants.ResponseStatus.ERROR.toString());
65 logger.info(ONAPLogConstants.Markers.EXIT, "Exiting");
66 } catch (Exception e) {
67 logger.warn("Error in incoming SOAP Message Inteceptor", e);