diff options
45 files changed, 603 insertions, 487 deletions
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/KeystoneAuthHolderTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/KeystoneAuthHolderTest.java new file mode 100644 index 0000000000..af24975771 --- /dev/null +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/cloud/authentication/KeystoneAuthHolderTest.java @@ -0,0 +1,59 @@ +/* + * ============LICENSE_START========================================== + * org.onap.music + * =================================================================== + * Copyright (c) 2019 IBM. + * =================================================================== + * 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 + * + * 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 specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================= + * ==================================================================== + */ +package org.onap.so.cloud.authentication; + +import static org.junit.Assert.assertEquals; + +import java.util.Calendar; + +import org.junit.Before; +import org.junit.Test; + +public class KeystoneAuthHolderTest { + + private KeystoneAuthHolder keystoneAuthHolder; + private Calendar calendar = Calendar.getInstance(); + + @Before + public void setUp() { + keystoneAuthHolder = new KeystoneAuthHolder(); + } + + @Test + public void testGetId() { + keystoneAuthHolder.setId("001"); + assertEquals("001", keystoneAuthHolder.getId()); + } + + @Test + public void testGetexpiration() { + keystoneAuthHolder.setexpiration(calendar); + assertEquals(calendar, keystoneAuthHolder.getexpiration()); + } + + @Test + public void testGetServiceUrl() { + keystoneAuthHolder.setHeatUrl("testURL"); + assertEquals("testURL", keystoneAuthHolder.getServiceUrl()); + } + +} diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java index 02164ccec1..920cb11e4c 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/CallbackHandlerService.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,8 @@ import org.camunda.bpm.engine.runtime.MessageCorrelationResult; import org.onap.so.bpmn.core.UrnPropertiesReader; 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.Service; @@ -47,7 +51,7 @@ public class CallbackHandlerService { public static final long FAST_POLL_INT_MS = 100; public static final long SLOW_POLL_INT_MS = 1000; - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, CallbackHandlerService.class); + private static final Logger logger = LoggerFactory.getLogger(CallbackHandlerService.class); @Autowired RuntimeService runtimeService; @@ -75,7 +79,7 @@ public class CallbackHandlerService { long startTime = System.currentTimeMillis(); - LOGGER.debug(logMarker + " " + method + " received message: " + logger.debug(logMarker + " " + method + " received message: " + (message == null ? "" : System.lineSeparator()) + message); try { @@ -101,7 +105,7 @@ public class CallbackHandlerService { logCallbackSuccess(method, startTime); return new CallbackSuccess(); } catch (Exception e) { - LOGGER.debug("Exception :",e); + logger.debug("Exception :",e); String msg = "Caught " + e.getClass().getSimpleName() + " processing " + messageEventName + " with " + correlationVariable + " = '" + correlationValue + "'"; @@ -133,7 +137,7 @@ public class CallbackHandlerService { protected boolean correlate(String messageEventName, String correlationVariable, String correlationValue, Map<String, Object> variables, String logMarker) { try{ - LOGGER.debug(logMarker + " Attempting to find process waiting" + logger.debug(logMarker + " Attempting to find process waiting" + " for " + messageEventName + " with " + correlationVariable + " = '" + correlationValue + "'"); @@ -200,7 +204,7 @@ public class CallbackHandlerService { execInfoList.add(new ExecInfo(execution)); } - LOGGER.debug(logMarker + " Found " + count + " process(es) waiting" + logger.debug(logMarker + " Found " + count + " process(es) waiting" + " for " + messageEventName + " with " + correlationVariable + " = '" + correlationValue + "': " + execInfoList); @@ -211,9 +215,9 @@ public class CallbackHandlerService { + messageEventName + " with " + correlationVariable + " = '" + correlationValue + "'; last exception was:" + queryException; - LOGGER.debug(msg); - LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, msg, queryException); + logger.debug(msg); + logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError.getValue(), msg, queryException); } return false; @@ -234,7 +238,7 @@ public class CallbackHandlerService { // acknowledged the notification associated with request #1. try { - LOGGER.debug(logMarker + " Running " + execInfoList.get(0) + " to receive " + logger.debug(logMarker + " Running " + execInfoList.get(0) + " to receive " + messageEventName + " with " + correlationVariable + " = '" + correlationValue + "'"); @@ -254,9 +258,9 @@ public class CallbackHandlerService { String msg = "Caught " + ole.getClass().getSimpleName() + " after receiving " + messageEventName + " with " + correlationVariable + " = '" + correlationValue + "': " + ole; - LOGGER.debug(msg); - LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN CORRELATION ERROR -", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, msg, ole); + logger.debug(msg); + logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN CORRELATION ERROR -", + MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue(), msg, ole); //Retry for OptimisticLocking Exceptions int retryCount = 0; @@ -269,7 +273,7 @@ public class CallbackHandlerService { } } - LOGGER.debug("Retry correlate for OptimisticLockingException, retryCount:" + retryCount); + logger.debug("Retry correlate for OptimisticLockingException, retryCount:{}", retryCount); for (; retryCount >0 ; retryCount--) { @@ -283,20 +287,20 @@ public class CallbackHandlerService { .processInstanceVariableEquals(correlationVariable, correlationValue) .correlateWithResult(); retryCount = 0; - LOGGER.debug("OptimisticLockingException retry was successful, seting retryCount: " + retryCount); + logger.debug("OptimisticLockingException retry was successful, seting retryCount: {}", retryCount); } catch (OptimisticLockingException olex) { //oleFlag = ex instanceof org.camunda.bpm.engine.OptimisticLockingException; String strMsg = "Received exception, OptimisticLockingException retry failed, retryCount:" + retryCount + " | exception returned: " + olex; - LOGGER.debug(strMsg); - LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, strMsg, olex); + logger.debug(strMsg); + logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError.getValue(), strMsg, olex); } catch (Exception excep) { retryCount = 0; //oleFlag = ex instanceof org.camunda.bpm.engine.OptimisticLockingException; String strMsg = "Received exception, OptimisticLockingException retry failed, retryCount:" + retryCount + " | exception returned: " + excep; - LOGGER.debug(strMsg); - LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, strMsg, excep); + logger.debug(strMsg); + logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError.getValue(), strMsg, excep); } } @@ -308,9 +312,9 @@ public class CallbackHandlerService { + execInfoList.get(0) + " after receiving " + messageEventName + " with " + correlationVariable + " = '" + correlationValue + "': " + e; - LOGGER.debug(msg); - LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, msg, e); + logger.debug(msg); + logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError.getValue(), msg, e); } } catch (Exception e) { // This must be an exception from the flow itself. Log it, but don't @@ -318,9 +322,9 @@ public class CallbackHandlerService { String msg = "Caught " + e.getClass().getSimpleName() + " after receiving " + messageEventName + " with " + correlationVariable + " = '" + correlationValue + "': " + e; - LOGGER.debug(msg); - LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN CORRELATION ERROR -", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, msg, e); + logger.debug(msg); + logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN CORRELATION ERROR -", + MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue(), msg, e); } return true; @@ -332,12 +336,6 @@ public class CallbackHandlerService { * @param startTime the request start time */ protected void logCallbackSuccess(String method, long startTime) { - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, - MsoLogger.ResponseCode.Suc, "Completed " + method); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, - MsoLogger.ResponseCode.Suc, "Completed " + method, - "BPMN", MsoLogger.getServiceName(), null); } /** @@ -361,19 +359,12 @@ public class CallbackHandlerService { */ protected void logCallbackError(String method, long startTime, String msg, Exception e) { if (e == null) { - LOGGER.error(MessageEnum.BPMN_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, msg); + logger.error("{} {} {} {} {}", MessageEnum.BPMN_CALLBACK_EXCEPTION.toString(), "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError.getValue(), msg); } else { - LOGGER.error(MessageEnum.BPMN_CALLBACK_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.UnknownError, msg, e); + logger.error("{} {} {} {} {}", MessageEnum.BPMN_CALLBACK_EXCEPTION.toString(), "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.UnknownError.getValue(), msg, e); } - - LOGGER.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, - MsoLogger.ResponseCode.InternalError, "Completed " + method); - - LOGGER.recordMetricEvent(startTime, MsoLogger.StatusCode.COMPLETE, - MsoLogger.ResponseCode.InternalError, "Completed " + method, - "BPMN", MsoLogger.getServiceName(), null); } /** diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java index 014b06deff..f9f06447a7 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowAsyncResource.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 @@ -39,8 +41,9 @@ import org.onap.logging.ref.slf4j.ONAPLogConstants; import org.onap.so.bpmn.common.workflow.context.WorkflowContext; import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder; import org.onap.so.bpmn.common.workflow.context.WorkflowResponse; -import org.onap.so.logger.MsoLogger; import org.openecomp.mso.bpmn.common.workflow.service.WorkflowProcessorException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -79,7 +82,7 @@ public class WorkflowAsyncResource extends ProcessEngineAwareService { this.processor = processor; } - protected static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,WorkflowAsyncResource.class); + protected static final Logger logger = LoggerFactory.getLogger(WorkflowAsyncResource.class); protected static final long DEFAULT_WAIT_TIME = 60000; //default wait time /** diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java index 02cda8009f..8b35f0e6d6 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowMessageResource.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 @@ -36,6 +38,8 @@ import org.onap.so.bpmn.common.workflow.service.CallbackHandlerService.CallbackE import org.onap.so.bpmn.common.workflow.service.CallbackHandlerService.CallbackResult; 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; @@ -54,7 +58,7 @@ import io.swagger.annotations.ApiOperation; @Api(description = "Provides a generic service to inject messages into a waiting BPMN Proccess") @Component public class WorkflowMessageResource{ - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, WorkflowMessageResource.class); + private static final Logger logger = LoggerFactory.getLogger(WorkflowMessageResource.class); private static final String LOGMARKER = "[WORKFLOW-MESSAGE]"; @Autowired @@ -78,7 +82,7 @@ public class WorkflowMessageResource{ MsoLogger.setServiceName("MSO." + method); MsoLogger.setLogContext(correlator, "N/A"); - LOGGER.debug(LOGMARKER + " Received workflow message" + logger.debug(LOGMARKER + " Received workflow message" + " type='" + messageType + "'" + " correlator='" + correlator + "'" + (contentType == null ? "" : " contentType='" + contentType + "'") @@ -86,17 +90,17 @@ public class WorkflowMessageResource{ if (messageType == null || messageType.isEmpty()) { String msg = "Missing message type"; - LOGGER.debug(LOGMARKER + " " + msg); - LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.DataError, LOGMARKER + ":" + msg); + logger.debug(LOGMARKER + " " + msg); + logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.DataError.getValue(), LOGMARKER + ":" + msg); return Response.status(400).entity(msg).build(); } if (correlator == null || correlator.isEmpty()) { String msg = "Missing correlator"; - LOGGER.debug(LOGMARKER + " " + msg); - LOGGER.error(MessageEnum.BPMN_GENERAL_EXCEPTION, "BPMN", MsoLogger.getServiceName(), - MsoLogger.ErrorCode.DataError, LOGMARKER + ":" + msg); + logger.debug(LOGMARKER + " " + msg); + logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION.toString(), "BPMN", MsoLogger.getServiceName(), + MsoLogger.ErrorCode.DataError.getValue(), LOGMARKER + ":" + msg); return Response.status(400).entity(msg).build(); } @@ -121,4 +125,4 @@ public class WorkflowMessageResource{ return Response.status(204).build(); } } -}
\ No newline at end of file +} diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java index 5afd7e00e8..b1062962a6 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowProcessor.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 @@ -29,15 +31,16 @@ import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.runtime.ProcessInstance; import org.camunda.bpm.engine.variable.impl.VariableMapImpl; import org.onap.so.bpmn.common.workflow.context.WorkflowResponse; -import org.onap.so.logger.MsoLogger; import org.openecomp.mso.bpmn.common.workflow.service.WorkflowProcessorException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; @Service public class WorkflowProcessor extends ProcessEngineAwareService { - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, WorkflowProcessor.class); + private static final Logger logger = LoggerFactory.getLogger(WorkflowProcessor.class); protected static final String logMarker = "[WRKFLOW-RESOURCE]"; @Async @@ -55,21 +58,17 @@ public class WorkflowProcessor extends ProcessEngineAwareService { // Note: this creates a random businessKey if it wasn't specified. String businessKey = getBusinessKey(inputVariables); - msoLogger.debug("***Received MSO startProcessInstanceByKey with processKey: " + processKey - + " and variables: " + inputVariables); + logger.debug("***Received MSO startProcessInstanceByKey with processKey: {} and variables: {}", processKey, + inputVariables); RuntimeService runtimeService = getProcessEngineServices().getRuntimeService(); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processKey, businessKey, inputVariables); processInstanceId = processInstance.getId(); - msoLogger.debug(logMarker + "Process " + processKey + ":" + processInstanceId + " " + logger.debug(logMarker + "Process " + processKey + ":" + processInstanceId + " " + (processInstance.isEnded() ? "ENDED" : "RUNNING")); } catch (Exception e) { - - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError, - logMarker + "Error in starting the process: " + e.getMessage()); - WorkflowResponse workflowResponse = new WorkflowResponse(); workflowResponse.setResponse("Error occurred while executing the process: " + e); workflowResponse.setProcessInstanceID(processInstanceId); diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java index c2a7f41140..92f1b7a816 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/common/workflow/service/WorkflowResource.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 @@ -50,6 +52,8 @@ import org.onap.so.bpmn.common.workflow.context.WorkflowResponse; import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.slf4j.MDC; import org.springframework.stereotype.Component; @@ -61,7 +65,7 @@ import io.swagger.annotations.ApiOperation; @Component public class WorkflowResource extends ProcessEngineAwareService { - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, WorkflowResource.class); + private static final Logger logger = LoggerFactory.getLogger(WorkflowResource.class); private static final String LOGMARKER = "[WRKFLOW-RESOURCE]"; private static final int DEFAULT_WAIT_TIME = 30000; @@ -99,7 +103,7 @@ public class WorkflowResource extends ProcessEngineAwareService { try { //Kickoff the process - ProcessThread thread = new ProcessThread(inputVariables,processKey,msoLogger); + ProcessThread thread = new ProcessThread(inputVariables,processKey); thread.start(); Map<String, Object> responseMap = null; @@ -141,7 +145,7 @@ public class WorkflowResource extends ProcessEngineAwareService { processInstance = thread.getProcessInstance(); if (processInstance == null) { - msoLogger.debug(LOGMARKER + processKey + " process has not been created yet"); + logger.debug("{} process has not been created yet", LOGMARKER + processKey ); continue; } @@ -151,7 +155,7 @@ public class WorkflowResource extends ProcessEngineAwareService { responseMap = getResponseMap(processInstance, processKey, timeProcessEnded); if (responseMap == null) { - msoLogger.debug(LOGMARKER + processKey + " has not produced a response yet"); + logger.debug("{} has not produced a response yet", LOGMARKER + processKey); if (timeProcessEnded.longValue() != 0) { long elapsedSinceEnded = System.currentTimeMillis() - timeProcessEnded.longValue(); @@ -192,14 +196,15 @@ public class WorkflowResource extends ProcessEngineAwareService { workflowResponse.setMessageCode(500); return Response.status(500).entity(workflowResponse).build(); } catch (Exception ex) { - msoLogger.debug(LOGMARKER + "Exception in startProcessInstance by key",ex); + logger.debug(LOGMARKER + "Exception in startProcessInstance by key",ex); workflowResponse.setMessage("Fail" ); workflowResponse.setResponse("Error occurred while executing the process: " + ex.getMessage()); if (processInstance != null) workflowResponse.setProcessInstanceID(processInstance.getId()); - - msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "BPMN", MDC.get(processKey), - MsoLogger.ErrorCode.UnknownError, LOGMARKER + workflowResponse.getMessage() - + " for processKey: " + processKey + " with response: " + workflowResponse.getResponse()); + + logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "BPMN", MDC.get(processKey), + MsoLogger.ErrorCode.UnknownError.getValue(), + LOGMARKER + workflowResponse.getMessage() + " for processKey: " + processKey + " with response: " + + workflowResponse.getResponse()); workflowResponse.setMessageCode(500); recordEvents(processKey, workflowResponse, startTime); @@ -222,21 +227,13 @@ public class WorkflowResource extends ProcessEngineAwareService { try { return Integer.parseInt(timeout)*1000; } catch (NumberFormatException nex) { - msoLogger.debug("Invalid input for mso-service-request-timeout"); + logger.debug("Invalid input for mso-service-request-timeout"); } } return DEFAULT_WAIT_TIME; } private void recordEvents(String processKey, WorkflowResponse response, long startTime) { - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - LOGMARKER + response.getMessage() + " for processKey: " - + processKey + " with response: " + response.getResponse(), "BPMN", MDC.get(processKey), null); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - LOGMARKER + response.getMessage() + " for processKey: " - + processKey + " with response: " + response.getResponse()); } private void setLogContext(String processKey, Map<String, Object> inputVariables) { @@ -266,7 +263,7 @@ public class WorkflowResource extends ProcessEngineAwareService { try { return pes.getRuntimeService().createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult() == null ? true : false ; } catch (Exception e) { - msoLogger.debug("Exception :",e); + logger.debug("Exception :",e); return true; } } @@ -287,7 +284,7 @@ public class WorkflowResource extends ProcessEngineAwareService { try { workflowResponse.setMessageCode(Integer.parseInt(responseCode)); } catch(NumberFormatException nex) { - msoLogger.debug(LOGMARKER + "Failed to parse ResponseCode: " + responseCode); + logger.debug(LOGMARKER + "Failed to parse ResponseCode: " + responseCode); workflowResponse.setMessageCode(-1); } @@ -298,7 +295,7 @@ public class WorkflowResource extends ProcessEngineAwareService { } else if ("Fail".equalsIgnoreCase(String.valueOf(status))) { workflowResponse.setMessage("Fail"); } else { - msoLogger.debug(LOGMARKER + "Unrecognized Status: " + responseCode); + logger.debug(LOGMARKER + "Unrecognized Status: " + responseCode); workflowResponse.setMessage("Fail"); } } @@ -310,15 +307,13 @@ public class WorkflowResource extends ProcessEngineAwareService { private class ProcessThread extends Thread { private final Map<String,Object> inputVariables; private final String processKey; - private final MsoLogger msoLogger; private final String businessKey; private ProcessInstance processInstance = null; private Exception exception = null; - public ProcessThread(Map<String, Object> inputVariables, String processKey, MsoLogger msoLogger) { + public ProcessThread(Map<String, Object> inputVariables, String processKey) { this.inputVariables = inputVariables; this.processKey = processKey; - this.msoLogger = msoLogger; this.businessKey = UUID.randomUUID().toString(); } @@ -352,14 +347,6 @@ public class WorkflowResource extends ProcessEngineAwareService { long startTime = System.currentTimeMillis(); try { - msoLogger.debug(LOGMARKER + "***Received MSO startProcessInstanceByKey with processKey:" - + processKey + " and variables: " + inputVariables); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, LOGMARKER - + "Call to MSO workflow/services in Camunda. Received MSO startProcessInstanceByKey with" - + " processKey:" + processKey - + " businessKey:" + businessKey - + " variables: " + inputVariables); RuntimeService runtimeService = getProcessEngineServices().getRuntimeService(); @@ -370,7 +357,7 @@ public class WorkflowResource extends ProcessEngineAwareService { processKey, inputVariables); } catch (Exception e) { - msoLogger.debug(LOGMARKER + "ProcessThread caught an exception executing " + logger.debug(LOGMARKER + "ProcessThread caught an exception executing " + processKey + ": " + e); setException(e); } @@ -441,7 +428,7 @@ public class WorkflowResource extends ProcessEngineAwareService { responseMapVariable); if (responseMap != null) { - msoLogger.debug(LOGMARKER + "Obtained " + responseMapVariable + logger.debug(LOGMARKER + "Obtained " + responseMapVariable + " from process " + processInstanceId + " history"); return responseMap; } @@ -455,12 +442,12 @@ public class WorkflowResource extends ProcessEngineAwareService { // Check for 'WorkflowResponse' variable Object workflowResponseObject = getVariableFromHistory(historyService, processInstanceId, "WorkflowResponse"); String workflowResponse = workflowResponseObject == null ? null : String.valueOf(workflowResponseObject); - msoLogger.debug(LOGMARKER + "WorkflowResponse: " + workflowResponse); + logger.debug(LOGMARKER + "WorkflowResponse: " + workflowResponse); if (workflowResponse != null) { Object responseCodeObject = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode"); String responseCode = responseCodeObject == null ? null : String.valueOf(responseCodeObject); - msoLogger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode); + logger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode); responseMap = new HashMap<>(); responseMap.put("WorkflowResponse", workflowResponse); responseMap.put("ResponseCode", responseCode); @@ -496,17 +483,17 @@ public class WorkflowResource extends ProcessEngineAwareService { } } - msoLogger.debug(LOGMARKER + "WorkflowException: " + workflowExceptionText); + logger.debug(LOGMARKER + "WorkflowException: " + workflowExceptionText); // BEGIN LEGACY SUPPORT. TODO: REMOVE THIS CODE Object object = getVariableFromHistory(historyService, processInstanceId, processKey + "Response"); String response = object == null ? null : String.valueOf(object); - msoLogger.debug(LOGMARKER + processKey + "Response: " + response); + logger.debug(LOGMARKER + processKey + "Response: " + response); if (response != null) { object = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode"); String responseCode = object == null ? null : String.valueOf(object); - msoLogger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode); + logger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode); responseMap = new HashMap<>(); responseMap.put("Response", response); responseMap.put("ResponseCode", responseCode); @@ -516,12 +503,12 @@ public class WorkflowResource extends ProcessEngineAwareService { object = getVariableFromHistory(historyService, processInstanceId, prefix + "ErrorResponse"); String errorResponse = object == null ? null : String.valueOf(object); - msoLogger.debug(LOGMARKER + prefix + "ErrorResponse: " + errorResponse); + logger.debug(LOGMARKER + prefix + "ErrorResponse: " + errorResponse); if (errorResponse != null) { object = getVariableFromHistory(historyService, processInstanceId, prefix + "ResponseCode"); String responseCode = object == null ? null : String.valueOf(object); - msoLogger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode); + logger.debug(LOGMARKER + prefix + "ResponseCode: " + responseCode); responseMap = new HashMap<>(); responseMap.put("Response", errorResponse); responseMap.put("ResponseCode", responseCode); @@ -545,7 +532,7 @@ public class WorkflowResource extends ProcessEngineAwareService { return runtimeService.getVariable(executionId, variableName); } catch (ProcessEngineException e) { // Most likely cause is that the execution no longer exists. - msoLogger.debug("Error retrieving execution " + executionId + logger.debug("Error retrieving execution " + executionId + " variable " + variableName + ": " + e); return null; } @@ -562,8 +549,8 @@ public class WorkflowResource extends ProcessEngineAwareService { .processInstanceId(processInstanceId).variableName(variableName).singleResult(); return v == null ? null : v.getValue(); } catch (Exception e) { - msoLogger.debug("Error retrieving process " + processInstanceId - + " variable " + variableName + " from history: " + e); + logger.debug("Error retrieving process {} variable {} from history: ", processInstanceId, + variableName, e); return null; } } @@ -589,42 +576,27 @@ public class WorkflowResource extends ProcessEngineAwareService { variablesMap.put(variableInstance.getName(), variableInstance.getValue().toString()); } - msoLogger.debug(LOGMARKER + "***Received MSO getProcessVariables with processKey:" + processKey + " and variables: " + variablesMap.toString()); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, LOGMARKER - + "Call to MSO workflow/services in Camunda. Received MSO getProcessVariables with processKey:" - + processKey + " and variables: " - + variablesMap.toString()); - + logger.debug(LOGMARKER + "***Received MSO getProcessVariables with processKey:" + processKey + " and variables: " + + variablesMap.toString()); response.setVariables(variablesMap); response.setMessage("Success"); response.setResponse("Successfully retrieved the variables"); response.setProcessInstanceID(processInstanceId); - msoLogger.debug(LOGMARKER + response.getMessage() + " for processKey: " + processKey + " with response: " + response.getResponse()); + logger.debug(LOGMARKER + response.getMessage() + " for processKey: " + processKey + " with response: " + response + .getResponse()); } catch (Exception ex) { response.setMessage("Fail"); response.setResponse("Failed to retrieve the variables," + ex.getMessage()); response.setProcessInstanceID(processInstanceId); - - msoLogger.error (MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "BPMN", MDC.get(processKey), MsoLogger.ErrorCode.UnknownError, LOGMARKER - + response.getMessage() - + " for processKey: " - + processKey - + " with response: " - + response.getResponse()); - msoLogger.debug("Exception :",ex); + + logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), "BPMN", MDC.get(processKey), + MsoLogger.ErrorCode.UnknownError.getValue(), + LOGMARKER + response.getMessage() + " for processKey: " + processKey + " with response: " + response + .getResponse()); + logger.debug("Exception :",ex); } - - msoLogger.recordMetricEvent ( startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - LOGMARKER + response.getMessage() + " for processKey: " - + processKey + " with response: " + response.getResponse(), "BPMN", MDC.get(processKey), null); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - LOGMARKER + response.getMessage() + " for processKey: " - + processKey + " with response: " + response.getResponse()); - return response; } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java index 5435194f39..62aad7e345 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/core/plugins/LoggingAndURNMappingPlugin.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 @@ -56,7 +58,8 @@ import org.onap.so.bpmn.core.BPMNLogger; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; -import org.slf4j.MDC; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.AbstractEnvironment; import org.springframework.core.env.Environment; @@ -279,7 +282,7 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { * Logs details about the current activity. */ public class LoggingExecutionListener implements ExecutionListener { - private final MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,LoggingExecutionListener.class); + private final Logger logger = LoggerFactory.getLogger(LoggingExecutionListener.class); private String event; @@ -317,7 +320,7 @@ public class LoggingAndURNMappingPlugin extends AbstractProcessEnginePlugin { MsoLogger.setLogContext(requestId, svcid); } } catch(Exception e) { - logger.error(e); + logger.error("Exception occurred", e); } } } diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/CXFConfiguration.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/CXFConfiguration.java index 62be1330b1..cb20ded8de 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/CXFConfiguration.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/CXFConfiguration.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 @@ -36,10 +38,11 @@ import org.onap.so.bpmn.common.adapter.vnf.VnfAdapterNotify; import org.onap.so.bpmn.common.workflow.service.WorkflowAsyncResource; import org.onap.so.bpmn.common.workflow.service.WorkflowMessageResource; import org.onap.so.bpmn.common.workflow.service.WorkflowResource; -import org.onap.so.logger.MsoLogger; import org.onap.so.logging.cxf.interceptor.SOAPLoggingInInterceptor; import org.onap.so.logging.cxf.interceptor.SOAPLoggingOutInterceptor; import org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.web.servlet.ServletRegistrationBean; import org.springframework.context.annotation.Bean; @@ -52,7 +55,7 @@ import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider; @Configuration public class CXFConfiguration { - private static final MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,CXFConfiguration.class); + private static final Logger logger = LoggerFactory.getLogger(CXFConfiguration.class); @Autowired private Bus bus; diff --git a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java index 7956ecc363..af9ab2899e 100644 --- a/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.java +++ b/bpmn/mso-infrastructure-bpmn/src/main/java/org/onap/so/bpmn/infrastructure/MSOInfrastructureApplication.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 @@ -28,8 +30,9 @@ import org.camunda.bpm.application.PreUndeploy; import org.camunda.bpm.application.ProcessApplicationInfo; import org.camunda.bpm.engine.ProcessEngine; import org.onap.so.bpmn.common.DefaultToShortClassNameBeanNameGenerator; -import org.onap.so.logger.MsoLogger; import org.onap.so.logging.jaxrs.filter.MDCTaskDecorator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -52,8 +55,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; @Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class) }) public class MSOInfrastructureApplication { - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, - MSOInfrastructureApplication.class); + private static final Logger logger = LoggerFactory.getLogger(MSOInfrastructureApplication.class); @Value("${mso.async.core-pool-size}") private int corePoolSize; @@ -81,20 +83,11 @@ public class MSOInfrastructureApplication { @PostDeploy public void postDeploy(ProcessEngine processEngineInstance) { - long startTime = System.currentTimeMillis(); - - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - "Post deployment complete..."); } @PreUndeploy public void cleanup(ProcessEngine processEngine, ProcessApplicationInfo processApplicationInfo, List<ProcessEngine> processEngines) { - long startTime = System.currentTimeMillis(); - - msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, - "Pre Undeploy complete..."); - } @Bean @@ -109,4 +102,4 @@ public class MSOInfrastructureApplication { executor.initialize(); return executor; } -}
\ No newline at end of file +} diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleIT.java index fd38ff024d..f6284f3535 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleIT.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleIT.java @@ -3,7 +3,9 @@ * ONAP - SO * ================================================================================ * 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,14 +33,12 @@ import java.util.HashMap; import java.util.Map; import java.util.UUID; -import org.camunda.bpm.engine.RuntimeService; -import org.camunda.bpm.engine.test.Deployment; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.onap.so.BaseIntegrationTest; import org.onap.so.bpmn.core.WorkflowException; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Unit test for CreateAAIVfModule.bpmn. @@ -46,7 +46,7 @@ import org.onap.so.logger.MsoLogger; public class CreateAAIVfModuleIT extends BaseIntegrationTest { - MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,CreateAAIVfModuleIT.class); + Logger logger = LoggerFactory.getLogger(CreateAAIVfModuleIT.class); @Test public void TestCreateGenericVnfSuccess_200() { @@ -264,4 +264,4 @@ public class CreateAAIVfModuleIT extends BaseIntegrationTest { .withStatus(200))); } -}
\ No newline at end of file +} diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleVolumeGroupIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleVolumeGroupIT.java index 6af705fd54..f72ca79dc6 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleVolumeGroupIT.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/CreateAAIVfModuleVolumeGroupIT.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,7 +36,8 @@ import org.junit.Assert; import org.junit.Test; import org.onap.so.BaseIntegrationTest; import org.onap.so.bpmn.mock.FileUtil; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Unit tests for CreateAAIVfModuleVolumeGroup.bpmn. @@ -42,7 +45,7 @@ import org.onap.so.logger.MsoLogger; public class CreateAAIVfModuleVolumeGroupIT extends BaseIntegrationTest { - MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,CreateAAIVfModuleVolumeGroupIT.class); + Logger logger = LoggerFactory.getLogger(CreateAAIVfModuleVolumeGroupIT.class); /** * Test the happy path through the flow. @@ -66,8 +69,8 @@ public class CreateAAIVfModuleVolumeGroupIT extends BaseIntegrationTest { Assert.assertTrue(isProcessEnded(businessKey)); String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse"); Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode"); - logger.debug("Subflow response code: " + responseCode); - logger.debug("Subflow response: " + response); + logger.debug("Subflow response code: {}", responseCode); + logger.debug("Subflow response: {}", response); Assert.assertEquals(200, responseCode.intValue()); logEnd(); @@ -93,8 +96,8 @@ public class CreateAAIVfModuleVolumeGroupIT extends BaseIntegrationTest { Assert.assertTrue(isProcessEnded(businessKey)); String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponse"); Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponseCode"); - logger.debug("Subflow response code: " + responseCode); - logger.debug("Subflow response: " + response); + logger.debug("Subflow response code: {}", responseCode); + logger.debug("Subflow response: {}", response); Assert.assertEquals(404, responseCode.intValue()); logEnd(); @@ -122,8 +125,8 @@ public class CreateAAIVfModuleVolumeGroupIT extends BaseIntegrationTest { Assert.assertTrue(isProcessEnded(businessKey)); String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse"); Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode"); - logger.debug("Subflow response code: " + responseCode); - logger.debug("Subflow response: " + response); + logger.debug("Subflow response code: {}", responseCode); + logger.debug("Subflow response: {}", response); Assert.assertEquals(404, responseCode.intValue()); logEnd(); diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DeleteAAIVfModuleIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DeleteAAIVfModuleIT.java index 27b39aec64..f98e4477aa 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DeleteAAIVfModuleIT.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/DeleteAAIVfModuleIT.java @@ -33,11 +33,11 @@ import java.util.UUID; import org.camunda.bpm.engine.RuntimeService; import org.camunda.bpm.engine.test.Deployment; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.onap.so.BaseIntegrationTest; import org.onap.so.bpmn.core.WorkflowException; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Unit test for DeleteAAIVfModule.bpmn. @@ -46,7 +46,7 @@ import org.onap.so.logger.MsoLogger; public class DeleteAAIVfModuleIT extends BaseIntegrationTest { private static final String EOL = "\n"; - MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,DeleteAAIVfModuleIT.class); + Logger logger = LoggerFactory.getLogger(DeleteAAIVfModuleIT.class); @Test public void TestDeleteGenericVnfSuccess_200() { diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/FalloutHandlerIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/FalloutHandlerIT.java index a6d26540dc..f477926f99 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/FalloutHandlerIT.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/FalloutHandlerIT.java @@ -3,7 +3,9 @@ * ONAP - SO * ================================================================================ * 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,7 +35,8 @@ import java.util.UUID; import org.junit.Assert; import org.junit.Test; import org.onap.so.BaseIntegrationTest; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Unit test for FalloutHandler.bpmn. @@ -41,7 +44,7 @@ import org.onap.so.logger.MsoLogger; public class FalloutHandlerIT extends BaseIntegrationTest { - MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,FalloutHandlerIT.class); + Logger logger = LoggerFactory.getLogger(FalloutHandlerIT.class); private void setupMocks() { @@ -147,7 +150,7 @@ public class FalloutHandlerIT extends BaseIntegrationTest { public void msoFalloutHandlerWithNotificationurlNoRequestId() throws Exception{ String method = getClass().getSimpleName() + "." + new Object() { }.getClass().getEnclosingMethod().getName(); - logger.debug("STARTED TEST: " + method); + logger.debug("STARTED TEST: {}", method); //Setup Mocks setupMocks(); //Execute Flow @@ -186,7 +189,7 @@ public class FalloutHandlerIT extends BaseIntegrationTest { public void msoFalloutHandlerWithNoNotificationurlNoRequestId() throws Exception{ String method = getClass().getSimpleName() + "." + new Object() { }.getClass().getEnclosingMethod().getName(); - logger.debug("STARTED TEST: " + method); + logger.debug("STARTED TEST: {}", method); //Setup Mocks setupMocks(); //Execute Flow diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ManualHandlingIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ManualHandlingIT.java index 744ef9bea5..67ae7de928 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ManualHandlingIT.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/ManualHandlingIT.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,14 @@ import org.camunda.bpm.engine.task.TaskQuery; import org.junit.Assert; import org.junit.Test; import org.onap.so.BaseIntegrationTest; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Unit test for RainyDayHandler.bpmn. */ public class ManualHandlingIT extends BaseIntegrationTest { - MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,ManualHandlingIT.class); + Logger logger = LoggerFactory.getLogger(ManualHandlingIT.class); @Test public void TestManualHandlingSuccess() { @@ -76,8 +79,8 @@ public class ManualHandlingIT extends BaseIntegrationTest { List<Task> tasks = q.orderByTaskCreateTime().asc().list(); for (Task task : tasks) { - logger.debug("TASK ID: " + task.getId()); - logger.debug("TASK NAME: " + task.getName()); + logger.debug("TASK ID: {}", task.getId()); + logger.debug("TASK NAME: {}", task.getName()); try { logger.debug("Completing the task"); @@ -85,7 +88,7 @@ public class ManualHandlingIT extends BaseIntegrationTest { completeVariables.put("responseValue", "skip"); taskService.complete(task.getId(), completeVariables); } catch(Exception e) { - logger.debug("GOT EXCEPTION: " + e.getMessage()); + logger.debug("GOT EXCEPTION: {}", e.getMessage()); } } @@ -93,4 +96,4 @@ public class ManualHandlingIT extends BaseIntegrationTest { Assert.assertTrue(isProcessEnded(businessKey)); } -}
\ No newline at end of file +} diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingTestIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingTestIT.java index 398efb972f..b370e6c48f 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingTestIT.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/OofHomingTestIT.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,7 +36,8 @@ import org.onap.so.bpmn.core.domain.ServiceDecomposition; import org.onap.so.bpmn.core.domain.ServiceInstance; import org.onap.so.bpmn.core.domain.VnfResource; import org.onap.so.bpmn.mock.FileUtil; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.ArrayList; @@ -56,7 +59,7 @@ import static org.onap.so.bpmn.mock.StubResponseOof.mockOof_500; @Ignore public class OofHomingTestIT extends BaseIntegrationTest { - MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,CreateAAIVfModuleIT.class); + Logger logger = LoggerFactory.getLogger(CreateAAIVfModuleIT.class); ServiceDecomposition serviceDecomposition = new ServiceDecomposition(); String subscriber = ""; @@ -261,7 +264,7 @@ public class OofHomingTestIT extends BaseIntegrationTest { vnfModel.setModelType("testModelTypeVNF"); vnf.setModelInfo(vnfModel); vnfList.add(vnf); - logger.debug("SERVICE DECOMP: " + serviceDecomposition.getServiceResourcesJsonString()); + logger.debug("SERVICE DECOMP: {}", serviceDecomposition.getServiceResourcesJsonString()); serviceDecomposition.setModelInfo(sModel); serviceDecomposition.setAllottedResources(arList); serviceDecomposition.setVnfResources(vnfList); @@ -416,9 +419,8 @@ public class OofHomingTestIT extends BaseIntegrationTest { ServiceDecomposition sd = (ServiceDecomposition) getVariableFromHistory(busKey, "serviceDecomposition"); - logger.debug("In testHoming_success_vnfResourceList, ServiceDecomposition = " + sd); + logger.debug("In testHoming_success_vnfResourceList, ServiceDecomposition = {}", sd); List<VnfResource> vnfResourceList = sd.getVnfResources(); -//logger.debug(" vnfResourceList = " + vnfResourceList); vnfResourceList.get(0).setResourceId("test-resource-id-000"); // Invoke Homing @@ -454,29 +456,27 @@ public class OofHomingTestIT extends BaseIntegrationTest { "WorkflowException"); ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition"); - logger.debug("serviceDecompositionExp is: " + serviceDecompositionExp); + logger.debug("serviceDecompositionExp is: {}", serviceDecompositionExp); Resource resourceVnf = serviceDecompositionExp.getServiceResource("test-resource-id-000"); - logger.debug("resourceVnf is: " + resourceVnf); + logger.debug("resourceVnf is: {}", resourceVnf); HomingSolution resourceVnfHoming = resourceVnf.getHomingSolution(); String resourceVnfHomingString = resourceVnfHoming.toString(); - logger.debug("resourceVnfHomingString is: " + resourceVnfHomingString); + logger.debug("resourceVnfHomingString is: {}", resourceVnfHomingString); resourceVnfHomingString = resourceVnfHomingString.replaceAll("\\s+", " "); - logger.debug("Now resourceVnfHomingString is: " + resourceVnfHomingString); + logger.debug("Now resourceVnfHomingString is: {}", resourceVnfHomingString); assertNull(workflowException); //Verify request String oofRequest = (String) getVariableFromHistory(businessKey, "oofRequest"); - logger.debug("oofRequest is: " + oofRequest); + logger.debug("oofRequest is: {}", oofRequest); assertEquals(FileUtil.readResourceFile("__files/BuildingBlocks/oofRequest_infravnf"). replaceAll("\n", "").replaceAll("\r", ""). replaceAll("\t", ""), oofRequest.replaceAll("\n", ""). replaceAll("\r", "").replaceAll("\t", "")); - //logger.debug("resourceVnfHoming.getVnf().getResourceId() is: " + resourceVnfHoming.getVnf().getResourceId()); - assertEquals(homingSolutionService("service", "service-instance-01234", "MDTNJ01", "test-resource-id-000","CloudOwner", "mtmnj1a", @@ -539,7 +539,6 @@ public class OofHomingTestIT extends BaseIntegrationTest { } @Test - public void testHoming_error_inputVariable() throws Exception { String businessKey = UUID.randomUUID().toString(); diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/PrepareUpdateAAIVfModuleIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/PrepareUpdateAAIVfModuleIT.java index b8ae341361..8b8abab6b2 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/PrepareUpdateAAIVfModuleIT.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/PrepareUpdateAAIVfModuleIT.java @@ -3,7 +3,9 @@ * ONAP - SO * ================================================================================ * 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,12 +35,12 @@ import java.util.UUID; import org.camunda.bpm.engine.test.Deployment; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.onap.so.BaseIntegrationTest; import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.bpmn.mock.FileUtil; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Unit tests for PrepareUpdateAAIVfModule.bpmn. @@ -46,7 +48,7 @@ import org.onap.so.logger.MsoLogger; public class PrepareUpdateAAIVfModuleIT extends BaseIntegrationTest { - MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,PrepareUpdateAAIVfModuleIT.class); + Logger logger = LoggerFactory.getLogger(PrepareUpdateAAIVfModuleIT.class); /** * Test the happy path through the flow. @@ -73,11 +75,11 @@ public class PrepareUpdateAAIVfModuleIT extends BaseIntegrationTest { Assert.assertTrue(isProcessEnded(businessKey)); String response = (String) getVariableFromHistory(businessKey, "PUAAIVfMod_updateVfModuleResponse"); Integer responseCode = (Integer) getVariableFromHistory(businessKey, "PUAAIVfMod_updateVfModuleResponseCode"); - logger.debug("Subflow response code: " + responseCode); - logger.debug("Subflow response: " + response); + logger.debug("Subflow response code: {}", responseCode); + logger.debug("Subflow response: {}", response); Assert.assertEquals(200, responseCode.intValue()); String heatStackId = (String) getVariableFromHistory(businessKey, "PUAAIVfMod_heatStackId"); - logger.debug("Ouput heat-stack-id:" + heatStackId); + logger.debug("Ouput heat-stack-id:{}", heatStackId); Assert.assertEquals("slowburn", heatStackId); logEnd(); @@ -106,11 +108,11 @@ public class PrepareUpdateAAIVfModuleIT extends BaseIntegrationTest { String response = (String) getVariableFromHistory(businessKey, "PUAAIVfMod_getVnfResponse"); Integer responseCode = (Integer) getVariableFromHistory(businessKey, "PUAAIVfMod_getVnfResponseCode"); WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - logger.debug("Subflow response code: " + responseCode); - logger.debug("Subflow response: " + response); + logger.debug("Subflow response code: {}", responseCode); + logger.debug("Subflow response: {}", response); Assert.assertEquals(404, responseCode.intValue()); Assert.assertNotNull(workflowException); - logger.debug("Subflow WorkflowException error message: " + workflowException.getErrorMessage()); + logger.debug("Subflow WorkflowException error message: {}", workflowException.getErrorMessage()); logEnd(); } @@ -137,7 +139,7 @@ public class PrepareUpdateAAIVfModuleIT extends BaseIntegrationTest { WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); Assert.assertNotNull(workflowException); - logger.debug("Subflow WorkflowException error message: " + workflowException.getErrorMessage()); + logger.debug("Subflow WorkflowException error message: {}", workflowException.getErrorMessage()); Assert.assertTrue(workflowException.getErrorMessage().startsWith("VF Module validation error: Orchestration")); logEnd(); @@ -165,7 +167,7 @@ public class PrepareUpdateAAIVfModuleIT extends BaseIntegrationTest { WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); Assert.assertNotNull(workflowException); - logger.debug("Subflow WorkflowException error message: " + workflowException.getErrorMessage()); + logger.debug("Subflow WorkflowException error message: {}", workflowException.getErrorMessage()); Assert.assertTrue(workflowException.getErrorMessage().startsWith("VF Module validation error: VF Module")); logEnd(); @@ -196,11 +198,11 @@ public class PrepareUpdateAAIVfModuleIT extends BaseIntegrationTest { String response = (String) getVariableFromHistory(businessKey, "PUAAIVfMod_updateVfModuleResponse"); Integer responseCode = (Integer) getVariableFromHistory(businessKey, "PUAAIVfMod_updateVfModuleResponseCode"); WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - logger.debug("Subflow response code: " + responseCode); - logger.debug("Subflow response: " + response); + logger.debug("Subflow response code: {}", responseCode); + logger.debug("Subflow response: {}", response); Assert.assertEquals(404, responseCode.intValue()); Assert.assertNotNull(workflowException); - logger.debug("Subflow WorkflowException error message: " + workflowException.getErrorMessage()); + logger.debug("Subflow WorkflowException error message: {}", workflowException.getErrorMessage()); logEnd(); } diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SDNCAdapterRestV2IT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SDNCAdapterRestV2IT.java index baf41d120b..12e12dc7d6 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SDNCAdapterRestV2IT.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SDNCAdapterRestV2IT.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 @@ -35,7 +37,8 @@ import org.junit.Ignore; import org.junit.Test; import org.onap.so.BaseIntegrationTest; import org.onap.so.bpmn.mock.FileUtil; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Unit tests for SDNCAdapterRestV2.bpmn. @@ -48,7 +51,7 @@ public class SDNCAdapterRestV2IT extends BaseIntegrationTest { private final CallbackSet callbacks = new CallbackSet(); - MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,SDNCAdapterRestV2IT.class); + Logger logger = LoggerFactory.getLogger(SDNCAdapterRestV2IT.class); /** diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SniroHomingV1IT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SniroHomingV1IT.java index f3f950746c..2205d01cca 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SniroHomingV1IT.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/SniroHomingV1IT.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 @@ -38,7 +40,8 @@ import org.onap.so.BaseIntegrationTest; import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.bpmn.core.domain.*; import org.onap.so.bpmn.mock.FileUtil; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** @@ -47,7 +50,7 @@ import org.onap.so.logger.MsoLogger; @Ignore public class SniroHomingV1IT extends BaseIntegrationTest { - MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,SniroHomingV1IT.class); + Logger logger = LoggerFactory.getLogger(SniroHomingV1IT.class); ServiceDecomposition serviceDecomposition = new ServiceDecomposition(); @@ -121,7 +124,7 @@ public class SniroHomingV1IT extends BaseIntegrationTest { vnfModel.setModelType("testModelTypeVNF"); vnf.setModelInfo(vnfModel); vnfList.add(vnf); - logger.debug("SERVICE DECOMP: " + serviceDecomposition.getServiceResourcesJsonString()); + logger.debug("SERVICE DECOMP: {}", serviceDecomposition.getServiceResourcesJsonString()); serviceDecomposition.setModelInfo(sModel); serviceDecomposition.setAllottedResources(arList); serviceDecomposition.setVnfResources(vnfList); diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIGenericVnfIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIGenericVnfIT.java index e1a265b274..48790708f0 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIGenericVnfIT.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIGenericVnfIT.java @@ -3,7 +3,9 @@ * ONAP - SO * ================================================================================ * 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 @@ -39,7 +41,8 @@ import org.junit.Test; import org.onap.so.BaseIntegrationTest; import org.onap.so.bpmn.core.WorkflowException; import org.onap.so.bpmn.mock.FileUtil; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Unit tests for UpdateAAIGenericVnf bpmn. @@ -47,7 +50,7 @@ import org.onap.so.logger.MsoLogger; public class UpdateAAIGenericVnfIT extends BaseIntegrationTest { - MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,CreateAAIVfModuleIT.class); + Logger logger = LoggerFactory.getLogger(CreateAAIVfModuleIT.class); /** @@ -73,8 +76,8 @@ public class UpdateAAIGenericVnfIT extends BaseIntegrationTest { Assert.assertTrue(isProcessEnded(businessKey)); String response = (String) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponse"); Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponseCode"); - logger.debug("Subflow response code: " + responseCode); - logger.debug("Subflow response: " + response); + logger.debug("Subflow response code: {}", responseCode); + logger.debug("Subflow response: {}", response); Assert.assertEquals(200, responseCode.intValue()); logEnd(); @@ -103,7 +106,7 @@ public class UpdateAAIGenericVnfIT extends BaseIntegrationTest { Assert.assertTrue(isProcessEnded(businessKey)); WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - logger.debug("Workflow Exception: " + workflowException); + logger.debug("Workflow Exception: {}", workflowException); Assert.assertNotNull(workflowException); logEnd(); @@ -132,8 +135,8 @@ public class UpdateAAIGenericVnfIT extends BaseIntegrationTest { Assert.assertTrue(isProcessEnded(businessKey)); String response = (String) getVariableFromHistory(businessKey, "UAAIGenVnf_getGenericVnfResponse"); Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIGenVnf_getGenericVnfResponseCode"); - logger.debug("Subflow response code: " + responseCode); - logger.debug("Subflow response: " + response); + logger.debug("Subflow response code: {}", responseCode); + logger.debug("Subflow response: {}", response); Assert.assertEquals(404, responseCode.intValue()); logEnd(); @@ -164,8 +167,8 @@ public class UpdateAAIGenericVnfIT extends BaseIntegrationTest { Assert.assertTrue(isProcessEnded(businessKey)); String response = (String) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponse"); Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponseCode"); - logger.debug("Subflow response code: " + responseCode); - logger.debug("Subflow response: " + response); + logger.debug("Subflow response code: {}", responseCode); + logger.debug("Subflow response: {}", response); Assert.assertEquals(404, responseCode.intValue()); logEnd(); diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIVfModuleIT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIVfModuleIT.java index 3ff2657193..3dd2ac957c 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIVfModuleIT.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/UpdateAAIVfModuleIT.java @@ -3,7 +3,9 @@ * ONAP - SO * ================================================================================ * 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 @@ -39,6 +41,8 @@ import org.junit.Test; import org.onap.so.BaseIntegrationTest; import org.onap.so.bpmn.mock.FileUtil; import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Unit tests for UpdateAAIVfModuleTest.bpmn. @@ -46,7 +50,7 @@ import org.onap.so.logger.MsoLogger; public class UpdateAAIVfModuleIT extends BaseIntegrationTest { - MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,CreateAAIVfModuleIT.class); + Logger logger = LoggerFactory.getLogger(CreateAAIVfModuleIT.class); /** @@ -72,8 +76,8 @@ public class UpdateAAIVfModuleIT extends BaseIntegrationTest { Assert.assertTrue(isProcessEnded(businessKey)); String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponse"); Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponseCode"); - logger.debug("Subflow response code: " + responseCode); - logger.debug("Subflow response: " + response); + logger.debug("Subflow response code: {}", responseCode); + logger.debug("Subflow response: {}", response); Assert.assertEquals(200, responseCode.intValue()); logEnd(); @@ -101,8 +105,8 @@ public class UpdateAAIVfModuleIT extends BaseIntegrationTest { Assert.assertTrue(isProcessEnded(businessKey)); String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_getVfModuleResponse"); Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_getVfModuleResponseCode"); - logger.debug("Subflow response code: " + responseCode); - logger.debug("Subflow response: " + response); + logger.debug("Subflow response code: {}", responseCode); + logger.debug("Subflow response: {}", response); Assert.assertEquals(404, responseCode.intValue()); logEnd(); @@ -132,8 +136,8 @@ public class UpdateAAIVfModuleIT extends BaseIntegrationTest { Assert.assertTrue(isProcessEnded(businessKey)); String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponse"); Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponseCode"); - logger.debug("Subflow response code: " + responseCode); - logger.debug("Subflow response: " + response); + logger.debug("Subflow response code: {}", responseCode); + logger.debug("Subflow response: {}", response); Assert.assertEquals(404, responseCode.intValue()); logEnd(); diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/VnfAdapterRestV1IT.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/VnfAdapterRestV1IT.java index fc15e92bca..ad08f8b2bb 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/VnfAdapterRestV1IT.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/VnfAdapterRestV1IT.java @@ -1,9 +1,11 @@ /*- - * ============LICENSE_START======================================================= + * ============LICENSE_START======================================================= * ONAP - SO - * ================================================================================ + * ================================================================================ * 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 @@ -38,7 +40,8 @@ import org.junit.Ignore; import org.junit.Test; import org.onap.so.BaseIntegrationTest; import org.onap.so.bpmn.core.WorkflowException; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Unit tests for VnfAdapterRestV1. @@ -46,7 +49,7 @@ import org.onap.so.logger.MsoLogger; public class VnfAdapterRestV1IT extends BaseIntegrationTest { - MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,VnfAdapterRestV1IT.class); + Logger logger = LoggerFactory.getLogger(VnfAdapterRestV1IT.class); private static final String EOL = "\n"; @@ -256,7 +259,7 @@ public class VnfAdapterRestV1IT extends BaseIntegrationTest { waitForProcessEnd(businessKey, 10000); String response = (String) getVariableFromHistory(businessKey, "vnfAdapterRestV1Response"); - logger.debug("Response:\n" + response); + logger.debug("Response:\n{}", response); assertTrue(response!=null && response.contains("<createVfModuleResponse>")); assertTrue((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator")); @@ -285,7 +288,7 @@ public class VnfAdapterRestV1IT extends BaseIntegrationTest { waitForProcessEnd(businessKey, 10000); String response = (String) getVariableFromHistory(businessKey, "vnfAdapterRestV1Response"); - logger.debug("Response:\n" + response); + logger.debug("Response:\n{}", response); assertTrue(response.contains("<updateVfModuleResponse>")); assertTrue((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator")); @@ -314,7 +317,7 @@ public class VnfAdapterRestV1IT extends BaseIntegrationTest { waitForProcessEnd(businessKey, 10000); String response = (String) getVariableFromHistory(businessKey, "vnfAdapterRestV1Response"); - logger.debug("Response:\n" + response); + logger.debug("Response:\n{}", response); assertTrue(response.contains("<deleteVfModuleResponse>")); assertTrue((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator")); @@ -343,7 +346,7 @@ public class VnfAdapterRestV1IT extends BaseIntegrationTest { waitForProcessEnd(businessKey, 10000); String response = (String) getVariableFromHistory(businessKey, "vnfAdapterRestV1Response"); - logger.debug("Response:\n" + response); + logger.debug("Response:\n{}", response); assertTrue(response.contains("<rollbackVfModuleResponse>")); assertTrue((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator")); @@ -376,7 +379,7 @@ public class VnfAdapterRestV1IT extends BaseIntegrationTest { logger.debug(wfe.toString()); String response = (String) getVariableFromHistory(businessKey, "WorkflowResponse"); - logger.debug("Response:\n" + response); + logger.debug("Response:\n{}", response); assertTrue(response.contains("<vfModuleException>")); assertFalse((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator")); diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java index d24e953196..117d3b213a 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/common/WorkflowTest.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 @@ -81,7 +83,8 @@ import org.onap.so.bpmn.common.workflow.service.WorkflowMessageResource; import org.onap.so.bpmn.common.workflow.service.WorkflowResource; import org.onap.so.bpmn.core.domain.Resource; import org.onap.so.bpmn.core.domain.ServiceDecomposition; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -106,7 +109,7 @@ import org.xml.sax.SAXException; public abstract class WorkflowTest { - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, WorkflowTest.class); + private static final Logger logger = LoggerFactory.getLogger(WorkflowTest.class); //TODO this is not used anymore, can maybe be removed @Rule @@ -165,14 +168,14 @@ public abstract class WorkflowTest { * Logs a test start method. */ protected void logStart() { - msoLogger.debug("STARTED TEST"); + logger.debug("STARTED TEST"); } /** * Logs a test end method. */ protected void logEnd() { - msoLogger.debug("ENDED TEST"); + logger.debug("ENDED TEST"); } /** @@ -184,14 +187,14 @@ public abstract class WorkflowTest { protected void invokeSubProcess(String processKey, String businessKey, Map<String, Object> injectedVariables) { RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean(); List<String> arguments = runtimeMxBean.getInputArguments(); - msoLogger.debug("JVM args = " + arguments); + logger.debug("JVM args = {}", arguments); msoRequestId = (String) injectedVariables.get("mso-request-id"); String requestId = (String) injectedVariables.get("msoRequestId"); if (msoRequestId == null && requestId == null) { String msg = "mso-request-id variable was not provided"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -205,14 +208,14 @@ public abstract class WorkflowTest { protected String invokeSubProcess(String processKey, Map<String, Object> injectedVariables) { RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean(); List<String> arguments = runtimeMxBean.getInputArguments(); - msoLogger.debug("JVM args = " + arguments); + logger.debug("JVM args = {}", arguments); msoRequestId = (String) injectedVariables.get("mso-request-id"); String requestId = (String) injectedVariables.get("msoRequestId"); if (msoRequestId == null && requestId == null) { String msg = "mso-request-id variable was not provided"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -256,13 +259,13 @@ public abstract class WorkflowTest { RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean(); List<String> arguments = runtimeMxBean.getInputArguments(); - msoLogger.debug("JVM args = " + arguments); + logger.debug("JVM args = {}", arguments); Map<String, Object> variables = createVariables(schemaVersion, businessKey, request, injectedVariables, false); VariableMapImpl variableMapImpl = createVariableMapImpl(variables); - msoLogger.debug("Sending " + request + " to " + processKey + " process"); + logger.debug("Sending {} to {} process", request, processKey); TestAsyncResponse asyncResponse = new TestAsyncResponse(); @@ -290,13 +293,13 @@ public abstract class WorkflowTest { RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean(); List<String> arguments = runtimeMxBean.getInputArguments(); - msoLogger.debug("JVM args = " + arguments); + logger.debug("JVM args = {}", arguments); Map<String, Object> variables = createVariables(schemaVersion, businessKey, request, injectedVariables, serviceInstantiationModel); VariableMapImpl variableMapImpl = createVariableMapImpl(variables); - msoLogger.debug("Sending " + request + " to " + processKey + " process"); + logger.debug("Sending {} to {} process", request, processKey); return workflowResource.startProcessInstanceByKey( processKey, variableMapImpl); @@ -337,7 +340,7 @@ public abstract class WorkflowTest { for (String var : notAllowed) { if (var.equals(key)) { String msg = "Cannot specify " + var + " in injected variables"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } } @@ -367,11 +370,11 @@ public abstract class WorkflowTest { catch(Exception e) { } if (msoRequestId == null || msoRequestId.trim().equals("")) { - msoLogger.debug("No requestId element in injectedVariables"); + logger.debug("No requestId element in injectedVariables"); variables.put("mso-request-id", UUID.randomUUID().toString()); } if (msoServiceInstanceId == null || msoServiceInstanceId.trim().equals("")) { - msoLogger.debug("No seviceInstanceId element in injectedVariables"); + logger.debug("No seviceInstanceId element in injectedVariables"); variables.put("mso-service-instance-id", UUID.randomUUID().toString()); } @@ -387,7 +390,7 @@ public abstract class WorkflowTest { } if (msoRequestId == null || msoRequestId.trim().equals("")) { String msg = "No request-id element in " + request; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } } @@ -446,8 +449,7 @@ public abstract class WorkflowTest { */ protected WorkflowResponse receiveResponse(String businessKey, TestAsyncResponse asyncResponse, long timeout) { - msoLogger.debug("Waiting " + timeout + "ms for process with business key " + businessKey - + " to send a response"); + logger.debug("Waiting {}ms for process with business key {} to send a response", timeout, businessKey); long now = System.currentTimeMillis() + timeout; long endTime = now + timeout; @@ -456,7 +458,7 @@ public abstract class WorkflowTest { Response response = asyncResponse.getResponse(); if (response != null) { - msoLogger.debug("Received a response from process with business key " + businessKey); + logger.debug("Received a response from process with business key {}", businessKey); Object entity = response.getEntity(); @@ -464,7 +466,7 @@ public abstract class WorkflowTest { String msg = "Response entity is " + (entity == null ? "null" : entity.getClass().getName()) + ", expected WorkflowResponse"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); return null; // unreachable } @@ -477,7 +479,7 @@ public abstract class WorkflowTest { } catch (InterruptedException e) { String msg = "Interrupted waiting for a response from process with business key " + businessKey; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); return null; // unreachable } @@ -487,7 +489,7 @@ public abstract class WorkflowTest { String msg = "No response received from process with business key " + businessKey + " within " + timeout + "ms"; - msoLogger.debug(msg); + logger.debug(msg); fail("Process with business key " + businessKey + " did not end within 10000ms"); return null; // unreachable } @@ -525,7 +527,7 @@ public abstract class WorkflowTest { if (callbackData == null) { String msg = "No callback defined for '" + action + "' SDNC request"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -536,7 +538,7 @@ public abstract class WorkflowTest { contentType = JSON; } else { String msg = "Invalid SDNC program modifier: '" + modifier + "'"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -625,7 +627,7 @@ public abstract class WorkflowTest { if (callbackData == null) { String msg = "No callback defined for '" + action + "' SDNC request"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -637,7 +639,7 @@ public abstract class WorkflowTest { if (callbackData == null) { String msg = "No callback defined for '" + action + "' SDNC request"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -650,7 +652,7 @@ public abstract class WorkflowTest { respMsg = "SERVER ERROR"; } else { String msg = "Invalid SDNC program modifier: '" + modifier + "'"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -699,7 +701,7 @@ public abstract class WorkflowTest { if (callbackData == null) { String msg = "No callback defined for '" + action + "' VNF REST request"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -710,7 +712,7 @@ public abstract class WorkflowTest { contentType = "text/plain"; } else { String msg = "Invalid VNF REST program modifier: '" + modifier + "'"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -763,18 +765,18 @@ public abstract class WorkflowTest { if (callbackData == null) { String msg = "No callback defined for '" + action + "' VNF request"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } content = callbackData.getContent(); } else if ("ERR".equals(modifier)) { String msg = "Currently unsupported VNF program modifier: '" + modifier + "'"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } else { String msg = "Invalid VNF program modifier: '" + modifier + "'"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -790,7 +792,7 @@ public abstract class WorkflowTest { if (!injected) { String msg = "Failed to inject VNF '" + action + "' callback"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -810,8 +812,7 @@ public abstract class WorkflowTest { * @param timeout the timeout in milliseconds */ protected void waitForRunningProcessCount(String processKey, int count, long timeout) { - msoLogger.debug("Waiting " + timeout + "ms for there to be " + count + " " - + processKey + " instances"); + logger.debug("Waiting {}ms for there to be {} {} instances", timeout, count, processKey); long now = System.currentTimeMillis() + timeout; long endTime = now + timeout; @@ -824,8 +825,7 @@ public abstract class WorkflowTest { .list().size(); if (actual != last) { - msoLogger.debug("There are now " + actual + " " - + processKey + " instances"); + logger.debug("There are now {} {} instances", actual, processKey); last = actual; } @@ -838,7 +838,7 @@ public abstract class WorkflowTest { } catch (InterruptedException e) { String msg = "Interrupted waiting for there to be " + count + " " + processKey + " instances"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -847,7 +847,7 @@ public abstract class WorkflowTest { String msg = "Timed out waiting for there to be " + count + " " + processKey + " instances"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -862,8 +862,7 @@ public abstract class WorkflowTest { protected Object getProcessVariable(String processKey, String variable, long timeout) { - msoLogger.debug("Waiting " + timeout + "ms for " - + processKey + "." + variable + " to be set"); + logger.debug("Waiting " + timeout + "ms for " + processKey + "." + variable + " to be set"); long now = System.currentTimeMillis() + timeout; long endTime = now + timeout; @@ -874,10 +873,10 @@ public abstract class WorkflowTest { while (value == null) { if (now > endTime) { if (processInstance == null) { - msoLogger.debug("Timed out waiting for " + logger.debug("Timed out waiting for " + processKey + " to start"); } else { - msoLogger.debug("Timed out waiting for " + logger.debug("Timed out waiting for " + processKey + "[" + processInstance.getId() + "]." + variable + " to be set"); } @@ -896,7 +895,8 @@ public abstract class WorkflowTest { processInstance = processInstanceQuery.singleResult(); }else{ //TODO There shouldnt be more than one in the list but seems to be happening, need to figure out why happening and best way to get correct one from list - msoLogger.debug("Process Instance Query returned " + processInstanceQuery.count() + " instance. Getting the last instance in the list"); + logger.debug("Process Instance Query returned {} instance. Getting the last instance in the list", + processInstanceQuery.count()); List<ProcessInstance> processList = processInstanceQuery.list(); processInstance = processList.get((processList.size() - 1)); } @@ -910,15 +910,14 @@ public abstract class WorkflowTest { try { Thread.sleep(200); } catch (InterruptedException e) { - msoLogger.debug("Interrupted waiting for " - + processKey + "." + variable + " to be set"); + logger.debug("Interrupted waiting for {}.{} to be set", processKey, variable); return null; } now = System.currentTimeMillis(); } - msoLogger.debug(processKey + "[" + logger.debug(processKey + "[" + processInstance.getId() + "]." + variable + "=" + value); @@ -952,10 +951,10 @@ public abstract class WorkflowTest { // Deprecated usage. All test code should switch to the (( ... )) syntax. content = content.replace("{{REQUEST-ID}}", sdncRequestId); - msoLogger.debug("Injecting SDNC adapter callback"); + logger.debug("Injecting SDNC adapter callback"); Response response = workflowMessageResource.deliver(contentType, "SDNCAResponse", sdncRequestId, content); - msoLogger.debug("Workflow response to SDNC adapter callback: " + response); + logger.debug("Workflow response to SDNC adapter callback: " + response); return true; } @@ -987,7 +986,7 @@ public abstract class WorkflowTest { // TODO this needs to be fixed. It is causing double tags and content // Need to parse content before setting below since content includes not just RequestData or modify callback files to only contain RequestData contents. - msoLogger.debug("Injecting SDNC adapter callback"); + logger.debug("Injecting SDNC adapter callback"); CallbackHeader callbackHeader = new CallbackHeader(); callbackHeader.setRequestId(sdncRequestId); callbackHeader.setResponseCode(String.valueOf(respCode)); @@ -996,7 +995,7 @@ public abstract class WorkflowTest { sdncAdapterCallbackRequest.setCallbackHeader(callbackHeader); sdncAdapterCallbackRequest.setRequestData(content); SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest); - msoLogger.debug("Workflow response to SDNC adapter callback: " + sdncAdapterResponse); + logger.debug("Workflow response to SDNC adapter callback: " + sdncAdapterResponse); return true; } @@ -1023,10 +1022,10 @@ public abstract class WorkflowTest { // Deprecated usage. All test code should switch to the (( ... )) syntax. content = content.replace("{{MESSAGE-ID}}", messageId); - msoLogger.debug("Injecting VNF adapter callback"); + logger.debug("Injecting VNF adapter callback"); Response response = workflowMessageResource.deliver(contentType, "VNFAResponse", messageId, content); - msoLogger.debug("Workflow response to VNF adapter callback: " + response); + logger.debug("Workflow response to VNF adapter callback: {}", response); return true; } @@ -1059,7 +1058,7 @@ public abstract class WorkflowTest { content = content.replace("{{REQUEST-ID}}", msoRequestId); } - msoLogger.debug("Injecting VNF adapter callback"); + logger.debug("Injecting VNF adapter callback"); // Is it possible to unmarshal this with JAXB? I couldn't. @@ -1132,8 +1131,8 @@ public abstract class WorkflowTest { createVnfNotification.setRollback(rollback); } catch (Exception e) { - msoLogger.debug("Failed to unmarshal VNF callback content:"); - msoLogger.debug(content); + logger.debug("Failed to unmarshal VNF callback content:"); + logger.debug(content); return false; } @@ -1175,7 +1174,7 @@ public abstract class WorkflowTest { // Deprecated usage. All test code should switch to the (( ... )) syntax. content = content.replace("{{MESSAGE-ID}}", messageId); - msoLogger.debug("Injecting VNF adapter delete callback"); + logger.debug("Injecting VNF adapter delete callback"); // Is it possible to unmarshal this with JAXB? I couldn't. @@ -1195,8 +1194,8 @@ public abstract class WorkflowTest { } } catch (Exception e) { - msoLogger.debug("Failed to unmarshal VNF Delete callback content:"); - msoLogger.debug(content); + logger.debug("Failed to unmarshal VNF Delete callback content:"); + logger.debug(content); return false; } @@ -1239,7 +1238,7 @@ public abstract class WorkflowTest { // Deprecated usage. All test code should switch to the (( ... )) syntax. content = content.replace("{{REQUEST-ID}}", msoRequestId); - msoLogger.debug("Injecting VNF adapter callback"); + logger.debug("Injecting VNF adapter callback"); // Is it possible to unmarshal this with JAXB? I couldn't. @@ -1308,8 +1307,8 @@ public abstract class WorkflowTest { updateVnfNotification.setRollback(rollback); } catch (Exception e) { - msoLogger.debug("Failed to unmarshal VNF callback content:"); - msoLogger.debug(content); + logger.debug("Failed to unmarshal VNF callback content:"); + logger.debug(content); return false; } @@ -1362,7 +1361,7 @@ public abstract class WorkflowTest { if (callbackData == null) { String msg = "No '" + action + "' workflow message callback is defined"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -1370,7 +1369,7 @@ public abstract class WorkflowTest { if (messageType == null || messageType.trim().equals("")) { String msg = "No workflow message type is defined in the '" + action + "' callback"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -1378,7 +1377,7 @@ public abstract class WorkflowTest { contentType = callbackData.getContentType(); } else { String msg = "Invalid workflow message program modifier: '" + modifier + "'"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -1416,10 +1415,10 @@ public abstract class WorkflowTest { content = content.replace("((CORRELATOR))", correlator); } - msoLogger.debug("Injecting " + messageType + " message"); + logger.debug("Injecting " + messageType + " message"); Response response = workflowMessageResource.deliver(contentType, messageType, correlator, content); - msoLogger.debug("Workflow response to " + messageType + " message: " + response); + logger.debug("Workflow response to {} message: {}", messageType, response); return true; } @@ -1458,7 +1457,7 @@ public abstract class WorkflowTest { if (callbackData == null) { String msg = "No '" + action + "' workflow message callback is defined"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -1466,7 +1465,7 @@ public abstract class WorkflowTest { if (messageType == null || messageType.trim().equals("")) { String msg = "No workflow message type is defined in the '" + action + "' callback"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -1474,7 +1473,7 @@ public abstract class WorkflowTest { contentType = callbackData.getContentType(); } else { String msg = "Invalid workflow message program modifier: '" + modifier + "'"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -1588,10 +1587,10 @@ public abstract class WorkflowTest { } } } - msoLogger.debug("Injecting " + messageType + " message"); + logger.debug("Injecting " + messageType + " message"); Response response = workflowMessageResource.deliver(contentType, messageType, correlator, content); - msoLogger.debug("Workflow response to " + messageType + " message: " + response); + logger.debug("Workflow response to {} message: {}", messageType, response); return true; } @@ -1602,15 +1601,14 @@ public abstract class WorkflowTest { * @param timeout the amount of time to wait, in milliseconds */ protected void waitForProcessEnd(String businessKey, long timeout) { - msoLogger.debug("Waiting " + timeout + "ms for process with business key " + - businessKey + " to end"); + logger.debug("Waiting {}ms for process with business key {} to end", timeout, businessKey); long now = System.currentTimeMillis() + timeout; long endTime = now + timeout; while (now <= endTime) { if (isProcessEnded(businessKey)) { - msoLogger.debug("Process with business key " + businessKey + " has ended"); + logger.debug("Process with business key {} has ended", businessKey); return; } @@ -1619,7 +1617,7 @@ public abstract class WorkflowTest { } catch (InterruptedException e) { String msg = "Interrupted waiting for process with business key " + businessKey + " to end"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -1628,7 +1626,7 @@ public abstract class WorkflowTest { String msg = "Process with business key " + businessKey + " did not end within " + timeout + "ms"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -1643,15 +1641,14 @@ public abstract class WorkflowTest { * @author cb645j */ protected void waitForProcessEnd(String businessKey, String processName, long timeout) { - msoLogger.debug("Waiting " + timeout + "ms for process with business key " + - businessKey + " to end"); + logger.debug("Waiting {}ms for process with business key {} to end", timeout, businessKey); long now = System.currentTimeMillis() + timeout; long endTime = now + timeout; while (now <= endTime) { if (isProcessEnded(businessKey, processName)) { - msoLogger.debug("Process with business key " + businessKey + " has ended"); + logger.debug("Process with business key {} has ended", businessKey); return; } @@ -1660,7 +1657,7 @@ public abstract class WorkflowTest { } catch (InterruptedException e) { String msg = "Interrupted waiting for process with business key " + businessKey + " to end"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -1669,7 +1666,7 @@ public abstract class WorkflowTest { String msg = "Process with business key " + businessKey + " did not end within " + timeout + "ms"; - msoLogger.debug(msg); + logger.debug(msg); fail(msg); } @@ -1747,8 +1744,8 @@ public abstract class WorkflowTest { .variableName(variableName).singleResult(); return v == null ? null : v.getValue(); } catch (Exception e) { - msoLogger.debug("Error retrieving variable " + variableName + - " from historical process with business key " + businessKey + ": " + e); + logger.debug("Error retrieving variable {} from historical process with business key {}: ", variableName, businessKey, + e); return null; } } @@ -1777,10 +1774,12 @@ public abstract class WorkflowTest { return variable == null ? null : variable.getValue(); }catch(ProcessEngineException e){ - msoLogger.debug("Multiple proccess instances exist with process name " + processName + " and business key " + businessKey + ". Must pass instance index as a parameter."); + logger.debug("Multiple proccess instances exist with process name {} and business key {}. Must pass instance " + + "index as a parameter.", processName, businessKey); return null; }catch(Exception e){ - msoLogger.debug("Error retrieving variable " + variableName + " from historical process for process " + processName + " with business key " + businessKey + ": " + e); + logger.debug("Error retrieving variable {} from historical process for process {} with business key {}: ", + variableName, processName, businessKey, e); return null; } } @@ -1814,7 +1813,8 @@ public abstract class WorkflowTest { return variable == null ? null : variable.getValue(); }catch(Exception e) { - msoLogger.debug("Error retrieving variable " + variableName + " from historical process for process " + processName + " with business key " + businessKey + ": " + e); + logger.debug("Error retrieving variable {} from historical process for process {} with business key {}: ", + variableName, processName, businessKey, e); return null; } } @@ -1851,8 +1851,7 @@ public abstract class WorkflowTest { .variableName(variableName).singleResult(); return v == null ? null : v.getValue(); } catch (Exception e) { - msoLogger.debug("Error retrieving variable " + variableName + - " from sub flow: " + subflowName + ", Exception is: " + e); + logger.debug("Error retrieving variable {} from sub flow: {}, Exception is: ", variableName, subflowName, e); return null; } } @@ -1886,8 +1885,8 @@ public abstract class WorkflowTest { .variableName(variableName).singleResult(); return v == null ? null : v.getValue(); } catch (Exception e) { - msoLogger.debug("Error retrieving variable " + variableName + - " from " + subflowInstanceIndex + " instance index of sub flow: " + subflowName + ", Exception is: " + e); + logger.debug("Error retrieving variable {} from {} instance index of sub flow: {}, Exception is: ", variableName, + subflowInstanceIndex, subflowName, e); return null; } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandler.java index d801a94c9b..74d5f7a9e6 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandler/recipe/CamundaClientErrorHandler.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.apihandler.recipe; import java.io.IOException; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.HttpStatus; import org.springframework.http.client.ClientHttpResponse; import org.springframework.web.client.ResponseErrorHandler; @@ -31,15 +34,12 @@ import org.springframework.web.client.ResponseErrorHandler; public class CamundaClientErrorHandler implements ResponseErrorHandler{ - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, CamundaClientErrorHandler.class); + private static Logger logger = LoggerFactory.getLogger(CamundaClientErrorHandler.class); @Override public void handleError(ClientHttpResponse response) throws IOException { - - msoLogger.debug(response.getBody().toString()); - //msoLogger.recordMetricEvent(startTime, MsoLogger.StatusCode.ERROR, - // MsoLogger.ResponseCode.CommunicationError, e.getMessage(), "BPMN", fullURL, null); - } + logger.debug(response.getBody().toString()); + } @Override public boolean hasError(ClientHttpResponse response) throws IOException { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandler.java index 862e9a668f..b002aa9f54 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandler.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 @@ -23,6 +25,9 @@ package org.onap.so.apihandlerinfra; import java.net.URI; import java.util.Collections; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; @@ -38,13 +43,10 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; -import java.util.UUID; import org.apache.http.HttpStatus; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; import org.springframework.core.env.Environment; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; @@ -59,16 +61,16 @@ import io.swagger.annotations.ApiOperation; @Path("/globalhealthcheck") @Api(value="/globalhealthcheck",description="APIH Infra Global Health Check") public class GlobalHealthcheckHandler { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, GlobalHealthcheckHandler.class); - private static final String CONTEXTPATH_PROPERTY = "management.context-path"; - private static final String PROPERTY_DOMAIN = "mso.health.endpoints"; - private static final String CATALOGDB_PROPERTY = PROPERTY_DOMAIN+".catalogdb"; - private static final String REQUESTDB_PROPERTY = PROPERTY_DOMAIN+".requestdb"; - private static final String SDNC_PROPERTY = PROPERTY_DOMAIN+".sdnc"; - private static final String OPENSTACK_PROPERTY = PROPERTY_DOMAIN+".openstack"; - private static final String BPMN_PROPERTY = PROPERTY_DOMAIN+".bpmn"; - private static final String ASDC_PROPERTY = PROPERTY_DOMAIN+".asdc"; - private static final String REQUESTDBATTSVC_PROPERTY = PROPERTY_DOMAIN+".requestdbattsvc"; + private static Logger logger = LoggerFactory.getLogger(GlobalHealthcheckHandler.class); + private static final String CONTEXTPATH_PROPERTY = "management.context-path"; + private static final String PROPERTY_DOMAIN = "mso.health.endpoints"; + private static final String CATALOGDB_PROPERTY = PROPERTY_DOMAIN + ".catalogdb"; + private static final String REQUESTDB_PROPERTY = PROPERTY_DOMAIN + ".requestdb"; + private static final String SDNC_PROPERTY = PROPERTY_DOMAIN + ".sdnc"; + private static final String OPENSTACK_PROPERTY = PROPERTY_DOMAIN + ".openstack"; + private static final String BPMN_PROPERTY = PROPERTY_DOMAIN + ".bpmn"; + private static final String ASDC_PROPERTY = PROPERTY_DOMAIN + ".asdc"; + private static final String REQUESTDBATTSVC_PROPERTY = PROPERTY_DOMAIN + ".requestdbattsvc"; private static final String DEFAULT_PROPERTY_VALUE = ""; // e.g. /manage @@ -117,7 +119,7 @@ public class GlobalHealthcheckHandler { // Generated RequestId String requestId = requestContext.getProperty("requestId").toString(); MsoLogger.setLogContext(requestId, null); - msoLogger.info(MessageEnum.APIH_GENERATED_REQUEST_ID, requestId, "", ""); + logger.info("{} {}", MessageEnum.APIH_GENERATED_REQUEST_ID.toString(), requestId); // set APIH status, this is the main entry point rsp.setApih(HealthcheckStatus.UP.toString()); @@ -137,14 +139,14 @@ public class GlobalHealthcheckHandler { rsp.setRequestdbAdapterAttsvc(querySubsystemHealth(MsoSubsystems.REQUESTDBATT)); // set Message rsp.setMessage(String.format("HttpStatus: %s", HttpStatus.SC_OK)); - msoLogger.info(rsp.toString(), "", ""); + logger.info(rsp.toString()); HEALTH_CHECK_RESPONSE = Response.status (HttpStatus.SC_OK) .entity (rsp) .build (); }catch (Exception ex){ - msoLogger.error(ex); + logger.error("Exception occurred", ex); rsp.setMessage(ex.getMessage()); HEALTH_CHECK_RESPONSE = Response.status (HttpStatus.SC_INTERNAL_SERVER_ERROR) .entity (rsp) @@ -170,7 +172,7 @@ public class GlobalHealthcheckHandler { // build final endpoint url UriBuilder builder = UriBuilder.fromPath(ept).path(actuatorContextPath).path(health); URI uri = builder.build(); - msoLogger.info("Calculated URL: "+uri.toString(), "", ""); + logger.info("Calculated URL: {}", uri.toString()); ResponseEntity<SubsystemHealthcheckResponse> result = restTemplate.exchange(uri, HttpMethod.GET, buildHttpEntityForRequest(), SubsystemHealthcheckResponse.class); @@ -178,13 +180,13 @@ public class GlobalHealthcheckHandler { return processResponseFromSubsystem(result,subsystem); }catch(Exception ex){ - msoLogger.error("Exception occured in GlobalHealthcheckHandler.querySubsystemHealth() "+ ex); + logger.error("Exception occured in GlobalHealthcheckHandler.querySubsystemHealth() ", ex); return HealthcheckStatus.DOWN.toString(); } } protected String processResponseFromSubsystem(ResponseEntity<SubsystemHealthcheckResponse> result, MsoSubsystems subsystem){ if(result == null || result.getStatusCodeValue() != HttpStatus.SC_OK){ - msoLogger.error(String.format("Globalhealthcheck: checking subsystem: %s failed ! result object is: %s", + logger.error(String.format("Globalhealthcheck: checking subsystem: %s failed ! result object is: %s", subsystem, result == null? "NULL": result)); return HealthcheckStatus.DOWN.toString(); @@ -196,7 +198,7 @@ public class GlobalHealthcheckHandler { if("UP".equalsIgnoreCase(status)){ return HealthcheckStatus.UP.toString(); }else{ - msoLogger.error(subsystem + ", query health endpoint did not return UP status!"); + logger.error("{}, query health endpoint did not return UP status!", subsystem); return HealthcheckStatus.DOWN.toString(); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java index 81a197c85c..d686e80352 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ManualTasks.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 @@ -55,6 +57,8 @@ import org.onap.so.exceptions.ValidationException; 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; @@ -68,7 +72,7 @@ import io.swagger.annotations.ApiOperation; @Path("/tasks") @Component public class ManualTasks { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, ManualTasks.class); + private static Logger logger = LoggerFactory.getLogger(ManualTasks.class); @org.springframework.beans.factory.annotation.Value("${mso.camunda.rest.task.uri}") @@ -94,9 +98,9 @@ public class ManualTasks { String requestId = requestContext.getProperty("requestId").toString(); MsoLogger.setLogContext(requestId, null); - msoLogger.info(MessageEnum.APIH_GENERATED_REQUEST_ID, requestId, "", ""); + logger.info("{} {}", MessageEnum.APIH_GENERATED_REQUEST_ID.toString(), requestId); long startTime = System.currentTimeMillis (); - msoLogger.debug ("requestId is: " + requestId); + logger.debug ("requestId is: {}", requestId); TasksRequest taskRequest = null; String apiVersion = version.substring(1); @@ -203,9 +207,7 @@ public class ManualTasks { // BPEL accepted the request, the request is in progress if (bpelStatus == HttpStatus.SC_NO_CONTENT || bpelStatus == HttpStatus.SC_ACCEPTED) { - msoLogger.debug ("Received good response from Camunda"); - - msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "BPMN completed the request"); + logger.debug ("Received good response from Camunda"); TaskRequestReference trr = new TaskRequestReference(); trr.setTaskId(taskId); String completeResp = null; @@ -224,8 +226,8 @@ public class ManualTasks { throw validateException; } - msoLogger.debug("Response to the caller: " + completeResp); - msoLogger.debug ("End of the transaction, the final response is: " + (String) completeResp); + logger.debug("Response to the caller: {}", completeResp); + logger.debug ("End of the transaction, the final response is: {}", completeResp); return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestId, completeResp, apiVersion); } else { ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, MsoLogger.ErrorCode.BusinessProcesssError).build(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java index 7f602323e1..411a5e584a 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoRequest.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 @@ -66,7 +68,6 @@ import org.onap.so.apihandlerinfra.vnfbeans.VnfInputs; import org.onap.so.apihandlerinfra.vnfbeans.VnfRequest; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.client.RequestsDbClient; -import org.onap.so.db.request.data.repository.InfraActiveRequestsRepository; import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.LogConstants; import org.onap.so.logger.MessageEnum; @@ -84,6 +85,8 @@ import org.onap.so.serviceinstancebeans.RequestParameters; import org.onap.so.serviceinstancebeans.Service; import org.onap.so.serviceinstancebeans.ServiceException; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -107,7 +110,7 @@ public class MsoRequest { @Autowired private ResponseBuilder builder; - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH,MsoRequest.class); + private static Logger logger = LoggerFactory.getLogger(MsoRequest.class); public Response buildServiceErrorResponse (int httpResponseCode, MsoException exceptionType, String errorText, String messageId, List<String> variables, String version) { @@ -150,8 +153,9 @@ public class MsoRequest { mapper.setSerializationInclusion(Include.NON_DEFAULT); requestErrorStr = mapper.writeValueAsString(re); }catch(Exception e){ - msoLogger.error (MessageEnum.APIH_VALIDATION_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception in buildServiceErrorResponse writing exceptionType to string ", e); - } + logger.error("{} {} {}", MessageEnum.APIH_VALIDATION_ERROR.toString(), MsoLogger.ErrorCode.DataError.getValue(), + "Exception in buildServiceErrorResponse writing exceptionType to string ", e); + } return builder.buildResponse(httpResponseCode, null, requestErrorStr, version); } @@ -162,9 +166,9 @@ public class MsoRequest { public void parse (ServiceInstancesRequest sir, HashMap<String,String> instanceIdMap, Actions action, String version, String originalRequestJSON, int reqVersion, Boolean aLaCarteFlag) throws ValidationException, IOException { - msoLogger.debug ("Validating the Service Instance request"); + logger.debug ("Validating the Service Instance request"); List<ValidationRule> rules = new ArrayList<>(); - msoLogger.debug ("Incoming version is: " + version + " coverting to int: " + reqVersion); + logger.debug ("Incoming version is: {} coverting to int: {}", version, reqVersion); RequestParameters requestParameters = sir.getRequestDetails().getRequestParameters(); ValidationInformation info = new ValidationInformation(sir, instanceIdMap, action, reqVersion, aLaCarteFlag, requestParameters); @@ -249,9 +253,7 @@ public class MsoRequest { } }catch(Exception e){ - //msoLogger.error (MessageEnum.APIH_VALIDATION_ERROR, e); throw new ValidationException ("QueryParam ServiceInfo", e); - } } @@ -382,9 +384,10 @@ public class MsoRequest { aq.setRequestStatus (status.toString ()); aq.setLastModifiedBy (Constants.MODIFIED_BY_APIHANDLER); } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception when creation record request", e); - - if (!status.equals (Status.FAILED)) { + logger.error("{} {} {}", MessageEnum.APIH_DB_INSERT_EXC.toString(), MsoLogger.ErrorCode.DataError.getValue(), + "Exception when creation record request", e); + + if (!status.equals (Status.FAILED)) { throw e; } } @@ -421,9 +424,10 @@ public class MsoRequest { aq.setLastModifiedBy (Constants.MODIFIED_BY_APIHANDLER); } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception when creation record request", e); - - if (!status.equals (Status.FAILED)) { + logger.error("{} {} {}", MessageEnum.APIH_DB_INSERT_EXC.toString(), MsoLogger.ErrorCode.DataError.getValue(), + "Exception when creation record request", e); + + if (!status.equals (Status.FAILED)) { throw e; } } @@ -447,9 +451,10 @@ public class MsoRequest { request.setRequestUrl(MDC.get(LogConstants.HTTP_URL)); requestsDbClient.save(request); } catch (Exception e) { - msoLogger.error(MessageEnum.APIH_DB_UPDATE_EXC, e.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "Exception when updating record in DB"); - msoLogger.debug ("Exception: ", e); - } + logger.error("{} {} {} {}", MessageEnum.APIH_DB_UPDATE_EXC.toString(), e.getMessage(), + MsoLogger.ErrorCode.DataError.getValue(), "Exception when updating record in DB"); + logger.debug("Exception: ", e); + } } @@ -531,8 +536,9 @@ public class MsoRequest { return null; } catch (Exception e) { - msoLogger.error (MessageEnum.APIH_DOM2STR_ERROR, "", "", MsoLogger.ErrorCode.DataError, "Exception in domToStr", e); - } + logger.error("{} {} {}", MessageEnum.APIH_DOM2STR_ERROR.toString(), MsoLogger.ErrorCode.DataError.getValue(), + "Exception in domToStr", e); + } return null; } @@ -556,12 +562,12 @@ public class MsoRequest { ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(Include.NON_NULL); //mapper.configure(Feature.WRAP_ROOT_VALUE, true); - msoLogger.debug ("building sir from object " + sir); + logger.debug ("building sir from object {}", sir); String requestJSON = mapper.writeValueAsString(sir); // Perform mapping from VID-style modelInfo fields to ASDC-style modelInfo fields - msoLogger.debug("REQUEST JSON before mapping: " + requestJSON); + logger.debug("REQUEST JSON before mapping: {}", requestJSON); // modelUuid = modelVersionId requestJSON = requestJSON.replaceAll("\"modelVersionId\":","\"modelUuid\":"); // modelCustomizationUuid = modelCustomizationId @@ -570,7 +576,7 @@ public class MsoRequest { requestJSON = requestJSON.replaceAll("\"modelCustomizationName\":","\"modelInstanceName\":"); // modelInvariantUuid = modelInvariantId requestJSON = requestJSON.replaceAll("\"modelInvariantId\":","\"modelInvariantUuid\":"); - msoLogger.debug("REQUEST JSON after mapping: " + requestJSON); + logger.debug("REQUEST JSON after mapping: {}", requestJSON); return requestJSON; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/NodeHealthcheckHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/NodeHealthcheckHandler.java index 35f196b263..cb458a7420 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/NodeHealthcheckHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/NodeHealthcheckHandler.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,7 +35,8 @@ import javax.ws.rs.core.Response; import org.apache.http.HttpStatus; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; -import org.onap.so.utils.UUIDChecker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import io.swagger.annotations.Api; @@ -44,7 +47,7 @@ import io.swagger.annotations.ApiOperation; @Component public class NodeHealthcheckHandler { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, NodeHealthcheckHandler.class); + private static Logger logger = LoggerFactory.getLogger(NodeHealthcheckHandler.class); private static final String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>"; @@ -61,8 +64,7 @@ public class NodeHealthcheckHandler { MsoLogger.setServiceName ("NodeHealthcheck"); // Generated RequestId String requestId = requestContext.getProperty("requestId").toString(); - MsoLogger.setLogContext(requestId, null); - msoLogger.info(MessageEnum.APIH_GENERATED_REQUEST_ID, requestId, "", ""); + logger.info("{} {}", MessageEnum.APIH_GENERATED_REQUEST_ID.toString(), requestId); return HEALTH_CHECK_RESPONSE; } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java index b65b82a87d..d74a4de451 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/OrchestrationRequests.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 @@ -63,6 +65,8 @@ import org.onap.so.serviceinstancebeans.RequestDetails; import org.onap.so.serviceinstancebeans.RequestList; import org.onap.so.serviceinstancebeans.RequestStatus; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -76,7 +80,7 @@ import io.swagger.annotations.ApiOperation; @Component public class OrchestrationRequests { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, OrchestrationRequests.class); + private static Logger logger = LoggerFactory.getLogger(OrchestrationRequests.class); @Autowired @@ -106,7 +110,7 @@ public class OrchestrationRequests { requestProcessingData = requestsDbClient.getRequestProcessingDataBySoRequestId(requestId); } catch (Exception e) { - msoLogger.error(e); + logger.error("Exception occurred", e); ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, MsoLogger.ErrorCode.AvailabilityError).build(); @@ -164,7 +168,7 @@ public class OrchestrationRequests { throw new ValidationException("At least one filter query param must be specified"); } }catch(ValidationException ex){ - msoLogger.error(ex); + logger.error("Exception occurred", ex); ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.DataError).build(); ValidateException validateException = new ValidateException.Builder(ex.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_GENERAL_SERVICE_ERROR).cause(ex).errorInfo(errorLoggerInfo).build(); @@ -202,7 +206,7 @@ public class OrchestrationRequests { public Response unlockOrchestrationRequest(String requestJSON, @PathParam("requestId") String requestId, @PathParam("version") String version) throws ApiException{ long startTime = System.currentTimeMillis (); - msoLogger.debug ("requestId is: " + requestId); + logger.debug ("requestId is: {}", requestId); ServiceInstancesRequest sir = null; InfraActiveRequests infraActiveRequest = null; @@ -212,7 +216,7 @@ public class OrchestrationRequests { ObjectMapper mapper = new ObjectMapper(); sir = mapper.readValue(requestJSON, ServiceInstancesRequest.class); } catch(IOException e){ - msoLogger.error(e); + logger.error("Exception occurred", e); ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).build(); ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed : " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); @@ -223,7 +227,7 @@ public class OrchestrationRequests { try{ msoRequest.parseOrchestration(sir); } catch (Exception e) { - msoLogger.error(e); + logger.error("Exception occurred", e); ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).build(); ValidateException validateException = new ValidateException.Builder("Error parsing request: " + e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) .errorInfo(errorLoggerInfo).build(); @@ -319,7 +323,7 @@ public class OrchestrationRequests { requestDetails = mapper.readValue(requestBody, RequestDetails.class); } } catch (IOException e) { - msoLogger.error(e); + logger.error("Exception occurred", e); ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).build(); ValidateException validateException = new ValidateException.Builder("Mapping of request to JSON object failed : ", HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e).errorInfo(errorLoggerInfo).build(); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index a473b0939e..1f9f5f5fbe 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.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 @@ -83,6 +85,8 @@ import org.onap.so.serviceinstancebeans.VfModules; import org.onap.so.serviceinstancebeans.Vnfs; import org.onap.so.utils.CryptoUtils; import org.onap.so.utils.UUIDChecker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.ParameterizedTypeReference; @@ -126,7 +130,7 @@ import java.util.Optional; @Api(value="/onap/so/infra/serviceInstantiation",description="Infrastructure API Requests for Service Instances") public class ServiceInstances { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH,MsoRequest.class); + private static Logger logger = LoggerFactory.getLogger(MsoRequest.class); private static String NAME = "name"; private static String VALUE = "value"; private static final String SAVE_TO_DB = "save instance to db"; @@ -893,7 +897,7 @@ public class ServiceInstances { try { validateHeaders(requestContext); } catch (ValidationException e) { - msoLogger.error(e); + logger.error("Exception occurred", e); ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_VALIDATION_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); ValidateException validateException = new ValidateException.Builder(e.getMessage(), HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) .errorInfo(errorLoggerInfo).build(); @@ -1016,7 +1020,7 @@ public class ServiceInstances { respHandler = new ResponseHandler (response, requestClient.getType ()); bpelStatus = respHandler.getStatus (); } catch (ApiException e) { - msoLogger.error(e); + logger.error("Exception occurred", e); ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); ValidateException validateException = new ValidateException.Builder("Exception caught mapping Camunda JSON response to object", HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) .errorInfo(errorLoggerInfo).build(); @@ -1041,7 +1045,7 @@ public class ServiceInstances { jsonResponse.getRequestReferences().setRequestSelfLink(null); } } catch (IOException e) { - msoLogger.error(e); + logger.error("Exception occurred", e); ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_BPEL_RESPONSE_ERROR, MsoLogger.ErrorCode.SchemaError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); ValidateException validateException = new ValidateException.Builder("Exception caught mapping Camunda JSON response to object", HttpStatus.SC_NOT_ACCEPTABLE, ErrorNumbers.SVC_BAD_PARAMETER).cause(e) .errorInfo(errorLoggerInfo).build(); @@ -1130,7 +1134,7 @@ public class ServiceInstances { sir.getRequestDetails().setCloudConfiguration(serviceInstRequest.getRequestDetails().getCloudConfiguration()); sir.getRequestDetails().getRequestParameters().setUserParams(serviceInstRequest.getRequestDetails().getRequestParameters().getUserParams()); } - msoLogger.debug("Value as string: " + mapper.writeValueAsString(sir)); + logger.debug("Value as string: {}", mapper.writeValueAsString(sir)); return mapper.writeValueAsString(sir); } return null; @@ -1214,7 +1218,7 @@ public class ServiceInstances { headers.add(HttpHeaders.AUTHORIZATION, "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes())); } } catch(GeneralSecurityException e) { - msoLogger.error("Security exception", e); + logger.error("Security exception", e); } return headers; } @@ -1453,7 +1457,7 @@ public class ServiceInstances { } protected List<Map<String, Object>> configureUserParams(RequestParameters reqParams) throws IOException { - msoLogger.debug("Configuring UserParams for Macro Request"); + logger.debug("Configuring UserParams for Macro Request"); Map<String, Object> userParams = new HashMap<>(); for(Map<String, Object> params : reqParams.getUserParams()){ @@ -1789,7 +1793,7 @@ public class ServiceInstances { testApi = TestApi.valueOf(requestTestApi); return Optional.of(testApi.getModelName()); } catch (Exception e) { - msoLogger.warnSimple("Catching the exception on the valueOf enum call and continuing", e); + logger.warn("Catching the exception on the valueOf enum call and continuing", e); throw new IllegalArgumentException("Invalid TestApi is provided", e); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java index f9e6c276ec..0a72cf68ad 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/TasksHandler.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 @@ -55,7 +57,8 @@ import org.onap.so.apihandlerinfra.tasksbeans.TasksGetResponse; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; -import org.onap.so.utils.UUIDChecker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -72,7 +75,7 @@ import io.swagger.annotations.ApiOperation; public class TasksHandler { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH,TasksHandler.class); + private static Logger logger = LoggerFactory.getLogger(TasksHandler.class); @Value("${mso.camunda.rest.task.uri}") private String requestUrl; @@ -95,14 +98,9 @@ public class TasksHandler { @QueryParam("originalRequestDate") String originalRequestDate, @QueryParam("originalRequestorId") String originalRequestorId, @PathParam("version") String version) throws ApiException { - Response responseBack = null; - - String requestId = UUIDChecker.generateUUID(msoLogger); - MsoLogger.setServiceName ("ManualTasksQuery"); - // Generate a Request Id - UUIDChecker.generateUUID(msoLogger); + Response responseBack = null; String apiVersion = version.substring(1); - + // Prepare the query string to /task interface TaskVariables tv = new TaskVariables(); @@ -229,13 +227,9 @@ public class TasksHandler { throw validateException; } - return builder.buildResponse(HttpStatus.SC_ACCEPTED, requestId, jsonResponse, apiVersion); + return builder.buildResponse(HttpStatus.SC_ACCEPTED, "", jsonResponse, apiVersion); } - protected MsoLogger getMsoLogger () { - return msoLogger; - } - // Makes a GET call to Camunda to get variables for this task private TaskList getTaskInfo(String taskId) throws ApiException{ TaskList taskList; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java index d743c440e7..00f1d6889d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudOrchestration.java @@ -4,12 +4,14 @@ * ================================================================================ * 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 - * + * * 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. @@ -24,6 +26,7 @@ package org.onap.so.apihandlerinfra.tenantisolation; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.HashMap; +import java.util.UUID; import javax.inject.Provider; import javax.transaction.Transactional; @@ -54,7 +57,8 @@ import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; -import org.onap.so.utils.UUIDChecker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -68,9 +72,9 @@ import io.swagger.annotations.ApiOperation; @Api(value="/onap/so/infra/cloudResources",description="API Requests for cloud resources - Tenant Isolation") public class CloudOrchestration { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, CloudOrchestration.class); + private static Logger logger = LoggerFactory.getLogger(CloudOrchestration.class); private static final String ENVIRONMENT_ID_KEY = "operationalEnvironmentId"; - + @Autowired private TenantIsolationRequest tenantIsolationRequest ; @@ -87,7 +91,7 @@ public class CloudOrchestration { @ApiOperation(value="Create an Operational Environment",response=Response.class) @Transactional public Response createOperationEnvironment(String request, @PathParam("version") String version, @Context ContainerRequestContext requestContext) throws ApiException{ - msoLogger.debug("Received request to Create Operational Environment"); + logger.debug("Received request to Create Operational Environment"); return cloudOrchestration(request, Action.create, null, version, getRequestId(requestContext)); } @@ -99,7 +103,7 @@ public class CloudOrchestration { @Transactional public Response activateOperationEnvironment(String request, @PathParam("version") String version, @PathParam("operationalEnvironmentId") String operationalEnvironmentId, @Context ContainerRequestContext requestContext) throws ApiException{ - msoLogger.debug("Received request to Activate an Operational Environment"); + logger.debug("Received request to Activate an Operational Environment"); HashMap<String, String> instanceIdMap = new HashMap<>(); instanceIdMap.put(ENVIRONMENT_ID_KEY, operationalEnvironmentId); return cloudOrchestration(request, Action.activate, instanceIdMap, version, getRequestId(requestContext)); @@ -112,7 +116,7 @@ public class CloudOrchestration { @ApiOperation(value="Deactivate an Operational Environment",response=Response.class) @Transactional public Response deactivateOperationEnvironment(String request, @PathParam("version") String version, @PathParam("operationalEnvironmentId") String operationalEnvironmentId, @Context ContainerRequestContext requestContext) throws ApiException{ - msoLogger.debug("Received request to Deactivate an Operational Environment"); + logger.debug("Received request to Deactivate an Operational Environment"); HashMap<String, String> instanceIdMap = new HashMap<>(); instanceIdMap.put(ENVIRONMENT_ID_KEY, operationalEnvironmentId); return cloudOrchestration(request, Action.deactivate, instanceIdMap, version, getRequestId(requestContext)); @@ -121,7 +125,7 @@ public class CloudOrchestration { private Response cloudOrchestration(String requestJSON, Action action, HashMap<String, String> instanceIdMap, String version, String requestId) throws ApiException{ MsoLogger.setLogContext(requestId, null); - msoLogger.info(MessageEnum.APIH_GENERATED_REQUEST_ID, requestId, "", ""); + logger.info("{} {}", MessageEnum.APIH_GENERATED_REQUEST_ID.toString(), requestId); long startTime = System.currentTimeMillis (); CloudOrchestrationRequest cor = null; tenantIsolationRequest.setRequestId(requestId); @@ -168,7 +172,7 @@ public class CloudOrchestration { if(instanceIdMap != null && instanceIdMap.get(ENVIRONMENT_ID_KEY) != null) { instanceId = instanceIdMap.get(ENVIRONMENT_ID_KEY); } else { - instanceId = UUIDChecker.generateUUID(msoLogger); + instanceId = UUID.randomUUID().toString(); tenantIsolationRequest.setOperationalEnvironmentId(instanceId); cor.setOperationalEnvironmentId(instanceId); } @@ -217,7 +221,7 @@ public class CloudOrchestration { private CloudOrchestrationRequest convertJsonToCloudOrchestrationRequest(String requestJSON, Action action, long startTime, CloudOrchestrationRequest cor) throws ApiException { try{ - msoLogger.debug("Converting incoming JSON request to Object"); + logger.debug("Converting incoming JSON request to Object"); ObjectMapper mapper = new ObjectMapper(); return mapper.readValue(requestJSON, CloudOrchestrationRequest.class); } catch(IOException e){ diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java index 6d8ca96080..377b03c4ab 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/CloudResourcesOrchestration.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 @@ -60,7 +62,8 @@ import org.onap.so.exceptions.ValidationException; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; -import org.onap.so.utils.UUIDChecker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -74,7 +77,7 @@ import io.swagger.annotations.ApiOperation; @Api(value="onap/so/infra/cloudResourcesRequests",description="API GET Requests for cloud resources - Tenant Isolation") public class CloudResourcesOrchestration { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, CloudResourcesOrchestration.class); + private static Logger logger = LoggerFactory.getLogger(CloudResourcesOrchestration.class); @Autowired RequestsDbClient requestDbClient; @@ -94,7 +97,7 @@ public class CloudResourcesOrchestration { CloudOrchestrationRequest cor = null; - msoLogger.debug ("requestId is: " + requestId); + logger.debug ("requestId is: " + requestId); try{ ObjectMapper mapper = new ObjectMapper(); @@ -156,7 +159,6 @@ public class CloudResourcesOrchestration { @Transactional public Response getOperationEnvironmentStatusFilter(@Context UriInfo ui, @PathParam("version") String version ) throws ApiException{ MsoLogger.setServiceName ("getOperationEnvironmentStatusFilter"); - UUIDChecker.generateUUID(msoLogger); MultivaluedMap<String, String> queryParams = ui.getQueryParameters(); List<String> requestIdKey = queryParams.get("requestId"); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.java index e75d56e7d3..ace0fb664c 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.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 @@ -48,6 +50,8 @@ import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.serviceinstancebeans.RequestError; import org.onap.so.serviceinstancebeans.ServiceException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import com.fasterxml.jackson.annotation.JsonInclude.Include; @@ -62,7 +66,7 @@ import io.swagger.annotations.ApiOperation; @Api(value="/onap/so/infra/modelDistributions",description="API Requests for Model Distributions") public class ModelDistributionRequest { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, ModelDistributionRequest.class); + private static Logger logger = LoggerFactory.getLogger(ModelDistributionRequest.class); @Autowired private Provider<TenantIsolationRunnable> tenantIsolationRunnable; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java index 855a5433f3..47cbb0c895 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRequest.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 @@ -49,6 +51,8 @@ import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.utils.UUIDChecker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -75,7 +79,7 @@ public class TenantIsolationRequest { @Autowired private RequestsDbClient requestsDbClient; - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, TenantIsolationRequest.class); + private static Logger logger = LoggerFactory.getLogger(TenantIsolationRequest.class); TenantIsolationRequest (String requestId) { @@ -351,8 +355,9 @@ public class TenantIsolationRequest { request.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); requestsDbClient.save(request); } catch (Exception e) { - msoLogger.error(MessageEnum.APIH_DB_UPDATE_EXC, e.getMessage(), "", "", MsoLogger.ErrorCode.DataError, "Exception when updating record in DB"); - msoLogger.debug ("Exception: ", e); + logger.error("{} {} {} {}", MessageEnum.APIH_DB_UPDATE_EXC.toString(), e.getMessage(), + MsoLogger.ErrorCode.DataError.getValue(), "Exception when updating record in DB"); + logger.debug("Exception: ", e); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java index 7ad7e6626d..00ce137ee3 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/TenantIsolationRunnable.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 @@ -35,7 +37,8 @@ import org.onap.so.apihandlerinfra.tenantisolationbeans.OperationalEnvironment; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.requestsdb.RequestsDBHelper; -import org.slf4j.MDC; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.scheduling.annotation.Async; @@ -45,7 +48,7 @@ import org.springframework.stereotype.Component; @Scope("prototype") public class TenantIsolationRunnable { - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, TenantIsolationRunnable.class); + private static final Logger logger = LoggerFactory.getLogger(TenantIsolationRunnable.class); @Autowired private RequestsDBHelper requestDb; @@ -62,8 +65,9 @@ public class TenantIsolationRunnable { @Async public void run(Action action, String operationalEnvType, CloudOrchestrationRequest cor, String requestId) throws ApiException { - - msoLogger.debug ("Starting threadExecution in TenantIsolationRunnable for Action " + action.name() + " and OperationalEnvType: " + operationalEnvType); + + logger.debug("Starting threadExecution in TenantIsolationRunnable for Action {} and OperationalEnvType: {}", + action.name(), operationalEnvType); try { if(Action.create.equals(action)) { @@ -74,7 +78,8 @@ public class TenantIsolationRunnable { } else { ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.DataError).build(); ValidateException validateException = new ValidateException.Builder("Invalid OperationalEnvironment Type specified for Create Action", - HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo).build(); + HttpStatus.SC_BAD_REQUEST, ErrorNumbers.SVC_BAD_PARAMETER).errorInfo(errorLoggerInfo) + .build(); throw validateException; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java index 6a5de77c73..870fa11b5c 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/AAIClientHelper.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,14 +36,15 @@ import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.graphinventory.entities.uri.Depth; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @Component public class AAIClientHelper { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, AAIClientHelper.class); + private static Logger logger = LoggerFactory.getLogger(AAIClientHelper.class); /** * Get managing ECOMP Environment Info from A&AI diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelper.java index dcd3a42875..eb0721270d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelper.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/ActivateVnfDBHelper.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,13 +24,14 @@ package org.onap.so.apihandlerinfra.tenantisolation.helpers; import org.onap.so.db.request.beans.OperationalEnvDistributionStatus; import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; @Component public class ActivateVnfDBHelper { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, ActivateVnfDBHelper.class); + private static Logger logger = LoggerFactory.getLogger(ActivateVnfDBHelper.class); /** * Insert record to OperationalEnvServiceModelStatus table diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java index 5ead7ddd7f..9303e12071 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/helpers/SDCClientHelper.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 @@ -39,13 +41,15 @@ import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.utils.CryptoUtils; import org.onap.so.utils.TargetEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @Component public class SDCClientHelper { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, SDCClientHelper.class); + private static Logger logger = LoggerFactory.getLogger(SDCClientHelper.class); private static final String SDC_CONTENT_TYPE = "application/json"; private static final String SDC_ACCEPT_TYPE = "application/json"; private static String PARTIAL_SDC_URI = "/sdc/v1/catalog/services/"; @@ -106,9 +110,9 @@ public class SDCClientHelper { sdcResponseJsonObj = enhanceJsonResponse(new JSONObject(responseData), statusCode); } catch (Exception ex) { - msoLogger.debug("calling SDC Exception message: " + ex.getMessage()); + logger.debug("calling SDC Exception message: {}", ex.getMessage()); String errorMessage = " Encountered Error while calling SDC POST Activate. " + ex.getMessage(); - msoLogger.debug(errorMessage); + logger.debug(errorMessage); sdcResponseJsonObj.put("statusCode", String.valueOf(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode())); sdcResponseJsonObj.put("messageId", ""); sdcResponseJsonObj.put("message", errorMessage); @@ -217,7 +221,7 @@ public class SDCClientHelper { } catch (Exception e) { - msoLogger.debug("Failed to decrypt credentials: " + toDecrypt, e); + logger.debug("Failed to decrypt credentials: {}", toDecrypt, e); } return result; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java index 1d2a445c40..f70fe71554 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfOperationalEnvironment.java @@ -50,6 +50,8 @@ import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.requestsdb.RequestsDBHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @@ -58,7 +60,7 @@ import org.springframework.stereotype.Component; @Component public class ActivateVnfOperationalEnvironment { - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, ActivateVnfOperationalEnvironment.class); + private static final Logger logger = LoggerFactory.getLogger(ActivateVnfOperationalEnvironment.class); private static final int DEFAULT_ACTIVATE_RETRY_COUNT = 3; private static final String DISTRIBUTION_STATUS_SENT = "SENT"; private static final String OPER_ENVIRONMENT_ID_KEY = "operational-environment-id"; @@ -100,12 +102,12 @@ public class ActivateVnfOperationalEnvironment { ecompOperationalEnvironmentId = operationalEnvironments.get(0).getURIKeys().get(OPER_ENVIRONMENT_ID_KEY); } } - msoLogger.debug(" vnfOperationalEnvironmentId : " + vnfOperationalEnvironmentId); - msoLogger.debug(" ecompOperationalEnvironmentId : " + ecompOperationalEnvironmentId); + logger.debug(" vnfOperationalEnvironmentId : {}", vnfOperationalEnvironmentId); + logger.debug(" ecompOperationalEnvironmentId : {}", ecompOperationalEnvironmentId); OperationalEnvironment operationalEnv = wrapper.asBean(OperationalEnvironment.class).get(); String workloadContext = operationalEnv.getWorkloadContext(); - msoLogger.debug(" aai workloadContext: " + workloadContext); + logger.debug(" aai workloadContext: {}", workloadContext); if (!vidWorkloadContext.equals(workloadContext)) { ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_GENERAL_EXCEPTION, MsoLogger.ErrorCode.BusinessProcesssError).build(); throw new ValidateException.Builder(" The vid workloadContext did not match from aai record. " + " vid workloadContext:" + vidWorkloadContext + " aai workloadContext:" + workloadContext, diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java index 66cfd349df..219a2efcac 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/ActivateVnfStatusOperationalEnvironment.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 @@ -42,13 +44,15 @@ import org.onap.so.db.request.beans.OperationalEnvServiceModelStatus; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.requestsdb.RequestsDBHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class ActivateVnfStatusOperationalEnvironment { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, ActivateVnfStatusOperationalEnvironment.class); + private static Logger logger = LoggerFactory.getLogger(ActivateVnfStatusOperationalEnvironment.class); private String origRequestId = ""; private String errorMessage = ""; private OperationalEnvDistributionStatus queryDistributionDbResponse = null; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java index b09bbae0ad..6ba78aa175 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateEcompOperationalEnvironment.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 @@ -32,13 +34,15 @@ import org.onap.so.apihandlerinfra.tenantisolation.helpers.AAIClientObjectBuilde import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.requestsdb.RequestsDBHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class CreateEcompOperationalEnvironment { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, CreateEcompOperationalEnvironment.class); + private static Logger logger = LoggerFactory.getLogger(CreateEcompOperationalEnvironment.class); @Autowired private AAIClientObjectBuilder aaiClientObjectBuilder; @@ -56,11 +60,12 @@ public class CreateEcompOperationalEnvironment { // Call client to publish to DMaap try { - msoLogger.debug("1" + request.getOperationalEnvironmentId()); - msoLogger.debug("2" + request.getRequestDetails().getRequestInfo().getInstanceName()); - msoLogger.debug("3" + request.getRequestDetails().getRequestParameters().getOperationalEnvironmentType().toString()); - msoLogger.debug("4" + request.getRequestDetails().getRequestParameters().getTenantContext()); - msoLogger.debug("5" + request.getRequestDetails().getRequestParameters().getWorkloadContext()); + logger.debug("1 {}", request.getOperationalEnvironmentId()); + logger.debug("2 {}", request.getRequestDetails().getRequestInfo().getInstanceName()); + logger.debug("3 {}", request.getRequestDetails().getRequestParameters().getOperationalEnvironmentType() + .toString()); + logger.debug("4 {}", request.getRequestDetails().getRequestParameters().getTenantContext()); + logger.debug("5 {}", request.getRequestDetails().getRequestParameters().getWorkloadContext()); dmaapClient.dmaapPublishOperationalEnvRequest(request.getOperationalEnvironmentId(), diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java index 36226aae68..2eaba25234 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/CreateVnfOperationalEnvironment.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 @@ -48,6 +50,8 @@ import org.onap.so.client.grm.beans.Version; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.requestsdb.RequestsDBHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -56,7 +60,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; @Component public class CreateVnfOperationalEnvironment { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, CreateVnfOperationalEnvironment.class); + private static Logger logger = LoggerFactory.getLogger(CreateVnfOperationalEnvironment.class); protected CloudOrchestrationRequest request; @Autowired @@ -78,7 +82,7 @@ public class CreateVnfOperationalEnvironment { OperationalEnvironment aaiEnv = aaiResultWrapper.asBean(OperationalEnvironment.class).get(); //Find ECOMP environments in GRM - msoLogger.debug(" Start of GRM findRunningServicesAsString"); + logger.debug(" Start of GRM findRunningServicesAsString"); String searchKey = getSearchKey(aaiEnv); String tenantContext = getTenantContext().toUpperCase(); String jsonResponse = getGrmClient().findRunningServicesAsString(searchKey, 1, tenantContext); @@ -92,7 +96,7 @@ public class CreateVnfOperationalEnvironment { int ctr = 0; int total = serviceEndpointRequestList.size(); for (ServiceEndPointRequest requestList : serviceEndpointRequestList) { - msoLogger.debug("Creating endpoint " + ++ctr + " of " + total + ": " + requestList.getServiceEndPoint().getName()); + logger.debug("Creating endpoint " + ++ctr + " of " + total + ": " + requestList.getServiceEndPoint().getName()); getGrmClient().addServiceEndPoint(requestList); } @@ -137,7 +141,7 @@ public class CreateVnfOperationalEnvironment { private List<ServiceEndPointRequest> buildEndPointRequestList(ServiceEndPointList serviceEndPointList) throws TenantIsolationException { List<ServiceEndPoint> endpointList = serviceEndPointList.getServiceEndPointList(); - msoLogger.debug("Number of service endpoints from GRM: " + endpointList.size()); + logger.debug("Number of service endpoints from GRM: {}", endpointList.size()); List<ServiceEndPointRequest> serviceEndPointRequestList = new ArrayList<ServiceEndPointRequest>(); for(ServiceEndPoint serviceEndpoint : endpointList) { serviceEndPointRequestList.add(buildServiceEndpoint(serviceEndpoint)); diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java index 977184e2c5..2181215ca7 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/process/DeactivateVnfOperationalEnvironment.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 @@ -35,13 +37,16 @@ import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; import org.onap.so.requestsdb.RequestsDBHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @Component public class DeactivateVnfOperationalEnvironment { - private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH, DeactivateVnfOperationalEnvironment.class); + private static Logger logger = LoggerFactory.getLogger(DeactivateVnfOperationalEnvironment + .class); @Autowired private AAIClientHelper aaiHelper; diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java index a6fdcc958d..5eb3083003 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/RelatedInstancesValidation.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 @@ -25,7 +27,6 @@ import org.onap.so.apihandlerinfra.Action; import org.onap.so.apihandlerinfra.Actions; import org.onap.so.apihandlerinfra.Constants; import org.onap.so.exceptions.ValidationException; -import org.onap.so.logger.MsoLogger; import org.onap.so.serviceinstancebeans.InstanceDirection; import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.ModelType; @@ -33,11 +34,16 @@ import org.onap.so.serviceinstancebeans.RelatedInstance; import org.onap.so.serviceinstancebeans.RelatedInstanceList; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.onap.so.utils.UUIDChecker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RelatedInstancesValidation implements ValidationRule{ - private static boolean empty(String s) { - return (s == null || s.trim().isEmpty()); - } + + private static Logger logger = LoggerFactory.getLogger(RelatedInstancesValidation.class); + + private static boolean empty(String s) { + return (s == null || s.trim().isEmpty()); + } @Override public ValidationInformation validate(ValidationInformation info) throws ValidationException{ ServiceInstancesRequest sir = info.getSir(); @@ -50,7 +56,6 @@ public class RelatedInstancesValidation implements ValidationRule{ String vfModuleType = null; String vfModuleModelName = null; ModelInfo modelInfo = info.getSir().getRequestDetails().getModelInfo(); - MsoLogger msoLogger = MsoLogger.getMsoLogger (MsoLogger.Catalog.APIH, RelatedInstancesValidation.class); RelatedInstanceList[] instanceList = sir.getRequestDetails().getRelatedInstanceList(); String serviceModelName = null; String vnfModelName = null; @@ -229,7 +234,7 @@ public class RelatedInstancesValidation implements ValidationRule{ (reqVersion >= 4 && (requestScope.equalsIgnoreCase(ModelType.volumeGroup.name ()) || requestScope.equalsIgnoreCase(ModelType.vfModule.name ())) && action == Action.updateInstance || (requestScope.equalsIgnoreCase(ModelType.vfModule.name ()) && action == Action.scaleOut)) || (requestScope.equalsIgnoreCase(ModelType.service.name()) && (action.equals(Action.addRelationships) || action.equals(Action.removeRelationships)))){ - msoLogger.debug ("related instance exception"); + logger.debug("related instance exception"); throw new ValidationException ("related instances"); } if(instanceList == null && requestScope.equalsIgnoreCase(ModelType.instanceGroup.toString()) && action == Action.createInstance){ @@ -242,4 +247,4 @@ public class RelatedInstancesValidation implements ValidationRule{ info.setVfModuleType(vfModuleType); return info; } -}
\ No newline at end of file +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java index 4d4f23c083..54e7b27168 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/BaseTest.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 @@ -20,27 +22,20 @@ package org.onap.so.apihandlerinfra; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; import com.github.tomakehurst.wiremock.client.WireMock; import org.junit.After; import org.junit.BeforeClass; import org.junit.runner.RunWith; -import org.onap.so.logger.MsoLogger; -import org.onap.so.logger.MsoLogger.Catalog; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock; import org.springframework.core.env.Environment; -import org.springframework.http.HttpHeaders; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.jdbc.Sql; -import org.springframework.test.context.jdbc.Sql.ExecutionPhase; import org.springframework.test.context.junit4.SpringRunner; import javax.transaction.Transactional; @@ -55,7 +50,7 @@ import java.nio.file.Paths; @Transactional @AutoConfigureWireMock(port = 0) public abstract class BaseTest { - protected MsoLogger logger = MsoLogger.getMsoLogger(Catalog.GENERAL, BaseTest.class); + protected Logger logger = LoggerFactory.getLogger(BaseTest.class); protected TestRestTemplate restTemplate = new TestRestTemplate("test", "test"); @Autowired @@ -90,4 +85,4 @@ public abstract class BaseTest { public String getTestUrl(String requestId) { return "/infraActiveRequests/" + requestId; } -}
\ No newline at end of file +} |