package lan.dk.podcastserver.controller.task;

import lan.dk.podcastserver.business.UpdatePodcastBusiness;
import lan.dk.podcastserver.manager.ItemDownloadManager;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RestController
@RequestMapping("/api/task/updateManager")
public class UpdatePodcastController {

    @Resource
    UpdatePodcastBusiness updatePodcastBusiness;

    @Resource
    ItemDownloadManager IDM;

    @RequestMapping(value = "/updatePodcast", method = RequestMethod.GET, produces = "application/json")
    @ResponseStatus(value = HttpStatus.NO_CONTENT)
    private void updatePodcast () {
        updatePodcastBusiness.updateAsyncPodcast();
    }

    @RequestMapping(value = "/updatePodcast", method = RequestMethod.POST, produces = "application/json")
    @ResponseStatus(value = HttpStatus.NO_CONTENT)
    private void updatePodcast (@RequestBody int id) {
        updatePodcastBusiness.updatePodcast(id);
    }

    @RequestMapping(value = "/updatePodcast/force", method = RequestMethod.POST, produces = "application/json")
    @ResponseStatus(value = HttpStatus.NO_CONTENT)
    private void updatePodcastForced (@RequestBody int id) {
        updatePodcastBusiness.forceUpdatePodcast(id);
    }

    @RequestMapping(value = "/updateAndDownloadPodcast", method = RequestMethod.GET, produces = "application/json")
    @ResponseStatus(value = HttpStatus.NO_CONTENT)
    private void updateAndDownloadPodcast() {
        updatePodcastBusiness.updateAsyncPodcast();
        IDM.launchDownload();
    }

    @RequestMapping(value = "/deleteOdlItems", method = RequestMethod.GET, produces = "application/json")
    @ResponseStatus(value = HttpStatus.NO_CONTENT)
    private void deleteOldItem() {
        updatePodcastBusiness.deleteOldEpisode();
    }
}

@@ -400,20 +400,16 @@
 Resource
-%0A   
  UpdateP
@@ -446,17 +446,16 @@
 siness;%0A
-%0A
     @Res
@@ -459,20 +459,16 @@
 Resource
-%0A   
  ItemDow
@@ -562,39 +562,8 @@
 .GET
-, produces = %22application/json%22
 )%0A  
@@ -783,39 +783,8 @@
 POST
-, produces = %22application/json%22
 )%0A  
@@ -1026,39 +1026,8 @@
 POST
-, produces = %22application/json%22
 )%0A  
@@ -1284,39 +1284,8 @@
 .GET
-, produces = %22application/json%22
 )%0A  
@@ -1545,39 +1545,8 @@
 .GET
-, produces = %22application/json%22
 )%0A  

remove all produce annotation