diff options
author | Arindam Mondal <arind.mondal@samsung.com> | 2019-09-16 16:47:30 +0900 |
---|---|---|
committer | arindamm <arind.mondal@samsung.com> | 2019-09-16 16:48:56 +0900 |
commit | f270ebe165d6fac318f17a7b3d3bbcdb5ce1aac6 (patch) | |
tree | fa8a3a316ed204253c9f4d07203cec569fa8a529 /ecomp-sdk/epsdk-analytics/src | |
parent | 6529859fc521c3f82d399aaa90cee6521d5b9401 (diff) |
General Sonar Fixes
Issue-ID: PORTAL-740
Change-Id: I050c3ffa64ae95eadca3a99ec149736fa9dbde67
Signed-off-by: arindamm <arind.mondal@samsung.com>
Diffstat (limited to 'ecomp-sdk/epsdk-analytics/src')
-rw-r--r-- | ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/RaptorAdapter.java | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/RaptorAdapter.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/RaptorAdapter.java index fc5fdb36..c934f8d4 100644 --- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/RaptorAdapter.java +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/RaptorAdapter.java @@ -76,6 +76,7 @@ public class RaptorAdapter extends FusionAdapter { public static final int RAPTOR_USER_ID = 20000; // RAPTOR system user id (for auditing purposes) public static final String RAPTOR_CONTROLLER_CLASSNAME = "org.onap.portalsdk.analytics.controller.Controller"; public static final String KEY_USER_ROLES_CACHE = "userRoles"; + private static final String USER_ID = "user_id"; public void initializeRaptor() { org.onap.portalsdk.analytics.config.ConfigLoader.setConfigFilesPath(SystemProperties.getProperty(SystemProperties.RAPTOR_CONFIG_FILE_PATH)); @@ -86,7 +87,6 @@ public class RaptorAdapter extends FusionAdapter { /** Returns ID of the user currently logged in */ public static String getUserID(HttpServletRequest request) { return String.valueOf(UserUtils.getUserId(request)); - //return null; } public static String getUserID(String user_id) { @@ -95,7 +95,9 @@ public class RaptorAdapter extends FusionAdapter { public static String getUserBackdoorLoginId(HttpServletRequest request) { - if(AppUtils.getRequestNvlValue(request, "login_id").length()>0) return AppUtils.getRequestNvlValue(request, "login_id"); + if (AppUtils.getRequestNvlValue(request, "login_id").length() > 0) { + return AppUtils.getRequestNvlValue(request, "login_id"); + } return String.valueOf(UserUtils.getUserSession(request).getLoginId()); } @@ -106,19 +108,17 @@ public class RaptorAdapter extends FusionAdapter { /** Obtains user name by ID */ public static String getUserName(String userId) { Map<String, Long> params = new HashMap<String, Long>(); - params.put("user_id", new Long(userId)); + params.put(USER_ID, new Long(userId)); List list = getDataAccessService().executeNamedQuery("getUserNameById", params, null); String firstName = ""; String lastName = ""; - if (list != null) { - if (!list.isEmpty()) { + if (list != null && !list.isEmpty()) { Object[] user = (Object[]) list.get(0); firstName = (String) user[0]; // firstName scalar lastName = (String) user[1]; // lastName scalar - } } return lastName + ", " + firstName; @@ -131,7 +131,7 @@ public class RaptorAdapter extends FusionAdapter { public static String getUserEmail(String userId) { Map<String, Long> params = new HashMap<String, Long>(); - params.put("user_id", new Long(userId)); + params.put(USER_ID, new Long(userId)); List list = getDataAccessService().executeNamedQuery("getUserEmail", params, null); String email = ""; if (list != null && !list.isEmpty()) @@ -148,8 +148,8 @@ public class RaptorAdapter extends FusionAdapter { String loginId = ""; try{ - List<Criterion> restrictionsList = new ArrayList<Criterion>(); - Criterion criterion1 = Restrictions.eq("user_id", userId); + List<Criterion> restrictionsList = new ArrayList<>(); + Criterion criterion1 = Restrictions.eq(USER_ID, userId); restrictionsList.add(criterion1); List list = getDataAccessService().getList(User.class, null, restrictionsList, null); if (list != null) { @@ -173,7 +173,7 @@ public class RaptorAdapter extends FusionAdapter { /** Obtains list of all users (in IdNameValue objects) */ public static Map<Long, String> getAllUsers(String customizedQuery, String param, boolean isAdmin) { List users = null; - Map<Long, String> map = new LinkedHashMap<Long, String>(); + Map<Long, String> map = new LinkedHashMap<>(); if(customizedQuery.length()>0 && !isAdmin) { |