summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-BE-common
diff options
context:
space:
mode:
authorDominik Mizyn <d.mizyn@samsung.com>2019-07-01 12:08:24 +0200
committerDominik Mizyn <d.mizyn@samsung.com>2019-07-01 12:08:31 +0200
commit5d4fa2e1843eb947c05c24d379240069b7533dd9 (patch)
tree18e460382a5b7070af1fad2a5817d85a10486f3e /ecomp-portal-BE-common
parentb8d51d3080fe8c99b70b3a62ed484ad9ef267ba9 (diff)
LanguageServiceImpl logging vulnerability fix
Sonar issue: "Use a logger to log this exception" fix This patch also minor code issues Issue-ID: PORTAL-622 Change-Id: I304285ca7837bcf929249f7c6b93b6de9cf8fae5 Signed-off-by: Dominik Mizyn <d.mizyn@samsung.com>
Diffstat (limited to 'ecomp-portal-BE-common')
-rw-r--r--ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/LanguageServiceImpl.java34
1 files changed, 20 insertions, 14 deletions
diff --git a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/LanguageServiceImpl.java b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/LanguageServiceImpl.java
index 1aa12b21..17b12634 100644
--- a/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/LanguageServiceImpl.java
+++ b/ecomp-portal-BE-common/src/main/java/org/onap/portalapp/portal/service/LanguageServiceImpl.java
@@ -1,4 +1,4 @@
-/**
+/*
* Copyright (C) 2019 CMCC, Inc. and others. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,28 +13,33 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
package org.onap.portalapp.portal.service;
import com.alibaba.fastjson.JSONObject;
-
-import antlr.StringUtils;
-
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.onap.music.eelf.logging.EELFLoggerDelegate;
import org.onap.portalapp.portal.domain.EPUser;
import org.onap.portalapp.portal.domain.Language;
import org.onap.portalsdk.core.service.DataAccessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
@Service
public class LanguageServiceImpl implements LanguageService {
+ private final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(LanguageServiceImpl.class);
+
+ private final DataAccessService dataAccessService;
@Autowired
- private DataAccessService dataAccessService;
+ public LanguageServiceImpl(DataAccessService dataAccessService) {
+ this.dataAccessService = dataAccessService;
+ }
+
+ @SuppressWarnings("unchecked")
@Override
public JSONObject getLanguages() {
List<Language> languages = (List<Language>) dataAccessService.executeNamedQuery("queryLanguage",null,new HashMap());
@@ -44,7 +49,7 @@ public class LanguageServiceImpl implements LanguageService {
}
@Override
- public String setUpUserLanguage(Integer languageId, String loginId) throws Exception{
+ public String setUpUserLanguage(Integer languageId, String loginId) {
Map<String,Object> params = new HashMap<>();
params.put("login_id",loginId);
params.put("language_id",languageId);
@@ -52,13 +57,14 @@ public class LanguageServiceImpl implements LanguageService {
return "success";
}
+ @SuppressWarnings("unchecked")
@Override
public JSONObject getUserLanguage(String loginId) {
// get language_id from fn_user by loginId
- JSONObject result = new com.alibaba.fastjson.JSONObject();
+ JSONObject result = new JSONObject();
HashMap getUserParams = new HashMap();
getUserParams.put("login_id", loginId);
- List<EPUser> userList= null;
+ List<EPUser> userList;
try {
userList = dataAccessService.executeNamedQuery("getEPUserByLoginId", getUserParams, new HashMap());
@@ -70,7 +76,7 @@ public class LanguageServiceImpl implements LanguageService {
// get language name and alias from fn_language by languageId
HashMap<String,String> getLangParams = new HashMap();
getLangParams.put("language_id", String.valueOf(languageId));
- List<Language> languageList = null;
+ List<Language> languageList;
languageList = dataAccessService.executeNamedQuery("queryLanguageByLanguageId", getLangParams, new HashMap());
if (languageList != null && languageList.size() > 0) {
@@ -79,7 +85,7 @@ public class LanguageServiceImpl implements LanguageService {
}
}
} catch (Exception e) {
- e.printStackTrace();
+ logger.debug(EELFLoggerDelegate.debugLogger, e.getMessage());
}
return result;
}