use of org.springframework.scheduling.annotation.Scheduled in project jhipster-sample-app-dto by jhipster.
the class UserService method removeNotActivatedUsers.
/**
* Not activated users should be automatically deleted after 3 days.
* <p>
* This is scheduled to get fired everyday, at 01:00 (am).
*/
@Scheduled(cron = "0 0 1 * * ?")
public void removeNotActivatedUsers() {
List<User> users = userRepository.findAllByActivatedIsFalseAndCreatedDateBefore(Instant.now().minus(3, ChronoUnit.DAYS));
for (User user : users) {
log.debug("Deleting not activated user {}", user.getLogin());
userRepository.delete(user);
this.clearUserCaches(user);
}
}
use of org.springframework.scheduling.annotation.Scheduled in project jhipster-sample-app-websocket by jhipster.
the class UserService method removeNotActivatedUsers.
/**
* Not activated users should be automatically deleted after 3 days.
* <p>
* This is scheduled to get fired everyday, at 01:00 (am).
*/
@Scheduled(cron = "0 0 1 * * ?")
public void removeNotActivatedUsers() {
List<User> users = userRepository.findAllByActivatedIsFalseAndCreatedDateBefore(Instant.now().minus(3, ChronoUnit.DAYS));
for (User user : users) {
log.debug("Deleting not activated user {}", user.getLogin());
userRepository.delete(user);
this.clearUserCaches(user);
}
}
use of org.springframework.scheduling.annotation.Scheduled in project jhipster-sample-app-websocket by jhipster.
the class UserService method removeOldPersistentTokens.
/**
* Persistent Token are used for providing automatic authentication, they should be automatically deleted after
* 30 days.
* <p>
* This is scheduled to get fired everyday, at midnight.
*/
@Scheduled(cron = "0 0 0 * * ?")
public void removeOldPersistentTokens() {
LocalDate now = LocalDate.now();
persistentTokenRepository.findByTokenDateBefore(now.minusMonths(1)).forEach(token -> {
log.debug("Deleting token {}", token.getSeries());
User user = token.getUser();
user.getPersistentTokens().remove(token);
persistentTokenRepository.delete(token);
});
}
use of org.springframework.scheduling.annotation.Scheduled in project jhipster-sample-app-hazelcast by jhipster.
the class UserService method removeOldPersistentTokens.
/**
* Persistent Token are used for providing automatic authentication, they should be automatically deleted after
* 30 days.
* <p>
* This is scheduled to get fired everyday, at midnight.
*/
@Scheduled(cron = "0 0 0 * * ?")
public void removeOldPersistentTokens() {
LocalDate now = LocalDate.now();
persistentTokenRepository.findByTokenDateBefore(now.minusMonths(1)).forEach(token -> {
log.debug("Deleting token {}", token.getSeries());
User user = token.getUser();
user.getPersistentTokens().remove(token);
persistentTokenRepository.delete(token);
});
}
use of org.springframework.scheduling.annotation.Scheduled in project jhipster-sample-app-elasticsearch by jhipster.
the class UserService method removeNotActivatedUsers.
/**
* Not activated users should be automatically deleted after 3 days.
* <p>
* This is scheduled to get fired everyday, at 01:00 (am).
*/
@Scheduled(cron = "0 0 1 * * ?")
public void removeNotActivatedUsers() {
List<User> users = userRepository.findAllByActivatedIsFalseAndCreatedDateBefore(Instant.now().minus(3, ChronoUnit.DAYS));
for (User user : users) {
log.debug("Deleting not activated user {}", user.getLogin());
userRepository.delete(user);
userSearchRepository.delete(user);
this.clearUserCaches(user);
}
}
Aggregations