Controllers migration.

master
Rémi Cocula 8 years ago
parent 42709b0e0d
commit 2767d06731
  1. 19
      libresonic-main/src/main/java/org/libresonic/player/controller/ChangeCoverArtController.java
  2. 2
      libresonic-main/src/main/java/org/libresonic/player/controller/SetRatingController.java
  3. 52
      libresonic-main/src/main/java/org/libresonic/player/controller/StarredController.java
  4. 9
      libresonic-main/src/main/resources/libresonic-servlet.xml

@ -19,21 +19,19 @@
*/
package org.libresonic.player.controller;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.service.MediaFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.ServletRequestUtils;
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 org.libresonic.player.domain.MediaFile;
import org.libresonic.player.service.MediaFileService;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
/**
* Controller for changing cover art.
@ -47,6 +45,7 @@ public class ChangeCoverArtController {
@Autowired
private MediaFileService mediaFileService;
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
@ -61,7 +60,7 @@ public class ChangeCoverArtController {
album = dir.getAlbumName();
}
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put("id", id);
map.put("artist", artist);
map.put("album", album);

@ -27,6 +27,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.ServletRequestUtils;
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.view.RedirectView;
@ -49,6 +50,7 @@ public class SetRatingController {
private MediaFileService mediaFileService;
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request) throws Exception {
int id = ServletRequestUtils.getRequiredIntParameter(request, "id");
Integer rating = ServletRequestUtils.getIntParameter(request, "rating");

@ -20,21 +20,19 @@
package org.libresonic.player.controller;
import org.libresonic.player.dao.MediaFileDao;
import org.libresonic.player.domain.CoverArtScheme;
import org.libresonic.player.domain.MediaFile;
import org.libresonic.player.domain.MusicFolder;
import org.libresonic.player.domain.User;
import org.libresonic.player.domain.UserSettings;
import org.libresonic.player.domain.*;
import org.libresonic.player.service.MediaFileService;
import org.libresonic.player.service.PlayerService;
import org.libresonic.player.service.SecurityService;
import org.libresonic.player.service.SettingsService;
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.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -45,17 +43,24 @@ import java.util.Map;
*
* @author Sindre Mehus
*/
public class StarredController extends ParameterizableViewController {
@Controller
@RequestMapping("/starred")
public class StarredController {
@Autowired
private PlayerService playerService;
@Autowired
private MediaFileDao mediaFileDao;
@Autowired
private SecurityService securityService;
@Autowired
private SettingsService settingsService;
@Autowired
private MediaFileService mediaFileService;
@Override
@RequestMapping(method = RequestMethod.GET)
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
User user = securityService.getCurrentUser(request);
String username = user.getUsername();
@ -69,8 +74,8 @@ public class StarredController extends ParameterizableViewController {
mediaFileService.populateStarredDate(albums, username);
mediaFileService.populateStarredDate(files, username);
List<MediaFile> songs = new ArrayList<MediaFile>();
List<MediaFile> videos = new ArrayList<MediaFile>();
List<MediaFile> songs = new ArrayList<>();
List<MediaFile> videos = new ArrayList<>();
for (MediaFile file : files) {
(file.isVideo() ? videos : songs).add(file);
}
@ -83,28 +88,7 @@ public class StarredController extends ParameterizableViewController {
map.put("albums", albums);
map.put("songs", songs);
map.put("videos", videos);
ModelAndView result = super.handleRequestInternal(request, response);
result.addObject("model", map);
return result;
}
public void setSecurityService(SecurityService securityService) {
this.securityService = securityService;
}
public void setPlayerService(PlayerService playerService) {
this.playerService = playerService;
return new ModelAndView("starred","model",map);
}
public void setMediaFileDao(MediaFileDao mediaFileDao) {
this.mediaFileDao = mediaFileDao;
}
public void setSettingsService(SettingsService settingsService) {
this.settingsService = settingsService;
}
public void setMediaFileService(MediaFileService mediaFileService) {
this.mediaFileService = mediaFileService;
}
}

@ -15,14 +15,6 @@
<mvc:annotation-driven />
<context:component-scan base-package="org.libresonic.player.controller, org.libresonic.player.validator"/>
<bean id="starredController" class="org.libresonic.player.controller.StarredController">
<property name="viewName" value="starred"/>
<property name="playerService" ref="playerService"/>
<property name="securityService" ref="securityService"/>
<property name="settingsService" ref="settingsService"/>
<property name="mediaFileDao" ref="mediaFileDao"/>
<property name="mediaFileService" ref="mediaFileService"/>
</bean>
<bean id="dlnaSettingsController" class="org.libresonic.player.controller.DLNASettingsController">
<property name="viewName" value="dlnaSettings"/>
<property name="upnpService" ref="upnpService"/>
@ -174,7 +166,6 @@
<prop key="/notFound.view">multiController</prop>
<prop key="/index.view">multiController</prop>
<prop key="/videoPlayer.view">videoPlayerController</prop>
<prop key="/starred.view">starredController</prop>
<prop key="/dlnaSettings.view">dlnaSettingsController</prop>
<prop key="/sonosSettings.view">sonosSettingsController</prop>
<prop key="/shareSettings.view">shareSettingsController</prop>

Loading…
Cancel
Save