Controllers migration.

master
Rémi Cocula 8 years ago
parent 5b8e2b94c1
commit 627a8a9341
  1. 36
      libresonic-main/src/main/java/org/libresonic/player/controller/PodcastController.java
  2. 7
      libresonic-main/src/main/resources/libresonic-servlet.xml

@ -25,37 +25,42 @@ import org.libresonic.player.service.PlaylistService;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
import org.libresonic.player.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.ParameterizableViewController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.*;
/**
* Controller for the page used to generate the Podcast XML file.
*
* @author Sindre Mehus
*/
public class PodcastController extends ParameterizableViewController {
@Controller
@RequestMapping("/podcast")
public class PodcastController {
private static final DateFormat RSS_DATE_FORMAT = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US);
@Autowired
private PlaylistService playlistService;
@Autowired
private SettingsService settingsService;
@Autowired
private SecurityService securityService;
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
String url = request.getRequestURL().toString();
String username = securityService.getCurrentUsername(request);
List<Playlist> playlists = playlistService.getReadablePlaylistsForUser(username);
List<Podcast> podcasts = new ArrayList<Podcast>();
List<Podcast> podcasts = new ArrayList<>();
for (Playlist playlist : playlists) {
@ -85,27 +90,16 @@ public class PodcastController extends ParameterizableViewController {
podcasts.add(new Podcast(playlist.getName(), publishDate, enclosureUrl, length, type));
}
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
ModelAndView result = super.handleRequestInternal(request, response);
map.put("url", url);
map.put("podcasts", podcasts);
result.addObject("model", map);
return result;
return new ModelAndView("podcast","model",map);
}
public void setPlaylistService(PlaylistService playlistService) {
this.playlistService = playlistService;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
/**
* Contains information about a single Podcast.

@ -62,12 +62,6 @@
<bean id="allmusicController" class="org.libresonic.player.controller.AllmusicController">
<property name="viewName" value="allmusic"/>
</bean>
<bean id="podcastController" class="org.libresonic.player.controller.PodcastController">
<property name="viewName" value="podcast"/>
<property name="playlistService" ref="playlistService"/>
<property name="settingsService" ref="settingsService"/>
<property name="securityService" ref="securityService"/>
</bean>
<bean id="podcastChannelsController" class="org.libresonic.player.controller.PodcastChannelsController">
<property name="viewName" value="podcastChannels"/>
<property name="podcastService" ref="podcastService"/>
@ -312,7 +306,6 @@
<prop key="/podcastChannels.view">podcastChannelsController</prop>
<prop key="/podcastChannel.view">podcastChannelController</prop>
<prop key="/podcastReceiverAdmin.view">podcastReceiverAdminController</prop>
<prop key="/podcast.view">podcastController</prop>
<prop key="/podcast/**">podcastController</prop>
<prop key="/wap/download.view">downloadController</prop>
<prop key="/wap/**">wapController</prop>

Loading…
Cancel
Save