View Javadoc

1   package ch.busyboxes.agoo.controller;
2   
3   import org.apache.log4j.Logger;
4   import org.springframework.beans.factory.annotation.Autowired;
5   import org.springframework.stereotype.Controller;
6   import org.springframework.ui.ModelMap;
7   import org.springframework.web.bind.annotation.RequestMapping;
8   import org.springframework.web.bind.annotation.RequestMethod;
9   import org.springframework.web.bind.annotation.RequestParam;
10  
11  import ch.busyboxes.agoo.controller.model.WebWatchedFile;
12  import ch.busyboxes.agoo.service.WatchedFileService;
13  
14  /**
15   * This class represents the controller for file page
16   * 
17   * @author julien@busyboxes.ch
18   */
19  @Controller
20  public class FileController {
21  	
22  	/** Logger for this class */
23  	private Logger logger = Logger.getLogger(FileController.class);
24  	
25  	/** The watched file service */
26  	private WatchedFileService watchedFileService;
27  	
28  	/**
29  	 * This method responds to a request on the file details page
30  	 * 
31  	 * @param fileId the id of the folder
32  	 * @return model the model for the page
33  	 */
34  	@RequestMapping(value = "/file/details", method = RequestMethod.GET)
35  	public ModelMap fileDetails(@RequestParam(value = "fileId") Long fileId) {
36  		if (logger.isDebugEnabled()) {
37  			logger.debug("Getting /file/details, with folderId: " + Long.toString(fileId));
38  		}
39  		
40  		ModelMap model = new ModelMap();
41  		WebWatchedFile watchedFile = watchedFileService.getWatchedFileById(fileId);
42  		
43  		model.addAttribute("watchedFile", watchedFile);
44  		
45  		return model;
46  	}
47  
48  	/**
49  	 * Sets the watched file service
50  	 * 
51  	 * @param watchedFileService the watched file service
52  	 */
53  	@Autowired
54  	public void setWatchedFileService(WatchedFileService watchedFileService) {
55  		this.watchedFileService = watchedFileService;
56  	}
57  }