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;
 }
Example #10
0
 @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);
 }
Example #11
0
 public Collection<UserLogEntry> getUserLogEntries(Long userId) {
   return userRepository.loadUserLogEntries(userId);
 }
Example #12
0
 @Transactional(readOnly = false)
 public void saveUserLogEntry(UserLogEntry userLogEntry) {
   userRepository.storeUserLogEntry(userLogEntry);
 }
Example #13
0
 public UserProfile getUserProfile(Long id) {
   return userRepository.loadUserProfile(id);
 }
Example #14
0
 @Transactional(readOnly = false)
 public void deletePasswordRecoveryRequest(PasswordRecoveryRequest passwordRecoveryRequest) {
   logger.info("Deleting " + passwordRecoveryRequest);
   userRepository.deletePasswordRecoveryRequest(passwordRecoveryRequest);
 }
Example #15
0
 public PasswordRecoveryRequest findPasswordRecoveryRequest(String requestHash) {
   return userRepository.findPasswordRecoveryRequest(requestHash);
 }
Example #16
0
 public Group getGroupById(Long groupId) {
   return userRepository.loadGroupById(groupId);
 }
Example #17
0
 @Transactional(readOnly = false)
 public void updateUserProfile(UserProfile userProfile) {
   logger.info("Saving " + userProfile);
   userRepository.updateUserProfile(userProfile);
 }
Example #18
0
 @Transactional(readOnly = false)
 public void updateUser(User user) {
   logger.info("Saving " + user);
   userRepository.storeUser(user);
 }
Example #19
0
 public Collection<Community> getUserCommunities(Long userId) {
   return userRepository.loadUserCommunities(userId);
 }
Example #20
0
 public Community getCommunityById(Long communityId) {
   return userRepository.loadCommunityById(communityId);
 }
Example #21
0
 @Transactional(readOnly = false)
 public Community saveCommunity(Community community) {
   logger.info("Saving " + community);
   return userRepository.storeCommunity(community);
 }
Example #22
0
 public Integer getUserRequestForUserCount(Long userId) {
   return userRepository.getUserRequestForUserCount(userId);
 }
Example #23
0
 public Collection<Group> getUserGroups(Long userId) {
   return userRepository.loadUserGroups(userId);
 }
Example #24
0
 public UserDetails loadUserByUsername(String username)
     throws UsernameNotFoundException, DataAccessException {
   return userRepository.loadUserByUsername(username);
 }
Example #25
0
 public UserRequest getUserRequestById(Long requestId) {
   return userRepository.loadUserRequestById(requestId);
 }
Example #26
0
 @Transactional(readOnly = false)
 public void registerPasswordRecoveryRequest(PasswordRecoveryRequest passwordRecoveryRequest) {
   logger.info("Saving " + passwordRecoveryRequest);
   userRepository.storePasswordRecoveryRequest(passwordRecoveryRequest);
 }
Example #27
0
 public Collection<User> getAllUsers(User user, Integer lastLog, Integer lastReg) {
   return userRepository.loadAllUsers(user, lastLog, lastReg);
 }
Example #28
0
 public Collection<UserRequest> getUserRequestsByUserByType(
     Long userId, UserRequestType requestType) {
   return userRepository.loadUserRequestsByUser(userId, requestType);
 }
Example #29
0
 public boolean isUsernameExists(String username) {
   return userRepository.isUsernameExists(username);
 }
Example #30
0
 public Collection<Community> searchCommunities(String query) {
   return userRepository.findCommunities(query);
 }