1
19
20 package com.liferay.portlet.messageboards.job;
21
22 import com.liferay.portal.kernel.job.IntervalJob;
23 import com.liferay.portal.kernel.job.JobExecutionContext;
24 import com.liferay.portal.kernel.log.Log;
25 import com.liferay.portal.kernel.log.LogFactoryUtil;
26 import com.liferay.portal.kernel.util.Time;
27 import com.liferay.portal.util.PrefsPropsUtil;
28 import com.liferay.portal.util.PropsKeys;
29 import com.liferay.portal.util.PropsValues;
30 import com.liferay.portlet.messageboards.service.MBBanLocalServiceUtil;
31
32
38 public class ExpireBanJob implements IntervalJob {
39
40 public ExpireBanJob() {
41 try {
42 long rawInterval = PrefsPropsUtil.getLong(
43 PropsKeys.MESSAGE_BOARDS_EXPIRE_BAN_JOB_INTERVAL,
44 PropsValues.MESSAGE_BOARDS_EXPIRE_BAN_JOB_INTERVAL);
45
46 if (_log.isDebugEnabled()) {
47 _log.debug("Interval " + rawInterval + " minutes");
48 }
49
50 _interval = rawInterval * Time.MINUTE;
51 }
52 catch (Exception e) {
53 _log.error(e, e);
54 }
55 }
56
57 public void execute(JobExecutionContext context) {
58 try {
59 MBBanLocalServiceUtil.expireBans();
60 }
61 catch (Exception e) {
62 _log.error(e, e);
63 }
64 }
65
66 public long getInterval() {
67 return _interval;
68 }
69
70 private static Log _log = LogFactoryUtil.getLog(ExpireBanJob.class);
71
72 private long _interval;
73
74 }