use of org.survey.model.user.User in project survey by markoniemi.
the class UserServiceTestBase method delete.
@Test
public void delete() {
create();
for (int i = 0; i < ENTITY_COUNT; i++) {
User entity = orginalEntities.get(i);
entityService.delete(entity.getUsername());
Assert.assertFalse(entityService.exists(entity.getUsername()));
}
Assert.assertEquals(0, entityService.count());
}
use of org.survey.model.user.User in project survey by markoniemi.
the class EditUserBean method addUser.
public String addUser() {
user = new User();
user.setRole(Role.ROLE_USER);
return "addUser";
}
use of org.survey.model.user.User in project survey by markoniemi.
the class UserRepositoryAuthenticationProvider method authenticate.
/**
* Authenticate using UserRepository.
*/
@Override
public Authentication authenticate(Authentication authentication) {
log.debug("authenticate:" + authentication.getName());
User user = userService.findOne(authentication.getName());
return UserRepositoryAuthenticationProvider.authenticateUser(user, authentication);
}
use of org.survey.model.user.User in project survey by markoniemi.
the class PollServiceImpl method findByOwner.
public Poll[] findByOwner(String username) {
User user = userRepository.findByUsername(username);
if (user == null) {
return EMPTY_POLL_ARRAY;
}
Iterable<Poll> polls = pollRepository.findAllByOwner(user);
// return empty list instead of null
if (Iterables.isEmpty(polls)) {
return EMPTY_POLL_ARRAY;
} else {
return Iterables.toArray(polls, Poll.class);
}
}
use of org.survey.model.user.User in project survey by markoniemi.
the class UserServiceImpl method delete.
@Override
public void delete(String username) {
log.trace("delete: {}", username);
User user = userRepository.findByUsername(username);
// Validate.notNull(user, "User does not exist.");
if (user == null) {
return;
}
List<File> files = fileRepository.findAllByOwner(user);
fileRepository.delete(files);
userRepository.delete(user.getId());
}
Aggregations