1
2
3
4
5
6
7 package ch.colabproject.colab.api.controller;
8
9 import ch.colabproject.colab.api.controller.document.ExternalDataManager;
10 import ch.colabproject.colab.api.controller.monitoring.CronJobLogManager;
11 import ch.colabproject.colab.api.model.monitoring.CronJobLogName;
12 import ch.colabproject.colab.api.security.SessionManager;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
15
16 import javax.ejb.Schedule;
17 import javax.ejb.Singleton;
18 import javax.ejb.Startup;
19 import javax.inject.Inject;
20
21
22
23
24
25
26 @Singleton
27 @Startup
28 public class CronTab {
29
30
31 private static final Logger logger = LoggerFactory.getLogger(CronTab.class);
32
33
34 @Inject
35 private SessionManager sessionManager;
36
37
38 @Inject
39 private ExternalDataManager externalDataManager;
40
41
42 @Inject
43 private CronJobLogManager cronJobLogManager;
44
45
46
47
48 @Schedule(hour = "*", minute = "*", persistent = false)
49 public void saveActivityDates() {
50 logger.trace("CRON: Persist activity dates to database");
51 sessionManager.writeActivityDatesToDatabase();
52 cronJobLogManager.updateCronJobLogLastRunTime(CronJobLogName.SAVE_ACTIVITIES_DATE);
53 }
54
55
56
57
58 @Schedule(hour = "0", minute = "0", persistent = false)
59 public void dropOldHttpSession() {
60 logger.info("CRON: drop expired http session");
61 sessionManager.clearExpiredHttpSessions();
62 cronJobLogManager.updateCronJobLogLastRunTime(CronJobLogName.DROP_OLD_HTTP_SESSIONS);
63 }
64
65
66
67
68 @Schedule(hour = "0", minute = "30", persistent = false)
69 public void dropOldUrlMetadata() {
70 logger.info("CRON: clean url metadata cache");
71 externalDataManager.clearOutdated();
72 cronJobLogManager.updateCronJobLogLastRunTime(CronJobLogName.DROP_OLD_URL_METADATA);
73 }
74 }