@Transactional(readOnly = false) public void blockUser(Long userId) { User user = userRepository.loadUserByUserId(userId); user.setEnabled(!user.isEnabled()); logger.info("Blocking " + user); userRepository.storeUser(user); }
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 getUserByUserId(Long userId) { return userRepository.loadUserByUserId(userId); }