Search in sources :

Example 41 with Scheduled

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);
    }
}
Also used : User(io.github.jhipster.sample.domain.User) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 42 with Scheduled

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);
    }
}
Also used : User(io.github.jhipster.sample.domain.User) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 43 with Scheduled

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);
    });
}
Also used : User(io.github.jhipster.sample.domain.User) LocalDate(java.time.LocalDate) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 44 with Scheduled

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);
    });
}
Also used : User(io.github.jhipster.sample.domain.User) LocalDate(java.time.LocalDate) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 45 with Scheduled

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);
    }
}
Also used : User(io.github.jhipster.sample.domain.User) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Aggregations

Scheduled (org.springframework.scheduling.annotation.Scheduled)120 Date (java.util.Date)33 IOException (java.io.IOException)15 HashMap (java.util.HashMap)13 User (io.github.jhipster.sample.domain.User)8 List (java.util.List)8 Map (java.util.Map)8 File (java.io.File)7 ArrayList (java.util.ArrayList)7 SimpleDateFormat (java.text.SimpleDateFormat)6 Instant (java.time.Instant)6 LocalDate (java.time.LocalDate)6 SysConfig (com.itrus.portal.db.SysConfig)5 InetAddress (java.net.InetAddress)5 UnknownHostException (java.net.UnknownHostException)5 Contributor (ai.elimu.model.Contributor)4 Nabaztag (com.nabalive.data.core.model.Nabaztag)4 StoryBook (ai.elimu.model.content.StoryBook)3 Word (ai.elimu.model.content.Word)3 Locale (ai.elimu.model.enums.Locale)3