diff options
Diffstat (limited to 'common/src/main/java/org/onap')
4 files changed, 37 insertions, 8 deletions
diff --git a/common/src/main/java/org/onap/so/logger/LoggingAnchor.java b/common/src/main/java/org/onap/so/logger/LoggingAnchor.java new file mode 100644 index 0000000000..119ae4c43c --- /dev/null +++ b/common/src/main/java/org/onap/so/logger/LoggingAnchor.java @@ -0,0 +1,29 @@ +package org.onap.so.logger; + +import java.util.Collections; +import java.util.stream.Collectors; + +public class LoggingAnchor { + public static final String ONE = Collections.nCopies(1, "{}").stream().collect(Collectors.joining(" ")); + + public static final String TWO = Collections.nCopies(2, "{}").stream().collect(Collectors.joining(" ")); + + public static final String THREE = Collections.nCopies(3, "{}").stream().collect(Collectors.joining(" ")); + + public static final String FOUR = Collections.nCopies(4, "{}").stream().collect(Collectors.joining(" ")); + + public static final String FIVE = Collections.nCopies(5, "{}").stream().collect(Collectors.joining(" ")); + + public static final String SIX = Collections.nCopies(6, "{}").stream().collect(Collectors.joining(" ")); + + public static final String SEVEN = Collections.nCopies(7, "{}").stream().collect(Collectors.joining(" ")); + + public static final String EIGHT = Collections.nCopies(8, "{}").stream().collect(Collectors.joining(" ")); + + public static final String NINE = Collections.nCopies(9, "{}").stream().collect(Collectors.joining(" ")); + + public static final String TEN = Collections.nCopies(10, "{}").stream().collect(Collectors.joining(" ")); + + private LoggingAnchor() {} + +} 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 f42fc0111f..640660e97c 100644 --- a/common/src/main/java/org/onap/so/utils/CryptoUtils.java +++ b/common/src/main/java/org/onap/so/utils/CryptoUtils.java @@ -23,7 +23,7 @@ package org.onap.so.utils; -import com.google.common.base.Strings; +import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; @@ -90,7 +90,7 @@ public final class CryptoUtils { try { return CryptoUtils.encrypt(message, CLOUD_KEY); } catch (GeneralSecurityException e) { - logger.error(Strings.repeat("{} ", 3), MessageEnum.RA_GENERAL_EXCEPTION.toString(), + logger.error(LoggingAnchor.THREE, MessageEnum.RA_GENERAL_EXCEPTION.toString(), ErrorCode.BusinessProcesssError.getValue(), "Exception in encryptPassword ", e); return null; } @@ -100,7 +100,7 @@ public final class CryptoUtils { try { return CryptoUtils.decrypt(message, CLOUD_KEY); } catch (GeneralSecurityException e) { - logger.error(Strings.repeat("{} ", 3), MessageEnum.RA_GENERAL_EXCEPTION.toString(), + logger.error(LoggingAnchor.THREE, MessageEnum.RA_GENERAL_EXCEPTION.toString(), ErrorCode.BusinessProcesssError.getValue(), "Exception in encryptPassword ", e); return null; } 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 6a95334696..30fc92bf49 100644 --- a/common/src/main/java/org/onap/so/utils/UUIDChecker.java +++ b/common/src/main/java/org/onap/so/utils/UUIDChecker.java @@ -24,7 +24,7 @@ package org.onap.so.utils; import java.util.UUID; -import com.google.common.base.Strings; +import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -52,7 +52,7 @@ public class UUIDChecker { public static String getUUID() { String result = UUID.randomUUID().toString(); - logger.info(Strings.repeat("{} ", 2), MessageEnum.APIH_GENERATED_REQUEST_ID, result); + logger.info(LoggingAnchor.TWO, MessageEnum.APIH_GENERATED_REQUEST_ID, result); return result; } } 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 e6acb87eaa..0ff3ccfa9c 100644 --- a/common/src/main/java/org/onap/so/utils/XmlMarshaller.java +++ b/common/src/main/java/org/onap/so/utils/XmlMarshaller.java @@ -32,7 +32,7 @@ import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; import javax.xml.parsers.SAXParserFactory; import javax.xml.transform.sax.SAXSource; -import com.google.common.base.Strings; +import org.onap.so.logger.LoggingAnchor; import org.onap.so.exceptions.MarshallerException; import org.onap.so.logger.ErrorCode; import org.onap.so.logger.MessageEnum; @@ -53,7 +53,7 @@ public class XmlMarshaller { Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); jaxbMarshaller.marshal(object, stringWriter); } catch (JAXBException e) { - logger.error(Strings.repeat("{} ", 3), MessageEnum.GENERAL_EXCEPTION.toString(), + logger.error(LoggingAnchor.THREE, MessageEnum.GENERAL_EXCEPTION.toString(), ErrorCode.SchemaError.getValue(), e.getMessage(), e); throw new MarshallerException(e.getMessage(), ErrorCode.SchemaError.getValue(), e); } @@ -78,7 +78,7 @@ public class XmlMarshaller { SAXSource source = new SAXSource(xmlReader, inputSource); object = jaxbUnmarshaller.unmarshal(source, object.getClass()).getValue(); } catch (Exception e) { - logger.error(Strings.repeat("{} ", 3), MessageEnum.GENERAL_EXCEPTION.toString(), + logger.error(LoggingAnchor.THREE, MessageEnum.GENERAL_EXCEPTION.toString(), ErrorCode.SchemaError.getValue(), e.getMessage(), e); throw new MarshallerException(e.getMessage(), ErrorCode.SchemaError.getValue(), e); } |