Leonardo Vannucci
2018-09-17 13c46f877d0540f22b16f80facd7e60de74490fa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package it.digione.dg1cloud.scheduler;
 
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
 
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
 
import it.digione.dg1cloud.service.CleanerService;
import it.digione.dg1cloud.service.CloudService;
 
@Configuration
@EnableScheduling
public class RepositoryJob {
   
   private static final Logger logger = LoggerFactory.getLogger(RepositoryJob.class);
   
   @Autowired private CloudService cloudService;
   @Autowired private CleanerService cleanerService;
   
   @Scheduled(
       fixedDelayString = "${repository.scanner.job.fixed.delay}",
       initialDelayString = "${repository.scanner.job.initial.delay}"
   )
   public void scannerJob() throws JsonParseException, JsonMappingException, NoSuchAlgorithmException, IOException {
       logger.debug("Avvio servizio controllo home directory");
       cloudService.scannAccountHomeDirs();
       logger.debug("Fine");
   }
   
   @Scheduled(
       fixedDelayString = "${repository.cleaner.job.fixed.delay}",
       initialDelayString = "${repository.cleaner.job.initial.delay}"
   )
   public void cleanerJob() {
       logger.debug("Avvio servizio rimozione file scaduti");
       cleanerService.cleanExpiredStoredFiles();
       logger.debug("Fine");
   }
   
   @Scheduled(
       cron = "${repository.dircleaner.job.cron}"
   )
   public void dirCleanerJob() {
       logger.debug("Avvio servizio rimozione directory vuote");
       cleanerService.cleanEmptyStorageFolder();
       logger.debug("Fine");
   }
}