diff options
author | burdziak <olaf.burdziakowski@nokia.com> | 2019-04-12 12:58:24 +0200 |
---|---|---|
committer | burdziak <olaf.burdziakowski@nokia.com> | 2019-04-12 12:58:24 +0200 |
commit | 46b89e410acbb2ecbab4cac6382c92da57fffe1d (patch) | |
tree | dcf697e8921bd058221c92c836fb052c97bb94ac /ecomp-sdk/epsdk-music/src/main/java | |
parent | 2c6c55376190b63c8bcb76ba876b0a54f9d4fcc5 (diff) |
Fix sonar issues in MusicUtil
Change-Id: I19b7515c8bfcd614f3bf417267f0e53793ea53a2
Issue-ID: PORTAL-523
Signed-off-by: burdziak <olaf.burdziakowski@nokia.com>
Diffstat (limited to 'ecomp-sdk/epsdk-music/src/main/java')
-rw-r--r-- | ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicUtil.java | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicUtil.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicUtil.java index 15c3bb0c..2e17d0c1 100644 --- a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicUtil.java +++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicUtil.java @@ -68,11 +68,18 @@ public class MusicUtil { private static String cleanUpFreq = MusicProperties.getProperty(MusicProperties.MUSIC_CLEAN_UP_FREQUENCY); private static String musicSerializeCompress = MusicProperties.getProperty(MusicProperties.MUSIC_SERIALIZE_COMPRESS); private static String musicEnable = MusicProperties.getProperty(MusicProperties.MUSIC_ENABLE); + private static final String FAILED_2_READ_PROPERTY_FILE = "Failed to read property file "; + private static final String TRUE = "true"; public static boolean isSessionMetaAttr(String key){ return sessionAttrNameSet.contains(key); } + //hide public constructor + private MusicUtil() + { + } + @SuppressWarnings("unchecked") public static <T> T musicRestResponseDataParsing(ResultSet rs, String attributeName) throws Exception{ logger.debug(EELFLoggerDelegate.debugLogger, "musicRestResponseDataParsing: start"); @@ -87,7 +94,7 @@ public class MusicUtil { } @SuppressWarnings("unchecked") - public static <T> T musicDeserialize (ByteBuffer byteBuf) throws Exception{ + public static <T> T musicDeserialize (ByteBuffer byteBuf) throws IOException, ClassNotFoundException { logger.debug(EELFLoggerDelegate.debugLogger, "musicDeserialize: start"); ByteArrayInputStream byteArr = new ByteArrayInputStream(byteBuf.array()); ObjectInputStream ois = null; @@ -100,7 +107,7 @@ public class MusicUtil { return (T) ois.readObject(); } - public static ByteBuffer musicSerialize (Object value) throws Exception{ + public static ByteBuffer musicSerialize (Object value) { logger.debug(EELFLoggerDelegate.debugLogger, "musicSerialize: start"); ByteArrayOutputStream bo = new ByteArrayOutputStream(); try { @@ -121,7 +128,7 @@ public class MusicUtil { return ByteBuffer.wrap(bo.toByteArray()); } - public static MusicSession parseMetaData (Row row) throws Exception{ + public static MusicSession parseMetaData (Row row) { logger.debug(EELFLoggerDelegate.debugLogger, "parseMetaData: start"); if(row==null) @@ -157,34 +164,34 @@ public class MusicUtil { public static boolean isMusicSerializeCompress(){ if(musicSerializeCompress==null){ - logger.error(EELFLoggerDelegate.errorLogger, "Failed to read property file " + MusicProperties.MUSIC_SERIALIZE_COMPRESS +" fall back to eventual put"); + logger.error(EELFLoggerDelegate.errorLogger, FAILED_2_READ_PROPERTY_FILE + MusicProperties.MUSIC_SERIALIZE_COMPRESS +" fall back to eventual put"); return false; } - return musicSerializeCompress.trim().equalsIgnoreCase("true"); + return TRUE.equalsIgnoreCase(musicSerializeCompress.trim()); } public static boolean isAtomicPut(){ if(atomicPut==null){ - logger.error(EELFLoggerDelegate.errorLogger, "Failed to read property file " + MusicProperties.MUSIC_ATOMIC_PUT +" fall back to eventual put"); + logger.error(EELFLoggerDelegate.errorLogger, FAILED_2_READ_PROPERTY_FILE + MusicProperties.MUSIC_ATOMIC_PUT +" fall back to eventual put"); return false; } - return atomicPut.trim().equalsIgnoreCase("true"); + return TRUE.equalsIgnoreCase(atomicPut.trim()); } public static boolean isAtomicGet(){ if(atomicGet==null){ - logger.error(EELFLoggerDelegate.errorLogger, "Failed to read property file " + MusicProperties.MUSIC_ATOMIC_GET +" fall back to eventual get"); + logger.error(EELFLoggerDelegate.errorLogger, FAILED_2_READ_PROPERTY_FILE + MusicProperties.MUSIC_ATOMIC_GET +" fall back to eventual get"); return false; } - return atomicGet.trim().equalsIgnoreCase("true"); + return TRUE.equalsIgnoreCase(atomicGet.trim()); } public static boolean isCached(){ if(cached==null){ - logger.error(EELFLoggerDelegate.errorLogger, "Failed to read property file " + MusicProperties.MUSIC_CACHE +" fall back to non cache"); + logger.error(EELFLoggerDelegate.errorLogger, FAILED_2_READ_PROPERTY_FILE + MusicProperties.MUSIC_CACHE +" fall back to non cache"); return false; } - return cached.trim().equalsIgnoreCase("true"); + return TRUE.equalsIgnoreCase(cached.trim()); } public static int convertHoursToMillSec(int hour){ @@ -211,9 +218,7 @@ public class MusicUtil { public static boolean isMusicEnable(){ if(musicEnable==null) return false; - if(musicEnable.equals("true")) - return true; - else - return false; + + return TRUE.equals(musicEnable); } } |