summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManoop Talasila <talasila@research.att.com>2019-09-19 14:47:31 +0000
committerGerrit Code Review <gerrit@onap.org>2019-09-19 14:47:31 +0000
commitb033195c3eae493aedbaba8b2eb37c542b96ac6f (patch)
treedeff13bd4b134aee17be72ec099cb6a23aaedcf3
parent9185b3621ec4b5b8f5e5efd7b71efed458db572d (diff)
parentf270ebe165d6fac318f17a7b3d3bbcdb5ce1aac6 (diff)
Merge "General Sonar Fixes"
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/adapter/RaptorAdapter.java20
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/CadiAuthFilter.java4
-rw-r--r--ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/AuthUtil.java2
3 files changed, 13 insertions, 13 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) {
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/CadiAuthFilter.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/CadiAuthFilter.java
index 2336a514..a5a2b2ba 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/CadiAuthFilter.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/crossapi/CadiAuthFilter.java
@@ -79,8 +79,8 @@ public class CadiAuthFilter extends CadiFilter {
throw new ServletException("Filter init parameter " + INCLUDE_URL_ENDPOINTS + " is null or empty");
if (exclude_url_endpoints == null || exclude_url_endpoints.isEmpty())
throw new ServletException("Filter init parameter " + EXCLUDE_URL_ENDPOINTS + " is null or empty");
- includeUrlEndPointList = new ArrayList<String>(Arrays.asList(include_url_endpoints.split(",")));
- excludeUrlEndPointList = new ArrayList<String>(Arrays.asList(exclude_url_endpoints.split(",")));
+ includeUrlEndPointList = new ArrayList<>(Arrays.asList(include_url_endpoints.split(",")));
+ excludeUrlEndPointList = new ArrayList<>(Arrays.asList(exclude_url_endpoints.split(",")));
}
@Override
diff --git a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/AuthUtil.java b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/AuthUtil.java
index ac310805..2e47768a 100644
--- a/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/AuthUtil.java
+++ b/ecomp-sdk/epsdk-fw/src/main/java/org/onap/portalsdk/core/onboarding/util/AuthUtil.java
@@ -204,7 +204,7 @@ public class AuthUtil {
logger.debug("Request is Authorized");
}
} catch (ClassCastException e) {
- logger.warn("Given request is not CADI request: " + e.toString());
+ logger.warn("Given request is not CADI request: ", e);
if (appCredentials.isEmpty()) {
logger.debug("app credentails are empty");