diff options
author | r.bogacki <r.bogacki@samsung.com> | 2019-02-26 12:03:44 +0100 |
---|---|---|
committer | r.bogacki <r.bogacki@samsung.com> | 2019-02-26 12:04:20 +0100 |
commit | 48646235563469235f65dd18d75ea8129587895f (patch) | |
tree | 66ad7471dac8a27e016e9b1486f1f70a57a0b955 /adapters/mso-sdnc-adapter/src/main/java/org/onap | |
parent | 1212fa1a4b33c76d5cc01ebd1cc438a3e3bc433a (diff) |
Removed MsoLogger from 'mso-sdnc-adapter'
Removed MsoLogger from adapters ('mso-sdnc-adapter')
Replaced MsoLogger with plain slf4j.
Refactored login output.
Fixed imports.
Change-Id: I1656776a04b322b9b8da30a3cc6aad31cd621a3e
Issue-ID: LOG-631
Signed-off-by: Robert Bogacki <r.bogacki@samsung.com>
Diffstat (limited to 'adapters/mso-sdnc-adapter/src/main/java/org/onap')
15 files changed, 212 insertions, 175 deletions
diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterService.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterService.java index e74dd64bb3..5deec41d94 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterService.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/SDNCAdapterService.java @@ -5,6 +5,7 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2018 IBM. + * Modifications Copyright (c) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +34,8 @@ import javax.xml.ws.WebServiceFeature; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This class was generated by Apache CXF 2.7.11.redhat-3 @@ -46,7 +49,7 @@ import org.onap.so.logger.MsoLogger; targetNamespace = "http://org.onap/workflow/sdnc/adapter/wsdl/v1") public class SDNCAdapterService extends Service { - private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, SDNCAdapterService.class); + private static Logger logger = LoggerFactory.getLogger(SDNCAdapterService.class); private static final String SDNC_ADAPTER_WSDL="SDNCAdapter.wsdl"; public static final URL WSDL_LOCATION; @@ -58,16 +61,19 @@ public class SDNCAdapterService extends Service { try { wsdlUrl = Thread.currentThread().getContextClassLoader().getResource("main/resources/SDNCAdapter.wsdl"); } catch (Exception e) { - logger.error(MessageEnum.RA_WSDL_NOT_FOUND, SDNC_ADAPTER_WSDL, "", "", MsoLogger.ErrorCode.DataError, "Exception - WSDL not found", e); + logger.error("{} {} {} {}", MessageEnum.RA_WSDL_NOT_FOUND.toString(), SDNC_ADAPTER_WSDL, + MsoLogger.ErrorCode.DataError.getValue(), "Exception - WSDL not found", e); } if(wsdlUrl == null) { - logger.error(MessageEnum.RA_WSDL_NOT_FOUND, SDNC_ADAPTER_WSDL, "", "", MsoLogger.ErrorCode.DataError, "WSDL not found"); - } else { + logger.error("{} {} {} {}", MessageEnum.RA_WSDL_NOT_FOUND.toString(), SDNC_ADAPTER_WSDL, + MsoLogger.ErrorCode.DataError.getValue(), "WSDL not found"); + } else { try { - logger.info(MessageEnum.RA_PRINT_URL, SDNC_ADAPTER_WSDL, wsdlUrl.toURI().toString(), ""); + logger.info("{} {} {}", MessageEnum.RA_PRINT_URL.toString(), SDNC_ADAPTER_WSDL, wsdlUrl.toURI().toString()); } catch (Exception e) { - logger.error(MessageEnum.RA_WSDL_URL_CONVENTION_EXC, SDNC_ADAPTER_WSDL, "", "", MsoLogger.ErrorCode.DataError, "Exception - print URL", e); - } + logger.error("{} {} {} {}", MessageEnum.RA_WSDL_URL_CONVENTION_EXC.toString(), SDNC_ADAPTER_WSDL, + MsoLogger.ErrorCode.DataError.getValue(), "Exception - print URL", e); + } } WSDL_LOCATION = wsdlUrl; } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCAdapterCallbackRequest.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCAdapterCallbackRequest.java index 7ec20afffd..3dcd008ba5 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCAdapterCallbackRequest.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCAdapterCallbackRequest.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed 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 @@ -33,6 +35,9 @@ import javax.xml.bind.annotation.XmlType; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * <p>Java class for anonymous complex type. * @@ -67,7 +72,7 @@ public class SDNCAdapterCallbackRequest { @XmlElement(name = "RequestData") protected Object requestData; - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, SDNCAdapterCallbackRequest.class); + private static Logger logger = LoggerFactory.getLogger(SDNCAdapterCallbackRequest.class); /** * Gets the value of the callbackHeader property. @@ -130,8 +135,9 @@ public class SDNCAdapterCallbackRequest { } catch (Exception e) { - msoLogger.error(MessageEnum.RA_MARSHING_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception - MARSHING_ERROR", e); - } + logger.error("{} {} {}", MessageEnum.RA_MARSHING_ERROR.toString(), MsoLogger.ErrorCode.DataError.getValue(), + "Exception - MARSHING_ERROR", e); + } return ""; } } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCCallbackAdapterService.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCCallbackAdapterService.java index e4882090bf..fd288c6a04 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCCallbackAdapterService.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/client/SDNCCallbackAdapterService.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed 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 @@ -31,6 +33,8 @@ import javax.xml.ws.WebServiceFeature; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This class was generated by Apache CXF 2.7.11.redhat-3 @@ -44,7 +48,7 @@ import org.onap.so.logger.MsoLogger; targetNamespace = "http://org.onap/workflow/sdnc/adapter/callback/wsdl/v1") public class SDNCCallbackAdapterService extends Service { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, SDNCCallbackAdapterService.class); + private static Logger logger = LoggerFactory.getLogger(SDNCCallbackAdapterService.class); private static final String SDNC_CALLBACK_ADAPTER_WSDL="SDNCCallbackAdapter.wsdl"; public static final URL WSDL_LOCATION; public static final QName SERVICE = new QName("http://org.onap/workflow/sdnc/adapter/callback/wsdl/v1", "SDNCCallbackAdapterService"); @@ -54,16 +58,20 @@ public class SDNCCallbackAdapterService extends Service { try { wsdlUrl = Thread.currentThread().getContextClassLoader().getResource("main/resources/SDNCCallbackAdapter.wsdl"); } catch (Exception e) { - msoLogger.error(MessageEnum.RA_WSDL_NOT_FOUND, SDNC_CALLBACK_ADAPTER_WSDL, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - WSDL not found", e); + logger.error("{} {} {} {} {}", MessageEnum.RA_WSDL_NOT_FOUND.toString(), SDNC_CALLBACK_ADAPTER_WSDL, "SDNC", + MsoLogger.ErrorCode.DataError.getValue(), "Exception - WSDL not found", e); } if(wsdlUrl == null) { - msoLogger.error(MessageEnum.RA_WSDL_NOT_FOUND, SDNC_CALLBACK_ADAPTER_WSDL, "SDNC", "", MsoLogger.ErrorCode.DataError, "WSDL not found"); - } else { + logger.error("{} {} {} {} {}", MessageEnum.RA_WSDL_NOT_FOUND.toString(), SDNC_CALLBACK_ADAPTER_WSDL, "SDNC", + MsoLogger.ErrorCode.DataError.getValue(), "WSDL not found"); + } else { try { - msoLogger.info(MessageEnum.RA_PRINT_URL, SDNC_CALLBACK_ADAPTER_WSDL, wsdlUrl.toURI().toString(), "SDNC"); - } catch (Exception e) { - msoLogger.error(MessageEnum.RA_WSDL_URL_CONVENTION_EXC, SDNC_CALLBACK_ADAPTER_WSDL, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception - URL convention problem", e); - } + logger.info("{} {} {} {}", MessageEnum.RA_PRINT_URL.toString(), SDNC_CALLBACK_ADAPTER_WSDL, + wsdlUrl.toURI().toString(), "SDNC"); + } catch (Exception e) { + logger.error("{} {} {} {} {}", MessageEnum.RA_WSDL_URL_CONVENTION_EXC.toString(), SDNC_CALLBACK_ADAPTER_WSDL, + "SDNC", MsoLogger.ErrorCode.DataError.getValue(), "Exception - URL convention problem", e); + } } WSDL_LOCATION = wsdlUrl; } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/MapRequestTunables.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/MapRequestTunables.java index a5800fc73d..6262f2d86f 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/MapRequestTunables.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/MapRequestTunables.java @@ -5,6 +5,7 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2018 IBM. + * Modifications Copyright (c) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +25,8 @@ package org.onap.so.adapters.sdnc.impl; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @@ -31,7 +34,7 @@ import org.springframework.stereotype.Component; @Component public class MapRequestTunables { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA,MapRequestTunables.class); + private static Logger logger = LoggerFactory.getLogger(MapRequestTunables.class); public static final String GENERATED_KEY = "Generated key: "; @Autowired @@ -44,14 +47,14 @@ public class MapRequestTunables { String key; if ("query".equals(reqTunable.getAction())) { //due to variable format for reqTunable.getOperation() eg services/layer3-service-list/8fe4ba4f-35cf-4d9b-a04a-fd3f5d4c5cc9 key = Constants.REQUEST_TUNABLES + "." + reqTunable.getMsoAction() + ".." + reqTunable.getAction(); - msoLogger.debug(GENERATED_KEY + key); + logger.debug(GENERATED_KEY + key); } else if ("put".equals(reqTunable.getAction()) || "restdelete".equals(reqTunable.getAction())) { //due to variable format for reqTunable.getOperation() eg services/layer3-service-list/8fe4ba4f-35cf-4d9b-a04a-fd3f5d4c5cc9 key = Constants.REQUEST_TUNABLES + "..." + reqTunable.getAction(); - msoLogger.debug(GENERATED_KEY + key); + logger.debug(GENERATED_KEY + key); } else { key = Constants.REQUEST_TUNABLES + "." + reqTunable.getMsoAction() + "." + reqTunable.getOperation() +"." + reqTunable.getAction(); - msoLogger.debug(GENERATED_KEY + key); + logger.debug(GENERATED_KEY + key); } String value; @@ -61,31 +64,32 @@ public class MapRequestTunables { String[] parts = value.split("\\|"); //escape pipe if (parts.length < 3) { - msoLogger.warn(MessageEnum.RA_SDNC_INVALID_CONFIG, key, value, "SDNC", "", MsoLogger.ErrorCode.DataError, "Invalid config"); + logger.warn("{} {} {} {} {} {}", MessageEnum.RA_SDNC_INVALID_CONFIG.toString(), key, value, "SDNC", + MsoLogger.ErrorCode.DataError.getValue(), "Invalid config"); } for (int i = 0; i < parts.length; i++) { if (i == 0) { reqTunable.setReqMethod(parts[i]) ; - msoLogger.debug("Request Method is set to: " + reqTunable.getReqMethod()); + logger.debug("Request Method is set to: {}", reqTunable.getReqMethod()); } else if (i == 1) { reqTunable.setTimeout( parts[i]); - msoLogger.debug("Timeout is set to: " + reqTunable.getTimeout()); + logger.debug("Timeout is set to: {}", reqTunable.getTimeout()); } else if (i == 2) { reqTunable.setSdncUrl(env.getProperty(Constants.REQUEST_TUNABLES + "." + parts[i],"")); if (reqTunable.getOperation() != null && reqTunable.getSdncUrl() != null) { reqTunable.setSdncUrl(reqTunable.getSdncUrl() + reqTunable.getOperation()); } - msoLogger.debug("SDNC Url is set to: " + reqTunable.getSdncUrl()); + logger.debug("SDNC Url is set to: {}", reqTunable.getSdncUrl()); } else if (i == 3) { reqTunable.setHeaderName(parts[i]); - msoLogger.debug("HeaderName is set to: " + reqTunable.getHeaderName()); + logger.debug("HeaderName is set to: {}", reqTunable.getHeaderName()); } else if (i == 4) { reqTunable.setNamespace(parts[i]); - msoLogger.debug("NameSpace is set to: " + reqTunable.getNamespace()); + logger.debug("NameSpace is set to: {}", reqTunable.getNamespace()); } else if (i == 5) { reqTunable.setAsyncInd(parts[i]); - msoLogger.debug("AsyncInd is set to: " + reqTunable.getAsyncInd()); + logger.debug("AsyncInd is set to: {}", reqTunable.getAsyncInd()); } } @@ -96,9 +100,10 @@ public class MapRequestTunables { error = "Missing configuration for:" + key; } if (error != null) { - msoLogger.error(MessageEnum.RA_SDNC_MISS_CONFIG_PARAM, key, "SDNC", "", MsoLogger.ErrorCode.DataError, "Missing config param"); + logger.error("{} {} {} {} {}", MessageEnum.RA_SDNC_MISS_CONFIG_PARAM.toString(), key, "SDNC", + MsoLogger.ErrorCode.DataError.getValue(), "Missing config param"); } - msoLogger.debug ("RequestTunables Key:" + key + " Value:" + value + " Tunables:" + this.toString()); + logger.debug("RequestTunables Key:{} Value:{} Tunables:{}", key, value, this.toString()); return reqTunable; } } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCAdapterPortTypeImpl.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCAdapterPortTypeImpl.java index 4a6ac9f5e2..cf81ae4be0 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCAdapterPortTypeImpl.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCAdapterPortTypeImpl.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed 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 @@ -30,6 +32,8 @@ import org.onap.so.adapters.sdnc.SDNCAdapterResponse; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -40,7 +44,7 @@ public class SDNCAdapterPortTypeImpl implements SDNCAdapterPortType { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA,SDNCAdapterPortTypeImpl.class); + private static Logger logger = LoggerFactory.getLogger(SDNCAdapterPortTypeImpl.class); @Autowired @@ -48,7 +52,7 @@ public class SDNCAdapterPortTypeImpl implements SDNCAdapterPortType { @PostConstruct public void init () { - msoLogger.info(MessageEnum.RA_INIT_SDNC_ADAPTER, "SDNC", "SDNCAdapterPortType", ""); + logger.info("{} {} {}", MessageEnum.RA_INIT_SDNC_ADAPTER.toString(), "SDNC", "SDNCAdapterPortType"); } /** @@ -57,7 +61,7 @@ public class SDNCAdapterPortTypeImpl implements SDNCAdapterPortType { @Override public void healthCheck () { - msoLogger.debug("Health check call in SDNC Adapter"); + logger.debug("Health check call in SDNC Adapter"); } @@ -70,7 +74,8 @@ public class SDNCAdapterPortTypeImpl implements SDNCAdapterPortType { } catch (Exception e){ String respMsg = "Error sending request to SDNC. Failed to start SDNC Client thread " + e.getMessage(); - msoLogger.error(MessageEnum.RA_SEND_REQUEST_SDNC_ERR, "SDNC", "", MsoLogger.ErrorCode.DataError, respMsg, e); + logger.error("{} {} {} {}", MessageEnum.RA_SEND_REQUEST_SDNC_ERR.toString(), "SDNC", + MsoLogger.ErrorCode.DataError.getValue(), respMsg, e); SDNCResponse sdncResp = new SDNCResponse(bpelReqId); sdncResp.setRespCode(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java index 59884f25b8..d7f2c11d0b 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java @@ -55,6 +55,8 @@ import org.onap.so.adapters.sdnc.client.SDNCCallbackAdapterService; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.scheduling.annotation.Async; @@ -74,7 +76,7 @@ public class SDNCRestClient{ @Autowired private MapRequestTunables tunablesMapper; - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA,SDNCRestClient.class); + private static Logger logger = LoggerFactory.getLogger(SDNCRestClient.class); private static final String EXCEPTION_MSG="Exception while evaluate xpath"; private static final String MSO_INTERNAL_ERROR="MsoInternalError"; @@ -83,7 +85,7 @@ public class SDNCRestClient{ public void executeRequest(SDNCAdapterRequest bpelRequest) { - msoLogger.debug("BPEL Request:" + bpelRequest.toString()); + logger.debug("BPEL Request:" + bpelRequest.toString()); // Added delay to allow completion of create request to SDNC // before executing activate of create request. @@ -124,11 +126,9 @@ public class SDNCRestClient{ } long sdncStartTime = System.currentTimeMillis(); SDNCResponse sdncResp = getSdncResp(sdncReqBody, rt); - msoLogger.recordMetricEvent (sdncStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from SDNC", "SDNC", action + "." + operation, null); - msoLogger.debug ("Got the SDNC Response: " + sdncResp.getSdncRespXml()); + logger.debug ("Got the SDNC Response: {}", sdncResp.getSdncRespXml()); long bpelStartTime = System.currentTimeMillis(); sendRespToBpel(callbackUrl, sdncResp); - msoLogger.recordMetricEvent (bpelStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully send reauest to BPEL", "BPMN", callbackUrl, null); return; } @@ -142,8 +142,8 @@ public class SDNCRestClient{ SDNCResponse sdncResp = new SDNCResponse(rt.getReqId()); StringBuilder response = new StringBuilder(); - msoLogger.info(MessageEnum.RA_SEND_REQUEST_SDNC.name() + ":\n" + rt.toString(), "SDNC", ""); - msoLogger.trace("SDNC Request Body:\n" + sdncReqBody); + logger.info("{} :\n {} {}", MessageEnum.RA_SEND_REQUEST_SDNC.name(), rt.toString(), "SDNC"); + logger.trace("SDNC Request Body:{} \n", sdncReqBody); try { @@ -186,12 +186,13 @@ public class SDNCRestClient{ } sdncResp.setSdncRespXml(response.toString()); - msoLogger.info(MessageEnum.RA_RESPONSE_FROM_SDNC.name() + ":\n" + sdncResp.toString(), "SDNC", ""); + logger.info("{} :\n {} {}", MessageEnum.RA_RESPONSE_FROM_SDNC.name(), sdncResp.toString(), "SDNC"); return(sdncResp); } catch (Exception e) { - msoLogger.error(MessageEnum.RA_EXCEPTION_COMMUNICATE_SDNC, "SDNC", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception processing request to SDNC", e); + logger.error("{} {} {} {}", MessageEnum.RA_EXCEPTION_COMMUNICATE_SDNC.toString(), "SDNC", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception processing request to SDNC", e); //default sdncResp.setRespCode(HttpURLConnection.HTTP_INTERNAL_ERROR); String respMsg = "Error processing request to SDNC. "; @@ -231,7 +232,8 @@ public class SDNCRestClient{ eType = xpath.evaluate("error-type", error); sdncErrMsg = new StringBuilder(". SDNC Returned-[error-type:" + eType); } catch (Exception e3) { - msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-type", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, EXCEPTION_MSG, e3); + logger.error("{} {} {} {} {} {}", MessageEnum.RA_EVALUATE_XPATH_ERROR.toString(), "error-type", + error.toString(), "SDNC", MsoLogger.ErrorCode.DataError.getValue(), EXCEPTION_MSG, e3); } String eTag = null; @@ -239,7 +241,8 @@ public class SDNCRestClient{ eTag = xpath.evaluate( "error-tag", error); sdncErrMsg.append(", error-tag:").append(eTag); } catch (Exception e3) { - msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-tag", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, EXCEPTION_MSG, e3); + logger.error("{} {} {} {} {} {}", MessageEnum.RA_EVALUATE_XPATH_ERROR.toString(), "error-tag", + error.toString(), "SDNC", MsoLogger.ErrorCode.DataError.getValue(), EXCEPTION_MSG, e3); } String eMsg = null; @@ -247,15 +250,18 @@ public class SDNCRestClient{ eMsg = xpath.evaluate("error-message", error); sdncErrMsg.append(", error-message:").append(eMsg).append("]"); } catch (Exception e3) { - msoLogger.error (MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-message", error.toString(), "SDNC", "", MsoLogger.ErrorCode.DataError, EXCEPTION_MSG, e3); + logger.error("{} {} {} {} {} {}", MessageEnum.RA_EVALUATE_XPATH_ERROR.toString(), "error-message", error.toString(), + "SDNC", MsoLogger.ErrorCode.DataError.getValue(), EXCEPTION_MSG, e3); } } } catch (Exception e2) { - msoLogger.error (MessageEnum.RA_ANALYZE_ERROR_EXC, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception while analyse error", e2); + logger.error("{} {} {} {}", MessageEnum.RA_ANALYZE_ERROR_EXC.toString(), "SDNC", + MsoLogger.ErrorCode.DataError.getValue(), "Exception while analyse error", e2); } } //is != null } catch (Exception e1) { - msoLogger.error (MessageEnum.RA_ERROR_GET_RESPONSE_SDNC, "SDNC", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception while get SDNC response", e1); + logger.error("{} {} {} {}", MessageEnum.RA_ERROR_GET_RESPONSE_SDNC.toString(), "SDNC", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception while get SDNC response", e1); } } //con != null @@ -266,7 +272,8 @@ public class SDNCRestClient{ sdncResp.setRespMsg(respMsg); - msoLogger.error(MessageEnum.RA_EXCEPTION_COMMUNICATE_SDNC, "SDNC", "", MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with SDNC", e); + logger.error("{} {} {} {}", MessageEnum.RA_EXCEPTION_COMMUNICATE_SDNC.toString(), "SDNC", + MsoLogger.ErrorCode.AvailabilityError.getValue(), "Exception while communicate with SDNC", e); return sdncResp; } @@ -289,14 +296,15 @@ public class SDNCRestClient{ { cbReq.setRequestData(sdncResp.getSdncRespXml()); } - msoLogger.info(MessageEnum.RA_CALLBACK_BPEL.name() + ":\n" + cbReq.toString(), CAMUNDA, ""); + logger.info("{} :\n {} {}", MessageEnum.RA_CALLBACK_BPEL.name(), cbReq.toString(), CAMUNDA); URL wsdlUrl = null; try { wsdlUrl = new URL (bpelUrl); } catch (MalformedURLException e1) { error = "Caught exception initializing Callback wsdl " + e1.getMessage(); - msoLogger.error(MessageEnum.RA_INIT_CALLBACK_WSDL_ERR, CAMUNDA, "", MsoLogger.ErrorCode.DataError, "Exception initializing Callback wsdl", e1); + logger.error("{} {} {} {}", MessageEnum.RA_INIT_CALLBACK_WSDL_ERR.toString(), CAMUNDA, + MsoLogger.ErrorCode.DataError.getValue(), "Exception initializing Callback wsdl", e1); } @@ -310,7 +318,7 @@ public class SDNCRestClient{ bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, wsdlUrl.toExternalForm()); } else { - msoLogger.debug("wsdlUrl is NULL:"); + logger.debug("wsdlUrl is NULL:"); } //authentication @@ -326,22 +334,23 @@ public class SDNCRestClient{ } catch (Exception e2) { error = "Unable to set authorization in callback request " + e2.getMessage(); - msoLogger.error(MessageEnum.RA_SET_CALLBACK_AUTH_EXC, CAMUNDA, "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception - Unable to set authorization in callback request", e2); + logger.error("{} {} {} {}", MessageEnum.RA_SET_CALLBACK_AUTH_EXC.toString(), CAMUNDA, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), + "Exception - Unable to set authorization in callback request", e2); } - msoLogger.debug("Invoking Bpel Callback. BpelCallbackUrl:" + bpelUrl); + logger.debug("Invoking Bpel Callback. BpelCallbackUrl:{}", bpelUrl); cbPort.sdncAdapterCallback(cbReq); } catch (Exception e) { error = "Error sending BpelCallback request" + e.getMessage(); - msoLogger.error("Error " + MsoLogger.ErrorCode.BusinessProcesssError + " - " + MessageEnum.RA_CALLBACK_BPEL_EXC + " - " + error, e); - + logger.error("Error {} - {} - {}", MsoLogger.ErrorCode.BusinessProcesssError.getValue(), + MessageEnum.RA_CALLBACK_BPEL_EXC.toString(), error, e); } - msoLogger.info(MessageEnum.RA_CALLBACK_BPEL_COMPLETE.name(), CAMUNDA, ""); + logger.info(MessageEnum.RA_CALLBACK_BPEL_COMPLETE.name(), CAMUNDA); return; } - } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Utils.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Utils.java index 55af0d7cad..96e7dcf51a 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Utils.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/Utils.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed 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 @@ -33,13 +35,15 @@ import javax.xml.transform.stream.StreamResult; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Utils { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, Utils.class); + private static Logger logger = LoggerFactory.getLogger(Utils.class); private Utils() { } @@ -94,11 +98,12 @@ public class Utils { } String s = domToStr(newdoc); - msoLogger.debug("Formatted SdncReq:\n" + s); + logger.debug("Formatted SdncReq:\n", s); return s; } catch (Exception e) { - msoLogger.error(MessageEnum.RA_ERROR_CREATE_SDNC_REQUEST, "SDNC", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in genSdncReq", e); + logger.error("{} {} {} {}", MessageEnum.RA_ERROR_CREATE_SDNC_REQUEST.toString(), "SDNC", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception in genSdncReq", e); } return null; } @@ -127,11 +132,12 @@ public class Utils { } String s = domToStr(newdoc); - msoLogger.debug("Formatted SdncPutReq:\n" + s); + logger.debug("Formatted SdncPutReq:\n {}", s); return s; } catch (Exception e) { - msoLogger.error(MessageEnum.RA_ERROR_CREATE_SDNC_REQUEST, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception in genSdncPutReq", e); + logger.error("{} {} {} {}", MessageEnum.RA_ERROR_CREATE_SDNC_REQUEST.toString(), "SDNC", + MsoLogger.ErrorCode.DataError.getValue(), "Exception in genSdncPutReq", e); } return null; } @@ -161,11 +167,12 @@ public class Utils { root.appendChild(elem3); String s = domToStr(newdoc); - msoLogger.debug("Formatted SdncReq:" + s); + logger.debug("Formatted SdncReq: {}", s); return s; } catch (Exception e) { - msoLogger.error(MessageEnum.RA_ERROR_CREATE_SDNC_RESPONSE, "SDNC", "", MsoLogger.ErrorCode.DataError, "Exception in genMsoFailResp", e); + logger.error("{} {} {} {}", MessageEnum.RA_ERROR_CREATE_SDNC_RESPONSE.toString(), "SDNC", + MsoLogger.ErrorCode.DataError.getValue(), "Exception in genMsoFailResp", e); } return null; } @@ -191,7 +198,8 @@ public class Utils { s = s.replaceAll("xmlns=\"\"", ""); return s; } catch (Exception e) { - msoLogger.error(MessageEnum.RA_ERROR_CONVERT_XML2STR, "", "", MsoLogger.ErrorCode.DataError, "Exception - domToStr", e); + logger.error("{} {} {}", MessageEnum.RA_ERROR_CONVERT_XML2STR.toString(), MsoLogger.ErrorCode.DataError + .getValue(), "Exception - domToStr", e); } } return null; diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java index e427423763..6a66770d29 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/BPRestCallback.java @@ -6,6 +6,7 @@ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2018 IBM. + * Modifications Copyright (c) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +39,8 @@ import org.onap.so.adapters.sdnc.impl.Constants; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.onap.so.utils.CryptoUtils; @@ -49,7 +52,7 @@ import org.springframework.core.env.Environment; */ @Component public class BPRestCallback { - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA,BPRestCallback.class); + private static final Logger logger = LoggerFactory.getLogger(BPRestCallback.class); private static final String CAMUNDA="Camunda"; private static final String MSO_INTERNAL_ERROR="MsoInternalError"; @@ -66,7 +69,7 @@ public class BPRestCallback { * @return true if the message was consumed successfully by the endpoint */ public boolean send(String workflowMessageUrl, String messageType, String correlator, String message) { - LOGGER.debug(getClass().getSimpleName() + ".send(" + logger.debug(getClass().getSimpleName() + ".send(" + "workflowMessageUrl=" + workflowMessageUrl + " messageType=" + messageType + " correlator=" + correlator @@ -91,12 +94,13 @@ public class BPRestCallback { * @return true if the message was consumed successfully by the endpoint */ public boolean send(String url, String message) { - LOGGER.debug(getClass().getSimpleName() + ".send(" + logger.debug(getClass().getSimpleName() + ".send(" + "url=" + url + " message=" + message + ")"); - LOGGER.info(MessageEnum.RA_CALLBACK_BPEL, message == null ? "[no content]" : message, CAMUNDA, ""); + logger.info("{} {} {}", MessageEnum.RA_CALLBACK_BPEL.toString(), message == null ? "[no content]" : message, + CAMUNDA); HttpPost method = null; HttpResponse httpResponse = null; @@ -129,8 +133,8 @@ public class BPRestCallback { method.setHeader(ONAPLogConstants.Headers.INVOCATION_ID,MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID)); method.setHeader(ONAPLogConstants.Headers.PARTNER_NAME,"SO-SDNCAdapter"); } catch (Exception e) { - LOGGER.error(MessageEnum.RA_SET_CALLBACK_AUTH_EXC, CAMUNDA, "", MsoLogger.ErrorCode.BusinessProcesssError, - "Unable to set authorization in callback request", e); + logger.error("{} {} {} {}", MessageEnum.RA_SET_CALLBACK_AUTH_EXC.toString(), CAMUNDA, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Unable to set authorization in callback request", e); error = true; } @@ -146,14 +150,15 @@ public class BPRestCallback { if (httpResponse.getStatusLine().getStatusCode() >= 300) { String msg = "Received error response to callback request: " + httpResponse.getStatusLine(); - LOGGER.error(MessageEnum.RA_CALLBACK_BPEL_EXC, CAMUNDA, "", MsoLogger.ErrorCode.BusinessProcesssError, msg); + logger.error("{} {} {} {}", MessageEnum.RA_CALLBACK_BPEL_EXC.toString(), CAMUNDA, MsoLogger.ErrorCode + .BusinessProcesssError.getValue(), msg); } } return true; } catch (Exception e) { - LOGGER.error(MessageEnum.RA_CALLBACK_BPEL_EXC, CAMUNDA, "", MsoLogger.ErrorCode.BusinessProcesssError, - "Error sending callback request", e); + logger.error("{} {} {} {}", MessageEnum.RA_CALLBACK_BPEL_EXC.toString(), CAMUNDA, + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Error sending callback request", e); return false; } finally { if (httpResponse != null) { @@ -161,7 +166,7 @@ public class BPRestCallback { EntityUtils.consume(httpResponse.getEntity()); httpResponse = null; } catch (Exception e) { - LOGGER.debug("Exception:", e); + logger.debug("Exception:", e); } } @@ -169,10 +174,10 @@ public class BPRestCallback { try { method.reset(); } catch (Exception e) { - LOGGER.debug("Exception:", e); + logger.debug("Exception:", e); } } - LOGGER.info(MessageEnum.RA_CALLBACK_BPEL_COMPLETE, CAMUNDA, "",""); + logger.info("{} {}", MessageEnum.RA_CALLBACK_BPEL_COMPLETE.toString(), CAMUNDA); } } -}
\ No newline at end of file +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/MapTypedRequestTunablesData.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/MapTypedRequestTunablesData.java index 6f40ba07a9..fd9ce4c719 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/MapTypedRequestTunablesData.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/MapTypedRequestTunablesData.java @@ -5,6 +5,7 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2018 IBM. + * Modifications Copyright (c) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +28,8 @@ import org.onap.so.adapters.sdnc.impl.Constants; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @@ -34,9 +37,7 @@ import org.springframework.stereotype.Component; @Component public class MapTypedRequestTunablesData { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA,MapTypedRequestTunablesData.class); - - + private static Logger logger = LoggerFactory.getLogger(MapTypedRequestTunablesData.class); private static final String MISSING_CONFIGURATION_ERROR_MSG= "Missing configuration for: "; private static final String MISSING_CONFIG_PARAM_ERROR_MSG="Missing config param"; @@ -54,7 +55,8 @@ public class MapTypedRequestTunablesData { if ("".equals(value)) { error= MISSING_CONFIGURATION_ERROR_MSG + reqTunable.getKey(); - msoLogger.error(MessageEnum.RA_SDNC_MISS_CONFIG_PARAM, reqTunable.getKey(), "SDNC", "", MsoLogger.ErrorCode.DataError, MISSING_CONFIG_PARAM_ERROR_MSG); + logger.error("{} {} {} {} {}", MessageEnum.RA_SDNC_MISS_CONFIG_PARAM.toString(), reqTunable.getKey(), "SDNC", + MsoLogger.ErrorCode.DataError.getValue(), MISSING_CONFIG_PARAM_ERROR_MSG); throw new SDNCAdapterException(error); } @@ -63,41 +65,42 @@ public class MapTypedRequestTunablesData { if (parts.length != 5) { error="Invalid configuration for: " + reqTunable.getKey(); - msoLogger.error(MessageEnum.RA_SDNC_INVALID_CONFIG, reqTunable.getKey(), value, "SDNC", "", MsoLogger.ErrorCode.DataError, "Invalid config"); - + logger.error("{} {} {} {} {} {}", MessageEnum.RA_SDNC_INVALID_CONFIG.toString(), reqTunable.getKey(), value, "SDNC", + MsoLogger.ErrorCode.DataError.getValue(), "Invalid config"); throw new SDNCAdapterException(error); } reqTunable.setReqMethod(parts[0]); - msoLogger.trace("Request Method is set to: " + reqTunable.getReqMethod()); + logger.trace("Request Method is set to: {}", reqTunable.getReqMethod()); reqTunable.setTimeout(parts[1]); - msoLogger.trace("Timeout is set to: " + reqTunable.getTimeout()); + logger.trace("Timeout is set to: {}", reqTunable.getTimeout()); String urlPropKey = Constants.REQUEST_TUNABLES + "." + parts[2]; reqTunable.setSdncUrl(env.getProperty(urlPropKey, "")); if ("".equals(reqTunable.getSdncUrl())) { error=MISSING_CONFIGURATION_ERROR_MSG + urlPropKey; - msoLogger.error(MessageEnum.RA_SDNC_MISS_CONFIG_PARAM, urlPropKey, "SDNC", "", MsoLogger.ErrorCode.DataError, MISSING_CONFIG_PARAM_ERROR_MSG); + logger.error("{} {} {} {} {}", MessageEnum.RA_SDNC_MISS_CONFIG_PARAM.toString(), urlPropKey, "SDNC", + MsoLogger.ErrorCode.DataError.getValue(), MISSING_CONFIG_PARAM_ERROR_MSG); throw new SDNCAdapterException(error); } - msoLogger.trace("SDNC Url is set to: " + reqTunable.getSdncUrl()); + logger.trace("SDNC Url is set to: {}", reqTunable.getSdncUrl()); reqTunable.setHeaderName(parts[3]); - msoLogger.trace("Header Name is set to: " + reqTunable.getHeaderName()); + logger.trace("Header Name is set to: {}", reqTunable.getHeaderName()); reqTunable.setNamespace(parts[4]); - msoLogger.trace("Namespace is set to: " + reqTunable.getNamespace()); + logger.trace("Namespace is set to: {}", reqTunable.getNamespace()); reqTunable.setMyUrl(env.getProperty(Constants.MY_URL_PROP, "")); if ("".equals(reqTunable.getMyUrl())) { error=MISSING_CONFIGURATION_ERROR_MSG + Constants.MY_URL_PROP; - msoLogger.error(MessageEnum.RA_SDNC_MISS_CONFIG_PARAM, Constants.MY_URL_PROP, "SDNC", "", - MsoLogger.ErrorCode.DataError, MISSING_CONFIG_PARAM_ERROR_MSG); + logger.error("{} {} {} {} {}", MessageEnum.RA_SDNC_MISS_CONFIG_PARAM.toString(), Constants.MY_URL_PROP, "SDNC", + MsoLogger.ErrorCode.DataError.getValue(), MISSING_CONFIG_PARAM_ERROR_MSG); throw new SDNCAdapterException(error); } @@ -108,7 +111,7 @@ public class MapTypedRequestTunablesData { reqTunable.setMyUrl(reqTunable.getMyUrl().concat(reqTunable.getMyUrlSuffix())); - msoLogger.debug(reqTunable.toString()); + logger.debug(reqTunable.toString()); return reqTunable; } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCAdapterUtils.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCAdapterUtils.java index dcb1fdae8c..8cafbda325 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCAdapterUtils.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCAdapterUtils.java @@ -5,6 +5,8 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed 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 @@ -21,11 +23,11 @@ package org.onap.so.adapters.sdnc.sdncrest; -import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.List; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.web.util.UriUtils; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -35,7 +37,7 @@ import org.w3c.dom.NodeList; * Utility methods used by SDNCAdapterRest. */ public final class SDNCAdapterUtils { - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, SDNCAdapterUtils.class); + private static final Logger logger = LoggerFactory.getLogger(SDNCAdapterUtils.class); /** * Instantiation is not allowed. */ @@ -67,4 +69,4 @@ public final class SDNCAdapterUtils { public static String encodeURLPathSegment(String pathSegment) { return UriUtils.encodePathSegment(pathSegment, "UTF-8"); } -}
\ No newline at end of file +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnector.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnector.java index 3ecf6337cf..06e7ab23a6 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnector.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCConnector.java @@ -6,6 +6,7 @@ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2018 IBM. + * Modifications Copyright (c) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,6 +55,8 @@ import org.onap.so.adapters.sdncrest.SDNCResponseCommon; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.w3c.dom.Document; @@ -68,7 +71,7 @@ import org.springframework.core.env.Environment; */ @Component public abstract class SDNCConnector { - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA,SDNCConnector.class); + private static final Logger logger = LoggerFactory.getLogger(SDNCConnector.class); private static final String MSO_INTERNAL_ERROR="MsoInternalError"; private static final String XPATH_EXCEPTION="XPath Exception"; @@ -76,8 +79,8 @@ public abstract class SDNCConnector { private Environment env; public SDNCResponseCommon send(String content, TypedRequestTunables rt) { - LOGGER.debug("SDNC URL: " + rt.getSdncUrl()); - LOGGER.debug("SDNC Request Body:\n" + content); + logger.debug("SDNC URL: {}", rt.getSdncUrl()); + logger.debug("SDNC Request Body:\n {}", content); HttpRequestBase method = null; HttpResponse httpResponse = null; @@ -122,7 +125,7 @@ public abstract class SDNCConnector { method.setHeader("Accept", "application/yang.data+xml"); } else { - LOGGER.debug("method is NULL:"); + logger.debug("method is NULL:"); } @@ -137,8 +140,8 @@ public abstract class SDNCConnector { int statusCode = httpResponse.getStatusLine().getStatusCode(); String statusMessage = httpResponse.getStatusLine().getReasonPhrase(); - LOGGER.debug("SDNC Response: " + statusCode + " " + statusMessage - + (responseContent == null ? "" : System.lineSeparator() + responseContent)); + logger.debug("SDNC Response: {} {}", statusCode, + statusMessage + (responseContent == null ? "" : System.lineSeparator() + responseContent)); if (httpResponse.getStatusLine().getStatusCode() >= 300) { String errMsg = "SDNC returned " + statusCode + " " + statusMessage; @@ -159,12 +162,12 @@ public abstract class SDNCConnector { method.reset(); } else { - LOGGER.debug("method is NULL:"); + logger.debug("method is NULL:"); } method = null; - LOGGER.info(MessageEnum.RA_RESPONSE_FROM_SDNC, responseContent, "SDNC", ""); + logger.info("{} {} {}", MessageEnum.RA_RESPONSE_FROM_SDNC.toString(), responseContent, "SDNC"); return createResponseFromContent(statusCode, statusMessage, responseContent, rt); } catch (SocketTimeoutException | ConnectTimeoutException e) { @@ -182,7 +185,7 @@ public abstract class SDNCConnector { try { EntityUtils.consume(httpResponse.getEntity()); } catch (Exception e) { - LOGGER.debug("Exception:", e); + logger.debug("Exception:", e); } } @@ -190,22 +193,20 @@ public abstract class SDNCConnector { try { method.reset(); } catch (Exception e) { - LOGGER.debug("Exception:", e); + logger.debug("Exception:", e); } } } } protected void logError(String errMsg) { - LOGGER.error(MessageEnum.RA_EXCEPTION_COMMUNICATE_SDNC, "SDNC", "", - MsoLogger.ErrorCode.AvailabilityError, errMsg); - + logger.error("{} {} {} {}", MessageEnum.RA_EXCEPTION_COMMUNICATE_SDNC.toString(), "SDNC", + MsoLogger.ErrorCode.AvailabilityError.getValue(), errMsg); } protected void logError(String errMsg, Throwable t) { - LOGGER.error(MessageEnum.RA_EXCEPTION_COMMUNICATE_SDNC, "SDNC", "", - MsoLogger.ErrorCode.AvailabilityError, errMsg, t); - + logger.error("{} {} {} {}", MessageEnum.RA_EXCEPTION_COMMUNICATE_SDNC.toString(), "SDNC", + MsoLogger.ErrorCode.AvailabilityError.getValue(), errMsg, t); } /** @@ -288,8 +289,8 @@ public abstract class SDNCConnector { String errorType = xpath.evaluate("error-type", error); info += "error-type:" + errorType; } catch (XPathExpressionException e) { - LOGGER.error(MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-type", error.toString(), "SDNC", "", - MsoLogger.ErrorCode.DataError, XPATH_EXCEPTION, e); + logger.error("{} {} {} {} {} {}", MessageEnum.RA_EVALUATE_XPATH_ERROR.toString(), "error-type", error.toString(), + "SDNC", MsoLogger.ErrorCode.DataError.getValue(), XPATH_EXCEPTION, e); } try { @@ -299,8 +300,8 @@ public abstract class SDNCConnector { } info += "error-tag:" + errorTag; } catch (XPathExpressionException e) { - LOGGER.error(MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-tag", error.toString(), "SDNC", "", - MsoLogger.ErrorCode.DataError, XPATH_EXCEPTION, e); + logger.error("{} {} {} {} {} {}", MessageEnum.RA_EVALUATE_XPATH_ERROR.toString(), "error-tag", error.toString(), + "SDNC", MsoLogger.ErrorCode.DataError.getValue(), XPATH_EXCEPTION, e); } try { @@ -310,8 +311,8 @@ public abstract class SDNCConnector { } info += "error-message:" + errorMessage; } catch (Exception e) { - LOGGER.error(MessageEnum.RA_EVALUATE_XPATH_ERROR, "error-message", error.toString(), "SDNC", "", - MsoLogger.ErrorCode.DataError, XPATH_EXCEPTION, e); + logger.error("{} {} {} {} {} {}", MessageEnum.RA_EVALUATE_XPATH_ERROR.toString(), "error-message", + error.toString(), "SDNC", MsoLogger.ErrorCode.DataError.getValue(), XPATH_EXCEPTION, e); } if (!info.isEmpty()) { @@ -323,8 +324,8 @@ public abstract class SDNCConnector { } } } catch (Exception e) { - LOGGER.error (MessageEnum.RA_ANALYZE_ERROR_EXC, "SDNC", "", - MsoLogger.ErrorCode.DataError, "Exception while analyzing errors", e); + logger.error("{} {} {} {}", MessageEnum.RA_ANALYZE_ERROR_EXC.toString(), "SDNC", + MsoLogger.ErrorCode.DataError.getValue(), "Exception while analyzing errors", e); } return output.toString(); diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestConnector.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestConnector.java index 8ca14501e5..57051e570e 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestConnector.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestConnector.java @@ -6,6 +6,7 @@ * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2018 IBM. + * Modifications Copyright (c) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +39,8 @@ import org.onap.so.adapters.sdncrest.SDNCErrorCommon; import org.onap.so.adapters.sdncrest.SDNCResponseCommon; import org.onap.so.adapters.sdncrest.SDNCServiceError; import org.onap.so.adapters.sdncrest.SDNCServiceResponse; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -52,17 +54,17 @@ import org.xml.sax.SAXException; @Component public class SDNCServiceRequestConnector extends SDNCConnector { - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA,SDNCServiceRequestConnector.class); + private static final Logger logger = LoggerFactory.getLogger(SDNCServiceRequestConnector.class); @Override protected SDNCResponseCommon createResponseFromContent(int statusCode, String statusMessage, String responseContent, TypedRequestTunables rt) { try { return parseResponseContent(responseContent); } catch (ParseException e) { - LOGGER.error(e); + logger.error("Error occured:", e); return createErrorResponse(HttpURLConnection.HTTP_INTERNAL_ERROR, e.getMessage(), rt); }catch (Exception e) { - LOGGER.error(e); + logger.error("Error occured:", e); return createErrorResponse(HttpURLConnection.HTTP_INTERNAL_ERROR, e.getMessage(), rt); } } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java index deb39ac54e..62233273b1 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SDNCServiceRequestTask.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed 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 @@ -34,12 +36,13 @@ import javax.xml.transform.stream.StreamResult; import org.apache.http.HttpStatus; import org.onap.so.adapters.sdnc.exception.SDNCAdapterException; import org.onap.so.adapters.sdncrest.RequestInformation; -import org.onap.so.adapters.sdncrest.SDNCErrorCommon; import org.onap.so.adapters.sdncrest.SDNCResponseCommon; import org.onap.so.adapters.sdncrest.SDNCServiceError; import org.onap.so.adapters.sdncrest.SDNCServiceRequest; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; @@ -48,7 +51,7 @@ import org.w3c.dom.Element; @Component public class SDNCServiceRequestTask { - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA,SDNCServiceRequestTask.class); + private static final Logger logger = LoggerFactory.getLogger(SDNCServiceRequestTask.class); @Autowired private SDNCServiceRequestConnector connector; @@ -91,24 +94,8 @@ public class SDNCServiceRequestTask { long sdncStartTime = System.currentTimeMillis(); SDNCResponseCommon response = connector.send(xml, mappedTunables); - if (response instanceof SDNCErrorCommon) { - LOGGER.recordMetricEvent(sdncStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - "Received success response from SDNC", "SDNC", sdncService + "." + sdncOperation, null); - } else { - LOGGER.recordMetricEvent(sdncStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, - "Received error response from SDNC", "SDNC", sdncService + "." + sdncOperation, null); - } - long bpStartTime = System.currentTimeMillis(); boolean callbackSuccess = bpRestCallback.send(request.getBPNotificationUrl(), response.toJson()); - - if (callbackSuccess) { - LOGGER.recordMetricEvent(bpStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - "Sent notification", "BPMN", request.getBPNotificationUrl(), null); - } else { - LOGGER.recordMetricEvent(bpStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, - "Failed to send notification", "BPMN", request.getBPNotificationUrl(), null); - } } private Element addChild(Element parent, String tag) { @@ -206,8 +193,8 @@ public class SDNCServiceRequestTask { addTextChild(agnosticServiceInformation, "content-type", contentType); addTextChild(agnosticServiceInformation, "anydata", anydata); } catch (Exception e) { - LOGGER.error(MessageEnum.RA_ERROR_CREATE_SDNC_REQUEST, "SDNC", "", - MsoLogger.ErrorCode.BusinessProcesssError, "Exception in genSdncReq", e); + logger.error("{} {} {} {}", MessageEnum.RA_ERROR_CREATE_SDNC_REQUEST.toString(), "SDNC", + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception in genSdncReq", e); return null; } @@ -225,12 +212,12 @@ public class SDNCServiceRequestTask { transformer.transform(new DOMSource(doc), new StreamResult(writer)); xml = writer.toString(); } catch (Exception e) { - LOGGER.error(MessageEnum.RA_ERROR_CONVERT_XML2STR, "", "", - MsoLogger.ErrorCode.DataError, "Exception - domToStr", e); + logger.error("{} {} {}", MessageEnum.RA_ERROR_CONVERT_XML2STR.toString(), MsoLogger.ErrorCode.DataError.getValue(), + "Exception - domToStr", e); return null; } - LOGGER.trace("Formatted SDNC service request XML:\n" + xml); + logger.trace("Formatted SDNC service request XML:\n {}", xml); return xml; } } diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SNIROResponse.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SNIROResponse.java index 48bc2d84bb..75a0b07643 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SNIROResponse.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/SNIROResponse.java @@ -5,6 +5,7 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Modifications Copyright (C) 2018 IBM. + * Modifications Copyright (c) 2019 Samsung * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +36,8 @@ import org.onap.so.adapters.sdnc.impl.Constants; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @@ -47,7 +50,7 @@ import org.springframework.stereotype.Component; @Path("/") @Component public class SNIROResponse { - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA,SNIROResponse.class); + private static final Logger logger = LoggerFactory.getLogger(SNIROResponse.class); @Autowired @@ -61,34 +64,18 @@ public class SNIROResponse { @Consumes("*/*") @Produces({MediaType.TEXT_PLAIN}) public Response serviceNotification(@PathParam("correlator") String correlator, String content) { - LOGGER.info(MessageEnum.RA_RECEIVE_SDNC_NOTIF, content, "SDNC", "SDNCNotify/SNIROResponse"); - - long startTime = System.currentTimeMillis(); + logger.info("{} {} {} {}", MessageEnum.RA_RECEIVE_SDNC_NOTIF.toString(), content, "SDNC", + "SDNCNotify/SNIROResponse"); String bpUrl = env.getProperty(Constants.BPEL_REST_URL_PROP, ""); if (bpUrl == null || ("").equals(bpUrl)) { String error = "Missing configuration for: " + Constants.BPEL_REST_URL_PROP; - LOGGER.error(MessageEnum.RA_SDNC_MISS_CONFIG_PARAM, Constants.BPEL_REST_URL_PROP, "SDNC", "", - MsoLogger.ErrorCode.DataError, "Missing config param"); + logger.error("{} {} {} {} {}", MessageEnum.RA_SDNC_MISS_CONFIG_PARAM.toString(), Constants.BPEL_REST_URL_PROP, + "SDNC", MsoLogger.ErrorCode.DataError.getValue(), "Missing config param"); return Response.status(HttpServletResponse.SC_BAD_REQUEST).entity(error).build(); } - - long bpStartTime = System.currentTimeMillis(); - boolean callbackSuccess = callback.send(bpUrl, "SNIROResponse", correlator, content); - - if (callbackSuccess) { - LOGGER.recordMetricEvent(bpStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - "Sent notification", "BPMN", bpUrl, null); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successful"); - } else { - LOGGER.recordMetricEvent(bpStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, - "Failed to send notification", "BPMN", bpUrl, null); - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, - "Failed to send notification"); - } - return Response.status(204).build(); } -}
\ No newline at end of file +} diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/TypedRequestTunables.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/TypedRequestTunables.java index 6331d6aaae..4ff6dbc9a6 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/TypedRequestTunables.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/sdncrest/TypedRequestTunables.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (c) 2019 Samsung + * ================================================================================ * Licensed 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 @@ -22,7 +24,8 @@ package org.onap.so.adapters.sdnc.sdncrest; import org.apache.commons.lang3.builder.ToStringBuilder; import org.onap.so.adapters.sdnc.impl.Constants; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Typed Request Tunables. Each entry is identified by a TYPE in the property name. @@ -39,7 +42,7 @@ import org.onap.so.logger.MsoLogger; */ public class TypedRequestTunables { - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA, TypedRequestTunables.class); + private static final Logger logger = LoggerFactory.getLogger(TypedRequestTunables.class); private String reqId; private String myUrlSuffix; @@ -82,7 +85,7 @@ public class TypedRequestTunables { */ public void setServiceKey(String service, String operation) { key = Constants.REQUEST_TUNABLES + ".service." + service + "." + operation; - LOGGER.debug("Generated " + getClass().getSimpleName() + " key: " + key); + logger.debug("Generated {} key: {}", getClass().getSimpleName(), key); } /** |