Beispiel #1
0
 @Transactional
 public UserDetails loadUserByUsername(String username)
     throws UsernameNotFoundException, DataAccessException {
   User u = userDao.getUserByName(username);
   if (u == null) {
     throw new UsernameNotFoundException("User '" + username + "' was not found");
   }
   //        LOG.debug("admin would be:" + passwordEncoder.encodePassword("admin", new Long(83)));
   return u;
 }
Beispiel #2
0
 @Transactional
 public void deleteUser(long id) {
   User u = userDao.getUserById(id);
   Role adminRole = roleService.getAdminRole();
   int articleCount = articleService.getArticleCountByUser(u);
   int adminCount = userDao.getAdminUserCount();
   LOG.debug("trying to delete user " + u.getUsername());
   LOG.debug("global admin count: " + adminCount);
   LOG.debug("is admin user: "******"number articles associated: " + articleCount);
   if (u.getAuthorities().contains(adminRole) && adminCount == 1) {
     LOG.error("cant delete last admin user");
     return;
   }
   if (articleCount > 0) {
     LOG.error("User still has articles associated");
     return;
   }
   LOG.debug("deleting user " + u.getUsername());
   userDao.deleteUser(u);
 }
Beispiel #3
0
 @Transactional
 public void saveUser(User u) {
   userDao.saveOrUpdate(u);
 }
Beispiel #4
0
 @Transactional
 public List<User> getAllUsers() {
   return userDao.getAllUsers();
 }
Beispiel #5
0
 @Transactional
 public int getUserCount() {
   return userDao.getUserCount();
 }
Beispiel #6
0
 @Transactional
 public void addUser(User u, String pass) {
   userDao.saveOrUpdate(u);
   u.setPassword(passwordEncoder.encodePassword(pass, u.getId()));
   userDao.saveOrUpdate(u);
 }
Beispiel #7
0
 @Transactional
 public User getUserById(long id) {
   return userDao.getUserById(id);
 }