public Collection<User> searchUsers(UserSearchForm searchForm) { List<User> result = new ArrayList<User>(); Long userId = searchForm.getUserId(); String username = searchForm.getUsername(); String nameOrSurname = searchForm.getNameOrSurname(); String email = searchForm.getEmail(); if (userId != null) { User user = userRepository.loadUserByUserId(userId); if (user != null) { result.add(user); } } else if (username != null && username.length() > 0) { User user = null; try { user = userRepository.loadUserByUsername(username); } catch (Exception e) { // user not found } if (user != null) { result.add(user); } } else { if (nameOrSurname != null && nameOrSurname.length() > 0) { result.addAll(userRepository.findUsersByNameOrSurname(nameOrSurname)); } if (email != null && email.length() > 0) { result.addAll(userRepository.findUsersByEmail(email)); } } return result; }
public User getUserByUsername(String username) { User user = null; try { user = userRepository.loadUserByUsername(username); } catch (Exception ex) { logger.error(ex); } return user; }
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { return userRepository.loadUserByUsername(username); }