Commit 7eaca0971f9c48839904cd5f04e60e0467b2815d

Authored by Rui Fernandes
1 parent 33885aeaad
Exists in master

configuration

src/alfresco/extension/trashcan-cleaner-context.xml
... ... @@ -10,6 +10,8 @@
10 10 <entry key="transactionService" value-ref="transactionService" />
11 11 <entry key="authenticationComponent" value-ref="authenticationComponent" />
12 12 <entry key="jobLockService" value-ref="jobLockService" />
  13 + <entry key="trashcan.daysToKeep" value="${trashcan.daysToKeep}" />
  14 + <entry key="trashcan.deleteBatchCount" value="${trashcan.deleteBatchCount}" />
13 15 </map>
14 16 </property>
15 17 </bean>
... ...
src/org/alfresco/trashcan/TrashcanCleaner.java
... ... @@ -95,6 +95,8 @@ public class TrashcanCleaner {
95 95 }
96 96  
97 97 private boolean olderThanDaysToKeep(NodeRef node) {
  98 + if(daysToKeep<=0)
  99 + return true;
98 100 Date archivedDate = (Date) nodeService.getProperty(node,
99 101 ContentModel.PROP_ARCHIVED_DATE);
100 102 return daysToKeep * DAYS_TO_MILLIS < System.currentTimeMillis()
... ...
src/org/alfresco/trashcan/TrashcanCleanerJob.java
... ... @@ -11,18 +11,20 @@ import org.quartz.JobExecutionException;
11 11 /**
12 12 *
13 13 * @author rjmfernandes@gmail.com
14   - *
  14 + *
15 15 */
16 16 public class TrashcanCleanerJob extends AbstractScheduledLockedJob {
17 17  
18 18 protected NodeService nodeService;
19 19 protected TransactionService transactionService;
20 20 protected AuthenticationComponent authenticationComponent;
  21 + private int deleteBatchCount = 1000;
  22 + private int daysToKeep = -1;
21 23  
22 24 @Override
23 25 public void executeJob(JobExecutionContext jobContext)
24 26 throws JobExecutionException {
25   - setServices(jobContext);
  27 + setUp(jobContext);
26 28 authenticationComponent.setSystemUserAsCurrentUser();
27 29 cleanInTransaction();
28 30 }
... ... @@ -39,13 +41,20 @@ public class TrashcanCleanerJob extends AbstractScheduledLockedJob {
39 41 txnWork);
40 42 }
41 43  
42   - private void setServices(JobExecutionContext jobContext) {
  44 + private void setUp(JobExecutionContext jobContext) {
43 45 nodeService = (NodeService) jobContext.getJobDetail().getJobDataMap()
44 46 .get("nodeService");
45 47 transactionService = (TransactionService) jobContext.getJobDetail()
46 48 .getJobDataMap().get("transactionService");
47 49 authenticationComponent = (AuthenticationComponent) jobContext
48 50 .getJobDetail().getJobDataMap().get("authenticationComponent");
  51 + Integer c_daysToKeep = (Integer) jobContext.getJobDetail()
  52 + .getJobDataMap().get("trashcan.daysToKeep");
  53 + Integer c_deleteBatchCount = (Integer) jobContext.getJobDetail()
  54 + .getJobDataMap().get("trashcan.deleteBatchCount");
  55 + daysToKeep = c_daysToKeep != null ? c_daysToKeep : daysToKeep;
  56 + deleteBatchCount = c_deleteBatchCount != null ? c_deleteBatchCount
  57 + : deleteBatchCount;
49 58  
50 59 }
51 60  
... ...