summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-music/src/main/java/org
diff options
context:
space:
mode:
authorManoop Talasila <talasila@research.att.com>2019-04-16 21:09:39 +0000
committerGerrit Code Review <gerrit@onap.org>2019-04-16 21:09:39 +0000
commitb775445aaa69c360aa1d8c44bbadb4713eb1271c (patch)
tree043dbc3cc9e0fab67c0195328e756ca52c00d0c7 /ecomp-sdk/epsdk-music/src/main/java/org
parentacdf1fd34f18160ff889179c690b24da04943101 (diff)
parent46b89e410acbb2ecbab4cac6382c92da57fffe1d (diff)
Merge "Fix sonar issues in MusicUtil"
Diffstat (limited to 'ecomp-sdk/epsdk-music/src/main/java/org')
-rw-r--r--ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicUtil.java35
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);
}
}