示例#1
0
  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;
  }
示例#2
0
 @Transactional(readOnly = false)
 public void blockUser(Long userId) {
   User user = userRepository.loadUserByUserId(userId);
   user.setEnabled(!user.isEnabled());
   logger.info("Blocking " + user);
   userRepository.storeUser(user);
 }
示例#3
0
 @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);
   }
 }
示例#4
0
 @Transactional(readOnly = false)
 public void deleteUserRequest(Long requestId) {
   UserRequest userRequest = userRepository.loadUserRequestById(requestId);
   if (userRequest != null) {
     logger.info("Deleting " + userRequest);
     userRepository.deleteUserRequest(userRequest);
   }
 }
示例#5
0
 @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);
   }
 }
示例#6
0
 @Transactional(readOnly = false)
 public void saveGroup(Group group) {
   for (Long memberId : group.getMembersIdSet()) {
     group.addMember(getUserProfileByUserId(memberId));
   }
   logger.info("Saving " + group);
   userRepository.storeGroup(group);
 }
示例#7
0
 public User getUserByUsername(String username) {
   User user = null;
   try {
     user = userRepository.loadUserByUsername(username);
   } catch (Exception ex) {
     logger.error(ex);
   }
   return user;
 }
示例#8
0
 public User getUserByEmail(String email) {
   User user = null;
   try {
     user = userRepository.loadUserByEmail(email);
   } catch (Exception ex) {
     logger.error(ex);
   }
   return user;
 }
示例#9
0
 @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;
 }
示例#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);
 }
示例#11
0
 public Collection<UserLogEntry> getUserLogEntries(Long userId) {
   return userRepository.loadUserLogEntries(userId);
 }
示例#12
0
 @Transactional(readOnly = false)
 public void saveUserLogEntry(UserLogEntry userLogEntry) {
   userRepository.storeUserLogEntry(userLogEntry);
 }
示例#13
0
 public UserProfile getUserProfile(Long id) {
   return userRepository.loadUserProfile(id);
 }
示例#14
0
 @Transactional(readOnly = false)
 public void deletePasswordRecoveryRequest(PasswordRecoveryRequest passwordRecoveryRequest) {
   logger.info("Deleting " + passwordRecoveryRequest);
   userRepository.deletePasswordRecoveryRequest(passwordRecoveryRequest);
 }
示例#15
0
 public PasswordRecoveryRequest findPasswordRecoveryRequest(String requestHash) {
   return userRepository.findPasswordRecoveryRequest(requestHash);
 }
示例#16
0
 public Group getGroupById(Long groupId) {
   return userRepository.loadGroupById(groupId);
 }
示例#17
0
 @Transactional(readOnly = false)
 public void updateUserProfile(UserProfile userProfile) {
   logger.info("Saving " + userProfile);
   userRepository.updateUserProfile(userProfile);
 }
示例#18
0
 @Transactional(readOnly = false)
 public void updateUser(User user) {
   logger.info("Saving " + user);
   userRepository.storeUser(user);
 }
示例#19
0
 public Collection<Community> getUserCommunities(Long userId) {
   return userRepository.loadUserCommunities(userId);
 }
示例#20
0
 public Community getCommunityById(Long communityId) {
   return userRepository.loadCommunityById(communityId);
 }
示例#21
0
 @Transactional(readOnly = false)
 public Community saveCommunity(Community community) {
   logger.info("Saving " + community);
   return userRepository.storeCommunity(community);
 }
示例#22
0
 public Integer getUserRequestForUserCount(Long userId) {
   return userRepository.getUserRequestForUserCount(userId);
 }
示例#23
0
 public Collection<Group> getUserGroups(Long userId) {
   return userRepository.loadUserGroups(userId);
 }
示例#24
0
 public UserDetails loadUserByUsername(String username)
     throws UsernameNotFoundException, DataAccessException {
   return userRepository.loadUserByUsername(username);
 }
示例#25
0
 public UserRequest getUserRequestById(Long requestId) {
   return userRepository.loadUserRequestById(requestId);
 }
示例#26
0
 @Transactional(readOnly = false)
 public void registerPasswordRecoveryRequest(PasswordRecoveryRequest passwordRecoveryRequest) {
   logger.info("Saving " + passwordRecoveryRequest);
   userRepository.storePasswordRecoveryRequest(passwordRecoveryRequest);
 }
示例#27
0
 public Collection<User> getAllUsers(User user, Integer lastLog, Integer lastReg) {
   return userRepository.loadAllUsers(user, lastLog, lastReg);
 }
示例#28
0
 public Collection<UserRequest> getUserRequestsByUserByType(
     Long userId, UserRequestType requestType) {
   return userRepository.loadUserRequestsByUser(userId, requestType);
 }
示例#29
0
 public boolean isUsernameExists(String username) {
   return userRepository.isUsernameExists(username);
 }
示例#30
0
 public Collection<Community> searchCommunities(String query) {
   return userRepository.findCommunities(query);
 }