diff options
author | Steve Smokowski <ss835w@att.com> | 2019-02-25 13:53:42 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-02-25 13:53:42 +0000 |
commit | edf132044317bc71a87a834a1b9dbe980d2e4639 (patch) | |
tree | b187e3f8c7075bc0ee6e762f86b26a002248b0f1 /common/src/main/java/org/onap | |
parent | 9dfac1f8a822ef3e904f5f594120e9d8d450e248 (diff) | |
parent | 8831c42007e44753ac926c82343d5820d2ea687c (diff) |
Merge "Removed MsoLogger from SO 'common' module"
Diffstat (limited to 'common/src/main/java/org/onap')
7 files changed, 58 insertions, 33 deletions
diff --git a/common/src/main/java/org/onap/so/client/RestRequest.java b/common/src/main/java/org/onap/so/client/RestRequest.java index 4788acfa7c..6f0d71cabf 100644 --- a/common/src/main/java/org/onap/so/client/RestRequest.java +++ b/common/src/main/java/org/onap/so/client/RestRequest.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 - 2018 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 @@ -26,13 +28,13 @@ import java.util.concurrent.Callable; import javax.ws.rs.NotFoundException; import javax.ws.rs.client.Entity; import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.Status; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RestRequest implements Callable<Response> { - private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, RestRequest.class); + private static final Logger logger = LoggerFactory.getLogger(RestRequest.class); private final RestClient client; private final String method; @@ -73,7 +75,7 @@ public class RestRequest implements Callable<Response> { mapper.get().map(response); } catch (NotFoundException e) { if (this.client.props.mapNotFoundToEmpty() && "GET".equals(method)) { - msoLogger.debug("RestClient recieved not found on URL: " + this.client.getWebTarget().getUri()); + logger.debug("RestClient recieved not found on URL: {}", this.client.getWebTarget().getUri()); return response; } else { throw e; diff --git a/common/src/main/java/org/onap/so/logger/LoggerStartupListener.java b/common/src/main/java/org/onap/so/logger/LoggerStartupListener.java index 794d02a240..cd7859a170 100644 --- a/common/src/main/java/org/onap/so/logger/LoggerStartupListener.java +++ b/common/src/main/java/org/onap/so/logger/LoggerStartupListener.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,11 +25,11 @@ package org.onap.so.logger; import java.net.InetAddress; import java.net.UnknownHostException; -import org.onap.so.utils.UUIDChecker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.classic.spi.LoggerContextListener; import ch.qos.logback.core.Context; @@ -37,8 +39,8 @@ import ch.qos.logback.core.spi.LifeCycle; @Component public class LoggerStartupListener extends ContextAwareBase implements LoggerContextListener, LifeCycle { - private boolean started = false; - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL, LoggerStartupListener.class); + private boolean started = false; + private static final Logger logger = LoggerFactory.getLogger(LoggerStartupListener.class); @Override public void start() { @@ -48,7 +50,7 @@ public class LoggerStartupListener extends ContextAwareBase implements LoggerCon try { addr = InetAddress.getLocalHost(); } catch (UnknownHostException e) { - LOGGER.error("UnknownHostException",e); + logger.error("UnknownHostException",e); } Context context = getContext(); @@ -73,10 +75,6 @@ public class LoggerStartupListener extends ContextAwareBase implements LoggerCon } @Override - public void onLevelChange(Logger arg0, Level arg1) { - } - - @Override public void onReset(LoggerContext arg0) { } @@ -87,4 +85,8 @@ public class LoggerStartupListener extends ContextAwareBase implements LoggerCon @Override public void onStop(LoggerContext arg0) { } + + @Override + public void onLevelChange(ch.qos.logback.classic.Logger logger, Level level) { + } } diff --git a/common/src/main/java/org/onap/so/openpojo/rules/HasAnnotationPropertyWithValueMatcher.java b/common/src/main/java/org/onap/so/openpojo/rules/HasAnnotationPropertyWithValueMatcher.java index 551305c14a..f76a27cce2 100644 --- a/common/src/main/java/org/onap/so/openpojo/rules/HasAnnotationPropertyWithValueMatcher.java +++ b/common/src/main/java/org/onap/so/openpojo/rules/HasAnnotationPropertyWithValueMatcher.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 @@ -21,19 +23,19 @@ package org.onap.so.openpojo.rules; import java.lang.annotation.Annotation; -import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeDiagnosingMatcher; -import org.onap.so.logger.MsoLogger; import com.openpojo.reflection.PojoField; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class HasAnnotationPropertyWithValueMatcher<T extends PojoField> extends TypeSafeDiagnosingMatcher<T> { - private MsoLogger logger=MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, HasAnnotationPropertyWithValueMatcher.class); + private Logger logger = LoggerFactory.getLogger(HasAnnotationPropertyWithValueMatcher.class); private final String attribute; private final Matcher<?> annotationMatcher; private final Class<? extends Annotation> annotationClass; diff --git a/common/src/main/java/org/onap/so/utils/CryptoUtils.java b/common/src/main/java/org/onap/so/utils/CryptoUtils.java index c35ced531d..a1097780c0 100644 --- a/common/src/main/java/org/onap/so/utils/CryptoUtils.java +++ b/common/src/main/java/org/onap/so/utils/CryptoUtils.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,8 @@ package org.onap.so.utils; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import javax.crypto.Cipher; import javax.crypto.spec.GCMParameterSpec; @@ -38,7 +42,8 @@ import java.util.Arrays; */ public final class CryptoUtils { - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA, CryptoUtils.class); + private static final Logger logger = LoggerFactory.getLogger(CryptoUtils.class); + private static final String AES = "AES"; private static final String CLOUD_KEY = "aa3871669d893c7fb8abbcda31b88b4f"; @@ -86,17 +91,19 @@ public final class CryptoUtils { try { return CryptoUtils.encrypt(message, CLOUD_KEY); } catch (GeneralSecurityException e) { - LOGGER.error (MessageEnum.RA_GENERAL_EXCEPTION, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in encryptPassword", e); - return null; - } + logger.error("{} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception in encryptPassword ", e); + return null; + } } public static String decryptCloudConfigPassword(String message) { try { return CryptoUtils.decrypt(message, CLOUD_KEY); } catch (GeneralSecurityException e) { - LOGGER.error (MessageEnum.RA_GENERAL_EXCEPTION, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in encryptPassword", e); - return null; - } + logger.error("{} {} {}", MessageEnum.RA_GENERAL_EXCEPTION.toString(), + MsoLogger.ErrorCode.BusinessProcesssError.getValue(), "Exception in encryptPassword ", e); + return null; + } } private static SecretKeySpec getSecretKeySpec (String keyString) { byte[] key = hexStringToByteArray (keyString); diff --git a/common/src/main/java/org/onap/so/utils/UUIDChecker.java b/common/src/main/java/org/onap/so/utils/UUIDChecker.java index fac73e84f9..36fa3d09ab 100644 --- a/common/src/main/java/org/onap/so/utils/UUIDChecker.java +++ b/common/src/main/java/org/onap/so/utils/UUIDChecker.java @@ -4,6 +4,7 @@ * ================================================================================ * 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. @@ -25,12 +26,15 @@ import java.util.UUID; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** */ public class UUIDChecker { - - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.GENERAL, UUIDChecker.class); + + private static final Logger logger = LoggerFactory.getLogger(UUIDChecker.class); + private UUIDChecker() { @@ -44,7 +48,7 @@ public class UUIDChecker { UUID uuid = UUID.fromString(id); return uuid.toString().equalsIgnoreCase(id); } catch (IllegalArgumentException iae) { - LOGGER.debug("IllegalArgumentException", iae); + logger.debug("IllegalArgumentException", iae); return false; } } diff --git a/common/src/main/java/org/onap/so/utils/XmlMarshaller.java b/common/src/main/java/org/onap/so/utils/XmlMarshaller.java index 903d055548..864266bf40 100644 --- a/common/src/main/java/org/onap/so/utils/XmlMarshaller.java +++ b/common/src/main/java/org/onap/so/utils/XmlMarshaller.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,12 +37,14 @@ import javax.xml.transform.sax.SAXSource; import org.onap.so.exceptions.MarshallerException; import org.onap.so.logger.MessageEnum; import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.xml.sax.InputSource; import org.xml.sax.XMLReader; public class XmlMarshaller { - private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, XmlMarshaller.class); + private static Logger logger = LoggerFactory.getLogger(XmlMarshaller.class); public static String marshal(Object object) throws MarshallerException { @@ -50,7 +54,8 @@ public class XmlMarshaller { Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); jaxbMarshaller.marshal(object, stringWriter); } catch (JAXBException e) { - logger.error(MessageEnum.GENERAL_EXCEPTION, "", "", "", MsoLogger.ErrorCode.SchemaError, e.getMessage(), e); + logger.error("{} {} {}", MessageEnum.GENERAL_EXCEPTION.toString(), + MsoLogger.ErrorCode.SchemaError.getValue(), e.getMessage(), e); throw new MarshallerException(e.getMessage(), MsoLogger.ErrorCode.SchemaError.getValue(), e); } @@ -74,7 +79,8 @@ public class XmlMarshaller { SAXSource source = new SAXSource(xmlReader, inputSource); object = jaxbUnmarshaller.unmarshal(source, object.getClass()).getValue(); } catch (Exception e) { - logger.error(MessageEnum.GENERAL_EXCEPTION, "", "", "", MsoLogger.ErrorCode.SchemaError, e.getMessage(), e); + logger.error("{} {} {}", MessageEnum.GENERAL_EXCEPTION.toString(), + MsoLogger.ErrorCode.SchemaError.getValue(), e.getMessage(), e); throw new MarshallerException(e.getMessage(), MsoLogger.ErrorCode.SchemaError.getValue(), e); } diff --git a/common/src/main/java/org/onap/so/web/exceptions/RuntimeExceptionMapper.java b/common/src/main/java/org/onap/so/web/exceptions/RuntimeExceptionMapper.java index 9ddfd0592c..2c249f1607 100644 --- a/common/src/main/java/org/onap/so/web/exceptions/RuntimeExceptionMapper.java +++ b/common/src/main/java/org/onap/so/web/exceptions/RuntimeExceptionMapper.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 - 2018 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 @@ -26,11 +28,12 @@ import javax.ws.rs.core.Response.Status; import javax.ws.rs.ext.ExceptionMapper; -import org.onap.so.logger.MsoLogger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class RuntimeExceptionMapper implements ExceptionMapper<RuntimeException> { - private static MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, RuntimeExceptionMapper.class); + private static Logger logger = LoggerFactory.getLogger(RuntimeExceptionMapper.class); @Override public Response toResponse(RuntimeException exception) { @@ -38,8 +41,7 @@ public class RuntimeExceptionMapper implements ExceptionMapper<RuntimeException> if (exception instanceof NotFoundException) { return Response.status(Status.NOT_FOUND).build(); } else { - - logger.error(exception); + logger.error("Error occured", exception); return Response.status(Status.INTERNAL_SERVER_ERROR).entity(new ExceptionResponse("Unexpected Internal Exception")).build(); } } |