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));
/** 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) {
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());
}
/** 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;
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())
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) {
/** 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) {