1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.batch;
17
18 import java.sql.Timestamp;
19 import java.util.Date;
20
21 import org.apache.commons.lang.time.DateUtils;
22 import org.kuali.ole.sys.OLEConstants;
23 import org.kuali.rice.krad.service.SessionDocumentService;
24
25 public class PurgeSessionDocumentsStep extends AbstractStep {
26 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(PurgeSessionDocumentsStep.class);
27
28 protected SessionDocumentService sessionDocumentService;
29
30
31
32
33 public boolean execute(String jobName, Date jobRunDate) {
34 try {
35 LOG.info("executing PurgeSessionDocumentsStep");
36 String maxAgeInDaysStr = parameterService.getParameterValueAsString(PurgeSessionDocumentsStep.class, OLEConstants.SystemGroupParameterNames.NUMBER_OF_DAYS_SINCE_LAST_UPDATE);
37 int maxAgeInDays = Integer.parseInt(maxAgeInDaysStr);
38
39 Timestamp expirationDate = new Timestamp(DateUtils.addDays(getDateTimeService().getCurrentDate(), -maxAgeInDays).getTime());
40
41 sessionDocumentService.purgeAllSessionDocuments(expirationDate);
42 return true;
43 }
44 catch (Exception e) {
45 LOG.error("error occured trying to purge session document from DB: ", e);
46 }
47 return false;
48 }
49
50 public void setSessionDocumentService(SessionDocumentService sessionDocumentService) {
51 this.sessionDocumentService = sessionDocumentService;
52 }
53
54
55 }