From 4c288cdd3d1393a18e8ef8d96f73f66e5996b54c Mon Sep 17 00:00:00 2001 From: Eylon Malin Date: Thu, 31 Oct 2019 09:29:10 +0200 Subject: rename class to JaxRsMetricLogClientFilter Issue-ID: VID-253 Change-Id: I47727690015ab0183ba25a57b19fb280231c6fb3 Signed-off-by: Eylon Malin --- .../org/onap/vid/aai/util/AAIRestInterface.java | 4 +- .../vid/logging/JaxRsMetricLogClientFilter.java | 38 +++++++++++++++++ .../onap/vid/logging/VidMetricLogClientFilter.java | 38 ----------------- .../org/onap/vid/mso/RestMsoImplementation.java | 4 +- .../logging/JaxRsMetricLogClientFilterTest.java | 49 ++++++++++++++++++++++ .../vid/logging/VidMetricLogClientFilterTest.java | 49 ---------------------- 6 files changed, 91 insertions(+), 91 deletions(-) create mode 100644 vid-app-common/src/main/java/org/onap/vid/logging/JaxRsMetricLogClientFilter.java delete mode 100644 vid-app-common/src/main/java/org/onap/vid/logging/VidMetricLogClientFilter.java create mode 100644 vid-app-common/src/test/java/org/onap/vid/logging/JaxRsMetricLogClientFilterTest.java delete mode 100644 vid-app-common/src/test/java/org/onap/vid/logging/VidMetricLogClientFilterTest.java diff --git a/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java b/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java index aadfd58cc..daa124770 100644 --- a/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java +++ b/vid-app-common/src/main/java/org/onap/vid/aai/util/AAIRestInterface.java @@ -41,7 +41,7 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.vid.aai.ExceptionWithRequestInfo; import org.onap.vid.aai.ResponseWithRequestInfo; import org.onap.vid.aai.exceptions.InvalidPropertyException; -import org.onap.vid.logging.VidMetricLogClientFilter; +import org.onap.vid.logging.JaxRsMetricLogClientFilter; import org.onap.vid.utils.Logging; import org.onap.vid.utils.Unchecked; import org.springframework.beans.factory.annotation.Autowired; @@ -125,7 +125,7 @@ public class AAIRestInterface { if (client == null) { try { client = httpsAuthClientFactory.getClient(HttpClientMode.WITH_KEYSTORE); - VidMetricLogClientFilter metricLogClientFilter = new VidMetricLogClientFilter(); + JaxRsMetricLogClientFilter metricLogClientFilter = new JaxRsMetricLogClientFilter(); client.register(metricLogClientFilter); } catch (Exception e) { logger.info(EELFLoggerDelegate.errorLogger, "Exception in REST call to DB in initRestClient" + e.toString()); diff --git a/vid-app-common/src/main/java/org/onap/vid/logging/JaxRsMetricLogClientFilter.java b/vid-app-common/src/main/java/org/onap/vid/logging/JaxRsMetricLogClientFilter.java new file mode 100644 index 000000000..fbea381fd --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/logging/JaxRsMetricLogClientFilter.java @@ -0,0 +1,38 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.vid.logging; + +import static org.onap.vid.logging.LoggingFilterHelper.updateInvocationIDInMdcWithHeaderValue; + +import javax.ws.rs.client.ClientRequestContext; +import javax.ws.rs.core.MultivaluedMap; +import org.onap.logging.filter.base.MetricLogClientFilter; +import org.onap.logging.ref.slf4j.ONAPLogConstants; + +public class JaxRsMetricLogClientFilter extends MetricLogClientFilter { + + @Override + protected void additionalPre(ClientRequestContext clientRequestContext, MultivaluedMap stringObjectMultivaluedMap) { + updateInvocationIDInMdcWithHeaderValue( + ()->(String)stringObjectMultivaluedMap.getFirst(ONAPLogConstants.Headers.INVOCATION_ID) + ); + } +} diff --git a/vid-app-common/src/main/java/org/onap/vid/logging/VidMetricLogClientFilter.java b/vid-app-common/src/main/java/org/onap/vid/logging/VidMetricLogClientFilter.java deleted file mode 100644 index 6b9222ef3..000000000 --- a/vid-app-common/src/main/java/org/onap/vid/logging/VidMetricLogClientFilter.java +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * VID - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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.vid.logging; - -import static org.onap.vid.logging.LoggingFilterHelper.updateInvocationIDInMdcWithHeaderValue; - -import javax.ws.rs.client.ClientRequestContext; -import javax.ws.rs.core.MultivaluedMap; -import org.onap.logging.filter.base.MetricLogClientFilter; -import org.onap.logging.ref.slf4j.ONAPLogConstants; - -public class VidMetricLogClientFilter extends MetricLogClientFilter { - - @Override - protected void additionalPre(ClientRequestContext clientRequestContext, MultivaluedMap stringObjectMultivaluedMap) { - updateInvocationIDInMdcWithHeaderValue( - ()->(String)stringObjectMultivaluedMap.getFirst(ONAPLogConstants.Headers.INVOCATION_ID) - ); - } -} diff --git a/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java b/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java index a2d71d900..2f5458d54 100644 --- a/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java +++ b/vid-app-common/src/main/java/org/onap/vid/mso/RestMsoImplementation.java @@ -40,7 +40,7 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate; import org.onap.vid.aai.util.HttpClientMode; import org.onap.vid.aai.util.HttpsAuthClient; import org.onap.vid.client.HttpBasicClient; -import org.onap.vid.logging.VidMetricLogClientFilter; +import org.onap.vid.logging.JaxRsMetricLogClientFilter; import org.onap.vid.utils.Logging; import org.onap.vid.utils.SystemPropertiesWrapper; import org.springframework.beans.factory.annotation.Autowired; @@ -131,7 +131,7 @@ public class RestMsoImplementation { } private void registerClientToMetricLogClientFilter(Client client) { - VidMetricLogClientFilter metricLogClientFilter = new VidMetricLogClientFilter(); + JaxRsMetricLogClientFilter metricLogClientFilter = new JaxRsMetricLogClientFilter(); client.register(metricLogClientFilter); } diff --git a/vid-app-common/src/test/java/org/onap/vid/logging/JaxRsMetricLogClientFilterTest.java b/vid-app-common/src/test/java/org/onap/vid/logging/JaxRsMetricLogClientFilterTest.java new file mode 100644 index 000000000..56efeaf1b --- /dev/null +++ b/vid-app-common/src/test/java/org/onap/vid/logging/JaxRsMetricLogClientFilterTest.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.vid.logging; + +import static org.testng.Assert.assertEquals; + +import javax.ws.rs.core.MultivaluedHashMap; +import javax.ws.rs.core.MultivaluedMap; +import org.onap.logging.ref.slf4j.ONAPLogConstants; +import org.slf4j.MDC; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +public class JaxRsMetricLogClientFilterTest { + + JaxRsMetricLogClientFilter metricLogClientFilter; + + @BeforeMethod + public void setup() { + this.metricLogClientFilter = new JaxRsMetricLogClientFilter(); + MDC.clear(); + } + + @Test + public void testAdditionalPre() { + MultivaluedMap headers = new MultivaluedHashMap<>(); + headers.add(ONAPLogConstants.Headers.INVOCATION_ID, "xyz"); + metricLogClientFilter.additionalPre(null, headers); + assertEquals(MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID), "xyz"); + } +} diff --git a/vid-app-common/src/test/java/org/onap/vid/logging/VidMetricLogClientFilterTest.java b/vid-app-common/src/test/java/org/onap/vid/logging/VidMetricLogClientFilterTest.java deleted file mode 100644 index aaf8eaf01..000000000 --- a/vid-app-common/src/test/java/org/onap/vid/logging/VidMetricLogClientFilterTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * VID - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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.vid.logging; - -import static org.testng.Assert.assertEquals; - -import javax.ws.rs.core.MultivaluedHashMap; -import javax.ws.rs.core.MultivaluedMap; -import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.slf4j.MDC; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -public class VidMetricLogClientFilterTest { - - VidMetricLogClientFilter metricLogClientFilter; - - @BeforeMethod - public void setup() { - this.metricLogClientFilter = new VidMetricLogClientFilter(); - MDC.clear(); - } - - @Test - public void testAdditionalPre() { - MultivaluedMap headers = new MultivaluedHashMap<>(); - headers.add(ONAPLogConstants.Headers.INVOCATION_ID, "xyz"); - metricLogClientFilter.additionalPre(null, headers); - assertEquals(MDC.get(ONAPLogConstants.MDCs.INVOCATION_ID), "xyz"); - } -} -- cgit 1.2.3-korg