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; }
@Transactional(readOnly = false) public void blockUser(Long userId) { User user = userRepository.loadUserByUserId(userId); user.setEnabled(!user.isEnabled()); logger.info("Blocking " + user); userRepository.storeUser(user); }
@Transactional(readOnly = false) public void deleteCommunity(Long communityId, Long userId) { Community community = userRepository.loadCommunityById(communityId); if (community.checkOwnership(userId) && community.getMembers().size() == 1) { logger.info("Deleting " + community); userRepository.deleteCommunity(community); } }
@Transactional(readOnly = false) public void deleteUserRequest(Long requestId) { UserRequest userRequest = userRepository.loadUserRequestById(requestId); if (userRequest != null) { logger.info("Deleting " + userRequest); userRepository.deleteUserRequest(userRequest); } }
@Transactional(readOnly = false) public void deleteGroup(Long groupId, Long userId) { Group group = userRepository.loadGroupById(groupId); if (group.checkOwnership(userId)) { logger.info("Deleting " + group); userRepository.deleteGroup(group); } }
@Transactional(readOnly = false) public void saveGroup(Group group) { for (Long memberId : group.getMembersIdSet()) { group.addMember(getUserProfileByUserId(memberId)); } logger.info("Saving " + group); userRepository.storeGroup(group); }
public User getUserByUsername(String username) { User user = null; try { user = userRepository.loadUserByUsername(username); } catch (Exception ex) { logger.error(ex); } return user; }
public User getUserByEmail(String email) { User user = null; try { user = userRepository.loadUserByEmail(email); } catch (Exception ex) { logger.error(ex); } return user; }
@Transactional(readOnly = false) public Long registerUser(User user, Locale locale) { user.addRole("ROLE_USER"); logger.info("Registering " + user); Long userId = userRepository.registerUser(user); if (userId != null) { sendRegistrationWelcomeEmail(user.getUserProfile(), locale); } return userId; }
@Transactional(readOnly = false) public void sendUserRequest(UserRequest userRequest) { for (UserRequest request : getAllUserRequestsByUser(userRequest.getOwnerId())) { if (request.getInviteeId().compareTo(userRequest.getInviteeId()) == 0 && request.getRequestType() == userRequest.getRequestType()) { return; // Do not send duplicate requests } } logger.info("Sending " + userRequest); userRepository.storeUserRequest(userRequest); }
public Collection<UserLogEntry> getUserLogEntries(Long userId) { return userRepository.loadUserLogEntries(userId); }
@Transactional(readOnly = false) public void saveUserLogEntry(UserLogEntry userLogEntry) { userRepository.storeUserLogEntry(userLogEntry); }
public UserProfile getUserProfile(Long id) { return userRepository.loadUserProfile(id); }
@Transactional(readOnly = false) public void deletePasswordRecoveryRequest(PasswordRecoveryRequest passwordRecoveryRequest) { logger.info("Deleting " + passwordRecoveryRequest); userRepository.deletePasswordRecoveryRequest(passwordRecoveryRequest); }
public PasswordRecoveryRequest findPasswordRecoveryRequest(String requestHash) { return userRepository.findPasswordRecoveryRequest(requestHash); }
public Group getGroupById(Long groupId) { return userRepository.loadGroupById(groupId); }
@Transactional(readOnly = false) public void updateUserProfile(UserProfile userProfile) { logger.info("Saving " + userProfile); userRepository.updateUserProfile(userProfile); }
@Transactional(readOnly = false) public void updateUser(User user) { logger.info("Saving " + user); userRepository.storeUser(user); }
public Collection<Community> getUserCommunities(Long userId) { return userRepository.loadUserCommunities(userId); }
public Community getCommunityById(Long communityId) { return userRepository.loadCommunityById(communityId); }
@Transactional(readOnly = false) public Community saveCommunity(Community community) { logger.info("Saving " + community); return userRepository.storeCommunity(community); }
public Integer getUserRequestForUserCount(Long userId) { return userRepository.getUserRequestForUserCount(userId); }
public Collection<Group> getUserGroups(Long userId) { return userRepository.loadUserGroups(userId); }
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { return userRepository.loadUserByUsername(username); }
public UserRequest getUserRequestById(Long requestId) { return userRepository.loadUserRequestById(requestId); }
@Transactional(readOnly = false) public void registerPasswordRecoveryRequest(PasswordRecoveryRequest passwordRecoveryRequest) { logger.info("Saving " + passwordRecoveryRequest); userRepository.storePasswordRecoveryRequest(passwordRecoveryRequest); }
public Collection<User> getAllUsers(User user, Integer lastLog, Integer lastReg) { return userRepository.loadAllUsers(user, lastLog, lastReg); }
public Collection<UserRequest> getUserRequestsByUserByType( Long userId, UserRequestType requestType) { return userRepository.loadUserRequestsByUser(userId, requestType); }
public boolean isUsernameExists(String username) { return userRepository.isUsernameExists(username); }
public Collection<Community> searchCommunities(String query) { return userRepository.findCommunities(query); }