Commit 45550442922802a0fd1d62ca68bdb3b27d1a20fc

Authored by Rui Fernandes
1 parent ff6672dc76
Exists in master

configuration

src/alfresco/extension/trashcan-cleaner-context.xml
... ... @@ -2,11 +2,16 @@
2 2 <!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
3 3  
4 4 <beans>
5   - <bean name="trashcanCleaner" class="org.springframework.scheduling.quartz.JobDetailBean">
6   - <property name="jobClass" value="org.alfresco.trashcan.TrashcanCleanerJob" />
7   - <property name="jobDataAsMap">
  5 +
  6 +<bean id="trashcanCleaner" class="org.alfresco.util.CronTriggerBean">
  7 + <property name="jobDetail">
  8 + <bean id="tempFileCleanerJobDetail" class="org.springframework.scheduling.quartz.JobDetailBean">
  9 + <property name="jobClass">
  10 + <value>org.alfresco.trashcan.TrashcanCleanerJob</value>
  11 + </property>
  12 + <property name="jobDataAsMap">
8 13 <map>
9   - <entry key="nodeRegistry" value-ref="nodeService" />
  14 + <entry key="nodeService" value-ref="nodeService" />
10 15 <entry key="transactionService" value-ref="transactionService" />
11 16 <entry key="authenticationComponent" value-ref="authenticationComponent" />
12 17 <entry key="jobLockService" value-ref="jobLockService" />
... ... @@ -14,13 +19,13 @@
14 19 <entry key="trashcan.deleteBatchCount" value="${trashcan.deleteBatchCount}" />
15 20 </map>
16 21 </property>
17   - </bean>
18   -
19   - <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
20   - <property name="jobDetail" ref="trashcanCleaner" />
21   - <!-- Repeat hourly on the half hour -->
22   - <property name="cronExpression">
23   - <value>${trashcan.cron}</value>
24   - </property>
25   - </bean>
26   -</beans>
27 22 \ No newline at end of file
  23 + </bean>
  24 + </property>
  25 + <property name="scheduler">
  26 + <ref bean="schedulerFactory" />
  27 + </property>
  28 + <property name="cronExpression">
  29 + <value>${trashcan.cron}</value>
  30 + </property>
  31 + </bean>
  32 +</beans>
... ...
src/org/alfresco/trashcan/TrashcanCleanerJob.java
... ... @@ -48,14 +48,20 @@ public class TrashcanCleanerJob extends AbstractScheduledLockedJob {
48 48 .getJobDataMap().get("transactionService");
49 49 authenticationComponent = (AuthenticationComponent) jobContext
50 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;
  51 + daysToKeep = getSetupValue("trashcan.daysToKeep", daysToKeep,
  52 + jobContext);
  53 + deleteBatchCount = getSetupValue("trashcan.deleteBatchCount",
  54 + deleteBatchCount, jobContext);
58 55  
59 56 }
60 57  
  58 + private static int getSetupValue(String parameterName, int defaultValue,
  59 + JobExecutionContext jobContext) {
  60 + String parameterValue = (String) jobContext.getJobDetail()
  61 + .getJobDataMap().get(parameterName);
  62 + return parameterValue != null && !parameterValue.trim().equals("") ? Integer
  63 + .parseInt(parameterValue)
  64 + : defaultValue;
  65 + }
  66 +
61 67 }
... ...