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