diff options
author | burdziak <olaf.burdziakowski@nokia.com> | 2019-07-08 14:47:39 +0200 |
---|---|---|
committer | burdziak <olaf.burdziakowski@nokia.com> | 2019-07-08 14:47:39 +0200 |
commit | 5609cc58c9e4abdb743bfcf0a66033f04452f23a (patch) | |
tree | 8bc2a1e8337eef6b449f380eba661818e3e1de0d | |
parent | 179ff1eb0c1ac9eef4d152c47df5cb12a4584c0f (diff) |
Fix sonar issues in MusicService
Change-Id: Ie5426cad77194eea3b328b22f7b1adaa5b9043a2
Issue-ID: PORTAL-523
Signed-off-by: burdziak <olaf.burdziakowski@nokia.com>
-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); } |