diff options
author | Manoop Talasila <talasila@research.att.com> | 2019-07-09 15:16:43 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-07-09 15:16:43 +0000 |
commit | 85bcb7ccd7b7cae29364a5999a81523929c98f23 (patch) | |
tree | 1428a306c1626411d25c857621c34c0e6b5d1dfe | |
parent | 707952b0d04897f4ac944484a42c87ddab74124e (diff) | |
parent | 5609cc58c9e4abdb743bfcf0a66033f04452f23a (diff) |
Merge "Fix sonar issues in MusicService"
-rw-r--r-- | ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/service/MusicService.java | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/service/MusicService.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/service/MusicService.java index 2cbc5a94..a057c496 100644 --- a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/service/MusicService.java +++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/service/MusicService.java @@ -97,7 +97,7 @@ public class MusicService { * @return ReturnType that includes required body information for Music api * @throws Exception */ - public static ReturnType setAttribute(String attributeName, Object value, String sessionId) throws Exception { + public static ReturnType setAttribute(String attributeName, Object value, String sessionId) throws MusicLockingException { logger.debug(EELFLoggerDelegate.debugLogger, "setAttribute: start with id " + sessionId); String tableName = null; ReturnType result = null; @@ -168,7 +168,7 @@ public class MusicService { * @return MusicSession * @throws Exception */ - public static MusicSession getMetaAttribute(String sessionId) throws Exception { + public static MusicSession getMetaAttribute(String sessionId) throws MusicLockingException,MusicServiceException { logger.debug(EELFLoggerDelegate.debugLogger, "getMetaAttribute: start with session Id: "+ sessionId); ResultSet result = null; PreparedQueryObject queryObject = new PreparedQueryObject(); @@ -380,7 +380,7 @@ public class MusicService { public static RestResponse<String> setAttributeAPI(String attributeName, Object value, Session session, String sessionId, String className, boolean isMeta) throws JsonProcessingException { - System.out.println("setAttribute: " + attributeName); + logger.debug(EELFLoggerDelegate.debugLogger, "setAttribute: " + attributeName); RestResponse<String> portalRestResponse = null; HttpEntity<Map<String, Object>> entity = new HttpEntity<>( getMusicRestBody(attributeName, value, sessionId, session, className, isMeta), getMusicHeader()); @@ -390,6 +390,7 @@ public class MusicService { response = template.exchange(url, HttpMethod.POST, entity, String.class); portalRestResponse = new RestResponse<>(RestStatusEnum.OK, SUCCESS, response.getBody()); } catch (Exception e) { + logger.debug(EELFLoggerDelegate.debugLogger, e.getLocalizedMessage()); portalRestResponse = new RestResponse<>(RestStatusEnum.ERROR, e.getMessage(), null); } return portalRestResponse; @@ -407,7 +408,7 @@ public class MusicService { public static RestResponse<String> getAttributeAPI(String attributeName, Object value, String sessionId, boolean isMeta) { - System.out.println("getAttribute: " + attributeName); + logger.debug(EELFLoggerDelegate.debugLogger, "setAttribute: " + attributeName); RestResponse<String> portalRestResponse = null; HttpEntity<String> entity = new HttpEntity<>(null, getMusicHeader()); ResponseEntity<String> response = null; @@ -416,6 +417,7 @@ public class MusicService { response = template.exchange(url, HttpMethod.GET, entity, String.class); portalRestResponse = new RestResponse<>(RestStatusEnum.OK, SUCCESS, response.getBody()); } catch (Exception e) { + logger.debug(EELFLoggerDelegate.debugLogger, e.getLocalizedMessage()); portalRestResponse = new RestResponse<>(RestStatusEnum.ERROR, e.getMessage(), null); } return portalRestResponse; @@ -439,6 +441,7 @@ public class MusicService { response = template.exchange(url, HttpMethod.DELETE, entity, String.class); portalRestResponse = new RestResponse<>(RestStatusEnum.OK, SUCCESS, response.getBody()); } catch (Exception e) { + logger.debug(EELFLoggerDelegate.debugLogger, e.getLocalizedMessage()); portalRestResponse = new RestResponse<>(RestStatusEnum.ERROR, e.getMessage(), null); } return portalRestResponse; @@ -485,14 +488,14 @@ public class MusicService { * calls * @throws JsonProcessingException */ - public static Map<String, Object> getMusicDelRestBody(String attribute_name) { + public static Map<String, Object> getMusicDelRestBody(String attributeName) { Map<String, Object> map = new HashMap<>(); Map<String, String> consistencyInfoMap = new HashMap<>(); consistencyInfoMap.put(MusicProperties.getProperty(MusicProperties.MUSIC_CONSISTENCYINFO), MusicProperties.getProperty(MusicProperties.MUSIC_CONSISTENCYINFO_VALUE)); - if (attribute_name != null && !attribute_name.equals("")) { + if (attributeName != null && !attributeName.isEmpty()) { Map<String, String> conditionsMap = new HashMap<>(); - conditionsMap.put("attribute_name", attribute_name); + conditionsMap.put("attribute_name", attributeName); map.put("conditions", conditionsMap); } map.put("consistencyInfo", consistencyInfoMap); @@ -596,11 +599,11 @@ public class MusicService { */ public static void cleanUpMusic() { boolean timeToCleanUp = MusicUtil.cleanUp(); // Decide whether to clean up or not - ReturnType result = null; + if(timeToCleanUp){ /**Getting a list of sessions that need to be cleaned up*/ List<String> sessionIDList = getSessionToBeDeleted(); - if(sessionIDList!=null || sessionIDList.size()!=0){ + if(sessionIDList!=null || !sessionIDList.isEmpty()){ StringBuilder sessionIDListCondition = new StringBuilder(); sessionIDListCondition.append("('"); for(String s : sessionIDList){ @@ -621,9 +624,9 @@ public class MusicService { queryObject.appendQueryString(querySB.toString()); try{ if (isAtomicPut) - result = MusicCore.atomicPut(musicKeySpace, null, null, queryObject, null); + MusicCore.atomicPut(musicKeySpace, null, null, queryObject, null); else - result = MusicCore.eventualPut(queryObject); + MusicCore.eventualPut(queryObject); }catch(Exception e){ logger.error(EELFLoggerDelegate.errorLogger, "Error while cleaning up music attributes tables" , e); } @@ -639,9 +642,9 @@ public class MusicService { queryObject.appendQueryString(querySB.toString()); try{ if (isAtomicPut) - result = MusicCore.atomicPut(musicKeySpace, null, null, queryObject, null); + MusicCore.atomicPut(musicKeySpace, null, null, queryObject, null); else - result = MusicCore.eventualPut(queryObject); + MusicCore.eventualPut(queryObject); }catch(Exception e){ logger.error(EELFLoggerDelegate.errorLogger, "Error while cleaning up music meta tables" , e); } |