View Javadoc

1   package org.musicontroller.core.jobs;
2   
3   import org.apache.log4j.Logger;
4   import org.musicontroller.dao.Dao;
5   import org.musicontroller.repair.ConsistencyChecker;
6   import org.musicontroller.repair.MergeArtistCopies;
7   import org.varienaja.util.DenseSet;
8   
9   public class ConsistencyCheckJob {
10  	private static final Logger log = Logger.getLogger(ConsistencyCheckJob.class);
11  	private Dao _dao;
12  		
13  	public void execute() {
14  		executeLinkChecks();
15  		executeMergeArtistCopies();
16  	}
17  	
18  	public void executeLinkChecks() {
19  		log.debug("LinkCheckJob started");
20  		try {			
21  			DenseSet nonExistingLinkIDs = ConsistencyChecker.checkLinks(_dao);
22  			if (nonExistingLinkIDs.size()==0) {
23  				log.debug("All songs have correct filesystem links.");
24  			} else {
25  				log.error("There were songs with missing filesystem links!");
26  			}
27  		} catch (Exception e){
28  			log.error("Error while checking links: "+e);
29  		}
30  		log.debug("LinkCheckJob finished");
31  	}
32  
33  	private void executeMergeArtistCopies() {
34  		MergeArtistCopies.execute(_dao);
35  	}
36  
37  	public Dao getDao() {
38  		return _dao;
39  	}
40  
41  	public void setDao(Dao _dao) {
42  		this._dao = _dao;
43  	}
44  }